public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: strager <strager.nds@gmail.com>
To: Andrew Burgess <aburgess@redhat.com>, Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/tui: add 'set tui mouse-events off' to restore mouse selection
Date: Wed, 1 Feb 2023 17:08:55 -0800	[thread overview]
Message-ID: <CAC-ggsHb6P2hS9FsVfan6ZEk9JSU=Zqt1PKvkfLSn33iRcF-6A@mail.gmail.com> (raw)
In-Reply-To: <87ilgltt15.fsf@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 6598 bytes --]

On Wed, Feb 1, 2023 at 4:41 AM Eli Zaretskii <eliz@gnu.org> wrote:
> This is OK, except that I don't think we use the term "plug-in" in our
> documentation.  I suggest to use "Python extensions" instead.

Fixed!

On Wed, Feb 1, 2023 at 4:41 AM Eli Zaretskii <eliz@gnu.org> wrote:
> Likewise here, and also please leave 2 spaces between sentences, per
> US English conventions we use in our documentation.
Fixed!

On Wed, Feb 1, 2023 at 5:27 AM Andrew Burgess <aburgess@redhat.com> wrote:
> I think it would be worth adding some text to the description of
> Window.click in doc/python.texi, along with a cross-reference back to
> this setting, as the Window.click is not going to work when this setting
> is off.

Great idea! I also found the "TUI Mouse Support" section and included
a few links in there too.

This is my first time using texinfo, so let me know if I made any mistakes.

Updated patch is attached.

---
 gdb/NEWS            |  6 ++++++
 gdb/doc/gdb.texinfo | 15 ++++++++++++++-
 gdb/doc/python.texi |  5 +++++
 gdb/tui/tui-io.c    |  3 ++-
 gdb/tui/tui-win.c   | 22 ++++++++++++++++++++++
 gdb/tui/tui-win.h   |  3 +++
 6 files changed, 52 insertions(+), 2 deletions(-)

diff --git gdb/NEWS gdb/NEWS
index 445d28efed9..1a00a6bd799 100644
--- gdb/NEWS
+++ gdb/NEWS
@@ -38,6 +38,12 @@ maintenance print record-instruction [ N ]
   prints how GDB would undo the N-th previous instruction, and if N is
   positive, it prints how GDB will redo the N-th following instruction.

+set tui mouse-events [on|off]
+show tui mouse-events
+  When on (default), mouse clicks control the TUI and can be accessed by
+  Python extensions.  When off, mouse clicks are handled by the terminal,
+  enabling terminal-native text selection.
+
 * MI changes

 ** mi now reports 'no-history' as a stop reason when hitting the end of the
diff --git gdb/doc/gdb.texinfo gdb/doc/gdb.texinfo
index 03033c7f9e3..65e85c7f8a1 100644
--- gdb/doc/gdb.texinfo
+++ gdb/doc/gdb.texinfo
@@ -29606,7 +29606,13 @@ the @key{SHIFT} key on your keyboard to
temporarily bypass
 @value{GDBN}'s TUI and access the terminal's native mouse copy/paste
 functionality (commonly, click-drag-release or double-click to select
 text, middle-click to paste).  This copy/paste works with the
-terminal's selection buffer, as opposed to the TUI's buffer.
+terminal's selection buffer, as opposed to the TUI's buffer.  Alternatively, to
+disable mouse support in the TUI entirely and give the terminal control over
+mouse clicks, turn off the @code{tui mouse-events} setting
+(@pxref{tui-mouse-events,,set tui mouse-events}).
+
+Python extensions can react to mouse clicks
+(@pxref{python-window-click,,Window.click}).

 @node TUI Commands
 @section TUI-specific Commands
@@ -29888,6 +29894,13 @@ source text at the next tab stop; the compact
display uses only as
 much space as is needed for the line numbers in the current file, and
 only a single space to separate the line numbers from the source.

+@anchor{tui-mouse-events}
+@item set tui mouse-events @r{[}on@r{|}off@r{]}
+@kindex set tui mouse-events
+When on (default), mouse clicks control the TUI (@pxref{TUI Mouse Support}).
+When off, mouse clicks are handled by the terminal, enabling terminal-native
+text selection.
+
 @kindex set debug tui
 @item set debug tui @r{[}on|off@r{]}
 Turn on or off display of @value{GDBN} internal debug messages relating
diff --git gdb/doc/python.texi gdb/doc/python.texi
index b04f1de2ddf..ab3050ca15c 100644
--- gdb/doc/python.texi
+++ gdb/doc/python.texi
@@ -6722,11 +6722,16 @@ contents.  A positive argument should cause
the viewport to move down,
 and so the content should appear to move up.
 @end defun

