Remove path name from test case
[binutils-gdb.git] / gdb / tui / tui-layout.h
index 206f1117445af2e852e62cec1ae87d8b4be69087..a6d34851bef4a47e28977cc87d53fbddec15121b 100644 (file)
@@ -26,6 +26,9 @@
 
 #include "tui/tui.h"
 #include "tui/tui-data.h"
+#include "gdbsupport/iterator-range.h"
+
+#include <unordered_map>
 
 /* Values that can be returned when handling a request to adjust a
    window's size.  */
@@ -108,7 +111,8 @@ public:
      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.
+     window.  A vertical or horizontal layout of just one window does not add
+     a 'V' or 'H' character.
 
      Of course, layouts are built recursively, so, when called on a partial
      layout, if this object represents a single window, then either the
@@ -116,7 +120,7 @@ public:
      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'
+     window then we will get back a valid fingerprint string (may contain '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;
@@ -358,10 +362,56 @@ extern void tui_adjust_window_width (struct tui_win_info *win,
 
 typedef std::function<tui_win_info * (const char *name)> window_factory;
 
+/* The type for a data structure that maps a window name to that window's
+   factory function.  */
+typedef std::unordered_map<std::string, window_factory> window_types_map;
+
 /* 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
    window.  */
 
 extern void tui_register_window (const char *name, window_factory &&factory);
 
+/* An iterator class that exposes just the window names from the
+   known_window_types map in tui-layout.c.  This is just a wrapper around
+   an iterator of the underlying known_window_types map, but this just
+   exposes the window names.  */
+
+struct known_window_names_iterator
+{
+  using known_window_types_iterator = window_types_map::iterator;
+
+  known_window_names_iterator (known_window_types_iterator &&iter)
+    : m_iter (std::move (iter))
+  { /* Nothing.  */ }
+
+  known_window_names_iterator &operator++ ()
+  {
+    ++m_iter;
+    return *this;
+  }
+
+  const std::string &operator* () const
+  { return (*m_iter).first; }
+
+  bool operator!= (const known_window_names_iterator &other) const
+  { return m_iter != other.m_iter; }
+
+private:
+
+  /* The underlying iterator.  */
+  known_window_types_iterator m_iter;
+};
+
+/* A range adapter that makes it possible to iterate over the names of all
+   known tui windows.  */
+
+using known_window_names_range
+  = iterator_range<known_window_names_iterator>;
+
+/* Return a range that can be used to walk over the name of all known tui
+   windows in a range-for loop.  */
+
+extern known_window_names_range all_known_window_names ();
+
 #endif /* TUI_TUI_LAYOUT_H */