Re: [PATCH v3] Make the TUI command window support the mouse

Hannes Domani via Gdb-patches
2021-06-13T17:56:14Z

Am Sonntag, 13. Juni 2021, 19:26:00 MESZ hat Pedro Alves <pedro@palves.net> Folgendes geschrieben:

> On 2021-06-13 2:04 p.m., Hannes Domani wrote:
> >  Am Sonntag, 13. Juni 2021, 04:46:15 MESZ hat Pedro Alves <pedro@palves.net> Folgendes geschrieben:
> >
> > This is great, thank you for doing this.
> >
> > I just tried it, and I had just one problem, see below.
> >
>
> >> +      /* For the standard keys, we can find them efficiently in the
> >> +    key_xxx macros, defined by ncurses.  We could also hardcode
> >> +    sequences readline understands, and/or use rl_get_termcap.
> >> +    See readline/readline.c:bind_arrow_keys_internal for
> >> +    hardcoded sequences.  */
> >> +      switch (ch)
> >> +    {
> >> +    case KEY_NPAGE: /* page down */
> >> +      return start_sequence (key_npage);
> >> +    case KEY_PPAGE: /* page up */
> >> +      return start_sequence (key_ppage);
> >> +    case KEY_DOWN:
> >> +      return start_sequence (key_down);
> >> +    case KEY_UP:
> >> +      return start_sequence (key_up);
> >> +    case KEY_RIGHT:
> >> +      return start_sequence (key_right);
> >> +    case KEY_LEFT:
> >> +      return start_sequence (key_left);
> >> +    case KEY_HOME:
> >> +      return start_sequence (key_home);
> >> +    case KEY_END:
> >> +      return start_sequence (key_end);
> >> +    case KEY_DC: /* del */
> >> +      return start_sequence (key_dc);
> >> +    case KEY_IC: /* ins */
> >> +      return start_sequence (key_ic);
> >> +    }
> >
> > PDcurses doesn't have these key_npage/key_ppage/key_down/... variables,
> > so I had to use the hardcoded sequences as you described.
> > This is working for the arrow keys and home/end, and for del I used '\004'
> > instead, but I didn't see any for page up/down and ins.
>
> Ack.  \004 is ctrl-d  ('d' & 0x1f).  I'm a bit wary of hardcoding it,
> since I imagine there might be some users out where that have bound
> ctrl-d to some other action in their inputrc.
>
> readline's bind_arrow_keys_internal has:
>
> #if defined (__MINGW32__)
>   rl_bind_keyseq_if_unbound ("\340H", rl_get_previous_history);
>   rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history);
>   rl_bind_keyseq_if_unbound ("\340M", rl_forward_char);
>   rl_bind_keyseq_if_unbound ("\340K", rl_backward_char);
>   rl_bind_keyseq_if_unbound ("\340G", rl_beg_of_line);
>   rl_bind_keyseq_if_unbound ("\340O", rl_end_of_line);
>   rl_bind_keyseq_if_unbound ("\340S", rl_delete);
>   rl_bind_keyseq_if_unbound ("\340R", rl_overwrite_mode);
>
>   /* These may or may not work because of the embedded NUL. */
>   rl_bind_keyseq_if_unbound ("\\000H", rl_get_previous_history);
>   rl_bind_keyseq_if_unbound ("\\000P", rl_get_next_history);
>   rl_bind_keyseq_if_unbound ("\\000M", rl_forward_char);
>   rl_bind_keyseq_if_unbound ("\\000K", rl_backward_char);
>   rl_bind_keyseq_if_unbound ("\\000G", rl_beg_of_line);
>   rl_bind_keyseq_if_unbound ("\\000O", rl_end_of_line);
>   rl_bind_keyseq_if_unbound ("\\000S", rl_delete);
>   rl_bind_keyseq_if_unbound ("\\000R", rl_overwrite_mode);
> #endif
>
> So would "\340S" and "\340R" work instead?  See attached patch.
>
> >
> > I'm not sure if it's even a problem for page up/down, they seem to not be used
> > by readline, but I couldn't make ins work.
>
> Ins works for me on konsole, and on a linux virtual console.  It does not work
> on xterm and rxvt.  Nor on konsole + ssh.  Nor under screen.  I confirmed that
> I get the same key sequence for the insert key on all those cases (run "cat" + press
> the key).  It's the same with bash and gdb in non-tui mode.  It's not specific to this
> patch.  I would guess readline is somehow finding that the terminal does not support
> overwrite mode.
>
> >
> > And rl_get_termcap returned for everything except "le" NULL, but I assume
> > that's just how it is on Windows.
>
> Unfortunate.
>
> Here's a new version.  Does this one work for you?

Yes, with this everything works, thanks.

Hannes