Browse code

Allow selecting past the 10th choice

John Hawthorn authored on 04/08/2014 21:38:43
Showing 1 changed files

  • fzy.c index 2801873..f99d735 100644
... ...
@@ -125,11 +125,15 @@ void draw_match(tty_t *tty, const char *choice, int selected){
125 125
 }
126 126
 
127 127
 void draw(tty_t *tty){
128
+	int start = 0;
129
+	if(current_selection >= NUMLINES){
130
+		start = current_selection - NUMLINES + 1;
131
+	}
128 132
 	int line = 0;
129 133
 	const char *prompt = "> ";
130 134
 	clear(tty);
131 135
 	fprintf(tty->fout, "%s%s\n", prompt, search);
132
-	for(size_t i = 0; line < NUMLINES && i < choices_available; i++){
136
+	for(size_t i = start; line < NUMLINES && i < choices_available; i++){
133 137
 		draw_match(tty, choices[choices_sorted[i]], i == current_selection);
134 138
 		line++;
135 139
 	}
... ...
@@ -154,11 +158,11 @@ void emit(tty_t *tty){
154 158
 }
155 159
 
156 160
 void action_prev(){
157
-	current_selection = (current_selection + NUMLINES - 1) % NUMLINES;
161
+	current_selection = (current_selection + choices_available - 1) % choices_available;
158 162
 }
159 163
 
160 164
 void action_next(){
161
-	current_selection = (current_selection + 1) % NUMLINES;
165
+	current_selection = (current_selection + 1) % choices_available;
162 166
 }
163 167
 
164 168
 void run(tty_t *tty){