public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug tui/30337] New: [gdb/tui] TUI in ansi terminal has one off width problem
@ 2023-04-12 11:15 vries at gcc dot gnu.org
  2023-04-12 11:15 ` [Bug tui/30337] [gdb/tui] TUI in ansi terminal has off-by-one " vries at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-04-12 11:15 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30337
           Summary: [gdb/tui] TUI in ansi terminal has one off width
                    problem
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: tui
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

I. Terminal used

I open a terminal, and can easily switch between maximized:
...
$ echo $COLUMNS 
118
$ echo $LINES
31
...
and non-maximized:
..
$ echo $COLUMNS 
78
$ echo $LINES
20
...


II. TERM=xterm

Now let's start gdb in TUI mode in maximized mode:
...
$ gdb \
    -ex "set tui border-kind ascii" \
    -ex "maint set tui-resize-message on" \
    -ex "tui enable"
...

That looks as expected (not posting, rather big).

Now let's resize to non-maximized:
...
+----------------------------------------------------------------------------+
|                                                                            |
|                                                                            |
|                                                                            |
|                                                                            |
|                                                                            |
|              [ No Source Available ]                                       |
|                                                                            |
|                                                                            |
|                                                                            |
|                                                                            |
+----------------------------------------------------------------------------+
None No process In:                                              L??   PC: ?? 
@@ resize done 0, size = 78x20
(gdb) 
...

OK, that looks good as well.


III. TERM=ansi

Now, let's repeat this, but with TERM set to ansi, as we do in the testsuite.

That looks ok, with the exception of "gdb)" appearing at the start of the line,
with the missing "(" glued to the end of the previous line.

Now, let's resize again to non-maximized:
...
+---------------------------------------------------------------------------||





              [ No Source Available ]                                      
|+---------------------------------------------------------------------------+No
ne No process In:                                             L??   PC: ?? |
|
|
|
|
@@ resize done 0, size = 77x20
(gdb) -----------------------------------------------------------------------




...

Well, the result looks a bit garbled, and the resize reports 77 instead of 78.

I tracked this down to readline underreporting the screen size, due to
_rl_term_autowrap == 0.

With this demonstrator patch:
...
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 008189eb99b..995355e9ecc 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -528,6 +528,8 @@ tui_resize_all (void)
   int screenheight, screenwidth;

   rl_get_screen_size (&screenheight, &screenwidth);
+  screenwidth++;
+
   width_diff = screenwidth - tui_term_width ();
   height_diff = screenheight - tui_term_height ();
   if (height_diff || width_diff)
...
we get instead the expected and non-garbled:
...
+----------------------------------------------------------------------------+
|                                                                            |
|                                                                            |
|                                                                            |
|                                                                            |
|                                                                            |
|              [ No Source Available ]                                       |
|                                                                            |
|                                                                            |
|                                                                            |
|                                                                            |
+----------------------------------------------------------------------------+
None No process In:                                           L??   PC: ?? @@
resize done 0, size = 78x20
(gdb) 
...

The problem seems to be related to this comment in Term::resize:
...
        # Somehow the number of columns transmitted to gdb is one less          
        # than what we request from expect.  We hide this weird                 
        # details from the caller.                                              
        _do_resize $_rows $cols
        stty columns [expr {$_cols + 1}] < $::gdb_tty_name
...
and indeed, after dropping the +1 in {$_cols + 1} the test passes (and ...
without timeouts).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2023-04-30 11:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12 11:15 [Bug tui/30337] New: [gdb/tui] TUI in ansi terminal has one off width problem vries at gcc dot gnu.org
2023-04-12 11:15 ` [Bug tui/30337] [gdb/tui] TUI in ansi terminal has off-by-one " vries at gcc dot gnu.org
2023-04-12 11:48 ` vries at gcc dot gnu.org
2023-04-12 12:45 ` vries at gcc dot gnu.org
2023-04-12 13:56 ` vries at gcc dot gnu.org
2023-04-13 12:43 ` vries at gcc dot gnu.org
2023-04-13 14:11 ` vries at gcc dot gnu.org
2023-04-30 11:06 ` cvs-commit at gcc dot gnu.org
2023-04-30 11:10 ` vries at gcc dot gnu.org

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