+2020-02-22 Tom Tromey <tom@tromey.com>
+
+ * tui/tui-layout.h (enum tui_adjust_result): New.
+ (class tui_layout_base) <adjust_size>: Return tui_adjust_result.
+ (class tui_layout_window) <adjust_size>: Return
+ tui_adjust_result. Rewrite.
+ (class tui_layout_split) <adjust_size>: Return tui_adjust_result.
+ * tui/tui-layout.c (tui_layout_split::adjust_size): Update.
+
2020-02-22 Tom Tromey <tom@tromey.com>
* tui/tui-layout.h (class tui_layout_split) <add_split>: Change
/* See tui-layout.h. */
-bool
+tui_adjust_result
tui_layout_split::adjust_size (const char *name, int new_height)
{
/* Look through the children. If one is a layout holding the named
int found_index = -1;
for (int i = 0; i < m_splits.size (); ++i)
{
- if (m_splits[i].layout->adjust_size (name, new_height))
- return true;
- const char *win_name = m_splits[i].layout->get_name ();
- if (win_name != nullptr && strcmp (name, win_name) == 0)
+ tui_adjust_result adjusted
+ = m_splits[i].layout->adjust_size (name, new_height);
+ if (adjusted == HANDLED)
+ return HANDLED;
+ if (adjusted == FOUND)
{
found_index = i;
break;
}
if (found_index == -1)
- return false;
+ return NOT_FOUND;
if (m_splits[found_index].layout->height == new_height)
- return true;
+ return HANDLED;
set_weights_from_heights ();
int delta = m_splits[found_index].weight - new_height;
apply (x, y, width, height);
}
- return true;
+ return HANDLED;
}
/* See tui-layout.h. */
#include "tui/tui.h"
#include "tui/tui-data.h"
+/* Values that can be returned when handling a request to adjust a
+ window's size. */
+enum tui_adjust_result
+{
+ /* Requested window was not found here. */
+ NOT_FOUND,
+ /* Window was found but not handled. */
+ FOUND,
+ /* Window was found and handled. */
+ HANDLED
+};
+
/* The basic object in a TUI layout. This represents a single piece
of screen real estate. Subclasses determine the exact
behavior. */
/* Adjust the size of the window named NAME to NEW_HEIGHT, updating
the sizes of the other windows around it. */
- virtual bool adjust_size (const char *name, int new_height) = 0;
+ virtual tui_adjust_result adjust_size (const char *name, int new_height) = 0;
/* Remove some windows from the layout, leaving the command window
and the window being passed in here. */
return m_contents.c_str ();
}
- bool adjust_size (const char *name, int new_height) override
+ tui_adjust_result adjust_size (const char *name, int new_height) override
{
- return false;
+ return m_contents == name ? FOUND : NOT_FOUND;
}
bool top_boxed_p () const override;
void apply (int x, int y, int width, int height) override;
- bool adjust_size (const char *name, int new_height) override;
+ tui_adjust_result adjust_size (const char *name, int new_height) override;
bool top_boxed_p () const override;