Fix key binding collisions

Still not fixed in handle_editor() though.
This commit is contained in:
Přemysl Eric Janouch 2018-10-25 17:39:14 +02:00
parent 6e34f480a9
commit 2484c94b39
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 12 additions and 10 deletions

22
sdn.cpp
View File

@ -620,7 +620,7 @@ fun handle (wint_t c, bool is_char) -> bool {
} }
// Translate the Alt key into a bit outside the range of Unicode // Translate the Alt key into a bit outside the range of Unicode
enum { ALT = 1 << 24 }; enum { ALT = 1 << 24, SYM = 1 << 25 };
if (c == 27) { if (c == 27) {
if (get_wch (&c) == ERR) { if (get_wch (&c) == ERR) {
beep (); beep ();
@ -628,16 +628,18 @@ fun handle (wint_t c, bool is_char) -> bool {
} }
c |= ALT; c |= ALT;
} }
if (!is_char)
c |= SYM;
const auto &current = g.entries[g.cursor]; const auto &current = g.entries[g.cursor];
switch (c) { switch (c) {
case ALT | L'\r': case ALT | L'\r':
case ALT | KEY_ENTER: case ALT | SYM | KEY_ENTER:
g.chosen_full = true; g.chosen_full = true;
g.chosen = current.filename; g.chosen = current.filename;
return false; return false;
case L'\r': case L'\r':
case KEY_ENTER: case SYM | KEY_ENTER:
if (choose (current)) if (choose (current))
break; break;
return false; return false;
@ -647,21 +649,21 @@ fun handle (wint_t c, bool is_char) -> bool {
case L'q': case L'q':
return false; return false;
case L'k': case CTRL L'p': case KEY_UP: case L'k': case CTRL L'p': case SYM | KEY_UP:
g.cursor--; g.cursor--;
break; break;
case L'j': case CTRL L'n': case KEY_DOWN: case L'j': case CTRL L'n': case SYM | KEY_DOWN:
g.cursor++; g.cursor++;
break; break;
case L'g': case ALT | L'<': case KEY_HOME: case L'g': case ALT | L'<': case SYM | KEY_HOME:
g.cursor = 0; g.cursor = 0;
break; break;
case L'G': case ALT | L'>': case KEY_END: case L'G': case ALT | L'>': case SYM | KEY_END:
g.cursor = int (g.entries.size ()) - 1; g.cursor = int (g.entries.size ()) - 1;
break; break;
case KEY_PPAGE: g.cursor -= LINES; break; case SYM | KEY_PPAGE: g.cursor -= LINES; break;
case KEY_NPAGE: g.cursor += LINES; break; case SYM | KEY_NPAGE: g.cursor += LINES; break;
case CTRL L'e': g.offset++; break; case CTRL L'e': g.offset++; break;
case CTRL L'y': g.offset--; break; case CTRL L'y': g.offset--; break;
@ -698,7 +700,7 @@ fun handle (wint_t c, bool is_char) -> bool {
case L'r': case L'r':
reload (); reload ();
break; break;
case KEY_RESIZE: case SYM | KEY_RESIZE:
case WEOF: case WEOF:
break; break;
default: default: