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;
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();
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);
}
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);