int userinput(struct context *c) {
enum {
- CTRLD = '\004',
- CLEAR = '\014',
- ESCAPE = '\033',
+ EOT = '\004',
+ FF = '\014',
+ ESC = '\033',
ALT = '2' + 1,
UP = 'A',
DOWN,
RIGHT,
LEFT,
- FORWARD = 'f',
BACKWARD = 'b',
+ FORWARD = 'f',
DEL = '\177',
};
getcolumns();
}
if (sigquit) {
- case CTRLD:
+ case EOT:
newline();
return 0;
}
addhistory(NULL);
}
break;
- case CLEAR:
+ case FF:
oldcursor = cursor;
cursor = start;
/* This is a very minimal way to handle arrow keys. All modifiers except for
* the ALT key are processed but ignored.
*
- * See "Terminal Input Sequences" reference in `README.md'. */
- case ESCAPE:
+ * See "Terminal Input Sequences" reference in `README.md'; some parts don't
+ * seem entirely accurate, but the table of modifier values was helpful. */
+ case ESC:
if ((current = getchar()) == '[') {
while ((current = getchar()) >= '0' && current <= '9');
if (current == ';') {
}
}
switch (current) {
- case FORWARD:
- while (cursor != end && *cursor != ' ') moveright();
- while (cursor != end && *cursor == ' ') moveright();
- break;
case BACKWARD:
while (cursor != start && *(cursor - 1) == ' ') moveleft();
while (cursor != start && *(cursor - 1) != ' ') moveleft();
+ break;
+ case FORWARD:
+ while (cursor != end && *cursor != ' ') moveright();
+ while (cursor != end && *cursor == ' ') moveright();
}
break;
case DEL: