diff --git a/vis-menu.c b/vis-menu.c index 5883a0d9d..5c08f6e22 100644 --- a/vis-menu.c +++ b/vis-menu.c @@ -369,85 +369,89 @@ run(void) { xread(0, &c, 1); esc_switch_top: switch(c) { - case CONTROL('['): /* ESC, need to press twice due to console limitations */ - c = CONTROL('C'); + case CONTROL('['): /* ESC, need to press twice due to console limitations */ + c = CONTROL('C'); + goto switch_top; + case '[': + xread(0, &c, 1); + switch(c) { + case '1': /* Home */ + case '7': + case 'H': + if (c != 'H') xread(0, &c, 1); /* Remove trailing '~' from stdin */ + c = CONTROL('A'); goto switch_top; - case '[': - xread(0, &c, 1); - switch(c) { - case '1': /* Home */ - case '7': - case 'H': - if (c != 'H') xread(0, &c, 1); /* Remove trailing '~' from stdin */ - c = CONTROL('A'); - goto switch_top; - case '3': /* Delete */ - xread(0, &c, 1); /* Remove trailing '~' from stdin */ - c = CONTROL('D'); - goto switch_top; - case '4': /* End */ - case '8': - case 'F': - if (c != 'F') xread(0, &c, 1); /* Remove trailing '~' from stdin */ - c = CONTROL('E'); - goto switch_top; - case '5': /* PageUp */ - xread(0, &c, 1); /* Remove trailing '~' from stdin */ - c = CONTROL('V'); - goto switch_top; - case '6': /* PageDown */ - xread(0, &c, 1); /* Remove trailing '~' from stdin */ - c = 'v'; - goto esc_switch_top; - case 'A': /* Up arrow */ - c = CONTROL('P'); - goto switch_top; - case 'B': /* Down arrow */ - c = CONTROL('N'); - goto switch_top; - case 'C': /* Right arrow */ - c = CONTROL('F'); - goto switch_top; - case 'D': /* Left arrow */ - c = CONTROL('B'); - goto switch_top; - } - break; - case 'b': - while (cursor > 0 && text[nextrune(-1)] == ' ') - cursor = nextrune(-1); - while (cursor > 0 && text[nextrune(-1)] != ' ') - cursor = nextrune(-1); - break; - case 'f': - while (text[cursor] != '\0' && text[nextrune(+1)] == ' ') + case '2': /* Insert */ + xread(0, &c, 1); /* Remove trailing '~' from stdin */ + c = CONTROL('Y'); + goto switch_top; + case '3': /* Delete */ + xread(0, &c, 1); /* Remove trailing '~' from stdin */ + c = CONTROL('D'); + goto switch_top; + case '4': /* End */ + case '8': + case 'F': + if (c != 'F') xread(0, &c, 1); /* Remove trailing '~' from stdin */ + c = CONTROL('E'); + goto switch_top; + case '5': /* PageUp */ + xread(0, &c, 1); /* Remove trailing '~' from stdin */ + c = CONTROL('V'); + goto switch_top; + case '6': /* PageDown */ + xread(0, &c, 1); /* Remove trailing '~' from stdin */ + c = 'v'; + goto esc_switch_top; + case 'A': /* Up arrow */ + c = CONTROL('P'); + goto switch_top; + case 'B': /* Down arrow */ + c = CONTROL('N'); + goto switch_top; + case 'C': /* Right arrow */ + c = CONTROL('F'); + goto switch_top; + case 'D': /* Left arrow */ + c = CONTROL('B'); + goto switch_top; + } + break; + case 'b': + while (cursor > 0 && text[nextrune(-1)] == ' ') + cursor = nextrune(-1); + while (cursor > 0 && text[nextrune(-1)] != ' ') + cursor = nextrune(-1); + break; + case 'f': + while (text[cursor] != '\0' && text[nextrune(+1)] == ' ') + cursor = nextrune(+1); + if (text[cursor] != '\0') { + do { cursor = nextrune(+1); - if (text[cursor] != '\0') { - do { - cursor = nextrune(+1); - } while (text[cursor] != '\0' && text[cursor] != ' '); - } - break; - case 'd': - while (text[cursor] != '\0' && text[nextrune(+1)] == ' ') { + } while (text[cursor] != '\0' && text[cursor] != ' '); + } + break; + case 'd': + while (text[cursor] != '\0' && text[nextrune(+1)] == ' ') { + cursor = nextrune(+1); + insert(NULL, nextrune(-1) - cursor); + } + if (text[cursor] != '\0') { + do { cursor = nextrune(+1); insert(NULL, nextrune(-1) - cursor); - } - if (text[cursor] != '\0') { - do { - cursor = nextrune(+1); - insert(NULL, nextrune(-1) - cursor); - } while (text[cursor] != '\0' && text[cursor] != ' '); - } - break; - case 'v': - if (!next) - break; - sel = curr = next; - calcoffsets(); - break; - default: + } while (text[cursor] != '\0' && text[cursor] != ' '); + } + break; + case 'v': + if (!next) break; + sel = curr = next; + calcoffsets(); + break; + default: + break; } break; case CONTROL('C'):