aboutsummaryrefslogtreecommitdiff
path: root/vis-menu.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-05-27 22:13:31 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-05-29 11:25:37 +0200
commit2ac072176e2b6ecfad4427dfc798f63c834c38ad (patch)
treeab0079b86b0ce8c046fa5198ac111d269b0c259b /vis-menu.c
parent8bd8422031eba0f98a904ef20a57507df4df21d5 (diff)
downloadvis-2ac072176e2b6ecfad4427dfc798f63c834c38ad.tar.gz
vis-2ac072176e2b6ecfad4427dfc798f63c834c38ad.tar.xz
vis-menu: reduce indentation level of switch statements
Diffstat (limited to 'vis-menu.c')
-rw-r--r--vis-menu.c152
1 files changed, 78 insertions, 74 deletions
diff --git a/vis-menu.c b/vis-menu.c
index 5883a0d..5c08f6e 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'):