GNU Binutils with patches for OS216
Revisión | e3555239e04fa6dba2a165b3b52598a880474a22 (tree) |
---|---|
Tiempo | 2015-05-14 21:18:06 |
Autor | Patrick Palka <patrick@parc...> |
Commiter | Patrick Palka |
Remove buggy xterm workaround in tui_dispatch_ctrl_char()
The function tui_dispatch_ctrl_char() has an old workaround (from 1999)
for buggy terminals and/or ncurses library that don't return page
up/down keys as single characters. Because the workaround is so old, I
think the bug it is targetting is no longer relevant anymore.
But more importantly, the workaround is itself buggy: it 1) performs a
blocking call to wgetch() and 2) if the key returned by wgetch() does
not make up a relevant key sequence it throws away the input instead of
pushing it back via ungetch(). And indeed the workaround breaks Alt-key
sequences under TERM=xterm because of bug #2.
So this patch removes the buggy workaround and tidies up the function
accordingly.
I personally tested this change on a recent xterm (with TERM=xterm) in
Fedora 20 and had no problems with having ncurses properly interpret
page up/down keys. And Alt-key sequences now work when TERM=xterm too.
gdb/ChangeLog:
* tui/tui-command.c: Remove include of <ctype.h>.
(tui_dispatch_ctrl_char): Remove workaround for xterm terminals.
@@ -1,3 +1,8 @@ | ||
1 | +2015-05-14 Patrick Palka <patrick@parcs.ath.cx> | |
2 | + | |
3 | + * tui/tui-command.c: Remove include of <ctype.h>. | |
4 | + (tui_dispatch_ctrl_char): Remove workaround for xterm terminals. | |
5 | + | |
1 | 6 | 2015-05-13 Martin Galvan <martin.galvan@tallertechnologies.com> |
2 | 7 | |
3 | 8 | * dwarf2read.c (die_needs_namespace): Return 1 for |
@@ -87,7 +92,7 @@ | ||
87 | 92 | |
88 | 93 | * tui/tui-win.c (tui_async_resize_screen): Clear win_resized |
89 | 94 | first before resizing the window. |
90 | - * tui.c (tui_enable): Likewise. | |
95 | + * tui/tui.c (tui_enable): Likewise. | |
91 | 96 | |
92 | 97 | 2015-05-13 Jan Kratochvil <jan.kratochvil@redhat.com> |
93 | 98 |
@@ -20,7 +20,6 @@ | ||
20 | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
21 | 21 | |
22 | 22 | #include "defs.h" |
23 | -#include <ctype.h> | |
24 | 23 | #include "tui/tui.h" |
25 | 24 | #include "tui/tui-data.h" |
26 | 25 | #include "tui/tui-win.h" |
@@ -54,80 +53,40 @@ tui_dispatch_ctrl_char (unsigned int ch) | ||
54 | 53 | on through and do nothing here. */ |
55 | 54 | if (win_info == NULL || win_info == TUI_CMD_WIN) |
56 | 55 | return ch; |
57 | - else | |
56 | + | |
57 | + switch (ch) | |
58 | 58 | { |
59 | - unsigned int c = 0, ch_copy = ch; | |
60 | - int i; | |
61 | - char *term; | |
62 | - | |
63 | - /* If this is an xterm, page next/prev keys aren't returned by | |
64 | - keypad as a single char, so we must handle them here. Seems | |
65 | - like a bug in the curses library? */ | |
66 | - term = (char *) getenv ("TERM"); | |
67 | - if (term) | |
68 | - { | |
69 | - for (i = 0; term[i]; i++) | |
70 | - term[i] = toupper (term[i]); | |
71 | - if ((strcmp (term, "XTERM") == 0) | |
72 | - && key_is_start_sequence (ch)) | |
73 | - { | |
74 | - unsigned int page_ch = 0; | |
75 | - unsigned int tmp_char; | |
76 | - WINDOW *w = TUI_CMD_WIN->generic.handle; | |
77 | - | |
78 | - tmp_char = 0; | |
79 | - while (!key_is_end_sequence (tmp_char)) | |
80 | - { | |
81 | - tmp_char = (int) wgetch (w); | |
82 | - if (tmp_char == ERR) | |
83 | - { | |
84 | - return ch; | |
85 | - } | |
86 | - if (!tmp_char) | |
87 | - break; | |
88 | - if (tmp_char == 53) | |
89 | - page_ch = KEY_PPAGE; | |
90 | - else if (tmp_char == 54) | |
91 | - page_ch = KEY_NPAGE; | |
92 | - else | |
93 | - { | |
94 | - return 0; | |
95 | - } | |
96 | - } | |
97 | - ch_copy = page_ch; | |
98 | - } | |
99 | - } | |
100 | - | |
101 | - switch (ch_copy) | |
102 | - { | |
103 | - case KEY_NPAGE: | |
104 | - tui_scroll_forward (win_info, 0); | |
105 | - break; | |
106 | - case KEY_PPAGE: | |
107 | - tui_scroll_backward (win_info, 0); | |
108 | - break; | |
109 | - case KEY_DOWN: | |
110 | - case KEY_SF: | |
111 | - tui_scroll_forward (win_info, 1); | |
112 | - break; | |
113 | - case KEY_UP: | |
114 | - case KEY_SR: | |
115 | - tui_scroll_backward (win_info, 1); | |
116 | - break; | |
117 | - case KEY_RIGHT: | |
118 | - tui_scroll_left (win_info, 1); | |
119 | - break; | |
120 | - case KEY_LEFT: | |
121 | - tui_scroll_right (win_info, 1); | |
122 | - break; | |
123 | - case '\f': | |
124 | - break; | |
125 | - default: | |
126 | - c = ch_copy; | |
127 | - break; | |
128 | - } | |
129 | - return c; | |
59 | + case KEY_NPAGE: | |
60 | + tui_scroll_forward (win_info, 0); | |
61 | + break; | |
62 | + case KEY_PPAGE: | |
63 | + tui_scroll_backward (win_info, 0); | |
64 | + break; | |
65 | + case KEY_DOWN: | |
66 | + case KEY_SF: | |
67 | + tui_scroll_forward (win_info, 1); | |
68 | + break; | |
69 | + case KEY_UP: | |
70 | + case KEY_SR: | |
71 | + tui_scroll_backward (win_info, 1); | |
72 | + break; | |
73 | + case KEY_RIGHT: | |
74 | + tui_scroll_left (win_info, 1); | |
75 | + break; | |
76 | + case KEY_LEFT: | |
77 | + tui_scroll_right (win_info, 1); | |
78 | + break; | |
79 | + case '\f': | |
80 | + break; | |
81 | + default: | |
82 | + /* We didn't recognize the character as a control character, so pass it | |
83 | + through. */ | |
84 | + return ch; | |
130 | 85 | } |
86 | + | |
87 | + /* We intercepted the control character, so return 0 (which readline | |
88 | + will interpret as a no-op). */ | |
89 | + return 0; | |
131 | 90 | } |
132 | 91 | |
133 | 92 | /* See tui-command.h. */ |