Commit c23d4f12 authored by Hisham's avatar Hisham
Browse files

Fix behavior of ESC key, getting rid of the annoying delay.

Thank you @Explorer09 for the push!
Closes #417.
parent 48254f92
...@@ -125,6 +125,8 @@ void CRT_fatalError(const char* note) __attribute__ ((noreturn)); ...@@ -125,6 +125,8 @@ void CRT_fatalError(const char* note) __attribute__ ((noreturn));
void CRT_handleSIGSEGV(int sgn); void CRT_handleSIGSEGV(int sgn);
#define KEY_ALT(x) KEY_F(60) + (x - 'A')
}*/ }*/
const char *CRT_treeStrAscii[TREE_STR_COUNT] = { const char *CRT_treeStrAscii[TREE_STR_COUNT] = {
...@@ -587,6 +589,11 @@ void CRT_init(int delay, int colorScheme) { ...@@ -587,6 +589,11 @@ void CRT_init(int delay, int colorScheme) {
define_key("\033[13~", KEY_F(3)); define_key("\033[13~", KEY_F(3));
define_key("\033[14~", KEY_F(4)); define_key("\033[14~", KEY_F(4));
define_key("\033[17;2~", KEY_F(18)); define_key("\033[17;2~", KEY_F(18));
char sequence[3] = "\033a";
for (char c = 'a'; c <= 'z'; c++) {
sequence[1] = c;
define_key(sequence, KEY_ALT('A' + (c - 'a')));
}
} }
#ifndef DEBUG #ifndef DEBUG
signal(11, CRT_handleSIGSEGV); signal(11, CRT_handleSIGSEGV);
...@@ -618,6 +625,7 @@ void CRT_init(int delay, int colorScheme) { ...@@ -618,6 +625,7 @@ void CRT_init(int delay, int colorScheme) {
#else #else
mousemask(BUTTON1_RELEASED, NULL); mousemask(BUTTON1_RELEASED, NULL);
#endif #endif
} }
void CRT_done() { void CRT_done() {
......
...@@ -115,6 +115,8 @@ void CRT_fatalError(const char* note) __attribute__ ((noreturn)); ...@@ -115,6 +115,8 @@ void CRT_fatalError(const char* note) __attribute__ ((noreturn));
void CRT_handleSIGSEGV(int sgn); void CRT_handleSIGSEGV(int sgn);
#define KEY_ALT(x) KEY_F(60) + (x - 'A')
extern const char *CRT_treeStrAscii[TREE_STR_COUNT]; extern const char *CRT_treeStrAscii[TREE_STR_COUNT];
......
...@@ -116,6 +116,7 @@ void InfoScreen_run(InfoScreen* this) { ...@@ -116,6 +116,7 @@ void InfoScreen_run(InfoScreen* this) {
if (this->inc->active) if (this->inc->active)
move(LINES-1, CRT_cursorX); move(LINES-1, CRT_cursorX);
ESCDELAY = 25;
int ch = getch(); int ch = getch();
if (ch == ERR) { if (ch == ERR) {
......
...@@ -189,6 +189,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { ...@@ -189,6 +189,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
} }
int prevCh = ch; int prevCh = ch;
ESCDELAY = 25;
ch = getch(); ch = getch();
HandlerResult result = IGNORED; HandlerResult result = IGNORED;
...@@ -244,28 +245,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { ...@@ -244,28 +245,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
redraw = false; redraw = false;
continue; continue;
} }
else if (ch == 27) { switch (ch) {
int ch2 = getch(); case KEY_ALT('H'): ch = KEY_LEFT; break;
if (ch2 != ERR) { case KEY_ALT('J'): ch = KEY_DOWN; break;
switch(ch2) case KEY_ALT('K'): ch = KEY_UP; break;
{ case KEY_ALT('L'): ch = KEY_RIGHT; break;
case 'h':
ch = KEY_LEFT;
break;
case 'j':
ch = KEY_DOWN;
break;
case 'k':
ch = KEY_UP;
break;
case 'l':
ch = KEY_RIGHT;
break;
default:
ungetch(ch2);
break;
}
}
} }
redraw = true; redraw = true;
if (Panel_eventHandlerFn(panelFocus)) { if (Panel_eventHandlerFn(panelFocus)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment