mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
b0fcf3e344
When applying layouts gdb computes the size of each window (or rather, each sub-layout within a layout) using integer arithmetic. As this rounds down the results, then, when all sub-layouts are sized, there is the possibility that we have some space left over. Currently, this space is just assigned to an arbitrary sub-layout. This can result in some unbalanced results. Consider this set of steps with current master: (gdb) tui enable (gdb) layout regs (gdb) info win Name Lines Columns Focus regs 7 80 src 9 80 (has focus) status 1 80 cmd 8 80 Notice the weird split between the src and regs windows, the original layout specification has these windows given equal weight. The problem is that, with rounding, both the regs and src windows are initially sized to 7, the extra 2 lines are then arbitrarily added to the src window. In this commit, rather than add all the extra space to one single window, I instead hand out the extra space 1 line at a time, looping over all the sub-layouts. We take care to respect the min/max sizes, and so, we now get this result: (gdb) tui enable (gdb) layout regs (gdb) info win Name Lines Columns Focus regs 8 80 src 8 80 (has focus) status 1 80 cmd 8 80 This looks more natural to me. This is obviously a change in behaviour, and so, lots of the existing tests need to be updated to take this into account. None of the changes are huge, it's just a line or two (or column for width) moved between windows.
106 lines
2.7 KiB
Plaintext
106 lines
2.7 KiB
Plaintext
# Copyright 2019-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 TUI resizing with empty windows.
|
|
|
|
tuiterm_env
|
|
|
|
standard_testfile
|
|
|
|
Term::clean_restart 24 80
|
|
|
|
if {![Term::enter_tui]} {
|
|
unsupported "TUI not supported"
|
|
return
|
|
}
|
|
|
|
# Each entry describes a layout. It has these items:
|
|
# 1. Layout name
|
|
# 2. Test name
|
|
# 3. List of boxes in 80x24 mode
|
|
# 4. List of boxes in 90x40 mode
|
|
# 5. List of test name and text for the empty window
|
|
set layouts {
|
|
{src src {{0 0 80 15}} {{0 0 90 26}}
|
|
{{"no source" "No Source Available"}}}
|
|
{regs src-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
|
|
{
|
|
{"no source" "No Source Available"}
|
|
{"no regs" "Register Values Unavailable"}
|
|
}}
|
|
{asm asm {{0 0 80 15}} {{0 0 90 26}}
|
|
{
|
|
{"no asm" "No Assembly Available"}
|
|
}}
|
|
{regs asm-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
|
|
{
|
|
{"no asm" "No Assembly Available"}
|
|
{"no regs" "Register Values Unavailable"}
|
|
}}
|
|
{split split {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
|
|
{
|
|
{"no source" "No Source Available"}
|
|
{"no asm" "No Assembly Available"}
|
|
}}
|
|
{regs split-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
|
|
{
|
|
{"no asm" "No Assembly Available"}
|
|
{"no regs" "Register Values Unavailable"}
|
|
}}
|
|
}
|
|
|
|
# Helper function to verify a list of boxes.
|
|
proc check_boxes {boxes} {
|
|
set boxno 1
|
|
foreach box $boxes {
|
|
eval Term::check_box [list "box $boxno"] $box
|
|
incr boxno
|
|
}
|
|
}
|
|
|
|
# Helper function to verify text.
|
|
proc check_text {text_list} {
|
|
set text [Term::get_all_lines]
|
|
foreach item $text_list {
|
|
lassign $item testname check
|
|
if {![gdb_assert {[regexp -- $check $text]} $testname]} {
|
|
Term::dump_screen
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach layout $layouts {
|
|
lassign $layout name testname small_boxes large_boxes text_list
|
|
|
|
with_test_prefix $testname {
|
|
Term::command "layout $name"
|
|
with_test_prefix 80x24 {
|
|
check_boxes $small_boxes
|
|
check_text $text_list
|
|
}
|
|
|
|
Term::resize 40 90
|
|
with_test_prefix 90x40 {
|
|
check_boxes $large_boxes
|
|
check_text $text_list
|
|
}
|
|
Term::resize 24 80
|
|
with_test_prefix "80x24 again" {
|
|
check_boxes $small_boxes
|
|
check_text $text_list
|
|
}
|
|
}
|
|
}
|