Oops, I forgot to cc gdb-patches@. > Instead of talking about overriding the terminal's behavior, this text > should say that the mouse events are interpreted either by GDB or by > the terminal. Thanks for the feedback. I removed the duplicate copy of 'set tui compact-source' documentation. I rewrote the 'set tui mouse-events' documentation to avoid mentioning 'overriding'. I also fixed a typo in the 'show tui mouse-events' command and fixed a typo in the commit message (see attached). --- gdb/NEWS | 6 ++++++ gdb/doc/gdb.texinfo | 6 ++++++ gdb/tui/tui-io.c | 3 ++- gdb/tui/tui-win.c | 23 +++++++++++++++++++++++ gdb/tui/tui-win.h | 3 +++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git gdb/NEWS gdb/NEWS index 445d28efed9..21399e86caa 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 + plugins. When off, mouse clicks are handled by the terminal. This enables + 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..02de9ad753a 100644 --- gdb/doc/gdb.texinfo +++ gdb/doc/gdb.texinfo @@ -29888,6 +29888,12 @@ 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-events @r{[}on@r{|}off@r{]} +@kindex set tui mouse-events +When on (default), mouse clicks control the TUI and can be accessed by plugins. +When off, mouse clicks are handled by the terminal. This enables 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/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..d7124592ca4 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,18 @@ 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 plugins.\n\ +When off, mouse clicks are handled by the terminal. This enables terminal-native\n\ +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