From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 584043858D33 for ; Wed, 1 Feb 2023 13:27:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 584043858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675258058; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eHkikIkLLL5shLP8+yg5uenC6jptyYkBCcjMcC5Rl4c=; b=JIYKecKP6icYghnh+rr+hPOOKe4dAu1agvXd5YlSeY8cinTNFreEY0Cd+K/h1iJkvv97zQ 8sRO/yvrH+UYkIsfgcyOZvTWYcXS8Y2DNmeSytHqTkP02VOkSr+R5HFzHtZ/vNA6/viuT7 jBHTVgWezbvNIW9+B+Mwud7Hp5rX5p4= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-623-gZ7NYmegPtCp-azwDneRbw-1; Wed, 01 Feb 2023 08:27:38 -0500 X-MC-Unique: gZ7NYmegPtCp-azwDneRbw-1 Received: by mail-qk1-f198.google.com with SMTP id c18-20020a05620a269200b0070d0f35e15eso11077609qkp.12 for ; Wed, 01 Feb 2023 05:27:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eHkikIkLLL5shLP8+yg5uenC6jptyYkBCcjMcC5Rl4c=; b=AkLLdr8qBHzBKAIz5+O6B40QVosSfwYJXNoTPFH0TE1wd/fGR3Jhm97gkAVLCrGDDX /yC9ssx0MMdOEMHWoutjaQ7dCs25HBDYkk2qs7e5n52HKCDNxsDd6EOqadHA54AVgs5a nyKtOvRKVHXiTLLflslmUDoE0PBUQSj7WD2H9tSD6fPpNDD/QNBtE6L9QYPKjMnXc/Q7 xfaqydjy+iwbNhwwdvkc3etWpSub+BEWv7QjqHPgGFa3bV6zyMblEpfpvPL98cr7CCVQ 4ow6eXLl4PWEVjBSKtW0dvbqKG+wVMO9TN82+vyUP/mmNsdB9cLQRd89EVMWi8X/vFWY tfJQ== X-Gm-Message-State: AO0yUKVIA2fk5VsnsG1Zt0iM++Dwz7DfA/ET4P0dpYRQp1qWgBiB1n6Z CfVd0vU2xVF+VctPoA5IXyC+Ccyc6Uu75b5hOOojiPhDuVVooTQhOv/2TjIFFv4OeMrtocogieZ cdHv8e6/ZWEDVsr9pX1ms3Q== X-Received: by 2002:a05:622a:345:b0:3b8:6a5d:cd97 with SMTP id r5-20020a05622a034500b003b86a5dcd97mr4172778qtw.34.1675258057542; Wed, 01 Feb 2023 05:27:37 -0800 (PST) X-Google-Smtp-Source: AK7set+B4iJKbVhAKqh98X1PQ0CYzT5vmcqzgl6wW/IXPDM1ftLd3y0Zqx5CQiQvELq3V3bi81Sxqw== X-Received: by 2002:a05:622a:345:b0:3b8:6a5d:cd97 with SMTP id r5-20020a05622a034500b003b86a5dcd97mr4172753qtw.34.1675258057252; Wed, 01 Feb 2023 05:27:37 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id eo3-20020a05622a544300b003b9ba2cf068sm1052774qtb.56.2023.02.01.05.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 05:27:36 -0800 (PST) From: Andrew Burgess To: strager , Eli Zaretskii Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb/tui: add 'set tui mouse-events off' to restore mouse selection In-Reply-To: References: <838rhnawf9.fsf@gnu.org> Date: Wed, 01 Feb 2023 13:27:34 +0000 Message-ID: <87ilgltt15.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_PDS_OTHER_BAD_TLD autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: strager via Gdb-patches writes: > 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 > From 3ee6bc8ad0b5ac17725233ba88aa4d12167df4f7 Mon Sep 17 00:00:00 2001 > From: "Matthew \"strager\" Glazar" > Date: Fri, 27 Jan 2023 16:19:45 -0800 > Subject: [PATCH] gdb/tui: add 'set tui mouse-events off' to restore mouse > selection > > Rationale: > I use the mouse with my terminal to select and copy text. In gdb, I use > the mouse to select a function name to set a breakpoint, or a variable > name to print, for example. > > When gdb is compiled with ncurses mouse support, gdb's TUI mode > intercepts mouse events. Left-clicking and dragging, which would > normally select text, seems to do nothing. This means I cannot select > text using my mouse anymore. This makes it harder to set breakpoints, > print variables, etc. > > Solution: > I tried to fix this issue by editing the 'mousemask' call to only enable > buttons 4 and 5. However, this still caused my terminal (gnome-terminal) > to not allow text to be selected. The only way I could make it work is > by calling 'mousemask (0, NULL);'. But doing so disables the mouse code > entirely, which other people might want. > > I therefore decided to make a setting in gdb called 'tui mouse-events'. > If enabled (the default), the behavior is as it is now: terminal mouse > events are given to gdb, disabling the terminal's default behavior. > If disabled (opt-in), the behavior is as it was before the year 2020: > terminal mouse events are not given to gdb, therefore the mouse can be > used to select and copy text. > > Notes: > I am not attached to the setting name or its description. Feel free to > suggest better wording. > > Testing: > I tested this change in gnome-terminal by performing the following steps > manually: > > 1. Run: gdb --args ./myprogram > 2. Enable TUI: press ctrl-x ctrl-a > 3. Click and drag text with the mouse. Observe no selection. > 4. Input: set tui mouse-events off > 5. Click and drag text with the mouse. Observe that selection works now. > 6. Input: set tui mouse-events on. > 7. Click and drag text with the mouse Observe no selection. > --- > 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. 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. Thanks, Andrew > + > @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