[2/3] TUI: Don't print KEY_RESIZE keys

Message ID 1420689885-31156-2-git-send-email-patrick@parcs.ath.cx
State New, archived
Headers

Commit Message

Patrick Palka Jan. 8, 2015, 4:04 a.m. UTC
  wgetch() sometimes returns KEY_RESIZE when ncurses detects that the
terminal has been resized.  This character then gets passed on to
readline which interprets it as a multibyte character.  Instead of
passing on this character to readline, intercept it as a (no-op) control
character and pass '\0' to readline.

gdb/ChangeLog:

	* tui/tui-command.c (tui_dispatch_ctrl_char): Ignore KEY_RESIZE
	keys.
---
 gdb/tui/tui-command.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Pedro Alves Jan. 8, 2015, 11:29 a.m. UTC | #1
On 01/08/2015 04:04 AM, Patrick Palka wrote:
> wgetch() sometimes returns KEY_RESIZE when ncurses detects that the
> terminal has been resized.  

I think curses SIGWINCH handler ends up _not_ installed, right?
We install our own, and so does readline.
So how did a resize manage to be detected/processed while inside
wgetch?

Thanks,
Pedro Alves
  
Patrick Palka Jan. 8, 2015, 12:32 p.m. UTC | #2
On Thu, Jan 8, 2015 at 6:29 AM, Pedro Alves <palves@redhat.com> wrote:
> On 01/08/2015 04:04 AM, Patrick Palka wrote:
>> wgetch() sometimes returns KEY_RESIZE when ncurses detects that the
>> terminal has been resized.
>
> I think curses SIGWINCH handler ends up _not_ installed, right?
> We install our own, and so does readline.
> So how did a resize manage to be detected/processed while inside
> wgetch?

I'm pretty sure that the SIGWINCH handlers does not get installed.
However ncurses may detect a resize event when we exit TUI (exiting
ncurses), then resize the terminal, then re-enter TUI (restarting
ncurses).  From there a KEY_RESIZE key is added to its internal FIFO.
And the next call to wgetch will return this KEY_RESIZE key.

>
> Thanks,
> Pedro Alves
>
  

Patch

diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index d1a5ddb..dfcf512 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -121,6 +121,7 @@  tui_dispatch_ctrl_char (unsigned int ch)
 	  tui_scroll_right (win_info, 1);
 	  break;
 	case '\f':
+	case KEY_RESIZE:
           break;
 	default:
 	  c = ch_copy;