Term::check_contents "split layout contents" \
"$main_line *$main_re.*$hex <main>"
-Term::check_box "source box in split layout" 0 0 80 7
-Term::check_box "asm box in split layout" 0 6 80 9
+Term::check_box "source box in split layout" 0 0 80 8
+Term::check_box "asm box in split layout" 0 7 80 8
set layouts {
{src src {{0 0 80 15}} {{0 0 90 26}}
{{"no source" "No Source Available"}}}
- {regs src-regs {{0 0 80 7} {0 6 80 9}} {{0 0 90 13} {0 12 90 13}}
+ {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 13}} {{0 0 90 26}}
+ {asm asm {{0 0 80 15}} {{0 0 90 26}}
{
{"no asm" "No Assembly Available"}
}}
- {regs asm-regs {{0 0 80 7} {0 6 80 9}} {{0 0 90 13} {0 12 90 13}}
+ {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 6} {0 5 80 8}} {{0 0 90 13} {0 12 90 13}}
+ {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 6} {0 5 80 8}} {{0 0 90 13} {0 12 90 13}}
+ {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"}
check_text $text_list
}
Term::resize 24 80
+ with_test_prefix "80x24 again" {
+ check_boxes $small_boxes
+ check_text $text_list
+ }
}
}
Term::check_contents "source at startup" "\\|.*21 *return 0"
Term::command "layout regs"
-Term::check_box "register box" 0 0 80 7
-Term::check_box "source box in regs layout" 0 6 80 9
+Term::check_box "register box" 0 0 80 8
+Term::check_box "source box in regs layout" 0 7 80 8
set text [Term::get_line 1]
# Just check for any register window content at all.
}
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::check_box "source box" 0 0 45 15
+ Term::check_box "asm box" 44 0 36 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::dump_screen
+ Term::check_box "source box" 0 0 50 15
+ Term::check_box "asm box" 49 0 31 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::check_box "source box" 0 0 42 15
+ Term::check_box "asm box" 41 0 39 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
+ Term::check_box "source box" 0 0 40 15
+ Term::check_box "asm box" 39 0 41 15
}
info[i].size = info[i].max_size;
if (info[i].size < info[i].min_size)
info[i].size = info[i].min_size;
- /* If there is any leftover size, just redistribute it to the
- last resizeable window, by dropping it from the allocated
- size. We could try to be fancier here perhaps, by
- redistributing this size among all windows, not just the
- last window. */
+ /* Keep a total of all the size we've used so far (we gain some
+ size back if this window can share a border with a preceding
+ window). Any unused space will be distributed between all of
+ the other windows (while respecting min/max sizes) later in
+ this function. */
used_size += info[i].size;
if (info[i].share_box)
--used_size;
}
/* Allocate any leftover size. */
- if (available_size >= used_size && last_index != -1)
+ if (available_size > used_size && last_index != -1)
{
- info[last_index].size += available_size - used_size;
+ /* Loop over all windows until all available space is used up. */
+ bool found_window_that_can_grow_p = true;
+ for (int idx = last_index;
+ available_size > used_size;
+ idx = (idx + 1) % m_splits.size ())
+ {
+ /* Once we have visited all of the windows, check that we did
+ manage to allocate some more space. This prevents us getting
+ stuck in the loop forever if we can't allocate anything
+ more. */
+ if (idx == last_index)
+ {
+ if (!found_window_that_can_grow_p)
+ break;
+ found_window_that_can_grow_p = false;
+ }
+
+ if (available_size > used_size
+ && info[idx].size < info[idx].max_size)
+ {
+ found_window_that_can_grow_p = true;
+ info[idx].size += 1;
+ used_size += 1;
+ }
+ }
if (debug_tui)
{