aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-01-24 22:02:59 +0000
committerAndrew Burgess <aburgess@redhat.com>2022-04-03 15:15:09 +0100
commit160444ec7fd7c6df81826b8e06aa32a2ac1df856 (patch)
tree203f32b2a5e84359ef9756ce50e1b5f64553eb6d /gdb/testsuite
parentef466e0f0827555fcae21a905b3a2b9a6c0a5712 (diff)
downloadgdb-160444ec7fd7c6df81826b8e06aa32a2ac1df856.zip
gdb-160444ec7fd7c6df81826b8e06aa32a2ac1df856.tar.gz
gdb-160444ec7fd7c6df81826b8e06aa32a2ac1df856.tar.bz2
gdb/tui: add new 'tui window width' command and 'winwidth' alias
This commit adds a new command 'tui window width', and an alias 'winwidth'. This command is equivalent to the old 'winheight' command (which was recently renamed 'tui window height'). Even though I recently moved the old tui commands under the tui namespace, and I would strongly encourage all new tui commands to be added as 'tui ....' only (users can create their own top-level aliases if they want), I'm breaking that suggestion here, and adding a 'winwidth' alias. Given that we already have 'winheight' and have done for years, it just didn't seem right to no have the matching 'winwidth'. You might notice in the test that the window resizing doesn't quite work right. I setup a horizontal layout, then grow and shrink the windows. At the end of the test the windows should be back to their original size... ... they are not. This isn't my fault, honest! GDB's window resizing is a little ... temperamental, and is prone to getting things slightly wrong during resizes, off by 1 type things. This is true for height resizing, as well as the new width resizing. Later patches in this series will rework the resizing algorithm, which should improve things in this area. For now, I'm happy that the width resizing is as good as the height resizing, given the existing quirks. For the docs side I include a paragraph that explains how multiple windows are required before the width can be adjusted. For completeness, I've added the same paragraph to the winheight description. With the predefined layouts this extra paragraph is not really needed for winheight, as there are always multiple windows on the screen. However, with custom layouts, this might not be true, so adding the paragraph seems like a good idea. As for the changes in gdb itself, I've mostly just taken the existing height adjustment code, changed the name to make it generic 'size' adjustment, and added a boolean flag to indicate if we are adjusting the width or the height.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.tui/winwidth.exp62
1 files changed, 62 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.tui/winwidth.exp b/gdb/testsuite/gdb.tui/winwidth.exp
new file mode 100644
index 0000000..b0a838b
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/winwidth.exp
@@ -0,0 +1,62 @@
+# Copyright 2022 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/>.
+
+# Test the "winwidth" command.
+
+tuiterm_env
+
+standard_testfile tui-layout.c
+
+if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
+ return -1
+}
+
+Term::clean_restart 24 80 $testfile
+if {![Term::enter_tui]} {
+ unsupported "TUI not supported"
+ return
+}
+
+Term::command "tui new-layout h { -horizontal src 1 asm 1 } 1 status 0 cmd 1"
+Term::command "layout h"
+
+with_test_prefix "original window sizes" {
+ Term::check_box "source box" 0 0 40 15
+ Term::check_box "asm box" 39 0 41 15
+ Term::command "winwidth src +5"
+}
+
+with_test_prefix "after src +5" {
+ Term::check_box "source box" 0 0 44 15
+ Term::check_box "asm box" 43 0 37 15
+ Term::command "winwidth asm -5"
+}
+
+with_test_prefix "after asm -5" {
+ Term::check_box "source box" 0 0 48 15
+ Term::check_box "asm box" 47 0 33 15
+ Term::command "winwidth asm +8"
+}
+
+with_test_prefix "after asm +8" {
+ Term::check_box "source box" 0 0 39 15
+ Term::check_box "asm box" 38 0 42 15
+ Term::command "winwidth src -2"
+}
+
+with_test_prefix "after src -2" {
+ Term::check_box "source box" 0 0 36 15
+ Term::check_box "asm box" 35 0 45 15
+}