From a416200cd1ee1d5e4534fca77821b17cf0c8ac37 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Wed, 8 Apr 2009 08:08:07 +0200 Subject: [PATCH] Cosmetics. --- selector.cc | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/selector.cc b/selector.cc index 50a852b..31a73e5 100644 --- a/selector.cc +++ b/selector.cc @@ -751,10 +751,11 @@ int main(int argc, char **argv) { lines[n++] = lines[k]; } } + nb_lines = n; if(inverse_order) { - for(int i = 0; i < nb_lines/2; i++) { + for(int i = 0; i < nb_lines / 2; i++) { char *s = lines[nb_lines - 1 - i]; lines[nb_lines - 1 - i] = lines[i]; lines[i] = s; @@ -805,17 +806,6 @@ int main(int argc, char **argv) { update_screen(¤t_line, &temporary_line, 0, nb_lines, lines, cursor_position, pattern); - // ^@ \000 - // ^A \001 - // ... - // ^Z \032 - // ^[ \033 - // ^\ \034 - // ^] \035 - // ^^ \036 - // ^_ \037 - // ^? \177 - do { key = getch(); @@ -826,11 +816,14 @@ int main(int argc, char **argv) { insert_char(pattern, &cursor_position, key); } - else if(key == KEY_BACKSPACE || key == '\010' || key == '\177') { + else if(key == KEY_BACKSPACE || + key == '\010' || // ^H + key == '\177') { // ^? backspace_char(pattern, &cursor_position); } - else if(key == KEY_DC || key == '\004') { + else if(key == KEY_DC || + key == '\004') { // ^D delete_char(pattern, &cursor_position); } @@ -850,46 +843,50 @@ int main(int argc, char **argv) { motion = -10; } - else if(key == KEY_DOWN || key == '\014') { + else if(key == KEY_DOWN || + key == '\014') { // ^N motion = 1; } - else if(key == KEY_UP || key == '\016') { + else if(key == KEY_UP || + key == '\016') { // ^P motion = -1; } - else if(key == KEY_LEFT || key == '\002') { + else if(key == KEY_LEFT || + key == '\002') { // ^B if(cursor_position > 0) cursor_position--; } - else if(key == KEY_RIGHT || key == '\006') { + else if(key == KEY_RIGHT || + key == '\006') { // ^F if(pattern[cursor_position]) cursor_position++; } - else if(key == '\001') { + else if(key == '\001') { // ^A cursor_position = 0; } - else if(key == '\005') { + else if(key == '\005') { // ^E cursor_position = strlen(pattern); } - else if(key == '\022') { + else if(key == '\022') { // ^R use_regexp = !use_regexp; } - else if(key == '\025') { + else if(key == '\025') { // ^U kill_before_cursor(pattern, &cursor_position); } - else if(key == '\013') { + else if(key == '\013') { // ^K kill_after_cursor(pattern, &cursor_position); } update_screen(¤t_line, &temporary_line, motion, nb_lines, lines, cursor_position, pattern); - } while(key != '\n' && key != KEY_ENTER && key != '\007'); + } while(key != '\n' && key != KEY_ENTER && key != '\007'); // ^G echo(); curs_set(1); -- 2.39.5