Add horizontal splitting to TUI layout
[deliverable/binutils-gdb.git] / gdb / tui / tui-layout.h
index 05089ab8fffc7551e11c8c90840d62a817932a84..6607e8d40d8c2f8dd6ea328f8ad5243db5ea1f41 100644 (file)
 #ifndef TUI_TUI_LAYOUT_H
 #define TUI_TUI_LAYOUT_H
 
+#include "ui-file.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.  */
@@ -44,8 +58,9 @@ public:
   /* Change the size and location of this layout.  */
   virtual void apply (int x, int y, int width, int height) = 0;
 
-  /* Return the minimum and maximum height of this layout.  */
-  virtual void get_sizes (int *min_height, int *max_height) = 0;
+  /* Return the minimum and maximum height or width of this layout.
+     HEIGHT is true to fetch height, false to fetch width.  */
+  virtual void get_sizes (bool height, int *min_value, int *max_value) = 0;
 
   /* True if the topmost item in this layout is boxed.  */
   virtual bool top_boxed_p () const = 0;
@@ -62,12 +77,20 @@ public:
 
   /* 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.  */
   virtual void remove_windows (const char *name) = 0;
 
+  /* Replace the window named NAME in the layout with the window named
+     NEW_WINDOW.  */
+  virtual void replace_window (const char *name, const char *new_window) = 0;
+
+  /* Append the specification to this window to OUTPUT.  DEPTH is the
+     depth of this layout in the hierarchy (zero-based).  */
+  virtual void specification (ui_file *output, int depth) = 0;
+
   /* The most recent space allocation.  */
   int x = 0;
   int y = 0;
@@ -101,9 +124,9 @@ public:
     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;
@@ -114,9 +137,13 @@ public:
   {
   }
 
+  void replace_window (const char *name, const char *new_window) override;
+
+  void specification (ui_file *output, int depth) override;
+
 protected:
 
-  void get_sizes (int *min_height, int *max_height) override;
+  void get_sizes (bool height, int *min_value, int *max_value) override;
 
 private:
 
@@ -133,14 +160,19 @@ class tui_layout_split : public tui_layout_base
 {
 public:
 
-  tui_layout_split () = default;
+  /* Create a new layout.  If VERTICAL is true, then windows in this
+     layout will be arranged vertically.  */
+  explicit tui_layout_split (bool vertical = true)
+    : m_vertical (vertical)
+  {
+  }
 
   DISABLE_COPY_AND_ASSIGN (tui_layout_split);
 
   /* Add a new split layout to this layout.  WEIGHT is the desired
      size, which is relative to the other weights given in this
      layout.  */
-  tui_layout_split *add_split (int weight);
+  void add_split (std::unique_ptr<tui_layout_split> &&layout, int weight);
 
   /* Add a new window to this layout.  NAME is the name of the window
      to add.  WEIGHT is the desired size, which is relative to the
@@ -151,7 +183,7 @@ public:
 
   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;
 
@@ -159,9 +191,13 @@ public:
 
   void remove_windows (const char *name) override;
 
+  void replace_window (const char *name, const char *new_window) override;
+
+  void specification (ui_file *output, int depth) override;
+
 protected:
 
-  void get_sizes (int *min_height, int *max_height) override;
+  void get_sizes (bool height, int *min_value, int *max_value) override;
 
 private:
 
@@ -179,6 +215,9 @@ private:
   /* The splits.  */
   std::vector<split> m_splits;
 
+  /* 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;
 };
@@ -189,7 +228,8 @@ private:
    way.  */
 extern void tui_add_win_to_layout (enum tui_win_type);
 
-extern void tui_set_layout (enum tui_layout_type);
+/* Set the initial layout.  */
+extern void tui_set_initial_layout ();
 
 /* Switch to the next layout.  */
 extern void tui_next_layout ();
This page took 0.027405 seconds and 4 git commands to generate.