public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Phi Debian <phi.debian@gmail.com>, Hannes Domani <ssbssa@yahoo.de>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: TUI enhancement suggestion.
Date: Mon, 15 Jun 2020 20:30:00 +0100	[thread overview]
Message-ID: <07772538-b41f-49e2-43c9-c6cb8831050b@redhat.com> (raw)
In-Reply-To: <CAJOr74iA-BJv24LoD5jJykMh_Kb6TH+U7kykpSPgia9WVF8Mtw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]

On 6/15/20 5:56 PM, Phi Debian via Gdb-patches wrote:
> Hi Pedro and all,
> 
> I am really sorry but I lost my bandwith, I am starting a new job tomorow
> leaving little room for investigation etc.
> 
> Regarding the point line, used to be inverse video on monochrome, i thought
> it was kind of bizare with highlighted text because we don't have a uniform
> background color (before patch) then an attempt was made to have a uniform
> background  color but then it monopolized one color that can't be used with
> foreground. The underline suffer the same problem as the inverse video, I.e
> its color change as we highlight text. That's why the little demo only
> underlined the front part of the line, that could be be reverse video too
> but just the whitespace on the front of the line are by definition
> monochrome.  I reckon my demo is bugged as you noticed, when disabling
> syntax highlight then my underline goes all the way through the point line.
> 
> May be an idea could be set the whole point line with un-highlited,
> monochrome,  then with the new range thing use reverse or underline for the
> sub part only

Yeah.  I actually saw some screenshots of IDEs disabling syntax highlighting
in the current highlighted source line the other day, and thought that looks
nice too, and probably a better solution that the underline idea.

E.g., looking around I found this:

 https://forum.unity.com/proxy.php?image=http%3A%2F%2Fpuu.sh%2FpL42e%2F11645e7230.gif&hash=fedb45091f23bfa99b53af562f56ff0c

Try the attached patch, and do "set tui current-line-highlight reverse-mono".

"set tui current-line-highlight reverse-styled" is the same as current GDB:

  https://i.imgur.com/UwX6bfz.png

"set tui current-line-highlight reverse-mono" gives you this:

  https://i.imgur.com/T1DeRum.png

Thanks,
Pedro Alves

[-- Attachment #2: 0001-set-tui-current-line-highlight-mode-reverse-styled-r.patch --]
[-- Type: text/x-patch, Size: 5155 bytes --]

From 5524ac5733cc95c652c5db1aff6dde362ae08b1b Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Mon, 15 Jun 2020 19:35:10 +0100
Subject: [PATCH] set tui current-line-highlight-mode
 reverse-styled|reverse-mono

---
 gdb/tui/tui-io.c  | 25 +++++++++++++++++--------
 gdb/tui/tui-win.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/tui/tui-win.h |  8 ++++++++
 3 files changed, 80 insertions(+), 8 deletions(-)

diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index e7a8ac77bce..4a012ca0eea 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -365,6 +365,10 @@ apply_ansi_escape (WINDOW *w, const char *buf)
 
   if (reverse_mode_p)
     {
+      current_line_highlight_mode mode = get_current_line_highlight_mode ();
+      if (mode == current_line_highlight_mode::reverse_mono)
+	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,19 +411,24 @@ 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 ();
-    }
-  else
-    {
-      style.set_bg (reverse_save_bg);
-      style.set_fg (reverse_save_fg);
+      current_line_highlight_mode mode = get_current_line_highlight_mode ();
+      switch (mode)
+	{
+	case current_line_highlight_mode::reverse_styled:
+	  reverse_save_bg = style.get_background ();
+	  reverse_save_fg = style.get_foreground ();
+	  break;
+	case current_line_highlight_mode::reverse_mono:
+	  style = {};
+	  break;
+	}
     }
 
+  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..81eeb090888 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -108,6 +108,16 @@ static const char *const tui_border_mode_enums[] = {
   NULL
 };
 
+static const char *highlight_mode_reverse_styled = "reverse-styled";
+static const char *highlight_mode_reverse_mono = "reverse-mono";
+
+/* Possible values for tui-current-line-highlight variable.  */
+static const char *const tui_current_line_highlight_mode_enums[] = {
+  highlight_mode_reverse_styled,
+  highlight_mode_reverse_mono,
+  NULL
+};
+
 struct tui_translate
 {
   const char *name;
@@ -218,6 +228,39 @@ show_tui_border_kind (struct ui_file *file,
 		    value);
 }
 
+/* Tui configuration variables controlled with set/show command.  */
+static const char *tui_current_line_highlight_mode
+  = highlight_mode_reverse_styled;
+
+current_line_highlight_mode
+get_current_line_highlight_mode ()
+{
+  for (int i = 0; i < ARRAY_SIZE (tui_current_line_highlight_mode_enums); i++)
+    if (tui_current_line_highlight_mode
+	== tui_current_line_highlight_mode_enums[i])
+      return (current_line_highlight_mode) i;
+
+  gdb_assert_not_reached ("unknown mode");
+}
+
+static void
+show_tui_current_line_highlight_mode (struct ui_file *file,
+				      int from_tty,
+				      struct cmd_list_element *c,
+				      const char *value)
+{
+  fprintf_filtered (file, _("\
+The mode to use for the current source highlight is \"%s\".\n"),
+		    value);
+}
+
+static void
+set_tui_current_line_highlight_mode (const char *ignore, int from_tty,
+				     struct cmd_list_element *c)
+{
+  if (TUI_SRC_WIN != nullptr)
+    TUI_SRC_WIN->refill ();
+}
 
 /* Tui internal configuration variables.  These variables are updated
    by tui_update_variables to reflect the tui configuration
@@ -1120,6 +1163,18 @@ the line numbers and uses less horizontal space."),
 			   tui_set_compact_source, tui_show_compact_source,
 			   &tui_setlist, &tui_showlist);
 
+  add_setshow_enum_cmd ("current-line-highlight-mode", no_class,
+			tui_current_line_highlight_mode_enums,
+			&tui_current_line_highlight_mode, _("\
+Set the attribute mode to use for the active TUI window border."), _("\
+Show the attribute mode to use for the active TUI window border."), _("\
+This variable controls the attributes to use for the active window border:\n\
+   reverse-styled  use reverse video for the background, and style the text\n\
+   reverse-mono    use reverse video for the background, don't style the text"),
+			set_tui_current_line_highlight_mode,
+			show_tui_current_line_highlight_mode,
+			&tui_setlist, &tui_showlist);
+
   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..f6a39bbf437 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -57,4 +57,12 @@ struct cmd_list_element **tui_get_cmd_list (void);
 /* Whether compact source display should be used.  */
 extern bool compact_source;
 
+enum current_line_highlight_mode
+{
+  reverse_styled,
+  reverse_mono,
+};
+
+current_line_highlight_mode get_current_line_highlight_mode ();
+
 #endif /* TUI_TUI_WIN_H */

base-commit: 669203174311c5be76744a879563c697cd479853
-- 
2.14.5


  reply	other threads:[~2020-06-15 19:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09  7:55 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 [this message]
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                         ` [PATCH] Add "set style tui-current-position on|off" default to off Pedro Alves
2020-06-16 14:33                           ` 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=07772538-b41f-49e2-43c9-c6cb8831050b@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=phi.debian@gmail.com \
    --cc=ssbssa@yahoo.de \
    /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).