X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=selector.cc;h=cf9df599dd01e03c4fa7d82e20dedced589922a6;hb=0030dc908abe01705612bd157a64cfc8b62bd1d1;hp=b84bd794d424f2c7bd7a7cd2317fae13ea406aef;hpb=40e6ea9378f98eac922050a7fad1cc161fe291e5;p=selector.git diff --git a/selector.cc b/selector.cc index b84bd79..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(); @@ -755,21 +766,18 @@ int main(int argc, char **argv) { if(key >= ' ' && key <= '~') { // Insert character int c = cursor_position; char t = pattern[c], u; - if(t) { - while(t) { - c++; - u = pattern[c]; - pattern[c] = t; - t = u; - } - pattern[cursor_position++] = key; - } else { - pattern[cursor_position++] = key; - pattern[cursor_position] = '\0'; + while(t) { + c++; + u = pattern[c]; + pattern[c] = t; + t = u; } + c++; + pattern[c] = '\0'; + 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; @@ -784,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]) { @@ -810,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]; @@ -848,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);