public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] [gdb/tui] Add tui border-kind active-ascii
@ 2023-05-08 14:10 Tom de Vries
  2023-05-08 14:10 ` [PATCH 1/3] [gdb/tui] Make tui_update_variables more readable Tom de Vries
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Tom de Vries @ 2023-05-08 14:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I wrote a patch that adds a new tui border-kind: active-ascii.

That patch makes changes in function tui_update_variables, and I ended up
writing a patch that simplifies it by factoring out some functions, to make
subsequent changes in the function easier.

While factoring out one of the functions, I noticed a pre-existing buglet in
one of them, so I wrote a separate patch to fix this.

Tested on x86_64-linux, by rebuilding and running test-cases gdb.tui/*.exp and
gdb.python/tui*.exp for each patch.

Tom de Vries (3):
  [gdb/tui] Make tui_update_variables more readable
  [gdb/tui] Fix buglet in set_border_kind_item
  [gdb/tui] Add tui border-kind active-ascii

 gdb/doc/gdb.texinfo                 |   4 +
 gdb/testsuite/gdb.tui/tui-focus.exp |   7 +-
 gdb/testsuite/lib/tuiterm.exp       |  49 +++++-----
 gdb/tui/tui-win.c                   | 139 +++++++++++++++++++++-------
 gdb/tui/tui-win.h                   |   6 ++
 gdb/tui/tui-wingeneral.c            |  17 +++-
 6 files changed, 163 insertions(+), 59 deletions(-)


base-commit: c239019c9f649867c686204d1ac8947a963784d8
-- 
2.35.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] [gdb/tui] Make tui_update_variables more readable
  2023-05-08 14:10 [PATCH 0/3] [gdb/tui] Add tui border-kind active-ascii Tom de Vries
@ 2023-05-08 14:10 ` Tom de Vries
  2023-12-15 19:48   ` Tom Tromey
  2023-05-08 14:10 ` [PATCH 2/3] [gdb/tui] Fix buglet in set_border_kind_item Tom de Vries
  2023-05-08 14:10 ` [PATCH 3/3] [gdb/tui] Add tui border-kind active-ascii Tom de Vries
  2 siblings, 1 reply; 8+ messages in thread
From: Tom de Vries @ 2023-05-08 14:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Make tui_update_variables more readable by factoring out two new helper
functions, set_border_attrs and set_border_kind_item.

This makes the code also more regular, and consequently we no longer need the
comment:
...
  /* If one corner changes, all characters are changed.
     Only check the first one.  */
...

Tested on x86_64-linux.
---
 gdb/tui/tui-win.c | 93 +++++++++++++++++++++++++++++++----------------
 1 file changed, 61 insertions(+), 32 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 7eac03f47a1..cf4cb920524 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -274,6 +274,40 @@ translate (const char *name, struct tui_translate *table)
   return table;
 }
 
+/* Helper function for tui_update_variables.  SET *LVAL to
+   translate (KEY, DICT)->value, and set *LVAL_CHANGED to true if *LVAL
+   changed.  */
+
+static void
+set_border_attrs (int *lval, const char *key, struct tui_translate *dict,
+		  bool *lval_changed)
+{
+  struct tui_translate *entry = translate (key, dict);
+
+  if (*lval != (chtype) entry->value)
+    {
+      *lval = entry->value;
+      *lval_changed = true;
+    }
+}
+
+/* Helper function for tui_update_variables.  SET *LVAL to
+   translate (KEY, DICT)->value, and set *LVAL_CHANGED to true if *LVAL
+   changed.  If translate (KEY, DICT)->value is negative, use ACS instead.  */
+
+static void
+set_border_kind_item (chtype *lval, const char *key,
+		      struct tui_translate *dict, int acs, bool *lval_changed)
+{
+  struct tui_translate *entry = translate (key, dict);
+
+  if (*lval != (chtype) entry->value)
+    {
+      *lval = (entry->value < 0) ? acs : entry->value;
+      *lval_changed = true;
+    }
+}
+
 /* Update the tui internal configuration according to gdb settings.
    Returns 1 if the configuration has changed and the screen should
    be redrawn.  */
@@ -281,44 +315,39 @@ bool
 tui_update_variables ()
 {
   bool need_redraw = false;
-  struct tui_translate *entry;
 
-  entry = translate (tui_border_mode, tui_border_mode_translate);
-  if (tui_border_attrs != entry->value)
-    {
-      tui_border_attrs = entry->value;
-      need_redraw = true;
-    }
-  entry = translate (tui_active_border_mode, tui_border_mode_translate);
-  if (tui_active_border_attrs != entry->value)
-    {
-      tui_active_border_attrs = entry->value;
-      need_redraw = true;
-    }
+  set_border_attrs (&tui_border_attrs, tui_border_mode,
+		    tui_border_mode_translate, &need_redraw);
 
-  /* If one corner changes, all characters are changed.
-     Only check the first one.  The ACS characters are determined at
-     run time by curses terminal management.  */
-  entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner);
-  if (tui_border_lrcorner != (chtype) entry->value)
-    {
-      tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value;
-      need_redraw = true;
-    }
-  entry = translate (tui_border_kind, tui_border_kind_translate_llcorner);
-  tui_border_llcorner = (entry->value < 0) ? ACS_LLCORNER : entry->value;
+  set_border_attrs (&tui_active_border_attrs, tui_active_border_mode,
+		    tui_border_mode_translate, &need_redraw);
+
+  /* The ACS characters are determined at run time by curses terminal
+     management.  */
+
+  set_border_kind_item (&tui_border_lrcorner, tui_border_kind,
+			tui_border_kind_translate_lrcorner, ACS_LRCORNER,
+			&need_redraw);
+
+  set_border_kind_item (&tui_border_llcorner, tui_border_kind,
+			tui_border_kind_translate_llcorner, ACS_LLCORNER,
+			&need_redraw);
 
-  entry = translate (tui_border_kind, tui_border_kind_translate_ulcorner);
-  tui_border_ulcorner = (entry->value < 0) ? ACS_ULCORNER : entry->value;
+  set_border_kind_item (&tui_border_ulcorner, tui_border_kind,
+			tui_border_kind_translate_ulcorner, ACS_ULCORNER,
+			&need_redraw);
 
-  entry = translate (tui_border_kind, tui_border_kind_translate_urcorner);
-  tui_border_urcorner = (entry->value < 0) ? ACS_URCORNER : entry->value;
+  set_border_kind_item (&tui_border_urcorner, tui_border_kind,
+			tui_border_kind_translate_urcorner, ACS_URCORNER,
+			&need_redraw);
 
-  entry = translate (tui_border_kind, tui_border_kind_translate_hline);
-  tui_border_hline = (entry->value < 0) ? ACS_HLINE : entry->value;
+  set_border_kind_item (&tui_border_hline, tui_border_kind,
+			tui_border_kind_translate_hline, ACS_HLINE,
+			&need_redraw);
 
-  entry = translate (tui_border_kind, tui_border_kind_translate_vline);
-  tui_border_vline = (entry->value < 0) ? ACS_VLINE : entry->value;
+  set_border_kind_item (&tui_border_vline, tui_border_kind,
+			tui_border_kind_translate_vline, ACS_VLINE,
+			&need_redraw);
 
   return need_redraw;
 }
-- 
2.35.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/3] [gdb/tui] Fix buglet in set_border_kind_item
  2023-05-08 14:10 [PATCH 0/3] [gdb/tui] Add tui border-kind active-ascii Tom de Vries
  2023-05-08 14:10 ` [PATCH 1/3] [gdb/tui] Make tui_update_variables more readable Tom de Vries
@ 2023-05-08 14:10 ` Tom de Vries
  2023-05-22 14:47   ` [pushed] [gdb/tui] Fix buglet in tui_update_variables Tom de Vries
  2023-05-08 14:10 ` [PATCH 3/3] [gdb/tui] Add tui border-kind active-ascii Tom de Vries
  2 siblings, 1 reply; 8+ messages in thread
From: Tom de Vries @ 2023-05-08 14:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

While factoring out set_border_kind_item I noticed a buglet:
...
  struct tui_translate *entry = translate (key, dict);

  if (*lval != (chtype) entry->value)
    {
      *lval = (entry->value < 0) ? acs : entry->value;
...

When assigning the new value to *lval, an entry->value of -1 is taken into
account, but not when comparing to the current value of *lval.

Fix this by introducing:
...
  int val = (entry->value < 0) ? acs : entry->value;
...
and using this in both comparison and assignment.

Tested on x86_64-linux.
---
 gdb/tui/tui-win.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index cf4cb920524..fedcac4b560 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -300,10 +300,11 @@ set_border_kind_item (chtype *lval, const char *key,
 		      struct tui_translate *dict, int acs, bool *lval_changed)
 {
   struct tui_translate *entry = translate (key, dict);
+  int val = (entry->value < 0) ? acs : entry->value;
 
-  if (*lval != (chtype) entry->value)
+  if (*lval != (chtype) val)
     {
-      *lval = (entry->value < 0) ? acs : entry->value;
+      *lval = val;
       *lval_changed = true;
     }
 }
-- 
2.35.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/3] [gdb/tui] Add tui border-kind active-ascii
  2023-05-08 14:10 [PATCH 0/3] [gdb/tui] Add tui border-kind active-ascii Tom de Vries
  2023-05-08 14:10 ` [PATCH 1/3] [gdb/tui] Make tui_update_variables more readable Tom de Vries
  2023-05-08 14:10 ` [PATCH 2/3] [gdb/tui] Fix buglet in set_border_kind_item Tom de Vries
@ 2023-05-08 14:10 ` Tom de Vries
  2023-12-15 19:50   ` Tom Tromey
  2 siblings, 1 reply; 8+ messages in thread
From: Tom de Vries @ 2023-05-08 14:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that after configuring TUI to just use plain ascii borders:
...
(gdb) show tui
tui active-border-mode:  The attribute mode to use for the active TUI window \
  border is "normal".
tui border-kind:  The kind of border for TUI windows is "ascii".
tui border-mode:  The attribute mode to use for the TUI window borders is \
  "normal".
...
there was no longer something to identify whether a window has focus.

Add a new border-kind active-ascii, that's like border-kind ascii for inactive
windows but uses '+' as hline and vline (instead of '-' and '|') for an active
window.

In other words, this border for an inactive window:
...
+-+
| |
+-+
...
and this border for an active window:
...
+++
+ +
+++
...

Tested on x86_64-linux.
---
 gdb/doc/gdb.texinfo                 |  4 ++
 gdb/testsuite/gdb.tui/tui-focus.exp |  7 +++-
 gdb/testsuite/lib/tuiterm.exp       | 49 ++++++++++++++-----------
 gdb/tui/tui-win.c                   | 57 ++++++++++++++++++++++++++---
 gdb/tui/tui-win.h                   |  6 +++
 gdb/tui/tui-wingeneral.c            | 17 ++++++---
 6 files changed, 107 insertions(+), 33 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 8c4177c1901..f5fda5f57a8 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -30267,6 +30267,10 @@ Use a space character to draw the border.
 @item ascii
 Use @sc{ascii} characters @samp{+}, @samp{-} and @samp{|} to draw the border.
 
+@item active-ascii
+Use @sc{ascii} character @samp{+} to draw the border of an active
+window, otherwise as border-kind @code{ascii}.
+
 @item acs
 Use the Alternate Character Set to draw the border.  The border is
 drawn using character line graphics if the terminal supports them.
diff --git a/gdb/testsuite/gdb.tui/tui-focus.exp b/gdb/testsuite/gdb.tui/tui-focus.exp
index 72f80523af3..42629821888 100644
--- a/gdb/testsuite/gdb.tui/tui-focus.exp
+++ b/gdb/testsuite/gdb.tui/tui-focus.exp
@@ -41,6 +41,10 @@ foreach spec {{src true} {cmd true} {status true} {regs false} \
 	    unsupported "TUI not supported"
 	    return
 	}
+	gdb_test_no_output "set tui border-kind active-ascii"
+
+	# Initial value, will be effective if "focus $window" fails.
+	set src_focus 1
 
 	Term::command_no_prompt_prefix "focus $window"
 
@@ -53,6 +57,7 @@ foreach spec {{src true} {cmd true} {status true} {regs false} \
 	    } else {
 		Term::check_region_contents "check focus message" 0 16 80 1 \
 		    "^Focus set to $window window\\.\\s*"
+		set src_focus [string equal $window "src"]
 	    }
 	} else {
 	    if {$window == "unknown"} {
@@ -64,7 +69,7 @@ foreach spec {{src true} {cmd true} {status true} {regs false} \
 	    }
 	}
 
-	Term::check_box "check src box" 0 0 80 15
+	Term::check_box "check src box" 0 0 80 15 $src_focus
 
 	# At one point the following 'focus prev' command would trigger a
 	# crash in GDB, GDB was allowing users to set focus to the 'status'
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 5e4235da942..ef89d0a8a2c 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -928,30 +928,33 @@ namespace eval Term {
 
     # Helper function for check_box.  Returns empty string if the box
     # is found, description of why not otherwise.
-    proc _check_box {x y width height} {
+    proc _check_box {x y width height hline vline corner} {
 	set x2 [expr {$x + $width - 1}]
 	set y2 [expr {$y + $height - 1}]
 
-	verbose -log "_check_box x=$x, y=$y, x2=$x2, y2=$y2, width=$width, height=$height"
+	verbose -log [join [list _check_box x=$x y=$y x2=$x2 y2=$y2 \
+				width=$width height=$height \
+				hline=$hline vline=$vline \
+				corner=$corner] ", "]
 
 	set c [get_char $x $y]
-	if {$c != "+"} {
-	    return "ul corner is $c, not +"
+	if {$c != $corner} {
+	    return "ul corner is $c, not $corner"
 	}
 
 	set c [get_char $x $y2]
-	if {$c != "+"} {
-	    return "ll corner is $c, not +"
+	if {$c != $corner} {
+	    return "ll corner is $c, not $corner"
 	}
 
 	set c [get_char $x2 $y]
-	if {$c != "+"} {
-	    return "ur corner is $c, not +"
+	if {$c != $corner} {
+	    return "ur corner is $c, not $corner"
 	}
 
 	set c [get_char $x2 $y2]
 	if {$c != "+"} {
-	    return "lr corner is $c, not +"
+	    return "lr corner is $c, not $corner"
 	}
 
 	# Note we do not check the full horizonal borders of the box.
@@ -960,25 +963,25 @@ namespace eval Term {
 	# title should appear as '+-VERY LONG TITLE-+', so we can
 	# check for the '+-' on the left, and '-+' on the right.
 	set c [get_char [expr {$x + 1}] $y]
-	if {$c != "-"} {
-	    return "ul title padding is $c, not -"
+	if {$c != $hline} {
+	    return "ul title padding is $c, not $hline"
 	}
 
 	set c [get_char [expr {$x2 - 1}] $y]
-	if {$c != "-"} {
-	    return "ul title padding is $c, not -"
+	if {$c != $hline} {
+	    return "ul title padding is $c, not $hline"
 	}
 
 	# Now check the vertical borders.
 	for {set i [expr {$y + 1}]} {$i < $y2 - 1} {incr i} {
 	    set c [get_char $x $i]
-	    if {$c != "|"} {
-		return "left side $i is $c, not |"
+	    if {$c != $vline} {
+		return "left side $i is $c, not $vline"
 	    }
 
 	    set c [get_char $x2 $i]
-	    if {$c != "|"} {
-		return "right side $i is $c, not |"
+	    if {$c != $vline} {
+		return "right side $i is $c, not $vline"
 	    }
 	}
 
@@ -986,9 +989,13 @@ namespace eval Term {
     }
 
     # Check for a box at the given coordinates.
-    proc check_box {test_name x y width height} {
+    proc check_box {test_name x y width height {active 0}} {
 	dump_box $x $y $width $height
-	set why [_check_box $x $y $width $height]
+	if { $active } {
+	    set why [_check_box $x $y $width $height "+" "+" "+"]
+	} else {
+	    set why [_check_box $x $y $width $height "-" "|" "+"]
+	}
 	if {$why == ""} {
 	    pass $test_name
 	} else {
@@ -996,7 +1003,7 @@ namespace eval Term {
 	}
     }
 
-    # Check whether the text contents of the terminal match the
+# Check whether the text contents of the terminal match the
     # regular expression.  Note that text styling is not considered.
     proc check_contents {test_name regexp} {
 	dump_screen
@@ -1058,7 +1065,7 @@ namespace eval Term {
 	variable _chars
 
 	dump_box $x $y $width $height
-	set why [_check_box $x $y $width $height]
+	set why [_check_box $x $y $width $height "-" "|" "+"]
 	if {$why != ""} {
 	    fail "$test_name (box check: $why)"
 	    return
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index fedcac4b560..ef8cb120657 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -93,6 +93,7 @@ static void parse_scrolling_args (const char *,
 static const char *const tui_border_kind_enums[] = {
   "space",
   "ascii",
+  "active-ascii",
   "acs",
   NULL
 };
@@ -137,6 +138,7 @@ static struct tui_translate tui_border_mode_translate[] = {
 static struct tui_translate tui_border_kind_translate_vline[] = {
   { "space",    ' ' },
   { "ascii",    '|' },
+  { "active-ascii", '+' },
   { "acs",      -1 },
   { 0, 0 },
   { "ascii",    '|' }
@@ -145,6 +147,7 @@ static struct tui_translate tui_border_kind_translate_vline[] = {
 static struct tui_translate tui_border_kind_translate_hline[] = {
   { "space",    ' ' },
   { "ascii",    '-' },
+  { "active-ascii", '+' },
   { "acs",      -1 },
   { 0, 0 },
   { "ascii",    '-' }
@@ -153,6 +156,7 @@ static struct tui_translate tui_border_kind_translate_hline[] = {
 static struct tui_translate tui_border_kind_translate_ulcorner[] = {
   { "space",    ' ' },
   { "ascii",    '+' },
+  { "active-ascii", '+' },
   { "acs",      -1 },
   { 0, 0 },
   { "ascii",    '+' }
@@ -161,6 +165,7 @@ static struct tui_translate tui_border_kind_translate_ulcorner[] = {
 static struct tui_translate tui_border_kind_translate_urcorner[] = {
   { "space",    ' ' },
   { "ascii",    '+' },
+  { "active-ascii", '+' },
   { "acs",      -1 },
   { 0, 0 },
   { "ascii",    '+' }
@@ -169,6 +174,7 @@ static struct tui_translate tui_border_kind_translate_urcorner[] = {
 static struct tui_translate tui_border_kind_translate_llcorner[] = {
   { "space",    ' ' },
   { "ascii",    '+' },
+  { "active-ascii", '+' },
   { "acs",      -1 },
   { 0, 0 },
   { "ascii",    '+' }
@@ -177,6 +183,7 @@ static struct tui_translate tui_border_kind_translate_llcorner[] = {
 static struct tui_translate tui_border_kind_translate_lrcorner[] = {
   { "space",    ' ' },
   { "ascii",    '+' },
+  { "active-ascii", '+' },
   { "acs",      -1 },
   { 0, 0 },
   { "ascii",    '+' }
@@ -253,6 +260,12 @@ chtype tui_border_ulcorner;
 chtype tui_border_urcorner;
 chtype tui_border_llcorner;
 chtype tui_border_lrcorner;
+chtype tui_active_border_vline;
+chtype tui_active_border_hline;
+chtype tui_active_border_ulcorner;
+chtype tui_active_border_urcorner;
+chtype tui_active_border_llcorner;
+chtype tui_active_border_lrcorner;
 
 int tui_border_attrs;
 int tui_active_border_attrs;
@@ -323,30 +336,61 @@ tui_update_variables ()
   set_border_attrs (&tui_active_border_attrs, tui_active_border_mode,
 		    tui_border_mode_translate, &need_redraw);
 
+  /* For inactive borders, active-ascii is the same as ascii.  */
+  const char *tui_inactive_border_kind
+    = ((strcmp (tui_border_kind, "active-ascii") == 0)
+       ? "ascii"
+       : tui_border_kind);
+  const char *tui_active_border_kind = tui_border_kind;
+
   /* The ACS characters are determined at run time by curses terminal
      management.  */
 
-  set_border_kind_item (&tui_border_lrcorner, tui_border_kind,
+  set_border_kind_item (&tui_border_lrcorner, tui_inactive_border_kind,
+			tui_border_kind_translate_lrcorner, ACS_LRCORNER,
+			&need_redraw);
+
+  set_border_kind_item (&tui_border_llcorner, tui_inactive_border_kind,
+			tui_border_kind_translate_llcorner, ACS_LLCORNER,
+			&need_redraw);
+
+  set_border_kind_item (&tui_border_ulcorner, tui_inactive_border_kind,
+			tui_border_kind_translate_ulcorner, ACS_ULCORNER,
+			&need_redraw);
+
+  set_border_kind_item (&tui_border_urcorner, tui_inactive_border_kind,
+			tui_border_kind_translate_urcorner, ACS_URCORNER,
+			&need_redraw);
+
+  set_border_kind_item (&tui_border_hline, tui_inactive_border_kind,
+			tui_border_kind_translate_hline, ACS_HLINE,
+			&need_redraw);
+
+  set_border_kind_item (&tui_border_vline, tui_inactive_border_kind,
+			tui_border_kind_translate_vline, ACS_VLINE,
+			&need_redraw);
+
+  set_border_kind_item (&tui_active_border_lrcorner, tui_active_border_kind,
 			tui_border_kind_translate_lrcorner, ACS_LRCORNER,
 			&need_redraw);
 
-  set_border_kind_item (&tui_border_llcorner, tui_border_kind,
+  set_border_kind_item (&tui_active_border_llcorner, tui_active_border_kind,
 			tui_border_kind_translate_llcorner, ACS_LLCORNER,
 			&need_redraw);
 
-  set_border_kind_item (&tui_border_ulcorner, tui_border_kind,
+  set_border_kind_item (&tui_active_border_ulcorner, tui_active_border_kind,
 			tui_border_kind_translate_ulcorner, ACS_ULCORNER,
 			&need_redraw);
 
-  set_border_kind_item (&tui_border_urcorner, tui_border_kind,
+  set_border_kind_item (&tui_active_border_urcorner, tui_active_border_kind,
 			tui_border_kind_translate_urcorner, ACS_URCORNER,
 			&need_redraw);
 
-  set_border_kind_item (&tui_border_hline, tui_border_kind,
+  set_border_kind_item (&tui_active_border_hline, tui_active_border_kind,
 			tui_border_kind_translate_hline, ACS_HLINE,
 			&need_redraw);
 
-  set_border_kind_item (&tui_border_vline, tui_border_kind,
+  set_border_kind_item (&tui_active_border_vline, tui_active_border_kind,
 			tui_border_kind_translate_vline, ACS_VLINE,
 			&need_redraw);
 
@@ -1244,6 +1288,7 @@ Show the kind of border for TUI windows."), _("\
 This variable controls the border of TUI windows:\n\
    space           use a white space\n\
    ascii           use ascii characters + - | for the border\n\
+   active-ascii    use ascii character + for the active border, otherwise as ascii\n\
    acs             use the Alternate Character Set"),
 			tui_set_var_cmd,
 			show_tui_border_kind,
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 3d35f1dfb7f..0c02cc3e2e9 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -35,6 +35,12 @@ extern chtype tui_border_lrcorner;
 extern chtype tui_border_llcorner;
 extern chtype tui_border_vline;
 extern chtype tui_border_hline;
+extern chtype tui_active_border_vline;
+extern chtype tui_active_border_hline;
+extern chtype tui_active_border_ulcorner;
+extern chtype tui_active_border_urcorner;
+extern chtype tui_active_border_llcorner;
+extern chtype tui_active_border_lrcorner;
 extern int tui_border_attrs;
 extern int tui_active_border_attrs;
 
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 82a023d09fe..ac07195c81f 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -99,12 +99,19 @@ box_win (struct tui_win_info *win_info,
 			   : tui_border_style.style ()));
   wattron (win, attrs);
 #ifdef HAVE_WBORDER
-  wborder (win, tui_border_vline, tui_border_vline,
-	   tui_border_hline, tui_border_hline,
-	   tui_border_ulcorner, tui_border_urcorner,
-	   tui_border_llcorner, tui_border_lrcorner);
+  wborder (win,
+	   highlight_flag ? tui_active_border_vline : tui_border_vline,
+	   highlight_flag ? tui_active_border_vline : tui_border_vline,
+	   highlight_flag ? tui_active_border_hline : tui_border_hline,
+	   highlight_flag ? tui_active_border_hline : tui_border_hline,
+	   highlight_flag ? tui_active_border_ulcorner : tui_border_ulcorner,
+	   highlight_flag ? tui_active_border_urcorner : tui_border_urcorner,
+	   highlight_flag ? tui_active_border_llcorner : tui_border_llcorner,
+	   highlight_flag ? tui_active_border_lrcorner : tui_border_lrcorner);
 #else
-  box (win, tui_border_vline, tui_border_hline);
+  box (win,
+       highlight_flag ? tui_active_border_vline : tui_border_vline,
+       highlight_flag ? tui_active_border_hline : tui_border_hline);
 #endif
   if (!win_info->title.empty ())
     {
-- 
2.35.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pushed] [gdb/tui] Fix buglet in tui_update_variables
  2023-05-08 14:10 ` [PATCH 2/3] [gdb/tui] Fix buglet in set_border_kind_item Tom de Vries
@ 2023-05-22 14:47   ` Tom de Vries
  0 siblings, 0 replies; 8+ messages in thread
From: Tom de Vries @ 2023-05-22 14:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

[ was: Re: [PATCH 2/3] [gdb/tui] Fix buglet in set_border_kind_item ]

On 5/8/23 16:10, Tom de Vries via Gdb-patches wrote:
> While factoring out set_border_kind_item I noticed a buglet:
> ...
>    struct tui_translate *entry = translate (key, dict);
> 
>    if (*lval != (chtype) entry->value)
>      {
>        *lval = (entry->value < 0) ? acs : entry->value;
> ...
> 
> When assigning the new value to *lval, an entry->value of -1 is taken into
> account, but not when comparing to the current value of *lval.
> 
> Fix this by introducing:
> ...
>    int val = (entry->value < 0) ? acs : entry->value;
> ...
> and using this in both comparison and assignment.
> 

I'm not sure if the enhancement "border-kind active-ascii" will make it, 
so I've ported this fix to trunk and committed.

Thanks,
- Tom



[-- Attachment #2: 0001-gdb-tui-Fix-buglet-in-tui_update_variables.patch --]
[-- Type: text/x-patch, Size: 1731 bytes --]

From cd1ed1fd2e8ccec34008d03a9b25132f4eb3bf64 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Mon, 8 May 2023 13:24:08 +0200
Subject: [pushed] [gdb/tui] Fix buglet in tui_update_variables

I noticed a buglet in tui_update_variables:
...
   entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner);
   if (tui_border_lrcorner != (chtype) entry->value)
    {
      tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value;
...

When assigning the new value to tui_border_lrcorner, an entry->value of -1 is
taken into account, but not when comparing to the current value of
tui_border_lrcorner.

Fix this by introducing:
...
  int val = (entry->value < 0) ? ACS_LRCORNER : entry->value;
...
and using this in both comparison and assignment.

Tested on x86_64-linux.
---
 gdb/tui/tui-win.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 6710b3e17e5..7abd1e225b9 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -300,9 +300,10 @@ tui_update_variables ()
      Only check the first one.  The ACS characters are determined at
      run time by curses terminal management.  */
   entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner);
-  if (tui_border_lrcorner != (chtype) entry->value)
+  int val = (entry->value < 0) ? ACS_LRCORNER : entry->value;
+  if (tui_border_lrcorner != (chtype) val)
     {
-      tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value;
+      tui_border_lrcorner = val;
       need_redraw = true;
     }
   entry = translate (tui_border_kind, tui_border_kind_translate_llcorner);

base-commit: 7a8a6f57eced9a8c27a93cb5c5977a33be7b1f72
-- 
2.35.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] [gdb/tui] Make tui_update_variables more readable
  2023-05-08 14:10 ` [PATCH 1/3] [gdb/tui] Make tui_update_variables more readable Tom de Vries
@ 2023-12-15 19:48   ` Tom Tromey
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2023-12-15 19:48 UTC (permalink / raw)
  To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries, Tom Tromey

>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> Make tui_update_variables more readable by factoring out two new helper
Tom> functions, set_border_attrs and set_border_kind_item.

LGTM.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] [gdb/tui] Add tui border-kind active-ascii
  2023-05-08 14:10 ` [PATCH 3/3] [gdb/tui] Add tui border-kind active-ascii Tom de Vries
@ 2023-12-15 19:50   ` Tom Tromey
  2023-12-15 20:04     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2023-12-15 19:50 UTC (permalink / raw)
  To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries, Tom Tromey

>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> Add a new border-kind active-ascii, that's like border-kind ascii for inactive
Tom> windows but uses '+' as hline and vline (instead of '-' and '|') for an active
Tom> window.

I'm fine with this if you still want to do it.
Personally I'm more interested in whether we can make the TUI look
"sleek and modern" but this sort of thing is fine too.

It may still need a doc review?  Not sure.

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] [gdb/tui] Add tui border-kind active-ascii
  2023-12-15 19:50   ` Tom Tromey
@ 2023-12-15 20:04     ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2023-12-15 20:04 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches, tdevries

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom de Vries <tdevries@suse.de>,  Tom Tromey <tom@tromey.com>
> Date: Fri, 15 Dec 2023 12:50:06 -0700
> 
> >>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> Add a new border-kind active-ascii, that's like border-kind ascii for inactive
> Tom> windows but uses '+' as hline and vline (instead of '-' and '|') for an active
> Tom> window.
> 
> I'm fine with this if you still want to do it.
> Personally I'm more interested in whether we can make the TUI look
> "sleek and modern" but this sort of thing is fine too.
> 
> It may still need a doc review?  Not sure.

The documentation part is basically trivial.  It's okay by me.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-12-15 20:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-08 14:10 [PATCH 0/3] [gdb/tui] Add tui border-kind active-ascii Tom de Vries
2023-05-08 14:10 ` [PATCH 1/3] [gdb/tui] Make tui_update_variables more readable Tom de Vries
2023-12-15 19:48   ` Tom Tromey
2023-05-08 14:10 ` [PATCH 2/3] [gdb/tui] Fix buglet in set_border_kind_item Tom de Vries
2023-05-22 14:47   ` [pushed] [gdb/tui] Fix buglet in tui_update_variables Tom de Vries
2023-05-08 14:10 ` [PATCH 3/3] [gdb/tui] Add tui border-kind active-ascii Tom de Vries
2023-12-15 19:50   ` Tom Tromey
2023-12-15 20:04     ` Eli Zaretskii

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).