public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Hannes Domani <ssbssa@yahoo.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/3] Add setting to enable/disable TUI mouse handling
Date: Mon,  7 Jun 2021 18:30:03 +0200	[thread overview]
Message-ID: <20210607163003.621-3-ssbssa@yahoo.de> (raw)
In-Reply-To: <20210607163003.621-1-ssbssa@yahoo.de>

Useful if the mouse events don't work correctly on a system, or the user just
doesn't need them.

gdb/ChangeLog:

2021-06-07  Hannes Domani  <ssbssa@yahoo.de>

	* tui/tui-data.c (tui_set_win_focus_to): Handle mouse setting.
	* tui/tui-io.c (tui_prep_terminal): Likewise.
	* tui/tui-win.c (tui_mouse): New global.
	(tui_set_mouse, tui_show_mouse_function): New functions.
	(_initialize_tui_win): Add mouse setting.
	* tui/tui-win.h (tui_mouse): Declare.

gdb/doc/ChangeLog:

2021-06-07  Hannes Domani  <ssbssa@yahoo.de>

	* gdb.texinfo (TUI Configuration): Document mouse setting.
---
 gdb/doc/gdb.texinfo |  4 ++++
 gdb/tui/tui-data.c  |  3 ++-
 gdb/tui/tui-io.c    |  2 +-
 gdb/tui/tui-win.c   | 36 ++++++++++++++++++++++++++++++++++++
 gdb/tui/tui-win.h   |  3 +++
 5 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 90d827a50e7..76d6bc8d321 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -28909,6 +28909,10 @@ The default display uses more space for line numbers and starts the
 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.
+
+@item set tui mouse @r{[}on@r{|}off@r{]}
+@kindex set tui mouse
+Set whether the TUI handles mouse events.
 @end table
 
 Note that the colors of the TUI borders can be controlled using the
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index e6452386628..43538766857 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -78,7 +78,8 @@ tui_set_win_focus_to (struct tui_win_info *win_info)
 #ifdef NCURSES_MOUSE_VERSION
       /* The mouse events only work with enabled keypad, so enable them
 	 accordingly.  */
-      mousemask (win_info != TUI_CMD_WIN ? ALL_MOUSE_EVENTS : 0, NULL);
+      mousemask ((tui_mouse && win_info != TUI_CMD_WIN
+		  ? ALL_MOUSE_EVENTS : 0), NULL);
 #endif
     }
 }
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 4570e55231b..075b4fa58c8 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -640,7 +640,7 @@ static void
 tui_prep_terminal (int notused1)
 {
 #ifdef NCURSES_MOUSE_VERSION
-  if (tui_win_with_focus () != TUI_CMD_WIN)
+  if (tui_mouse && tui_win_with_focus () != TUI_CMD_WIN)
     mousemask (ALL_MOUSE_EVENTS, NULL);
 #endif
 }
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 094b503eae8..2211f987fc4 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -822,6 +822,34 @@ tui_show_compact_source (struct ui_file *file, int from_tty,
   printf_filtered (_("TUI source window compactness is %s.\n"), value);
 }
 
+/* See tui-win.h.  */
+
+bool tui_mouse = false;
+
+/* Callback for "set tui mouse".  */
+
+static void
+tui_set_mouse (const char *ignore, int from_tty,
+	       struct cmd_list_element *c)
+{
+#ifndef NCURSES_MOUSE_VERSION
+  if (tui_mouse)
+    {
+      tui_mouse = false;
+      error (_("The curses library does not provide mouse events."));
+    }
+#endif
+}
+
+/* Callback for "show tui mouse".  */
+
+static void
+tui_show_mouse_function (struct ui_file *file, int from_tty,
+			 struct cmd_list_element *c, const char *value)
+{
+  printf_filtered (_("Handling of mouse events in TUI is %s.\n"), value);
+}
+
 /* Set the tab width of the specified window.  */
 static void
 tui_set_tab_width_command (const char *arg, int from_tty)
@@ -1119,6 +1147,14 @@ the line numbers and uses less horizontal space."),
 			   tui_set_compact_source, tui_show_compact_source,
 			   &tui_setlist, &tui_showlist);
 
+  add_setshow_boolean_cmd ("mouse", class_tui,
+			   &tui_mouse, _("\
+Set whether the TUI handles mouse events."), _("\
+Show whether the TUI handles mouse events."),
+			   nullptr,
+			   tui_set_mouse, tui_show_mouse_function,
+			   &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 a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index e9da9b98477..f771ec87400 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -51,4 +51,7 @@ struct cmd_list_element **tui_get_cmd_list (void);
 /* Whether compact source display should be used.  */
 extern bool compact_source;
 
+/* Whether the TUI handles mouse events.  */
+extern bool tui_mouse;
+
 #endif /* TUI_TUI_WIN_H */
-- 
2.31.1


  parent reply	other threads:[~2021-06-07 16:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210607163003.621-1-ssbssa.ref@yahoo.de>
2021-06-07 16:30 ` [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to Hannes Domani
2021-06-07 16:30   ` [PATCH 2/3] Disable mouse events if the command window has focos Hannes Domani
2021-06-07 16:30   ` Hannes Domani [this message]
2021-06-07 16:49     ` [PATCH 3/3] Add setting to enable/disable TUI mouse handling Eli Zaretskii
2021-06-17 14:54   ` [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to Hannes Domani

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=20210607163003.621-3-ssbssa@yahoo.de \
    --to=ssbssa@yahoo.de \
    --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).