public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Hannes Domani via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCHv2 1/2] Initial TUI mouse support
Date: Wed, 02 Jun 2021 12:48:16 -0600	[thread overview]
Message-ID: <87fsy0p0gf.fsf@tromey.com> (raw)
In-Reply-To: <20210529142636.11432-1-ssbssa@yahoo.de> (Hannes Domani via Gdb-patches's message of "Sat, 29 May 2021 16:26:35 +0200")

>>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:

Hannes> Implements an overridable tui_win_info::click method whose arguments
Hannes> are the mouse coordinates inside the specific window, and the mouse
Hannes> button clicked.

Hannes> And if the curses implementation supports 5 buttons, the 4th and 5th
Hannes> buttons are used for scrolling.

Thank you for doing this.  I have a few minor comments.

Hannes> Should there be a configure option for this at build time?
Hannes> I don't know if the mousemask/getmouse functions are available for
Hannes> all curses variants, so I would imagine an option --enable-mouse:
Hannes> - yes -> error if getmouse can't be linked
Hannes> - no -> just disable
Hannes> - auto -> enable if getmouse can be linked

I think it's fine to move forward, and if we have problems with it, we
can add a configure check for 'mousemask' and use that to disable the
new code.

The ncurses man page says we could check NCURSES_MOUSE_VERSION to see if
this is available.  So maybe new configure code isn't even needed.

       The feature macro NCURSES_MOUSE_VERSION is provided so the preprocessor
       can be used to test whether these features are present.

Hannes> +  /* Called for each mouse click inside this window.  */
Hannes> +  virtual void click (int mouse_x, int mouse_y, int mouse_button)
Hannes> +  {

I think it would be nice if this comment documented the meaning of x/y
(are they window- or terminal-relative?  And 0- or 1-based?) and also
the possible/typical values of mouse_button (0- or 1-based?).

Hannes> diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
Hannes> index a2be4d4353e..7787789f0c7 100644
Hannes> --- a/gdb/tui/tui-io.c
Hannes> +++ b/gdb/tui/tui-io.c
Hannes> @@ -33,6 +33,7 @@
Hannes>  #include "tui/tui-wingeneral.h"
Hannes>  #include "tui/tui-file.h"
Hannes>  #include "tui/tui-out.h"
Hannes> +#include "tui/tui-source.h"

Why was this needed?

Hannes> +		if ((mev.bstate & BUTTON1_CLICKED)
Hannes> +		    || (mev.bstate & BUTTON2_CLICKED)
Hannes> +		    || (mev.bstate & BUTTON3_CLICKED))

gdb style would use a '!= 0' after each test.

Hannes> +		  {
Hannes> +		    int button = (mev.bstate & BUTTON1_CLICKED) ? 1
Hannes> +		      : (mev.bstate & BUTTON2_CLICKED) ? 2
Hannes> +		      : 3;

The right-hand-side here would normally have an extra layer of () so
that the continuation lines are indented.  Also it would be good to
reformat that so the "?..:" parts line up more clearly.

thanks,
Tom

      parent reply	other threads:[~2021-06-02 18:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210529142636.11432-1-ssbssa.ref@yahoo.de>
2021-05-29 14:26 ` Hannes Domani
2021-05-29 14:26   ` [PATCHv2 2/2] Forward mouse click to python TUI window Hannes Domani
2021-05-29 14:49     ` Eli Zaretskii
2021-06-02 18:49     ` Tom Tromey
2021-06-02 18:48   ` Tom Tromey [this message]

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=87fsy0p0gf.fsf@tromey.com \
    --to=tom@tromey.com \
    --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).