* fhandler_console.cc (ALT_PRESSED): Define earlier, never undefine.

(CTRL_PRESSED): Ditto.
	(fhandler_console::read): Simplify expressions testing for pressed ALT
	or CTRL modifier keys.
	(get_nonascii_key): Ditto.
This commit is contained in:
Corinna Vinschen 2012-04-24 14:39:22 +00:00
parent 503a59c70b
commit d581bbfa8e
2 changed files with 15 additions and 10 deletions

View File

@ -1,3 +1,11 @@
2012-04-24 Corinna Vinschen <corinna@vinschen.de>
* fhandler_console.cc (ALT_PRESSED): Define earlier, never undefine.
(CTRL_PRESSED): Ditto.
(fhandler_console::read): Simplify expressions testing for pressed ALT
or CTRL modifier keys.
(get_nonascii_key): Ditto.
2012-04-24 Thomas Wolff <towo@towo.net> 2012-04-24 Thomas Wolff <towo@towo.net>
* fhandler.h (class dev_console): Add members ext_mouse_mode6 and * fhandler.h (class dev_console): Add members ext_mouse_mode6 and

View File

@ -41,6 +41,9 @@ details. */
is allocated using tmp_pathbuf!!! */ is allocated using tmp_pathbuf!!! */
#define CONVERT_LIMIT NT_MAX_PATH #define CONVERT_LIMIT NT_MAX_PATH
#define ALT_PRESSED (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)
#define CTRL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
/* /*
* Scroll the screen context. * Scroll the screen context.
* x1, y1 - ul corner * x1, y1 - ul corner
@ -421,8 +424,6 @@ fhandler_console::read (void *pv, size_t& buflen)
#define ich (input_rec.Event.KeyEvent.uChar.AsciiChar) #define ich (input_rec.Event.KeyEvent.uChar.AsciiChar)
#define wch (input_rec.Event.KeyEvent.uChar.UnicodeChar) #define wch (input_rec.Event.KeyEvent.uChar.UnicodeChar)
#define ALT_PRESSED (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)
#define CTRL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
/* Ignore key up events, except for left alt events with non-zero character /* Ignore key up events, except for left alt events with non-zero character
*/ */
@ -523,8 +524,6 @@ fhandler_console::read (void *pv, size_t& buflen)
} }
#undef ich #undef ich
#undef wch #undef wch
#undef ALT_PRESSED
#undef CTRL_PRESSED
break; break;
case MOUSE_EVENT: case MOUSE_EVENT:
@ -623,9 +622,9 @@ fhandler_console::read (void *pv, size_t& buflen)
dev_state.nModifiers = 0; dev_state.nModifiers = 0;
if (mouse_event.dwControlKeyState & SHIFT_PRESSED) if (mouse_event.dwControlKeyState & SHIFT_PRESSED)
dev_state.nModifiers |= 0x4; dev_state.nModifiers |= 0x4;
if (mouse_event.dwControlKeyState & (RIGHT_ALT_PRESSED|LEFT_ALT_PRESSED)) if (mouse_event.dwControlKeyState & ALT_PRESSED)
dev_state.nModifiers |= 0x8; dev_state.nModifiers |= 0x8;
if (mouse_event.dwControlKeyState & (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED)) if (mouse_event.dwControlKeyState & CTRL_PRESSED)
dev_state.nModifiers |= 0x10; dev_state.nModifiers |= 0x10;
/* Indicate the modifiers */ /* Indicate the modifiers */
@ -2205,15 +2204,13 @@ get_nonascii_key (INPUT_RECORD& input_rec, char *tmp)
int modifier_index = NORMAL; int modifier_index = NORMAL;
if (input_rec.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) if (input_rec.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED)
modifier_index = SHIFT; modifier_index = SHIFT;
if (input_rec.Event.KeyEvent.dwControlKeyState & if (input_rec.Event.KeyEvent.dwControlKeyState & CTRL_PRESSED)
(LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
modifier_index += CONTROL; modifier_index += CONTROL;
for (int i = 0; keytable[i].vk; i++) for (int i = 0; keytable[i].vk; i++)
if (input_rec.Event.KeyEvent.wVirtualKeyCode == keytable[i].vk) if (input_rec.Event.KeyEvent.wVirtualKeyCode == keytable[i].vk)
{ {
if ((input_rec.Event.KeyEvent.dwControlKeyState & if ((input_rec.Event.KeyEvent.dwControlKeyState & ALT_PRESSED)
(LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))
&& keytable[i].val[modifier_index] != NULL) && keytable[i].val[modifier_index] != NULL)
{ /* Generic ESC prefixing if Alt is pressed */ { /* Generic ESC prefixing if Alt is pressed */
tmp[0] = '\033'; tmp[0] = '\033';