Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hannes Domani via Gdb-patches <gdb-patches@sourceware.org>
To: Hannes Domani via Gdb-patches <gdb-patches@sourceware.org>,
	 Tom Tromey <tom@tromey.com>, Pedro Alves <pedro@palves.net>
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: Re: POC: Make the TUI command window support the mouse (Re: [PATCHv3 1/2] Initial TUI mouse support)
Date: Sat, 12 Jun 2021 12:32:25 +0000 (UTC)	[thread overview]
Message-ID: <1761936332.9225994.1623501145444@mail.yahoo.com> (raw)
In-Reply-To: <bb8428c5-06fb-c86f-2786-bb6c46ae0886@palves.net>

 Am Samstag, 12. Juni 2021, 04:41:12 MESZ hat Pedro Alves <pedro@palves.net> Folgendes geschrieben:

> On 2021-06-11 12:02 p.m., Hannes Domani wrote:
> >  Am Donnerstag, 10. Juni 2021, 20:47:01 MESZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben:
> >
> >>>>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:
> >>
> >> Hannes> I imagine the same is true for mouse escape sequences.
> >> Hannes> So I would just disable the mouse when the command window has focus, but
> >> Hannes> what do you think?
> >>
> >> I think this is a good fallback to have, but it would be better if we
> >> could make it really work somehow.  The problem with doing this is that
> >> if the command window has focus, then things like clicking in the source
> >> to set a breakpoint will not work.
> >
> > That would probably mean that keypad also has to be enabled when the
> > command window has focus.
> > I did a short test where I tried this, but then gdb crashed somewhere in
> > readline, and I stopped there, because I didn't want to debug readline code.
>
> We disable the keypad in the command window because we want to pass all escape
> sequences to readline, unprocessed by ncurses, so that e.g., up/down navigates
> the command history, left/right moves the cursor position, etc., just like if
> you weren't in the TUI.
>
> I first thought of fixing this by enabling the keypad, and then where we handle
> KEY_UP, etc., special case the command window, and call readline functions that do
> what you'd expect.  But the thing is that ends up being a poor readline emulation,
> and I didn't like where this was going.  Especially when I realized that for example,
> when you're in the middle for a reverse-search (c-r), KEY_UP does something different.
> Etc.
>
> I had a different idea to make this all work.  Warning, this is either a brilliant hack,
> or a really nasty hack, depending on perspective.  :-)
>
> The idea is to keep the keypad disabled in the command window.  However,
> we need to enable the keypad for ncurses to process mouse escape sequences.
> This is a conflict.  So here's the main trick behind the idea.  It breaks the conflict.
> Create a separate ncurses screen/terminal, with newterm, which reads from a pipe instead
> of from stdin.  Then, flush data from stdin into this pipe, BUT, make sure to never flush
> a non-mouse escape sequence into the pipe.  It's like the pipe is stdin, but with any
> non-mouse escape sequence filtered out.  This way, ncurses only either sees mouse
> escape sequences or normal ASCII keys.  In order to do this, we need to use
> a separate thread to flush stdin to the pipe.
>
> I gave this a try the other weekend, and ran into issues.  Today/tonight I gave it
> another go, and got it working.  It is a bit rough around the edges, but
> seems to work nicely.

If this works on Linux, then that's great, but Windows doesn't send mouse
escape sequences.

On the other hand, if keypad was enabled, couldn't we just forward readline
the escape sequences for the arrow keys instead?


Hannes

  reply	other threads:[~2021-06-12 12:33 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210603151453.15248-1-ssbssa.ref@yahoo.de>
2021-06-03 15:14 ` [PATCHv3 1/2] Initial TUI mouse support Hannes Domani via Gdb-patches
2021-06-03 15:14   ` [PATCHv3 2/2] Forward mouse click to python TUI window Hannes Domani via Gdb-patches
2021-06-03 17:16     ` Eli Zaretskii via Gdb-patches
2021-06-04 13:52     ` Tom Tromey
2021-06-04 13:51   ` [PATCHv3 1/2] Initial TUI mouse support Tom Tromey
2021-06-04 14:21     ` Hannes Domani via Gdb-patches
2021-06-04 15:20       ` Pedro Alves
2021-06-04 16:06         ` Hannes Domani via Gdb-patches
2021-06-04 16:23           ` Pedro Alves
2021-06-04 18:59             ` Eli Zaretskii via Gdb-patches
2021-06-04 18:57           ` Eli Zaretskii via Gdb-patches
2021-06-04 16:29         ` Pedro Alves
2021-06-04 16:48           ` Hannes Domani via Gdb-patches
2021-06-04 18:05             ` Joel Brobecker
2021-06-04 18:13           ` Simon Marchi via Gdb-patches
2021-06-04 18:39             ` Joel Brobecker
2021-06-04 20:31             ` Pedro Alves
2021-06-04 20:43               ` Pedro Alves
2021-06-04 21:15               ` Hannes Domani via Gdb-patches
2021-06-04 22:19                 ` Pedro Alves
2021-06-10 18:44               ` Tom Tromey
2021-06-13 17:26                 ` Pedro Alves
2021-06-18 15:01                   ` Tom Tromey
2021-06-18 17:42                     ` Pedro Alves
2021-06-04 18:46           ` Tom Tromey
2021-06-04 20:54             ` Pedro Alves
2021-06-04 23:48               ` Pedro Alves
2021-06-05 14:40                 ` Hannes Domani via Gdb-patches
2021-06-06  5:46                   ` Eli Zaretskii via Gdb-patches
2021-06-10 18:46                   ` Tom Tromey
2021-06-11 11:02                     ` Hannes Domani via Gdb-patches
2021-06-12  2:41                       ` POC: Make the TUI command window support the mouse (Re: [PATCHv3 1/2] Initial TUI mouse support) Pedro Alves
2021-06-12 12:32                         ` Hannes Domani via Gdb-patches [this message]
2021-06-12 18:08                           ` Pedro Alves
2021-06-13  2:46                             ` [PATCH v2] Make the TUI command window support the mouse Pedro Alves
2021-06-13 10:35                               ` Eli Zaretskii via Gdb-patches
2021-06-13 17:29                                 ` Pedro Alves
2021-06-13 18:02                                   ` Eli Zaretskii via Gdb-patches
2021-06-13 18:13                                     ` Pedro Alves
2021-06-13 13:04                               ` Hannes Domani via Gdb-patches
2021-06-13 17:25                                 ` [PATCH v3] " Pedro Alves
2021-06-13 17:55                                   ` Hannes Domani via Gdb-patches
2021-06-13 17:59                                     ` Pedro Alves
2021-06-17 11:04                                       ` [PUSHED v4] " Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1761936332.9225994.1623501145444@mail.yahoo.com \
    --to=gdb-patches@sourceware.org \
    --cc=brobecker@adacore.com \
    --cc=pedro@palves.net \
    --cc=ssbssa@yahoo.de \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox