From 0030dc908abe01705612bd157a64cfc8b62bd1d1 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Tue, 7 Apr 2009 22:36:11 +0200 Subject: [PATCH] Removed the control codes from the string and use the octal notation. --- selector.cc | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/selector.cc b/selector.cc index c936029..cf9df59 100644 --- a/selector.cc +++ b/selector.cc @@ -746,6 +746,17 @@ int main(int argc, char **argv) { update_screen(¤t_line, &temporary_line, 0, nb_lines, lines, cursor_position, pattern); + // \000 ^@ + // \001 ^A + // ... + // \032 ^Z + // \033 ^[ + // \034 ^\ + // \035 ^] + // \036 ^^ + // \037 ^_ + // \177 ^? + do { key = getch(); @@ -766,7 +777,7 @@ int main(int argc, char **argv) { pattern[cursor_position++] = key; } - else if(key == KEY_BACKSPACE || key == '' || key == '') { + else if(key == KEY_BACKSPACE || key == '\010' || key == '\177') { if(cursor_position > 0) { if(pattern[cursor_position]) { int c = cursor_position-1; @@ -781,7 +792,7 @@ int main(int argc, char **argv) { } } - else if(key == KEY_DC || key == '') { + else if(key == KEY_DC || key == '\004') { if(pattern[cursor_position]) { int c = cursor_position; while(pattern[c]) { @@ -807,35 +818,35 @@ int main(int argc, char **argv) { motion = -10; } - else if(key == KEY_DOWN || key == '') { + else if(key == KEY_DOWN || key == '\014') { motion = 1; } - else if(key == KEY_UP || key == '') { + else if(key == KEY_UP || key == '\016') { motion = -1; } - else if(key == KEY_LEFT || key == '') { + else if(key == KEY_LEFT || key == '\002') { if(cursor_position > 0) cursor_position--; } - else if(key == KEY_RIGHT || key == '') { + else if(key == KEY_RIGHT || key == '\006') { if(pattern[cursor_position]) cursor_position++; } - else if(key == '') { + else if(key == '\001') { cursor_position = 0; } - else if(key == '') { + else if(key == '\005') { cursor_position = strlen(pattern); } - else if(key == '') { + else if(key == '\022') { use_regexp = !use_regexp; } - else if(key == '') { + else if(key == '\025') { int s = 0; while(pattern[cursor_position + s]) { pattern[s] = pattern[cursor_position + s]; @@ -845,14 +856,14 @@ int main(int argc, char **argv) { cursor_position = 0; } - else if(key == ' ') { + else if(key == '\013') { pattern[cursor_position] = '\0'; } update_screen(¤t_line, &temporary_line, motion, nb_lines, lines, cursor_position, pattern); - } while(key != '\n' && key != KEY_ENTER && key != ''); + } while(key != '\n' && key != KEY_ENTER && key != '\007'); echo(); curs_set(1); -- 2.39.5