Skip to contentSkip to conversation

Fix control-{@[\]^_} and ESC

Qemu-devel Samuel Thibault 2 participants 3 messages Aug 29, 2010 – Oct 21, 2010

lore
Share & tools
lore
#0 lore raw

control-{@[\]^_} shouldn't get the 'a' - 'A' offset for correct translation. ESC is better simulated as escape key.

ui/curses.c +6 -3
index ed3165e..5d949d6 100644
@@ -238,9 +240,12 @@ static void curses_refresh(DisplayState *ds)
                 keysym = curses2keysym[chr];
 
             if (keysym == -1) {
-                if (chr < ' ')
-                    keysym = (chr + '@' - 'A' + 'a') | KEYSYM_CNTRL;
-                else
+                if (chr < ' ') {
+                    keysym = chr + '@';
+                    if (keysym >= 'A' && keysym <= 'Z')
+                        keysym += 'a' - 'A';
+                    keysym |= KEYSYM_CNTRL;
+                } else
                     keysym = chr;
             }
 
ui/curses_keys.h +1 -0
index 1decd11..c0d5eb4 100644
@@ -55,6 +55,7 @@ static const int curses2keysym[CURSES_KEYS] = {
     [0x7f] = KEY_BACKSPACE,
     ['\r'] = KEY_ENTER,
     ['\n'] = KEY_ENTER,
+    [27] = 27,
     [KEY_BTAB] = '\t' | KEYSYM_SHIFT,
 };
 
#1 lore raw

Hello,

This apparently has been neither applied, nor commented on. Could either be done?

Samuel

control-{@[\]^_} shouldn't get the 'a' - 'A' offset for correct translation. ESC is better simulated as escape key.

ui/curses.c +6 -3
index ed3165e..5d949d6 100644
@@ -238,9 +240,12 @@ static void curses_refresh(DisplayState *ds)
                 keysym = curses2keysym[chr];
 
             if (keysym == -1) {
-                if (chr < ' ')
-                    keysym = (chr + '@' - 'A' + 'a') | KEYSYM_CNTRL;
-                else
+                if (chr < ' ') {
+                    keysym = chr + '@';
+                    if (keysym >= 'A' && keysym <= 'Z')
+                        keysym += 'a' - 'A';
+                    keysym |= KEYSYM_CNTRL;
+                } else
                     keysym = chr;
             }
 
ui/curses_keys.h +1 -0
index 1decd11..c0d5eb4 100644
@@ -55,6 +55,7 @@ static const int curses2keysym[CURSES_KEYS] = {
     [0x7f] = KEY_BACKSPACE,
     ['\r'] = KEY_ENTER,
     ['\n'] = KEY_ENTER,
+    [27] = 27,
     [KEY_BTAB] = '\t' | KEYSYM_SHIFT,
 };
 
#2 lore raw
Quoted 4 lines · Samuel Thibault

Hello,

This apparently has been neither applied, nor commented on.  Could either be done?

Thanks, pushed the patch and sorry for missing the email the first time.

Cheers