Re: [PATCHv3 1/2] Initial TUI mouse support

Pedro Alves
2021-06-04T20:32:26Z

On 2021-06-04 7:13 p.m., Simon Marchi wrote:
> On 2021-06-04 12:29 p.m., Pedro Alves wrote:
>> The trouble is that now pressing anywhere on the screen with the mouse just results in
>> weird characters being printed on the command line window (probably uninterpreted control
>> sequences). That even prevents me from selecting text (something I do often) -- I wanted to do
>> that to paste the results here. I even tried suspending GDB with ^Z to then copy the text, but
>> that still leaves the mouse messed up. See this screenshot:
>>
>> https://i.imgur.com/bO7FKDO.png
>>
>> This was on Ubuntu 20.04.
>
> Obviously the printing random characters is bad. But it's possible that
> the not being able to select text is normal, as the application (GDB)
> now supports mouse events. In some terminal emulators, you can press
> shift while you click to say "I really want to select the display
> characters, not send mouse events to the program".

I'm on my Fedora 32 laptop currently, and here it works fine.

You can select text without having press any key. It basically works
as before. I suppose we could teach GDB to be smarter about text selection -- like,
if you select several lines of source code in the TUI source window, ideally
we'd select just the source code, instead of the source code plus the window
borders, etc. Then we would have an "escape" key to be able to disable special
mouse mode so you can select text in the whole terminal using regular text
terminal selection, and I suppose that that's what "shift" does in those programs
you mention.

I'm surprised to find that clicking a window doesn't set focus on it, though.
Is that supposed to work?

Pedro Alves

>
> It's the same with other TUI apps for me:
>
> - tmux (with "set -g mouse on" in ~/.tmux.conf)
> - tig (I don't remember if anything is needed to enable mouse support)
> - weechat (I don't remember if anything is needed to enable mouse
> support)
>
> In some of these programs, mouse support is disabled by default and you
> have to use some setting to enable it. So by default, standard
> selection would work. But if you enable mouse suport, then you have to
> use shift+click to select.
>
> Simon
>