From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 63FDD3858426; Sun, 30 Apr 2023 11:06:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63FDD3858426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682852772; bh=cXyZmzzL2ExE1TvW+NsJVAyM96LKCyyg35cj5Qzf5MQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=W1oc+8wjJy39B9gJ50zRJBU9OHtS5NeJXBHhpy+R71CyNybMJaaFSJ1/OOHIUMmfT qxFqRjrtTRoR6XbhbfVpLaXewHXAmtbE0r0WdIBheaI9tlmYuRRz8AtwVn+zrwf/Xv v9CPGCYFoBHp3um4hKOKBUqT8MaKIG6dzgJNfEoc= From: "cvs-commit at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug tui/30337] [gdb/tui] TUI in ansi terminal has off-by-one width problem Date: Sun, 30 Apr 2023 11:06:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: tui X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30337 --- Comment #6 from cvs-commit at gcc dot gnu.org --- The master branch has been updated by Tom de Vries : https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Ddeb1ba4e38bf= 1427d4297b1e9b3e5e73cbc9e456 commit deb1ba4e38bf1427d4297b1e9b3e5e73cbc9e456 Author: Tom de Vries Date: Sun Apr 30 13:06:23 2023 +0200 [gdb/tui] Fix TUI resizing for TERM=3Dansi With TERM=3Dansi, when resizing a TUI window from LINES/COLUMNS 31/118 (maximized) to 20/78 (de-maximized), I get a garbled screen (that ^L doesn't fix) and a message: ... @@ resize done 0, size =3D 77x20 ... with the resulting width being 77 instead of the expected 78. [ The discrepancy also manifests in CLI, filed as PR30346. ] The discrepancy comes from tui_resize_all, where we ask readline for the screen size: ... rl_get_screen_size (&screenheight, &screenwidth); ... As it happens, when TERM is set to ansi, readline decides that the term= inal cannot auto-wrap lines, and reserves one column to deal with that, and = as a result reports back one less than the actual screen width: ... $ echo $COLUMNS 78 $ TERM=3Dxterm gdb -ex "show width" -ex q Number of characters gdb thinks are in a line is 78. $ TERM=3Dansi gdb -ex "show width" -ex q Number of characters gdb thinks are in a line is 77. ... In tui_resize_all, we need the actual screen width, and using a screenw= idth of one less than the actual value garbles the screen. This is currently not causing trouble in testing because we have a workaround in place in proc Term::resize. If we disable the workaround: ... - stty columns [expr {$_cols + 1}] < $::gdb_tty_name + stty columns $_cols < $::gdb_tty_name ... and dump the screen we get the same type of screen garbling: ... 0 +---------------------------------------+| 1 || 2 || 3 || ... Another way to reproduce the problem is using command "maint info scree= n". After starting gdb with TERM=3Dansi, entering TUI, and issuing the comm= and, we get: ... Number of characters curses thinks are in a line is 78. ... and after maximizing and demaximizing the window we get: ... Number of characters curses thinks are in a line is 77. ... If we use TERM=3Dxterm, we do get the expected 78. Fix this by: - detecting when readline will report back less than the actual screen width, - accordingly setting a new variable readline_hidden_cols, - using readline_hidden_cols in tui_resize_all to fix the resize proble= m, and - removing the workaround in Term::resize. The test-case gdb.tui/empty.exp serves as regression test. I've applied the same fix in tui_async_resize_screen, the new test-case gdb.tui/resize-2.exp serves as a regression test for that change. With= out that fix, we have: ... FAIL: gdb.tui/resize-2.exp: again: gdb width 80 ... Tested on x86_64-linux. PR tui/30337 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30337 --=20 You are receiving this mail because: You are on the CC list for the bug.=