aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-io.c
diff options
context:
space:
mode:
authorHannes Domani <ssbssa@yahoo.de>2020-12-20 16:45:57 +0100
committerHannes Domani <ssbssa@yahoo.de>2021-06-04 16:15:01 +0200
commit1bace02a96a7124accf7910f271663b0b7e8754b (patch)
tree754add41ed47ed999e37ff986811e7da33b8f2bc /gdb/tui/tui-io.c
parent25e821a6c2db1f7fea8a50ff0deeb34af2e72aa3 (diff)
downloadgdb-1bace02a96a7124accf7910f271663b0b7e8754b.zip
gdb-1bace02a96a7124accf7910f271663b0b7e8754b.tar.gz
gdb-1bace02a96a7124accf7910f271663b0b7e8754b.tar.bz2
Initial TUI mouse support
Implements an overridable tui_win_info::click method whose arguments are the mouse coordinates inside the specific window, and the mouse button clicked. And if the curses implementation supports 5 buttons, the 4th and 5th buttons are used for scrolling. gdb/ChangeLog: 2021-06-04 Hannes Domani <ssbssa@yahoo.de> * ser-mingw.c (console_select_thread): Handle MOUSE_EVENT. * tui/tui-data.h (struct tui_win_info): Add click function. * tui/tui-io.c (tui_prep_terminal): Enable mouse events. (tui_deprep_terminal): Disable mouse events. (tui_dispatch_ctrl_char): Handle KEY_MOUSE. * tui/tui.c (tui_disable): Disable mouse events.
Diffstat (limited to 'gdb/tui/tui-io.c')
-rw-r--r--gdb/tui/tui-io.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index a2be4d4..7df0e2f 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -639,6 +639,9 @@ tui_redisplay_readline (void)
static void
tui_prep_terminal (int notused1)
{
+#ifdef NCURSES_MOUSE_VERSION
+ mousemask (ALL_MOUSE_EVENTS, NULL);
+#endif
}
/* Readline callback to restore the terminal. It is called once each
@@ -646,6 +649,9 @@ tui_prep_terminal (int notused1)
static void
tui_deprep_terminal (void)
{
+#ifdef NCURSES_MOUSE_VERSION
+ mousemask (0, NULL);
+#endif
}
#ifdef TUI_USE_PIPE_FOR_READLINE
@@ -978,6 +984,37 @@ tui_dispatch_ctrl_char (unsigned int ch)
case KEY_LEFT:
win_info->right_scroll (1);
break;
+#ifdef NCURSES_MOUSE_VERSION
+ case KEY_MOUSE:
+ {
+ MEVENT mev;
+ if (getmouse (&mev) != OK)
+ break;
+
+ for (tui_win_info *wi : all_tui_windows ())
+ if (mev.x > wi->x && mev.x < wi->x + wi->width - 1
+ && mev.y > wi->y && mev.y < wi->y + wi->height - 1)
+ {
+ if ((mev.bstate & BUTTON1_CLICKED) != 0
+ || (mev.bstate & BUTTON2_CLICKED) != 0
+ || (mev.bstate & BUTTON3_CLICKED) != 0)
+ {
+ int button = (mev.bstate & BUTTON1_CLICKED) != 0 ? 1
+ : ((mev.bstate & BUTTON2_CLICKED) != 0 ? 2
+ : 3);
+ wi->click (mev.x - wi->x - 1, mev.y - wi->y - 1, button);
+ }
+#ifdef BUTTON5_PRESSED
+ else if ((mev.bstate & BUTTON4_PRESSED) != 0)
+ wi->backward_scroll (3);
+ else if ((mev.bstate & BUTTON5_PRESSED) != 0)
+ wi->forward_scroll (3);
+#endif
+ break;
+ }
+ }
+ break;
+#endif
case '\f':
break;
default: