public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui
@ 2023-05-22 13:15 Tom de Vries
  2023-05-22 13:15 ` [PATCH 1/6] [gdb/testsuite] Use TERM=dummy in gdb.tui/tuiterm.exp Tom de Vries
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Tom de Vries @ 2023-05-22 13:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

For TUI testing, we'd like to use an xterm to replay scenario's that are
exercised in the testsuite, and vice versa create scenario's on an xterm and
be able to reproduce those in the testsuite.  In order to ensure identical
behaviour, we'd need identical TERM settings.

This series:
- introduces a new termcap entry ansi-for-tui that can be used with TUI in
  an xterm,
- adds the newline_glitch capability to ansiterm, and
- makes the TUI testsuite use ansi-for-tui.

Tested by re-running the TUI test-cases (gdb.tui/*.exp and gdb.python/tui*.exp)
on x86_64-linux.

Tom de Vries (6):
  [gdb/testsuite] Use TERM=dummy in gdb.tui/tuiterm.exp
  [gdb/testsuite] Factor out Term::_wrap_cursor
  [gdb/contrib] Add ansi-for-tui.sh
  [gdb/testsuite] Make ansi-for-tui available in with_tuiterm
  [gdb/testsuite] Implement the newline glitch in tuiterm
  [gdb/testsuite] Use ansi-for-tui in tuiterm

 gdb/contrib/ansi-for-tui.sh         |  66 +++++++++++++++
 gdb/testsuite/gdb.tui/tuiterm.exp   |  34 +++++++-
 gdb/testsuite/gdb.tui/wrap-line.exp |   4 +-
 gdb/testsuite/lib/gdb.exp           |  16 ++++
 gdb/testsuite/lib/tuiterm.exp       | 123 ++++++++++++++++++++++++++--
 5 files changed, 231 insertions(+), 12 deletions(-)
 create mode 100755 gdb/contrib/ansi-for-tui.sh


base-commit: 7b67409b99edca33b76961179286fb43a1714dd2
-- 
2.35.3


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

* [PATCH 1/6] [gdb/testsuite] Use TERM=dummy in gdb.tui/tuiterm.exp
  2023-05-22 13:15 [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui Tom de Vries
@ 2023-05-22 13:15 ` Tom de Vries
  2023-05-22 13:15 ` [PATCH] [gdb/tui] Add set style tui-status-window Tom de Vries
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-05-22 13:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

In test-case gdb.tui/tuiterm.exp we have:
...
proc setup_terminal { cols rows } {
    setenv TERM ansi
...

The TERM environment variable is used to tell applications about the
capabilities of a terminal, but it generally doesn't actually influence the
behaviour of the terminal.  In this test-case we test the tuiterm instead of
applications, and tuiterm also works the same regardless of the TERM setting.

Set TERM explictly to dumb and add a comment to avoid giving the impression
that the setting matters for the tuiterm behaviour.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.tui/tuiterm.exp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index 6cc6c628e73..8cd15cb33bb 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -55,7 +55,13 @@ proc check { test expected_contents expected_cur_col expected_cur_row } {
 }
 
 proc setup_terminal { cols rows } {
-    setenv TERM ansi
+    # The TERM environment variable is used to tell applications about the
+    # capabilities of a terminal, but it generally doesn't actually influence
+    # the behaviour of the terminal.  In this test-case we test the tuiterm,
+    # which behaves the same regardless of TERM setting.
+    # Set TERM explictly to dumb to avoid giving the impression that the
+    # setting matters for the tuiterm behaviour.
+    setenv TERM dumb
     Term::_setup $rows $cols
 }
 
-- 
2.35.3


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

* [PATCH] [gdb/tui] Add set style tui-status-window
  2023-05-22 13:15 [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui Tom de Vries
  2023-05-22 13:15 ` [PATCH 1/6] [gdb/testsuite] Use TERM=dummy in gdb.tui/tuiterm.exp Tom de Vries
@ 2023-05-22 13:15 ` Tom de Vries
  2023-05-22 13:47   ` Eli Zaretskii
  2023-05-22 13:15 ` [PATCH 2/6] [gdb/testsuite] Factor out Term::_wrap_cursor Tom de Vries
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Tom de Vries @ 2023-05-22 13:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Currently, the status window attributes are hardcoded to standout.

Add a new command "set style tui-status-window foreground/background/mode"
that controls the foreground and background colors, and the attributes for the
status window, where the attributes use the same <mode> options as used
for "set tui border-mode" and "set tui active-border-mode".

The default is none/none/standout, so there's no change in behaviour.

Tested on x86_64-linux.
---
 gdb/cli/cli-style.c             | 12 +++++++
 gdb/cli/cli-style.h             | 10 ++++++
 gdb/doc/gdb.texinfo             |  9 +++++
 gdb/testsuite/gdb.tui/basic.exp |  5 +++
 gdb/tui/tui-stack.c             | 16 +++++----
 gdb/tui/tui-win.c               | 58 +++++++++++++++++++++++++++++++++
 gdb/tui/tui-win.h               |  3 ++
 7 files changed, 106 insertions(+), 7 deletions(-)

diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index cd510b440db..29aa2d92cd3 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -101,6 +101,10 @@ cli_style_option tui_active_border_style ("tui-active-border",
 
 /* See cli-style.h.  */
 
+cli_style_option tui_status_window_style ("tui-status-window", ui_file_style::NONE);
+
+/* See cli-style.h.  */
+
 cli_style_option metadata_style ("metadata", ui_file_style::DIM);
 
 /* See cli-style.h.  */
@@ -469,6 +473,14 @@ TUI window that does have the focus."),
 						&style_show_list,
 						true);
 
+  tui_status_window_style.add_setshow_commands (no_class, _("\
+TUI status window styling.\n\
+Configure TUI status window colors\n\
+The \"tui-status-window\" style is used when GDB displays the status window."),
+						&style_set_list,
+						&style_show_list,
+						true);
+
   version_style.add_setshow_commands (no_class, _("\
 Version string display styling.\n\
 Configure colors used to display the GDB version string."),
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index f315241ccb4..b00c798caec 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -58,6 +58,13 @@ class cli_style_option
   /* Same as SET_LIST but for the show command list.  */
   struct cmd_list_element *show_list () { return m_show_list; };
 
+  /* Return the 'set style NAME' command list, that can be used
+     to add commands to.  */
+  struct cmd_list_element **modifiable_set_list () { return &m_set_list; };
+
+  /* Same as MODIFIABLE_SET_LIST but for the show command list.  */
+  struct cmd_list_element **modifiable_show_list () { return &m_show_list; };
+
   /* This style can be observed for any changes.  */
   gdb::observers::observable<> changed;
 
@@ -138,6 +145,9 @@ extern cli_style_option tui_border_style;
 /* The border style of a TUI window that does have the focus.  */
 extern cli_style_option tui_active_border_style;
 
+/* The style of a TUI status window.  */
+extern cli_style_option tui_status_window_style;
+
 /* The style to use for the GDB version string.  */
 extern cli_style_option version_style;
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index f23bcc5f3f8..c0e33c951b4 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27300,6 +27300,13 @@ general styling to @value{GDBN}.  @xref{TUI Configuration}.
 Control the styling of the active TUI border; that is, the TUI window
 that has the focus.
 
+@item tui-status-window
+Control the styling of the TUI status window.  Note that, unlike other
+styling options, the tui-border has a mode rather than an intensity.
+The values for mode are the same as for @ref{set tui border-mode} and
+@ref{set tui active-border-mode}.  By default, this style's mode is
+standout, and the foreground and background colors are none.
+
 @item disassembler comment
 Control the styling of comments in the disassembler output.  These are
 managed with the @code{set style disassembler comment} family of
@@ -30273,8 +30280,10 @@ Use the Alternate Character Set to draw the border.  The border is
 drawn using character line graphics if the terminal supports them.
 @end table
 
+@anchor{set tui border-mode}
 @item set tui border-mode @var{mode}
 @kindex set tui border-mode
+@anchor{set tui active-border-mode}
 @itemx set tui active-border-mode @var{mode}
 @kindex set tui active-border-mode
 Select the display attributes for the borders of the inactive windows
diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp
index 2c55c2b95bc..1bfcec21256 100644
--- a/gdb/testsuite/gdb.tui/basic.exp
+++ b/gdb/testsuite/gdb.tui/basic.exp
@@ -114,3 +114,8 @@ set status_window_line 15
 set status [Term::get_line_with_attrs $status_window_line]
 gdb_assert { [regexp "^<reverse:1>$re_noattr*<reverse:0>$" $status] == 1} \
     "status window: reverse"
+
+Term::command "set style tui-status-window mode normal"
+
+set status [Term::get_line_with_attrs $status_window_line]
+gdb_assert { [regexp "^$re_noattr*$" $status] == 1} "status window: normal"
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 76b8f066abb..46504b90f98 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -37,6 +37,9 @@
 #include "tui/tui-winsource.h"
 #include "tui/tui-file.h"
 #include "tui/tui-location.h"
+#include "tui/tui-win.h"
+#include "tui/tui-io.h"
+#include "cli/cli-style.h"
 
 #include "gdb_curses.h"
 
@@ -234,15 +237,14 @@ tui_locator_window::rerender ()
   std::string string = make_status_line ();
   scrollok (handle.get (), FALSE);
   wmove (handle.get (), 0, 0);
-  /* We ignore the return value from wstandout and wstandend, casting them
-     to void in order to avoid a compiler warning.  The warning itself was
-     introduced by a patch to ncurses 5.7 dated 2009-08-29, changing these
-     macro to expand to code that causes the compiler to generate an
-     unused-value warning.  */
-  (void) wstandout (handle.get ());
+
+  if (cli_styling)
+    tui_apply_style (handle.get (), tui_status_window_style.style ());
+  wattron (handle.get (), tui_status_window_attrs);
   waddstr (handle.get (), string.c_str ());
   wclrtoeol (handle.get ());
-  (void) wstandend (handle.get ());
+  wattroff (handle.get (), tui_status_window_attrs);
+  tui_apply_style (handle.get (), ui_file_style ());
   refresh_window ();
   wmove (handle.get (), 0, 0);
 }
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 6710b3e17e5..875149cd38b 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -346,6 +346,42 @@ tui_set_var_cmd (const char *null_args,
     tui_rehighlight_all ();
 }
 
+/* Value of "tui status-window-mode".  */
+
+static const char *tui_status_window_mode = "standout";
+
+/* See tui-win.h.  */
+
+int tui_status_window_attrs;
+
+/* Show value of "tui status-window-mode".  */
+
+static void
+show_tui_status_window_mode (struct ui_file *file,
+			     int from_tty,
+			     struct cmd_list_element *c,
+			     const char *value)
+{
+  gdb_printf (file, _("\
+The attribute mode to use for the TUI status window is \"%s\".\n"),
+	      value);
+}
+
+/* Set value of "tui status-window-mode".  */
+
+static void
+set_tui_status_window_mode (const char *null_args,
+			    int from_tty, struct cmd_list_element *c)
+{
+  struct tui_translate *entry
+    = translate (tui_status_window_mode, tui_border_mode_translate);
+  if (tui_status_window_attrs == entry->value)
+    return;
+
+  tui_status_window_attrs = entry->value;
+  if (tui_active)
+    tui_show_locator_content ();
+}
 \f
 
 /* True if TUI resizes should print a message.  This is used by the
@@ -1251,6 +1287,23 @@ This variable controls the attributes to use for the active window border:\n\
 			show_tui_active_border_mode,
 			&tui_setlist, &tui_showlist);
 
+  add_setshow_enum_cmd ("mode", no_class, tui_border_mode_enums,
+			&tui_status_window_mode, _("\
+Set the attribute mode to use for the TUI status window."), _("\
+Show the attribute mode to use for the TUI status window."), _("\
+This variable controls the attributes to use for the status window:\n\
+   normal          normal display\n\
+   standout        use highlight mode of terminal\n\
+   reverse         use reverse video mode\n\
+   half            use half bright\n\
+   half-standout   use half bright and standout mode\n\
+   bold            use extra bright or bold\n\
+   bold-standout   use extra bright or bold with standout mode"),
+			set_tui_status_window_mode,
+			show_tui_status_window_mode,
+			tui_status_window_style.modifiable_set_list (),
+			tui_status_window_style.modifiable_show_list ());
+
   add_setshow_zuinteger_cmd ("tab-width", no_class,
 			     &internal_tab_width, _("\
 Set the tab width, in characters, for the TUI."), _("\
@@ -1305,4 +1358,9 @@ When enabled, the left margin will use '_' and '0' instead of spaces."),
 
   tui_border_style.changed.attach (tui_rehighlight_all, "tui-win");
   tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win");
+  tui_status_window_style.changed.attach (tui_show_locator_content, "tui-win");
+
+  /* Assign default value.  */
+  tui_status_window_attrs
+    = translate (tui_status_window_mode, tui_border_mode_translate)->value;
 }
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 3d35f1dfb7f..5ace83a742a 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -38,6 +38,9 @@ extern chtype tui_border_hline;
 extern int tui_border_attrs;
 extern int tui_active_border_attrs;
 
+/* Attributes for the contents of the status window.  */
+extern int tui_status_window_attrs;
+
 extern bool tui_update_variables ();
 
 extern void tui_initialize_win (void);

base-commit: 5a8f5960fd8fc5136fc24ddaf08a25c73f9c8329
-- 
2.35.3


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

* [PATCH 2/6] [gdb/testsuite] Factor out Term::_wrap_cursor
  2023-05-22 13:15 [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui Tom de Vries
  2023-05-22 13:15 ` [PATCH 1/6] [gdb/testsuite] Use TERM=dummy in gdb.tui/tuiterm.exp Tom de Vries
  2023-05-22 13:15 ` [PATCH] [gdb/tui] Add set style tui-status-window Tom de Vries
@ 2023-05-22 13:15 ` Tom de Vries
  2023-05-22 13:15 ` [PATCH 3/6] [gdb/contrib] Add ansi-for-tui.sh Tom de Vries
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-05-22 13:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Factor out new proc Term::_wrap_cursor out of proc Term::_insert.

Tested on x86_64-linux.
---
 gdb/testsuite/lib/tuiterm.exp | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 5c0be85ee73..e52cb3e5b6d 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -609,6 +609,18 @@ namespace eval Term {
 	}
     }
 
+    # Set cursor to col 0 on the next line.  If we run off screen, error out.
+    proc _wrap_cursor {} {
+	variable _cur_col
+	variable _cur_row
+	variable _rows
+	set _cur_col 0
+	incr _cur_row
+	if {$_cur_row >= $_rows} {
+	    error "FIXME scroll"
+	}
+    }
+
     # Insert string at the cursor location.
     proc _insert {str} {
 	_log_cur "Inserted string '$str'" {
@@ -616,7 +628,6 @@ namespace eval Term {
 
 	    variable _cur_col
 	    variable _cur_row
-	    variable _rows
 	    variable _cols
 	    variable _attrs
 	    variable _chars
@@ -626,11 +637,7 @@ namespace eval Term {
 		    set _chars($_cur_col,$_cur_row) [list $char $lattr]
 		    incr _cur_col
 		    if {$_cur_col >= $_cols} {
-			set _cur_col 0
-			incr _cur_row
-			if {$_cur_row >= $_rows} {
-			    error "FIXME scroll"
-			}
+			_wrap_cursor
 		    }
 		}
 	    }
-- 
2.35.3


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

* [PATCH 3/6] [gdb/contrib] Add ansi-for-tui.sh
  2023-05-22 13:15 [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui Tom de Vries
                   ` (2 preceding siblings ...)
  2023-05-22 13:15 ` [PATCH 2/6] [gdb/testsuite] Factor out Term::_wrap_cursor Tom de Vries
@ 2023-05-22 13:15 ` Tom de Vries
  2023-05-22 13:15 ` [PATCH 4/6] [gdb/testsuite] Make ansi-for-tui available in with_tuiterm Tom de Vries
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-05-22 13:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Using TUI with native TERM=xterm on an xterm:
...
$ TERM=xterm gdb -q -tui
...
works fine:
...
┌──────────────────────────────────────┐
│                                      │
│                                      │
│[ No Source Available ]               │
│                                      │
│                                      │
└──────────────────────────────────────┘
In:                        L??   PC: ??
(gdb)
...

However, in the testsuite we use tuiterm with native TERM=ansi.

We'd like to use an xterm to replay scenario's that are exercised in the
testsuite, and vice versa create scenario's on an xterm and be able to
reproduce those in the testsuite.  In order to ensure identical behaviour,
we'd need identical TERM settings.  So, can we use TERM=ansi on an xterm?

Using TERM=ansi is supported on xterm, with two documented caveats [1]:
- using the Alternative Character Set is broken, and
- you'd occasionally need to repaint the screen to work around the fact that
  xterm has the newline glitch (xenl capability), but by using TERM=ansi you
  indicate it hasn't.

When using TUI on an xterm with TERM=ansi we immediately run into both
problems:
...
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³                                      ³
³                                      ³
³[ No Source Available ]               ³
³                                      ³
³                                      ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
In:                        L??   PC: ??(
gdb)
...
The border looks weird due to the problems with the ACS (PR tui/30370), and
the first char of the prompt ends up in the status line due the xenl
incompatibility (PR tui/30388).  As advertised, after doing ^L the latter
problem is solved, but not the former one.

Add a gdb/contrib script that can be used to generate a terminfo entry that
is based on the ansi terminfo entry but works around both of the problems, by:
- adding the xenl capability, and
- specifying ascii values for the hline, vline and border ACS chars, making
  tui border-kind acs equivalent to tui border-kind ascii.

I first used ansi-for-xterm as name, but found out that besides the
capabilities listed in the terminfo entry, ncurses also uses the name of the
terminal to decide whether to enable certain features, which consequently
requires more support in tuiterm.  So I chose ansi-for-tui instead.  It's also
more precise to use tui in the name because the ACS solution only supports
what TUI uses.

Tested on x86_64-linux, by checking that both problems are no longer
occurring:
...
+--------------------------------------+
|                                      |
|                                      |
|[ No Source Available ]               |
|                                      |
|                                      |
+--------------------------------------+
In:                        L??   PC: ??
(gdb)
...

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30370
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30388
---
 gdb/contrib/ansi-for-tui.sh | 66 +++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100755 gdb/contrib/ansi-for-tui.sh

diff --git a/gdb/contrib/ansi-for-tui.sh b/gdb/contrib/ansi-for-tui.sh
new file mode 100755
index 00000000000..570ae3def81
--- /dev/null
+++ b/gdb/contrib/ansi-for-tui.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+# Copyright (C) 2023 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Using TERM=ansi is supported on xterm, with two caveats [1]:
+# - using the Alternative Character Set is broken, and
+# - you'd occasionally need to repaint the screen to work around the fact that
+#   xterm has the newline glitch, but by using TERM=ansi you indicate it hasn't.
+# [1] http://man.he.net/man1/xterm
+#
+# This scripts addresses these two caveats by generating a new terminfo entry,
+# called ansi-for-tui, based on the ansi terminfo entry, with two
+# modifications:
+# - replace the acsc capability with a string that just uses ascii chars, and
+# - add the xenl capability.
+#
+# By default, it generates an entry in $HOME/.terminfo/a/ansi-for-tui.
+
+# This allows us to run TUI using "TERM=ansi-for-tui gdb -tui" on an xterm
+# and have things work as expected (just that tui border-kind acs and ascii
+# look the same).
+
+set -e
+
+base=ansi
+new=ansi-for-tui
+
+f=$(mktemp)
+
+# Copy from $base.
+infocmp -1 $base \
+	> "$f"
+
+# Add xenl.
+echo -e "\txenl," \
+     >> "$f"
+
+# Rename.
+sed -i "s/^$base/$new/" \
+    "$f"
+
+# Erase acsc line.
+sed -i "s/^\tacsc=.*$//" \
+    "$f"
+
+# Make acs hline, vline and corners fall back to ascii.
+echo -e "\tacsc=q-x|l+k+m+j+," \
+     >> "$f"
+
+# Compile.
+tic "$@" \
+    "$f"
+
+rm -f "$f"
-- 
2.35.3


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

* [PATCH 4/6] [gdb/testsuite] Make ansi-for-tui available in with_tuiterm
  2023-05-22 13:15 [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui Tom de Vries
                   ` (3 preceding siblings ...)
  2023-05-22 13:15 ` [PATCH 3/6] [gdb/contrib] Add ansi-for-tui.sh Tom de Vries
@ 2023-05-22 13:15 ` Tom de Vries
  2023-05-22 13:15 ` [PATCH 5/6] [gdb/testsuite] Implement the newline glitch in tuiterm Tom de Vries
  2023-05-22 13:15 ` [PATCH 6/6] [gdb/testsuite] Use ansi-for-tui " Tom de Vries
  6 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-05-22 13:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Use contrib/ansi-for-tui.sh to create a ansi-for-tui terminfo entry in cached
dir build/gdb/testsuite/cache/terminfo, and make it available in proc
with_tuiterm using TERMINFO.

Tested on x86_64-linux.
---
 gdb/testsuite/lib/gdb.exp     | 16 ++++++++++++++++
 gdb/testsuite/lib/tuiterm.exp | 11 ++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 133d914aff8..950a1073f74 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6578,6 +6578,22 @@ proc cached_file { filename txt {executable 0}} {
     return $filename
 }
 
+# Create a dir with name DIRNAME in the cache directory.  Return a list of:
+# - the full directory name, and
+# - 1 if a new dir was created, otherwise 0.
+
+proc cached_dir { dirname } {
+    set dirname [make_gdb_parallel_path cache $dirname]
+
+    if { [file exists $dirname] } {
+	return [list $dirname 0]
+    }
+
+    file mkdir $dirname
+
+    return [list $dirname 1]
+}
+
 # Return a wrapper around gdb that prevents generating a core file.
 
 proc gdb_no_core { } {
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index e52cb3e5b6d..4c0fdc9b6df 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -801,7 +801,16 @@ namespace eval Term {
     # BODY.
     proc with_tuiterm {rows cols body} {
 	global env stty_init
-	save_vars {env(TERM) stty_init} {
+
+	set res [cached_dir terminfo]
+	set terminfo [lindex $res 0]
+	set dir_created [lindex $res 1]
+	if { $dir_created } {
+	    exec $::srcdir/../contrib/ansi-for-tui.sh -o $terminfo
+	}
+
+	save_vars {env(TERM) env(TERMINFO) stty_init} {
+	    setenv TERMINFO $terminfo
 	    setenv TERM ansi
 	    _setup $rows $cols
 
-- 
2.35.3


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

* [PATCH 5/6] [gdb/testsuite] Implement the newline glitch in tuiterm
  2023-05-22 13:15 [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui Tom de Vries
                   ` (4 preceding siblings ...)
  2023-05-22 13:15 ` [PATCH 4/6] [gdb/testsuite] Make ansi-for-tui available in with_tuiterm Tom de Vries
@ 2023-05-22 13:15 ` Tom de Vries
  2023-05-22 13:15 ` [PATCH 6/6] [gdb/testsuite] Use ansi-for-tui " Tom de Vries
  6 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-05-22 13:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Implement the newline glitch in tuiterm (PR testsuite/30451).  The newline
glitch corresponds to the xenl terminfo capability.  It can be enabled by
setting Term::_newline_glitch to 1.

The functionality is as follows.

After printing a char at the end of the line, rather than wrapping the cursor
goes into a special state, called the ignore state in this implementation.

The ignore state is implemented by having the cursor positioned on the same
line, but immediately right of the last column, so effectively off-screen.

In the ignore_state:
- if a normal char is issued, the cursor wraps to the next line (so the ignore
  state is no longer active) and the char is printed.
- if a control sequence is issued, the cursor is repositioned to the last column
  (so the ignore state is no longer active) and the control sequence takes effect.
- if a tab character or other formatting controls like carriage return and newline
  are issued, they are ignored.

The most elaborate description of the newline glitch I found is here [1][2].

The idea to represent the ignore state as the cursor being off the screen I
got from here [3].

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30451

[1] https://invisible-island.net/xterm/xterm.faq.html#grep_colors
[2] https://invisible-island.net/xterm/xterm.faq.html#vt100_wrapping
[3] https://stackoverflow.com/a/31360700
---
 gdb/testsuite/gdb.tui/tuiterm.exp | 26 +++++++++
 gdb/testsuite/lib/tuiterm.exp     | 94 ++++++++++++++++++++++++++++++-
 2 files changed, 118 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index 8cd15cb33bb..08b492582c3 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -682,6 +682,30 @@ proc test_insert_line { } {
     } 2 0
 }
 
+proc test_newline_glitch { } {
+    setup_terminal 8 4
+
+    # This is part of a sequence that ncurses generates when we run TUI with
+    # TERM=ansi on an xterm, in other words, when the terminal does have the
+    # newline glitch, but the terminfo entry tells ncurses that it doesn't.
+    # Consequently, we get wonky output, which gives us a good test-case for
+    # the newline glitch.
+    set Term::_newline_glitch 1
+    Term::_insert "12345678"
+    Term::_insert "12345678"
+    Term::_csi_A
+    Term::_csi_B
+    Term::_insert "(gdb) "
+    Term::dump_screen
+
+    check "newline glitch" {
+	"12345678"
+	"1234567\\("
+	"gdb\\)    "
+	"        "
+    } 5 2
+}
+
 # Run proc TEST_PROC_NAME with a "small" terminal.
 
 proc run_one_test_small { test_proc_name } {
@@ -733,3 +757,5 @@ foreach_with_prefix test {
 } {
     run_one_test_large $test
 }
+
+test_newline_glitch
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 4c0fdc9b6df..bb0681f2034 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -33,6 +33,8 @@ namespace eval Term {
 
     variable _resize_count
 
+    variable _newline_glitch
+
     proc _log { what } {
 	verbose "+++ $what"
     }
@@ -50,6 +52,19 @@ namespace eval Term {
 	_log "$what, cursor: ($orig_cur_row, $orig_cur_col) -> ($_cur_row, $_cur_col)"
     }
 
+    proc in_ignore_state {} {
+	variable _cur_col
+	variable _cols
+	return [expr $_cur_col == $_cols]
+    }
+
+    proc cancel_ignore_state {} {
+	variable _cur_col
+	if { [in_ignore_state] } {
+	    incr _cur_col -1
+	}
+    }
+
     # If ARG is empty, return DEF: otherwise ARG.  This is useful for
     # defaulting arguments in CSIs.
     proc _default {arg def} {
@@ -81,10 +96,19 @@ namespace eval Term {
 
     # Beep.
     proc _ctl_0x07 {} {
+	if { [in_ignore_state] } {
+	    _log "Beep: ignored"
+	    return
+	}
     }
 
     # Backspace.
     proc _ctl_0x08 {} {
+	if { [in_ignore_state] } {
+	    _log "Backspace: ignored"
+	    return
+	}
+
 	_log_cur "Backspace" {
 	    variable _cur_col
 
@@ -96,6 +120,11 @@ namespace eval Term {
 
     # Linefeed.
     proc _ctl_0x0a {} {
+	if { [in_ignore_state] } {
+	    _log "Line feed: ignored"
+	    return
+	}
+
 	_log_cur "Line feed" {
 	    variable _cur_row
 	    variable _rows
@@ -123,6 +152,11 @@ namespace eval Term {
 
     # Carriage return.
     proc _ctl_0x0d {} {
+	if { [in_ignore_state] } {
+	    _log "Carriage return: ignored"
+	    return
+	}
+
 	_log_cur "Carriage return" {
 	    variable _cur_col
 
@@ -134,6 +168,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/ICH.html
     proc _csi_@ {args} {
+	cancel_ignore_state
+
 	set n [_default [lindex $args 0] 1]
 
 	_log_cur "Insert Character ($n)" {
@@ -158,6 +194,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/CUU.html
     proc _csi_A {args} {
+	cancel_ignore_state
+
 	set arg [_default [lindex $args 0] 1]
 
 	_log_cur "Cursor Up ($arg)" {
@@ -171,6 +209,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/CUD.html
     proc _csi_B {args} {
+	cancel_ignore_state
+
 	set arg [_default [lindex $args 0] 1]
 
 	_log_cur "Cursor Down ($arg)" {
@@ -185,6 +225,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/CUF.html
     proc _csi_C {args} {
+	cancel_ignore_state
+
 	set arg [_default [lindex $args 0] 1]
 
 	_log_cur "Cursor Forward ($arg)" {
@@ -199,6 +241,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/CUB.html
     proc _csi_D {args} {
+	cancel_ignore_state
+
 	set arg [_default [lindex $args 0] 1]
 
 	_log_cur "Cursor Backward ($arg)" {
@@ -212,6 +256,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/CNL.html
     proc _csi_E {args} {
+	cancel_ignore_state
+
 	set arg [_default [lindex $args 0] 1]
 
 	_log_cur "Cursor Next Line ($arg)" {
@@ -228,6 +274,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/CPL.html
     proc _csi_F {args} {
+	cancel_ignore_state
+
 	set arg [_default [lindex $args 0] 1]
 
 	_log_cur "Cursor Previous Line ($arg)" {
@@ -244,6 +292,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/CHA.html
     proc _csi_G {args} {
+	cancel_ignore_state
+
 	set arg [_default [lindex $args 0] 1]
 
 	_log_cur "Cursor Horizontal Absolute ($arg)" {
@@ -258,6 +308,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/CUP.html
     proc _csi_H {args} {
+	cancel_ignore_state
+
 	set row [_default [lindex $args 0] 1]
 	set col [_default [lindex $args 1] 1]
 
@@ -274,6 +326,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/CHT.html
     proc _csi_I {args} {
+	cancel_ignore_state
+
 	set n [_default [lindex $args 0] 1]
 
 	_log_cur "Cursor Horizontal Forward Tabulation ($n)" {
@@ -291,6 +345,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/ED.html
     proc _csi_J {args} {
+	cancel_ignore_state
+
 	set arg [_default [lindex $args 0] 0]
 
 	_log_cur "Erase in Display ($arg)" {
@@ -318,6 +374,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/EL.html
     proc _csi_K {args} {
+	cancel_ignore_state
+
 	set arg [_default [lindex $args 0] 0]
 
 	_log_cur "Erase in Line ($arg)" {
@@ -342,6 +400,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/IL.html
     proc _csi_L {args} {
+	cancel_ignore_state
+
 	set arg [_default [lindex $args 0] 1]
 
 	_log_cur "Insert Line ($arg)" {
@@ -369,6 +429,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/DL.html
     proc _csi_M {args} {
+	cancel_ignore_state
+
 	set count [_default [lindex $args 0] 1]
 
 	_log_cur "Delete line ($count)" {
@@ -394,6 +456,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/DCH.html
     proc _csi_P {args} {
+	cancel_ignore_state
+
 	set count [_default [lindex $args 0] 1]
 
 	_log_cur "Delete character ($count)" {
@@ -421,6 +485,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/SU.html
     proc _csi_S {args} {
+	cancel_ignore_state
+
 	set count [_default [lindex $args 0] 1]
 
 	_log_cur "Pan Down ($count)" {
@@ -455,6 +521,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/SD.html
     proc _csi_T {args} {
+	cancel_ignore_state
+
 	set count [_default [lindex $args 0] 1]
 
 	_log_cur "Pan Up ($count)" {
@@ -489,6 +557,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/ECH.html
     proc _csi_X {args} {
+	cancel_ignore_state
+
 	set n [_default [lindex $args 0] 1]
 
 	_log_cur "Erase chars ($n)" {
@@ -511,6 +581,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/CBT.html
     proc _csi_Z {args} {
+	cancel_ignore_state
+
 	set n [_default [lindex $args 0] 1]
 
 	_log_cur "Cursor Backward Tabulation ($n)" {
@@ -524,6 +596,8 @@ namespace eval Term {
     #
     # https://www.xfree86.org/current/ctlseqs.html (See `(REP)`)
     proc _csi_b {args} {
+	cancel_ignore_state
+
 	set n [_default [lindex $args 0] 1]
 
 	_log_cur "Repeat ($n)" {
@@ -537,6 +611,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/VPA.html
     proc _csi_d {args} {
+	cancel_ignore_state
+
 	set row [_default [lindex $args 0] 1]
 
 	_log_cur "Vertical Line Position Absolute ($row)" {
@@ -563,6 +639,8 @@ namespace eval Term {
     #
     # https://vt100.net/docs/vt510-rm/SGR.html
     proc _csi_m {args} {
+	cancel_ignore_state
+
 	_log_cur "Select Graphic Rendition ([join $args {, }])" {
 	    variable _attrs
 
@@ -631,13 +709,23 @@ namespace eval Term {
 	    variable _cols
 	    variable _attrs
 	    variable _chars
+	    variable _newline_glitch
 	    set lattr [array get _attrs]
 	    foreach char [split $str {}] {
 		_log_cur "  Inserted char '$char'" {
+		    if { $_newline_glitch } {
+			if { $_cur_col == $_cols} {
+			    _wrap_cursor
+			}
+		    }
+
 		    set _chars($_cur_col,$_cur_row) [list $char $lattr]
 		    incr _cur_col
-		    if {$_cur_col >= $_cols} {
-			_wrap_cursor
+
+		    if { !$_newline_glitch } {
+			if {$_cur_col == $_cols} {
+			    _wrap_cursor
+			}
 		    }
 		}
 	    }
@@ -675,12 +763,14 @@ namespace eval Term {
 	variable _cur_row
 	variable _attrs
 	variable _resize_count
+	variable _newline_glitch
 
 	set _rows $rows
 	set _cols $cols
 	set _cur_col 0
 	set _cur_row 0
 	set _resize_count 0
+	set _newline_glitch 0
 	_reset_attrs _attrs
 
 	_clear_lines 0 $_rows
-- 
2.35.3


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

* [PATCH 6/6] [gdb/testsuite] Use ansi-for-tui in tuiterm
  2023-05-22 13:15 [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui Tom de Vries
                   ` (5 preceding siblings ...)
  2023-05-22 13:15 ` [PATCH 5/6] [gdb/testsuite] Implement the newline glitch in tuiterm Tom de Vries
@ 2023-05-22 13:15 ` Tom de Vries
  6 siblings, 0 replies; 11+ messages in thread
From: Tom de Vries @ 2023-05-22 13:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Use terminfo entry ansi-for-tui instead of ansi in tuiterm.

In contrast to the ansi entry, the ansi-for-tui entry has the xenl capability
set, so set _newline_glitch to 1 to make sure tuiterm matches the newly
advertised behaviour.

Also the new entry makes tui border-kind acs a copy of tui border-kind ascii,
which allows us to remove this from prepare_for_tui:
...
   gdb_test_no_output "set tui border-kind ascii"
...

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.tui/wrap-line.exp | 4 ++--
 gdb/testsuite/lib/tuiterm.exp       | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.tui/wrap-line.exp b/gdb/testsuite/gdb.tui/wrap-line.exp
index 4587517504c..82e3167a210 100644
--- a/gdb/testsuite/gdb.tui/wrap-line.exp
+++ b/gdb/testsuite/gdb.tui/wrap-line.exp
@@ -93,8 +93,8 @@ proc test_wrap_cli_tui { auto_detected_width } {
 
     gdb_assert { $gdb_width == $::cols } "width"
 
-    # TERM=ansi, so readline hides the last column.
-    gdb_assert { $gdb_width == [expr $readline_width + 1] }
+    # TERM=ansi-for-tui, so readline doesn't hide the last column.
+    gdb_assert { $gdb_width == $readline_width }
 
     with_test_prefix cli {
 	set wrap_width $readline_width
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index bb0681f2034..0024cd85ee7 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -770,7 +770,7 @@ namespace eval Term {
 	set _cur_col 0
 	set _cur_row 0
 	set _resize_count 0
-	set _newline_glitch 0
+	set _newline_glitch 1
 	_reset_attrs _attrs
 
 	_clear_lines 0 $_rows
@@ -901,7 +901,7 @@ namespace eval Term {
 
 	save_vars {env(TERM) env(TERMINFO) stty_init} {
 	    setenv TERMINFO $terminfo
-	    setenv TERM ansi
+	    setenv TERM ansi-for-tui
 	    _setup $rows $cols
 
 	    uplevel $body
@@ -946,7 +946,6 @@ namespace eval Term {
 	    return 0
 	}
 
-	gdb_test_no_output "set tui border-kind ascii"
 	gdb_test_no_output "maint set tui-resize-message on"
 	return 1
     }
-- 
2.35.3


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

* Re: [PATCH] [gdb/tui] Add set style tui-status-window
  2023-05-22 13:15 ` [PATCH] [gdb/tui] Add set style tui-status-window Tom de Vries
@ 2023-05-22 13:47   ` Eli Zaretskii
  2023-05-22 14:22     ` Tom de Vries
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2023-05-22 13:47 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

> Cc: Tom Tromey <tom@tromey.com>
> Date: Mon, 22 May 2023 15:15:40 +0200
> From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
> 
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -27300,6 +27300,13 @@ general styling to @value{GDBN}.  @xref{TUI Configuration}.
>  Control the styling of the active TUI border; that is, the TUI window
>  that has the focus.
>  
> +@item tui-status-window
> +Control the styling of the TUI status window.  Note that, unlike other
> +styling options, the tui-border has a mode rather than an intensity.
> +The values for mode are the same as for @ref{set tui border-mode} and
> +@ref{set tui active-border-mode}.  By default, this style's mode is

This use of @ref is not recommended.  It looks better in the HTML
version of the manual, but in Info and in PDF it looks like a typo or
editing error.  I suggest to use @pxref instead, like this:

  The values for mode are the same as for tui border-mode (@pxref{set
  tui border-mode}) and tui active-border-mode.

It might look less elegant in HTML, but much better in other formats.

> +standout, and the foreground and background colors are none.
                                                          ^^^^
"@code{none}", perhaps?

> +@anchor{set tui border-mode}
>  @item set tui border-mode @var{mode}
>  @kindex set tui border-mode
> +@anchor{set tui active-border-mode}
>  @itemx set tui active-border-mode @var{mode}
>  @kindex set tui active-border-mode

If you go with my suggestion above about @pxref, you don't need the
second one of these @anchor's.

Thanks.

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

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

* Re: [PATCH] [gdb/tui] Add set style tui-status-window
  2023-05-22 13:47   ` Eli Zaretskii
@ 2023-05-22 14:22     ` Tom de Vries
  2023-05-22 15:50       ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Tom de Vries @ 2023-05-22 14:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches, Tom Tromey

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

On 5/22/23 15:47, Eli Zaretskii wrote:
>> Cc: Tom Tromey <tom@tromey.com>
>> Date: Mon, 22 May 2023 15:15:40 +0200
>> From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
>>
>> --- a/gdb/doc/gdb.texinfo
>> +++ b/gdb/doc/gdb.texinfo
>> @@ -27300,6 +27300,13 @@ general styling to @value{GDBN}.  @xref{TUI Configuration}.
>>   Control the styling of the active TUI border; that is, the TUI window
>>   that has the focus.
>>   
>> +@item tui-status-window
>> +Control the styling of the TUI status window.  Note that, unlike other
>> +styling options, the tui-border has a mode rather than an intensity.
>> +The values for mode are the same as for @ref{set tui border-mode} and
>> +@ref{set tui active-border-mode}.  By default, this style's mode is
> 
> This use of @ref is not recommended.  It looks better in the HTML
> version of the manual, but in Info and in PDF it looks like a typo or
> editing error.  I suggest to use @pxref instead, like this:
> 
>    The values for mode are the same as for tui border-mode (@pxref{set
>    tui border-mode}) and tui active-border-mode.
> 
> It might look less elegant in HTML, but much better in other formats.
> 

Done.

>> +standout, and the foreground and background colors are none.
>                                                            ^^^^
> "@code{none}", perhaps?
> 

Done.

>> +@anchor{set tui border-mode}
>>   @item set tui border-mode @var{mode}
>>   @kindex set tui border-mode
>> +@anchor{set tui active-border-mode}
>>   @itemx set tui active-border-mode @var{mode}
>>   @kindex set tui active-border-mode
> 
> If you go with my suggestion above about @pxref, you don't need the
> second one of these @anchor's.
> 

Done.

Thanks for the review, updated patch attached.

Thanks,
- Tom

[-- Attachment #2: 0001-gdb-tui-Add-set-style-tui-status-window.patch --]
[-- Type: text/x-patch, Size: 9640 bytes --]

From f760325e35a4a56bb165b7f70fb1ead4b12dc247 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Sat, 13 May 2023 20:52:55 +0200
Subject: [PATCH] [gdb/tui] Add set style tui-status-window

Currently, the status window attributes are hardcoded to standout.

Add a new command "set style tui-status-window foreground/background/mode"
that controls the foreground and background colors, and the attributes for the
status window, where the attributes use the same <mode> options as used
for "set tui border-mode" and "set tui active-border-mode".

The default is none/none/standout, so there's no change in behaviour.

Tested on x86_64-linux.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---
 gdb/cli/cli-style.c             | 12 +++++++
 gdb/cli/cli-style.h             | 10 ++++++
 gdb/doc/gdb.texinfo             |  9 +++++
 gdb/testsuite/gdb.tui/basic.exp |  5 +++
 gdb/tui/tui-stack.c             | 16 +++++----
 gdb/tui/tui-win.c               | 58 +++++++++++++++++++++++++++++++++
 gdb/tui/tui-win.h               |  3 ++
 7 files changed, 106 insertions(+), 7 deletions(-)

diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index cd510b440db..29aa2d92cd3 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -101,6 +101,10 @@ cli_style_option tui_active_border_style ("tui-active-border",
 
 /* See cli-style.h.  */
 
+cli_style_option tui_status_window_style ("tui-status-window", ui_file_style::NONE);
+
+/* See cli-style.h.  */
+
 cli_style_option metadata_style ("metadata", ui_file_style::DIM);
 
 /* See cli-style.h.  */
@@ -469,6 +473,14 @@ TUI window that does have the focus."),
 						&style_show_list,
 						true);
 
+  tui_status_window_style.add_setshow_commands (no_class, _("\
+TUI status window styling.\n\
+Configure TUI status window colors\n\
+The \"tui-status-window\" style is used when GDB displays the status window."),
+						&style_set_list,
+						&style_show_list,
+						true);
+
   version_style.add_setshow_commands (no_class, _("\
 Version string display styling.\n\
 Configure colors used to display the GDB version string."),
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index f315241ccb4..b00c798caec 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -58,6 +58,13 @@ class cli_style_option
   /* Same as SET_LIST but for the show command list.  */
   struct cmd_list_element *show_list () { return m_show_list; };
 
+  /* Return the 'set style NAME' command list, that can be used
+     to add commands to.  */
+  struct cmd_list_element **modifiable_set_list () { return &m_set_list; };
+
+  /* Same as MODIFIABLE_SET_LIST but for the show command list.  */
+  struct cmd_list_element **modifiable_show_list () { return &m_show_list; };
+
   /* This style can be observed for any changes.  */
   gdb::observers::observable<> changed;
 
@@ -138,6 +145,9 @@ extern cli_style_option tui_border_style;
 /* The border style of a TUI window that does have the focus.  */
 extern cli_style_option tui_active_border_style;
 
+/* The style of a TUI status window.  */
+extern cli_style_option tui_status_window_style;
+
 /* The style to use for the GDB version string.  */
 extern cli_style_option version_style;
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index f23bcc5f3f8..d402073a00b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27300,6 +27300,14 @@ general styling to @value{GDBN}.  @xref{TUI Configuration}.
 Control the styling of the active TUI border; that is, the TUI window
 that has the focus.
 
+@item tui-status-window
+Control the styling of the TUI status window.  Note that, unlike other
+styling options, the tui-border has a mode rather than an intensity.
+The values for mode are the same as for tui border-mode
+(@pxref{set tui border-mode}) and tui active-border-mode.
+By default, this style's mode is
+standout, and the foreground and background colors are @code{none}.
+
 @item disassembler comment
 Control the styling of comments in the disassembler output.  These are
 managed with the @code{set style disassembler comment} family of
@@ -30273,6 +30281,7 @@ Use the Alternate Character Set to draw the border.  The border is
 drawn using character line graphics if the terminal supports them.
 @end table
 
+@anchor{set tui border-mode}
 @item set tui border-mode @var{mode}
 @kindex set tui border-mode
 @itemx set tui active-border-mode @var{mode}
diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp
index 2c55c2b95bc..1bfcec21256 100644
--- a/gdb/testsuite/gdb.tui/basic.exp
+++ b/gdb/testsuite/gdb.tui/basic.exp
@@ -114,3 +114,8 @@ set status_window_line 15
 set status [Term::get_line_with_attrs $status_window_line]
 gdb_assert { [regexp "^<reverse:1>$re_noattr*<reverse:0>$" $status] == 1} \
     "status window: reverse"
+
+Term::command "set style tui-status-window mode normal"
+
+set status [Term::get_line_with_attrs $status_window_line]
+gdb_assert { [regexp "^$re_noattr*$" $status] == 1} "status window: normal"
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 76b8f066abb..46504b90f98 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -37,6 +37,9 @@
 #include "tui/tui-winsource.h"
 #include "tui/tui-file.h"
 #include "tui/tui-location.h"
+#include "tui/tui-win.h"
+#include "tui/tui-io.h"
+#include "cli/cli-style.h"
 
 #include "gdb_curses.h"
 
@@ -234,15 +237,14 @@ tui_locator_window::rerender ()
   std::string string = make_status_line ();
   scrollok (handle.get (), FALSE);
   wmove (handle.get (), 0, 0);
-  /* We ignore the return value from wstandout and wstandend, casting them
-     to void in order to avoid a compiler warning.  The warning itself was
-     introduced by a patch to ncurses 5.7 dated 2009-08-29, changing these
-     macro to expand to code that causes the compiler to generate an
-     unused-value warning.  */
-  (void) wstandout (handle.get ());
+
+  if (cli_styling)
+    tui_apply_style (handle.get (), tui_status_window_style.style ());
+  wattron (handle.get (), tui_status_window_attrs);
   waddstr (handle.get (), string.c_str ());
   wclrtoeol (handle.get ());
-  (void) wstandend (handle.get ());
+  wattroff (handle.get (), tui_status_window_attrs);
+  tui_apply_style (handle.get (), ui_file_style ());
   refresh_window ();
   wmove (handle.get (), 0, 0);
 }
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 6710b3e17e5..875149cd38b 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -346,6 +346,42 @@ tui_set_var_cmd (const char *null_args,
     tui_rehighlight_all ();
 }
 
+/* Value of "tui status-window-mode".  */
+
+static const char *tui_status_window_mode = "standout";
+
+/* See tui-win.h.  */
+
+int tui_status_window_attrs;
+
+/* Show value of "tui status-window-mode".  */
+
+static void
+show_tui_status_window_mode (struct ui_file *file,
+			     int from_tty,
+			     struct cmd_list_element *c,
+			     const char *value)
+{
+  gdb_printf (file, _("\
+The attribute mode to use for the TUI status window is \"%s\".\n"),
+	      value);
+}
+
+/* Set value of "tui status-window-mode".  */
+
+static void
+set_tui_status_window_mode (const char *null_args,
+			    int from_tty, struct cmd_list_element *c)
+{
+  struct tui_translate *entry
+    = translate (tui_status_window_mode, tui_border_mode_translate);
+  if (tui_status_window_attrs == entry->value)
+    return;
+
+  tui_status_window_attrs = entry->value;
+  if (tui_active)
+    tui_show_locator_content ();
+}
 \f
 
 /* True if TUI resizes should print a message.  This is used by the
@@ -1251,6 +1287,23 @@ This variable controls the attributes to use for the active window border:\n\
 			show_tui_active_border_mode,
 			&tui_setlist, &tui_showlist);
 
+  add_setshow_enum_cmd ("mode", no_class, tui_border_mode_enums,
+			&tui_status_window_mode, _("\
+Set the attribute mode to use for the TUI status window."), _("\
+Show the attribute mode to use for the TUI status window."), _("\
+This variable controls the attributes to use for the status window:\n\
+   normal          normal display\n\
+   standout        use highlight mode of terminal\n\
+   reverse         use reverse video mode\n\
+   half            use half bright\n\
+   half-standout   use half bright and standout mode\n\
+   bold            use extra bright or bold\n\
+   bold-standout   use extra bright or bold with standout mode"),
+			set_tui_status_window_mode,
+			show_tui_status_window_mode,
+			tui_status_window_style.modifiable_set_list (),
+			tui_status_window_style.modifiable_show_list ());
+
   add_setshow_zuinteger_cmd ("tab-width", no_class,
 			     &internal_tab_width, _("\
 Set the tab width, in characters, for the TUI."), _("\
@@ -1305,4 +1358,9 @@ When enabled, the left margin will use '_' and '0' instead of spaces."),
 
   tui_border_style.changed.attach (tui_rehighlight_all, "tui-win");
   tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win");
+  tui_status_window_style.changed.attach (tui_show_locator_content, "tui-win");
+
+  /* Assign default value.  */
+  tui_status_window_attrs
+    = translate (tui_status_window_mode, tui_border_mode_translate)->value;
 }
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 3d35f1dfb7f..5ace83a742a 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -38,6 +38,9 @@ extern chtype tui_border_hline;
 extern int tui_border_attrs;
 extern int tui_active_border_attrs;
 
+/* Attributes for the contents of the status window.  */
+extern int tui_status_window_attrs;
+
 extern bool tui_update_variables ();
 
 extern void tui_initialize_win (void);

base-commit: 7a8a6f57eced9a8c27a93cb5c5977a33be7b1f72
-- 
2.35.3


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

* Re: [PATCH] [gdb/tui] Add set style tui-status-window
  2023-05-22 14:22     ` Tom de Vries
@ 2023-05-22 15:50       ` Eli Zaretskii
  0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2023-05-22 15:50 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches, tom

> Date: Mon, 22 May 2023 16:22:32 +0200
> Cc: gdb-patches@sourceware.org, Tom Tromey <tom@tromey.com>
> From: Tom de Vries <tdevries@suse.de>
> 
> Thanks for the review, updated patch attached.

OK for the documentation part, thanks.

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

end of thread, other threads:[~2023-05-22 15:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22 13:15 [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui Tom de Vries
2023-05-22 13:15 ` [PATCH 1/6] [gdb/testsuite] Use TERM=dummy in gdb.tui/tuiterm.exp Tom de Vries
2023-05-22 13:15 ` [PATCH] [gdb/tui] Add set style tui-status-window Tom de Vries
2023-05-22 13:47   ` Eli Zaretskii
2023-05-22 14:22     ` Tom de Vries
2023-05-22 15:50       ` Eli Zaretskii
2023-05-22 13:15 ` [PATCH 2/6] [gdb/testsuite] Factor out Term::_wrap_cursor Tom de Vries
2023-05-22 13:15 ` [PATCH 3/6] [gdb/contrib] Add ansi-for-tui.sh Tom de Vries
2023-05-22 13:15 ` [PATCH 4/6] [gdb/testsuite] Make ansi-for-tui available in with_tuiterm Tom de Vries
2023-05-22 13:15 ` [PATCH 5/6] [gdb/testsuite] Implement the newline glitch in tuiterm Tom de Vries
2023-05-22 13:15 ` [PATCH 6/6] [gdb/testsuite] Use ansi-for-tui " Tom de Vries

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