diff options
author | Ron Yorston <rmy@pobox.com> | 2021-08-06 10:53:42 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-08-06 15:12:05 +0100 |
commit | 94c7e5f7b7bb24621a192c92e1ce961330988121 (patch) | |
tree | 7d1f52ee830ef57015aa91855709c691d354f826 /win32 | |
parent | c4cbc518d8bbc8ce051406c90f2ce12595925e83 (diff) | |
download | busybox-w32-94c7e5f7b7bb24621a192c92e1ce961330988121.tar.gz busybox-w32-94c7e5f7b7bb24621a192c92e1ce961330988121.tar.bz2 busybox-w32-94c7e5f7b7bb24621a192c92e1ce961330988121.zip |
win32: code shrink read_key()
No change in functionality. Saves 16 bytes.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/termios.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/win32/termios.c b/win32/termios.c index 605f73328..3a381903c 100644 --- a/win32/termios.c +++ b/win32/termios.c | |||
@@ -9,10 +9,8 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) | |||
9 | #if ENABLE_FEATURE_EURO | 9 | #if ENABLE_FEATURE_EURO |
10 | wchar_t uchar; | 10 | wchar_t uchar; |
11 | char achar; | 11 | char achar; |
12 | #else | ||
13 | char *s; | ||
14 | #endif | 12 | #endif |
15 | int alt_pressed = FALSE; | 13 | DWORD alt_pressed = FALSE; |
16 | DWORD state; | 14 | DWORD state; |
17 | 15 | ||
18 | if (fd != 0) | 16 | if (fd != 0) |
@@ -40,15 +38,11 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) | |||
40 | state = record.Event.KeyEvent.dwControlKeyState; | 38 | state = record.Event.KeyEvent.dwControlKeyState; |
41 | if (!record.Event.KeyEvent.bKeyDown) { | 39 | if (!record.Event.KeyEvent.bKeyDown) { |
42 | /* ignore all key up events except Alt */ | 40 | /* ignore all key up events except Alt */ |
43 | if (alt_pressed && !(state & LEFT_ALT_PRESSED) && | 41 | if (!(alt_pressed && (state & LEFT_ALT_PRESSED) == 0 && |
44 | record.Event.KeyEvent.wVirtualKeyCode == VK_MENU) | 42 | record.Event.KeyEvent.wVirtualKeyCode == VK_MENU)) |
45 | alt_pressed = FALSE; | ||
46 | else | ||
47 | continue; | 43 | continue; |
48 | } | 44 | } |
49 | else { | 45 | alt_pressed = state & LEFT_ALT_PRESSED; |
50 | alt_pressed = ((state & LEFT_ALT_PRESSED) != 0); | ||
51 | } | ||
52 | 46 | ||
53 | #if ENABLE_FEATURE_EURO | 47 | #if ENABLE_FEATURE_EURO |
54 | if (!record.Event.KeyEvent.uChar.UnicodeChar) { | 48 | if (!record.Event.KeyEvent.uChar.UnicodeChar) { |
@@ -113,7 +107,7 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) | |||
113 | ret = achar; | 107 | ret = achar; |
114 | #else | 108 | #else |
115 | if ( (record.Event.KeyEvent.uChar.AsciiChar & 0x80) == 0x80 ) { | 109 | if ( (record.Event.KeyEvent.uChar.AsciiChar & 0x80) == 0x80 ) { |
116 | s = &record.Event.KeyEvent.uChar.AsciiChar; | 110 | char *s = &record.Event.KeyEvent.uChar.AsciiChar; |
117 | OemToCharBuff(s, s, 1); | 111 | OemToCharBuff(s, s, 1); |
118 | } | 112 | } |
119 | ret = record.Event.KeyEvent.uChar.AsciiChar; | 113 | ret = record.Event.KeyEvent.uChar.AsciiChar; |