+@anchor{python-window-click}
 @defun Window.click (@var{x}, @var{y}, @var{button})
 This is called on a mouse click in this window.  @var{x} and @var{y} are
 the mouse coordinates inside the window (0-based, from the top left
 corner), and @var{button} specifies which mouse button was used, whose
 values can be 1 (left), 2 (middle), or 3 (right).
+
+When TUI mouse events are disabled by turning off the @code{tui mouse-events}
+setting (@pxref{tui-mouse-events,,set tui mouse-events}), then
@code{click} will
+not be called.
 @end defun

 @node Disassembly In Python
diff --git gdb/tui/tui-io.c gdb/tui/tui-io.c
index a17cf38a1f2..45ef34aeab5 100644
--- gdb/tui/tui-io.c
+++ gdb/tui/tui-io.c
@@ -655,7 +655,8 @@ static void
 tui_prep_terminal (int notused1)
 {
 #ifdef NCURSES_MOUSE_VERSION
-  mousemask (ALL_MOUSE_EVENTS, NULL);
+  if (tui_enable_mouse)
+    mousemask (ALL_MOUSE_EVENTS, NULL);
 #endif
 }

diff --git gdb/tui/tui-win.c gdb/tui/tui-win.c
index 008189eb99b..101fefcfe0a 100644
--- gdb/tui/tui-win.c
+++ gdb/tui/tui-win.c
@@ -897,6 +897,17 @@ tui_show_compact_source (struct ui_file *file,
int from_tty,
   gdb_printf (file, _("TUI source window compactness is %s.\n"), value);
 }

+bool tui_enable_mouse = true;
+
+/* Implement 'show tui mouse-events'.  */
+
+static void
+show_tui_mouse_events (struct ui_file *file, int from_tty,
+               struct cmd_list_element *c, const char *value)
+{
+  gdb_printf (file, _("TUI mouse events are %s.\n"), value);
+}
+
 /* Set the tab width of the specified window.  */
 static void
 tui_set_tab_width_command (const char *arg, int from_tty)
@@ -1284,6 +1295,17 @@ position indicator is styled."),
                &style_set_list,
                &style_show_list);

+  add_setshow_boolean_cmd ("mouse-events", class_tui,
+               &tui_enable_mouse, _("\
+Set whether TUI mode handles mouse clicks."), _("\
+Show whether TUI mode handles mouse clicks."), _("\
+When on (default), mouse clicks control the TUI and can be accessed
by Python\n\
+extensions.  When off, mouse clicks are handled by the terminal, enabling\n\
+terminal-native text selection."),
+               NULL,
+               show_tui_mouse_events,
+               &tui_setlist, &tui_showlist);
+
   tui_border_style.changed.attach (tui_rehighlight_all, "tui-win");
   tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win");
 }
diff --git gdb/tui/tui-win.h gdb/tui/tui-win.h
index 4b33f1f2b54..039993fba34 100644
--- gdb/tui/tui-win.h
+++ gdb/tui/tui-win.h
@@ -51,6 +51,9 @@ struct cmd_list_element **tui_get_cmd_list (void);
 /* Whether compact source display should be used.  */
 extern bool compact_source;

+/* Whether the TUI should intercept terminal mouse events.  */
+extern bool tui_enable_mouse;
+
 /* Whether to style the source and assembly code highlighted by the TUI's
    current position indicator.  */
 extern bool style_tui_current_position;
-- 
2.29.2

[-- Attachment #2: 0001-gdb-tui-add-set-tui-mouse-events-off-to-restore-mous.patch --]
[-- Type: application/x-patch, Size: 7614 bytes --]

  reply	other threads:[~2023-02-02  1:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-28  0:42 strager
2023-01-28  8:35 ` Eli Zaretskii
2023-02-01  8:35   ` strager
2023-02-01 12:41     ` Eli Zaretskii
2023-02-01 13:27     ` Andrew Burgess
2023-02-02  1:08       ` strager [this message]
2023-02-02  7:18         ` Eli Zaretskii
2023-02-02 19:50         ` Pedro Alves
2023-02-02 19:59           ` strager
2023-09-14  8:05             ` strager
2023-09-20 15:39               ` Pedro Alves
2023-02-02  9:33 ` Lancelot SIX
2023-02-02 11:11   ` strager

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='CAC-ggsHb6P2hS9FsVfan6ZEk9JSU=Zqt1PKvkfLSn33iRcF-6A@mail.gmail.com' \
    --to=strager.nds@gmail.com \
    --cc=aburgess@redhat.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).