[list h "{-horizontal asm 1 src 1} 1 status 0 cmd 1" \
{{0 0 40 15} {39 0 41 15}} \
"$hex <main>.*21.*return 0"] \
+ [list example3 "{-horizontal src 1 cmd 1} 1 status 0 asm 1" \
+ {{0 0 40 11} {0 12 80 12}} \
+ "21.*return 0.*$hex <main>"] \
+ [list example4 "src 1 status 0 {-horizontal cmd 1 regs 1} 1" \
+ {{0 0 80 11} {40 12 40 12}} ""] \
[list cmd_only "cmd 1" {} ""]]
# Helper function to verify a list of boxes.
/* See tui-layout.h. */
void
-tui_apply_current_layout ()
+tui_apply_current_layout (bool preserve_cmd_win_size_p)
{
struct gdbarch *gdbarch;
CORE_ADDR addr;
for (tui_win_info *win_info : tui_windows)
win_info->make_visible (false);
- applied_layout->apply (0, 0, tui_term_width (), tui_term_height ());
+ applied_layout->apply (0, 0, tui_term_width (), tui_term_height (),
+ preserve_cmd_win_size_p);
/* Keep the list of internal windows up-to-date. */
for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
static void
tui_set_layout (tui_layout_split *layout)
{
+ std::string old_fingerprint;
+ if (applied_layout != nullptr)
+ old_fingerprint = applied_layout->layout_fingerprint ();
+
applied_skeleton = layout;
applied_layout = layout->clone ();
- tui_apply_current_layout ();
+
+ std::string new_fingerprint = applied_layout->layout_fingerprint ();
+ bool preserve_command_window_size
+ = (TUI_CMD_WIN != nullptr && old_fingerprint == new_fingerprint);
+
+ tui_apply_current_layout (preserve_command_window_size);
}
/* See tui-layout.h. */
const char *name = type == SRC_WIN ? SRC_NAME : DISASSEM_NAME;
applied_layout->replace_window (tui_win_list[other]->name (), name);
- tui_apply_current_layout ();
+ tui_apply_current_layout (true);
}
/* Find LAYOUT in the "layouts" global and return its index. */
}
applied_layout->remove_windows (focus->name ());
- tui_apply_current_layout ();
+ tui_apply_current_layout (true);
}
static void
/* See tui-layout.h. */
void
-tui_layout_window::apply (int x_, int y_, int width_, int height_)
+tui_layout_window::apply (int x_, int y_, int width_, int height_,
+ bool preserve_cmd_win_size_p)
{
x = x_;
y = y_;
/* See tui-layout.h. */
+std::string
+tui_layout_window::layout_fingerprint () const
+{
+ if (strcmp (get_name (), "cmd") == 0)
+ return "C";
+ else
+ return "";
+}
+
+/* See tui-layout.h. */
+
void
tui_layout_split::add_split (std::unique_ptr<tui_layout_split> &&layout,
int weight)
}
else
{
- /* Simply re-apply the updated layout. */
- apply (x, y, width, height);
+ /* Simply re-apply the updated layout. We pass false here so that
+ the cmd window can be resized. However, we should have already
+ resized everything above to be "just right", so the apply call
+ here should not end up changing the sizes at all. */
+ apply (x, y, width, height, false);
}
return HANDLED;
/* See tui-layout.h. */
void
-tui_layout_split::apply (int x_, int y_, int width_, int height_)
+tui_layout_split::apply (int x_, int y_, int width_, int height_,
+ bool preserve_cmd_win_size_p)
{
TUI_SCOPED_DEBUG_ENTER_EXIT;
m_splits[i].layout->get_sizes (m_vertical, &info[i].min_size,
&info[i].max_size);
- if (!m_applied
+ if (preserve_cmd_win_size_p
&& cmd_win_already_exists
&& m_splits[i].layout->get_name () != nullptr
&& strcmp (m_splits[i].layout->get_name (), "cmd") == 0)
else if (info[i].share_box)
--size_accum;
if (m_vertical)
- m_splits[i].layout->apply (x, y + size_accum, width, info[i].size);
+ m_splits[i].layout->apply (x, y + size_accum, width, info[i].size,
+ preserve_cmd_win_size_p);
else
- m_splits[i].layout->apply (x + size_accum, y, info[i].size, height);
+ m_splits[i].layout->apply (x + size_accum, y, info[i].size, height,
+ preserve_cmd_win_size_p);
size_accum += info[i].size;
}
-
- m_applied = true;
}
/* See tui-layout.h. */
gdb_puts ("}", output);
}
+/* See tui-layout.h. */
+
+std::string
+tui_layout_split::layout_fingerprint () const
+{
+ for (auto &item : m_splits)
+ {
+ std::string fp = item.layout->layout_fingerprint ();
+ if (!fp.empty ())
+ return std::string (m_vertical ? "V" : "H") + fp;
+ }
+
+ return "";
+}
+
/* Destroy the layout associated with SELF. */
static void
"skeleton" layout. */
virtual std::unique_ptr<tui_layout_base> clone () const = 0;
- /* Change the size and location of this layout. */
- virtual void apply (int x, int y, int width, int height) = 0;
+ /* Change the size and location of this layout. When
+ PRESERVE_CMD_WIN_SIZE_P is true the current size of the TUI_CMD_WIN
+ is preserved, otherwise, the TUI_CMD_WIN will resize just like any
+ other window. */
+ virtual void apply (int x, int y, int width, int height,
+ bool preserve_cmd_win_size_p) = 0;
/* Return the minimum and maximum height or width of this layout.
HEIGHT is true to fetch height, false to fetch width. */
depth of this layout in the hierarchy (zero-based). */
virtual void specification (ui_file *output, int depth) = 0;
+ /* Return a FINGERPRINT string containing an abstract representation of
+ the location of the cmd window in this layout.
+
+ When called on a complete, top-level layout, the fingerprint will be a
+ non-empty string made of 'V' and 'H' characters, followed by a single
+ 'C' character. Each 'V' and 'H' represents a vertical or horizontal
+ layout that must be passed through in order to find the cmd
+ window.
+
+ Of course, layouts are built recursively, so, when called on a partial
+ layout, if this object represents a single window, then either the
+ empty string is returned (for non-cmd windows), or a string
+ containing a single 'C' is returned.
+
+ For object representing layouts, if the layout contains the cmd
+ window then we will get back a valid fingerprint string (contains 'V'
+ and 'H', ends with 'C'), or, if this layout doesn't contain the cmd
+ window, an empty string is returned. */
+ virtual std::string layout_fingerprint () const = 0;
+
/* Add all windows to the WINDOWS vector. */
virtual void get_windows (std::vector<tui_win_info *> *windows) = 0;
std::unique_ptr<tui_layout_base> clone () const override;
- void apply (int x, int y, int width, int height) override;
+ void apply (int x, int y, int width, int height,
+ bool preserve_cmd_win_size_p) override;
const char *get_name () const override
{
void specification (ui_file *output, int depth) override;
+ std::string layout_fingerprint () const override;
+
/* See tui_layout_base::get_windows. */
void get_windows (std::vector<tui_win_info *> *windows) override
{
std::unique_ptr<tui_layout_base> clone () const override;
- void apply (int x, int y, int width, int height) override;
+ void apply (int x, int y, int width, int height,
+ bool preserve_cmd_win_size_p) override;
tui_adjust_result set_height (const char *name, int new_height) override
{
void specification (ui_file *output, int depth) override;
+ std::string layout_fingerprint () const override;
+
/* See tui_layout_base::get_windows. */
void get_windows (std::vector<tui_win_info *> *windows) override
{
/* True if the windows in this split are arranged vertically. */
bool m_vertical;
-
- /* True if this layout has already been applied at least once. */
- bool m_applied = false;
};
/* Add the specified window to the layout in a logical way. This
some other window is chosen to remain. */
extern void tui_remove_some_windows ();
-/* Apply the current layout. */
-extern void tui_apply_current_layout ();
+/* Apply the current layout. When PRESERVE_CMD_WIN_SIZE_P is true the
+ current size of the TUI_CMD_WIN is preserved, otherwise, the TUI_CMD_WIN
+ will resize just like any other window. */
+extern void tui_apply_current_layout (bool);
/* Adjust the window height of WIN to NEW_HEIGHT. */
extern void tui_adjust_window_height (struct tui_win_info *win,
AIX 5.3 does not define clear. */
erase ();
clearok (curscr, TRUE);
- tui_apply_current_layout ();
- /* Turn keypad back on. */
+ /* Apply the current layout. The 'false' here allows the command
+ window to resize proportionately with containing terminal, rather
+ than maintaining a fixed size. */
+ tui_apply_current_layout (false); /* Turn keypad back on. */
keypad (TUI_CMD_WIN->handle.get (), TRUE);
}
}