summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2016-02-19 13:38:02 -0200
committerHisham <hisham@gobolinux.org>2016-02-19 13:38:02 -0200
commitc23d4f12d165c79be9f95da746914b94378d56c0 (patch)
treee683327bfb65fed1f97d83a4a801d818ef78b745
parent48254f92e4902ecd2b8ca27ae979b7d70e1ca804 (diff)
Fix behavior of ESC key, getting rid of the annoying delay.
Thank you @Explorer09 for the push! Closes #417.
-rw-r--r--CRT.c8
-rw-r--r--CRT.h2
-rw-r--r--InfoScreen.c1
-rw-r--r--ScreenManager.c28
4 files changed, 17 insertions, 22 deletions
diff --git a/CRT.c b/CRT.c
index 2ab20c2d..673e9512 100644
--- a/CRT.c
+++ b/CRT.c
@@ -125,6 +125,8 @@ void CRT_fatalError(const char* note) __attribute__ ((noreturn));
void CRT_handleSIGSEGV(int sgn);
+#define KEY_ALT(x) KEY_F(60) + (x - 'A')
+
}*/
const char *CRT_treeStrAscii[TREE_STR_COUNT] = {
@@ -587,6 +589,11 @@ void CRT_init(int delay, int colorScheme) {
define_key("\033[13~", KEY_F(3));
define_key("\033[14~", KEY_F(4));
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
signal(11, CRT_handleSIGSEGV);
@@ -618,6 +625,7 @@ void CRT_init(int delay, int colorScheme) {
#else
mousemask(BUTTON1_RELEASED, NULL);
#endif
+
}
void CRT_done() {
diff --git a/CRT.h b/CRT.h
index 5aac2171..ba10699e 100644
--- a/CRT.h
+++ b/CRT.h
@@ -115,6 +115,8 @@ void CRT_fatalError(const char* note) __attribute__ ((noreturn));
void CRT_handleSIGSEGV(int sgn);
+#define KEY_ALT(x) KEY_F(60) + (x - 'A')
+
extern const char *CRT_treeStrAscii[TREE_STR_COUNT];
diff --git a/InfoScreen.c b/InfoScreen.c
index 7ce9ca6a..a6dd55ad 100644
--- a/InfoScreen.c
+++ b/InfoScreen.c
@@ -116,6 +116,7 @@ void InfoScreen_run(InfoScreen* this) {
if (this->inc->active)
move(LINES-1, CRT_cursorX);
+ ESCDELAY = 25;
int ch = getch();
if (ch == ERR) {
diff --git a/ScreenManager.c b/ScreenManager.c
index a33d3420..db3fdee4 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -189,6 +189,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
}
int prevCh = ch;
+ ESCDELAY = 25;
ch = getch();
HandlerResult result = IGNORED;
@@ -244,28 +245,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
redraw = false;
continue;
}
- else if (ch == 27) {
- int ch2 = getch();
- if (ch2 != ERR) {
- switch(ch2)
- {
- 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;
- }
- }
+ switch (ch) {
+ case KEY_ALT('H'): ch = KEY_LEFT; break;
+ case KEY_ALT('J'): ch = KEY_DOWN; break;
+ case KEY_ALT('K'): ch = KEY_UP; break;
+ case KEY_ALT('L'): ch = KEY_RIGHT; break;
}
redraw = true;
if (Panel_eventHandlerFn(panelFocus)) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy