Browse code

action_next and action_prev

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

  • fzy.c index 56cf66f..2801873 100644
... ...
@@ -153,6 +153,14 @@ void emit(tty_t *tty){
153 153
 	exit(EXIT_SUCCESS);
154 154
 }
155 155
 
156
+void action_prev(){
157
+	current_selection = (current_selection + NUMLINES - 1) % NUMLINES;
158
+}
159
+
160
+void action_next(){
161
+	current_selection = (current_selection + 1) % NUMLINES;
162
+}
163
+
156 164
 void run(tty_t *tty){
157 165
 	run_search(search);
158 166
 	char ch;
... ...
@@ -180,9 +188,9 @@ void run(tty_t *tty){
180 188
 				search[search_size] = '\0';
181 189
 			run_search(search);
182 190
 		}else if(ch == 14){ /* C-N */
183
-			current_selection = (current_selection + 1) % NUMLINES;
191
+			action_next();
184 192
 		}else if(ch == 16){ /* C-P */
185
-			current_selection = (current_selection + NUMLINES - 1) % NUMLINES;
193
+			action_prev();
186 194
 		}else if(ch == 10){ /* Enter */
187 195
 			clear(tty);
188 196
 			emit(tty);