Also treat ^H as backspace

This commit is contained in:
lostd 2015-01-27 13:29:12 +02:00
parent f39db2b36b
commit 68be0868c6
2 changed files with 3 additions and 2 deletions

View File

@ -18,6 +18,7 @@ struct key bindings[] = {
{ KEY_BACKSPACE, SEL_BACK }, { KEY_BACKSPACE, SEL_BACK },
{ KEY_LEFT, SEL_BACK }, { KEY_LEFT, SEL_BACK },
{ 'h', SEL_BACK }, { 'h', SEL_BACK },
{ CONTROL('H'), SEL_BACK },
/* Inside */ /* Inside */
{ KEY_ENTER, SEL_GOIN }, { KEY_ENTER, SEL_GOIN },
{ '\r', SEL_GOIN }, { '\r', SEL_GOIN },

View File

@ -327,7 +327,7 @@ readln(void)
while ((c = getch()) != ERR) { while ((c = getch()) != ERR) {
if (c == KEY_ENTER || c == '\r') if (c == KEY_ENTER || c == '\r')
break; break;
if (c == KEY_BACKSPACE) { if (c == KEY_BACKSPACE || c == CONTROL('H')) {
getyx(stdscr, y, x); getyx(stdscr, y, x);
if (x >= x0) { if (x >= x0) {
i--; i--;
@ -386,7 +386,7 @@ readmore(char **str)
ret = 1; ret = 1;
goto out; goto out;
} }
if (c == KEY_BACKSPACE) { if (c == KEY_BACKSPACE || c == CONTROL('H')) {
i--; i--;
if (i > 0) { if (i > 0) {
ln = xrealloc(ln, (i + 1) * sizeof(*ln)); ln = xrealloc(ln, (i + 1) * sizeof(*ln));