From: Pedro Alves <palves@redhat.com>
To: Phi Debian <phi.debian@gmail.com>
Cc: Tom Tromey <tom@tromey.com>,
Pedro Alves via Gdb-patches <gdb-patches@sourceware.org>
Subject: [PATCH] Add "set style tui-current-position on|off" default to off
Date: Tue, 16 Jun 2020 12:02:31 +0100 [thread overview]
Message-ID: <73b40c12-cbd2-336a-3258-96f5134843a3@redhat.com> (raw)
In-Reply-To: <CAJOr74ihH28g3xcuhg9S8TyFF5TN3r5iDA3k154NrCq9CYLnKg@mail.gmail.com>
On 6/16/20 4:38 AM, Phi Debian via Gdb-patches wrote:
> Hi Pedro,
> I like the "set tui current-line-highlight reverse-mono" of your patch, it
> remove the underline need, the current line is well readable.
>
Great. Here's a more complete patch, now with documentation updated.
The option is now named:
"set style tui-current-position on|off"
and the default is now off.
From 854948d86fca90e894813ee08e349fec95c4d2ba Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Mon, 15 Jun 2020 19:35:10 +0100
Subject: [PATCH] Add "set style tui-current-position on|off", default to off
As discussed at:
https://sourceware.org/pipermail/gdb-patches/2020-June/169519.html
this patch disables source code highlighting for the text highlighted
by the TUI's current position indicator, and adds a command to enable
it back.
gdb/ChangeLog:
* NEWS: Document that the TUI no longer styles the source code
highlighted by the current position indicator by default.
Mention "set style tui-current-position".
* cli/cli-style.c (style_set_list, style_show_list): Make extern.
* gdbcmd.h (style_set_list, style_show_list): Declare.
* tui/tui-io.c (apply_ansi_escape): Return early if styling the
current position is disabled.
(tui_set_reverse_mode): If reversing, and source styling for the
current position is disabled, switch to default style, reversed.
* tui/tui-win.c (style_tui_current_position)
(show_style_tui_current_position, set_style_tui_current_position):
New.
(_initialize_tui_win): Install the "set/show style
tui-current-position" commands.
* tui/tui-win.h (style_tui_current_position): Declare.
gdb/doc/ChangeLog:
* gdb.texinfo (Output Styling): Document "set/show style
tui-current-position".
(TUI Overview): Document source code highlighting for the current
position indicator and mention "set style tui-current-position
off".
---
gdb/doc/gdb.texinfo | 17 +++++++++++++++--
gdb/NEWS | 8 ++++++++
gdb/cli/cli-style.c | 4 ++--
gdb/gdbcmd.h | 4 ++++
gdb/tui/tui-io.c | 13 ++++++++++++-
gdb/tui/tui-win.c | 37 +++++++++++++++++++++++++++++++++++++
gdb/tui/tui-win.h | 4 ++++
7 files changed, 82 insertions(+), 5 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 59e3e75d18a..48d0ffd8524 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -25521,6 +25521,15 @@ default is @samp{on}.
@item show style sources
Show the current state of source code styling.
+
+@item set style tui-current-position @samp{on|off}
+Enable or disable source code styling of the source code highlighted
+by the TUI's current position indicator. The default is @samp{off}.
+@xref{TUI, ,@value{GDBN} Text User Interface}.
+
+@item show style tui-current-position
+Show whether the source code highlighted by the TUI's current position
+indicator is styled.
@end table
Subcommands of @code{set style} control specific forms of styling.
@@ -27721,8 +27730,12 @@ This window shows the processor registers. Registers are highlighted
when their values change.
@end table
-The source and assembly windows show the current program position
-by highlighting the current line and marking it with a @samp{>} marker.
+The source and assembly windows show the current program position by
+highlighting the current line and marking it with a @samp{>} marker.
+By default, source code styling is disabled for the highlighted text,
+but you can enable it with the @code{set style tui-current-position
+on} command. @xref{Output Styling}.
+
Breakpoints are indicated with two markers. The first marker
indicates the breakpoint type:
diff --git a/gdb/NEWS b/gdb/NEWS
index cebfd18f0c6..0c72b687cfe 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -54,6 +54,10 @@
* TUI windows can now be arranged horizontally.
+* The TUI no longer styles the source code text highlighted by the
+ current position indicator by default. You can however re-enable
+ styling using the new "set style tui-current-position" command.
+
* The command history filename can now be set to the empty string
either using 'set history filename' or by setting 'GDBHISTFILE=' in
the environment. The effect of setting this filename to the empty
@@ -79,6 +83,10 @@ tui new-layout NAME WINDOW WEIGHT [WINDOW WEIGHT]...
Define a new TUI layout, specifying its name and the windows that
will be displayed.
+set style tui-current-position [on|off]
+ Whether to style the source code text highlighted by the TUI's
+ current position indicator. The default is off.
+
* New targets
GNU/Linux/RISC-V (gdbserver) riscv*-*-linux*
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index a0c3cc51801..acbb58ea7bf 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -253,8 +253,8 @@ cli_style_option::add_setshow_commands (enum command_class theclass,
&m_set_list, &m_show_list, (void *) this);
}
-static cmd_list_element *style_set_list;
-static cmd_list_element *style_show_list;
+cmd_list_element *style_set_list;
+cmd_list_element *style_show_list;
static void
set_style_enabled (const char *args, int from_tty, struct cmd_list_element *c)
diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h
index 4406094ea59..eed87d53847 100644
--- a/gdb/gdbcmd.h
+++ b/gdb/gdbcmd.h
@@ -128,6 +128,10 @@ extern struct cmd_list_element *setchecklist;
extern struct cmd_list_element *showchecklist;
+/* Chains containing all defined "set/show style" subcommands. */
+extern struct cmd_list_element *style_set_list;
+extern struct cmd_list_element *style_show_list;
+
/* Chain containing all defined "save" subcommands. */
extern struct cmd_list_element *save_cmdlist;
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index e7a8ac77bce..0f1d90b66dc 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -365,6 +365,9 @@ apply_ansi_escape (WINDOW *w, const char *buf)
if (reverse_mode_p)
{
+ if (!style_tui_current_position)
+ return n_read;
+
/* We want to reverse _only_ the default foreground/background
colors. If the foreground color is not the default (because
the text was styled), we want to leave it as is. If e.g.,
@@ -407,12 +410,18 @@ tui_set_reverse_mode (WINDOW *w, bool reverse)
ui_file_style style = last_style;
reverse_mode_p = reverse;
- style.set_reverse (reverse);
if (reverse)
{
reverse_save_bg = style.get_background ();
reverse_save_fg = style.get_foreground ();
+
+ if (!style_tui_current_position)
+ {
+ /* Switch to default style (reversed) while highlighting the
+ current position. */
+ style = {};
+ }
}
else
{
@@ -420,6 +429,8 @@ tui_set_reverse_mode (WINDOW *w, bool reverse)
style.set_fg (reverse_save_fg);
}
+ style.set_reverse (reverse);
+
tui_apply_style (w, style);
}
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a78837fe689..e9570a7924a 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -218,6 +218,30 @@ show_tui_border_kind (struct ui_file *file,
value);
}
+/* Implementation of the "set/show style tui-current-position" commands. */
+
+bool style_tui_current_position = false;
+
+static void
+show_style_tui_current_position (ui_file *file,
+ int from_tty,
+ cmd_list_element *c,
+ const char *value)
+{
+ fprintf_filtered (file, _("\
+Styling the text highlighted by the TUI's current position indicator is %s.\n"),
+ value);
+}
+
+static void
+set_style_tui_current_position (const char *ignore, int from_tty,
+ cmd_list_element *c)
+{
+ if (TUI_SRC_WIN != nullptr)
+ TUI_SRC_WIN->refill ();
+ if (TUI_DISASM_WIN != nullptr)
+ TUI_DISASM_WIN->refill ();
+}
/* Tui internal configuration variables. These variables are updated
by tui_update_variables to reflect the tui configuration
@@ -1120,6 +1144,19 @@ the line numbers and uses less horizontal space."),
tui_set_compact_source, tui_show_compact_source,
&tui_setlist, &tui_showlist);
+ add_setshow_boolean_cmd ("tui-current-position", class_maintenance,
+ &style_tui_current_position, _("\
+Set whether to style text highlighted by the TUI's current position indicator."),
+ _("\
+Show whether to style text highlighted by the TUI's current position indicator."),
+ _("\
+When enabled, the source code text highlighted by the TUI's current position\n\
+indicator is styled."),
+ set_style_tui_current_position,
+ show_style_tui_current_position,
+ &style_set_list,
+ &style_show_list);
+
tui_border_style.changed.attach (tui_rehighlight_all);
tui_active_border_style.changed.attach (tui_rehighlight_all);
}
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index e3791846307..4def8dd670b 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -57,4 +57,8 @@ struct cmd_list_element **tui_get_cmd_list (void);
/* Whether compact source display should be used. */
extern bool compact_source;
+/* Whether to style the source code text highlighted by the TUI's
+ current position indicator. */
+extern bool style_tui_current_position;
+
#endif /* TUI_TUI_WIN_H */
base-commit: 669203174311c5be76744a879563c697cd479853
--
2.14.5
next prev parent reply other threads:[~2020-06-16 11:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-09 7:55 TUI enhancement suggestion Phi Debian
2020-06-09 13:04 ` Pedro Alves
2020-06-09 14:32 ` Phi Debian
2020-06-09 15:03 ` Phi Debian
2020-06-11 10:34 ` Pedro Alves
2020-06-11 13:55 ` Phi Debian
2020-06-15 14:20 ` Pedro Alves
2020-06-15 15:48 ` Hannes Domani
2020-06-15 16:56 ` Phi Debian
2020-06-15 19:30 ` Pedro Alves
2020-06-15 19:47 ` Phi Debian
2020-06-15 20:12 ` Tom Tromey
2020-06-15 20:45 ` Pedro Alves
2020-06-16 3:38 ` Phi Debian
2020-06-16 11:02 ` Pedro Alves [this message]
2020-06-16 14:33 ` [PATCH] Add "set style tui-current-position on|off" default to off Eli Zaretskii
2022-11-15 10:09 ` Andrew Burgess
2022-11-15 12:15 ` Pedro Alves
2022-11-16 10:41 ` Andrew Burgess
2022-11-17 6:30 ` Phi Debian
[not found] ` <CAJOr74jg==A7NM4qtWEq6neXqxpxxtUEVdDgsahfvRobW+Q0wA@mail.gmail.com>
[not found] ` <CAJOr74hQdi6Y4MpGy=J-3CTRA2PP08OebTO2hBFN5NyDRokb3Q@mail.gmail.com>
[not found] ` <CAJOr74gyyw4hJm9j0fzKQdzkJKzq=yiAXyZx_c2Q=RA8GTSN7Q@mail.gmail.com>
[not found] ` <ed9ea9c6-3d4d-6ba7-4672-bff2b2617012@redhat.com>
2020-06-10 20:25 ` TUI enhancement suggestion Phi Debian
2020-06-11 10:17 ` Pedro Alves
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=73b40c12-cbd2-336a-3258-96f5134843a3@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=phi.debian@gmail.com \
--cc=tom@tromey.com \
/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).