+2020-07-01 Tom Tromey <tom@tromey.com>
+
+ * tui/tui-wingeneral.c (tui_win_info::refresh_window): Move from
+ tui_gen_win_info.
+ (tui_win_info::make_window): Merge with
+ tui_gen_win_info::make_window.
+ (tui_win_info::make_visible): Move from tui_gen_win_info.
+ * tui/tui-win.c (tui_win_info::max_width): Move from
+ tui_gen_win_info.
+ * tui/tui-layout.h (class tui_layout_window) <m_window>: Change
+ type.
+ <window_factory>: Likewise.
+ * tui/tui-layout.c (tui_win_info::resize): Move from
+ tui_gen_win_info.
+ (make_standard_window): Change return type.
+ (get_locator_window, tui_get_window_by_name): Likewise.
+ (tui_layout_window::apply): Remove a cast.
+ * tui/tui-data.h (MIN_WIN_HEIGHT): Move earlier.
+ (struct tui_win_info): Merge with tui_gen_win_info.
+ (struct tui_gen_win_info): Remove.
+
2020-07-01 Tom Tromey <tom@tromey.com>
* tui/tui-stack.h (struct tui_locator_window): Derive from
}
};
+#define MIN_WIN_HEIGHT 3
+
/* Generic window information. */
-struct tui_gen_win_info
+struct tui_win_info
{
protected:
- tui_gen_win_info () = default;
+ tui_win_info () = default;
+ DISABLE_COPY_AND_ASSIGN (tui_win_info);
/* This is called after the window is resized, and should update the
window's contents. */
- virtual void rerender ()
- {
- }
+ virtual void rerender ();
virtual void make_window ();
public:
- tui_gen_win_info (tui_gen_win_info &&) = default;
-
- virtual ~tui_gen_win_info ()
- {
- }
+ tui_win_info (tui_win_info &&) = default;
+ virtual ~tui_win_info () = default;
/* Call to refresh this window. */
virtual void refresh_window ();
}
/* Compute the maximum height of this window. */
- virtual int max_height () const = 0;
+ virtual int max_height () const;
/* Compute the minimum height of this window. */
- virtual int min_height () const = 0;
+ virtual int min_height () const
+ {
+ return MIN_WIN_HEIGHT;
+ }
/* Compute the maximum width of this window. */
int max_width () const;
/* Return true if this window can be boxed. */
virtual bool can_box () const
{
- return false;
+ return true;
}
/* Resize this window. The parameters are used to set the window's
wnoutrefresh (handle.get ());
}
- /* Window handle. */
- std::unique_ptr<WINDOW, curses_deleter> handle;
- /* Window width. */
- int width = 0;
- /* Window height. */
- int height = 0;
- /* Origin of window. */
- int x = 0;
- int y = 0;
-};
-
-/* Constant definitions. */
-#define SRC_NAME "src"
-#define CMD_NAME "cmd"
-#define DATA_NAME "regs"
-#define DISASSEM_NAME "asm"
-#define STATUS_NAME "status"
-#define MIN_WIN_HEIGHT 3
-
-/* This defines information about each logical window. */
-struct tui_win_info : public tui_gen_win_info
-{
-protected:
-
- tui_win_info () = default;
- DISABLE_COPY_AND_ASSIGN (tui_win_info);
-
- /* Scroll the contents vertically. This is only called via
- forward_scroll and backward_scroll. */
- virtual void do_scroll_vertical (int num_to_scroll) = 0;
-
- /* Scroll the contents horizontally. This is only called via
- left_scroll and right_scroll. */
- virtual void do_scroll_horizontal (int num_to_scroll) = 0;
-
- void rerender () override;
-
- void make_window () override;
-
-public:
-
- ~tui_win_info () override
- {
- }
-
- int max_height () const override;
-
- int min_height () const override
- {
- return MIN_WIN_HEIGHT;
- }
-
/* Called after the tab width has been changed. */
virtual void update_tab_width ()
{
return true;
}
- bool can_box () const override
- {
- return true;
- }
-
void check_and_display_highlight_if_needed ();
+ /* Window handle. */
+ std::unique_ptr<WINDOW, curses_deleter> handle;
+ /* Window width. */
+ int width = 0;
+ /* Window height. */
+ int height = 0;
+ /* Origin of window. */
+ int x = 0;
+ int y = 0;
+
/* Window title to display. */
std::string title;
/* Is this window highlighted? */
bool is_highlighted = false;
+
+protected:
+
+ /* Scroll the contents vertically. This is only called via
+ forward_scroll and backward_scroll. */
+ virtual void do_scroll_vertical (int num_to_scroll) = 0;
+
+ /* Scroll the contents horizontally. This is only called via
+ left_scroll and right_scroll. */
+ virtual void do_scroll_horizontal (int num_to_scroll) = 0;
};
+/* Constant definitions. */
+#define SRC_NAME "src"
+#define CMD_NAME "cmd"
+#define DATA_NAME "regs"
+#define DISASSEM_NAME "asm"
+#define STATUS_NAME "status"
/* Global Data. */
extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
}
void
-tui_gen_win_info::resize (int height_, int width_,
- int origin_x_, int origin_y_)
+tui_win_info::resize (int height_, int width_,
+ int origin_x_, int origin_y_)
{
if (width == width_ && height == height_
&& x == origin_x_ && y == origin_y_
windows. */
template<enum tui_win_type V, class T>
-static tui_gen_win_info *
+static tui_win_info *
make_standard_window (const char *)
{
if (tui_win_list[V] == nullptr)
/* Helper function to wrap tui_locator_win_info_ptr for
tui_get_window_by_name. */
-static tui_gen_win_info *
+static tui_win_info *
get_locator_window (const char *)
{
return tui_locator_win_info_ptr ();
/* Helper function that returns a TUI window, given its name. */
-static tui_gen_win_info *
+static tui_win_info *
tui_get_window_by_name (const std::string &name)
{
for (tui_win_info *window : saved_tui_windows)
if (iter == known_window_types->end ())
error (_("Unknown window type \"%s\""), name.c_str ());
- tui_gen_win_info *result = iter->second (name.c_str ());
+ tui_win_info *result = iter->second (name.c_str ());
if (result == nullptr)
error (_("Could not create window \"%s\""), name.c_str ());
return result;
height = height_;
gdb_assert (m_window != nullptr);
m_window->resize (height, width, x, y);
- if (dynamic_cast<tui_win_info *> (m_window) != nullptr)
- tui_windows.push_back ((tui_win_info *) m_window);
+ tui_windows.push_back (m_window);
}
/* See tui-layout.h. */
/* When a layout is applied, this is updated to point to the window
object. */
- tui_gen_win_info *m_window = nullptr;
+ tui_win_info *m_window = nullptr;
};
/* A TUI layout that holds other layouts. */
/* The type of a function that is used to create a TUI window. */
-typedef std::function<tui_gen_win_info * (const char *name)> window_factory;
+typedef std::function<tui_win_info * (const char *name)> window_factory;
/* Register a new TUI window type. NAME is the name of the window
type. FACTORY is a function that can be called to instantiate the
/* See tui-data.h. */
int
-tui_gen_win_info::max_width () const
+tui_win_info::max_width () const
{
return tui_term_width () - 2;
}
/* See tui-data.h. */
void
-tui_gen_win_info::refresh_window ()
+tui_win_info::refresh_window ()
{
if (handle != NULL)
tui_wrefresh (handle.get ());
}
}
-
void
-tui_gen_win_info::make_window ()
+tui_win_info::make_window ()
{
handle.reset (newwin (height, width, y, x));
if (handle != NULL)
if (suppress_output)
wnoutrefresh (handle.get ());
scrollok (handle.get (), TRUE);
+ if (can_box ())
+ box_win (this, false);
}
}
-void
-tui_win_info::make_window ()
-{
- tui_gen_win_info::make_window ();
- if (handle != NULL && can_box ())
- box_win (this, false);
-}
-
/* We can't really make windows visible, or invisible. So we have to
delete the entire window when making it visible, and create it
again when making it visible. */
void
-tui_gen_win_info::make_visible (bool visible)
+tui_win_info::make_visible (bool visible)
{
if (is_visible () == visible)
return;