From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 10/24] Change return type of tui_layout_base::adjust_size
Date: Sat, 04 Jan 2020 18:34:00 -0000 [thread overview]
Message-ID: <20200104183410.17114-11-tom@tromey.com> (raw)
In-Reply-To: <20200104183410.17114-1-tom@tromey.com>
This changes tui_layout_base::adjust_size to return a new enum type.
I broke this out into a separate patch because it simplifies a
subsequent patch.
gdb/ChangeLog
2020-01-04 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.
Change-Id: I821b48ab06a9b9485875e147bd08a3bc46b900a0
---
gdb/ChangeLog | 9 +++++++++
gdb/tui/tui-layout.c | 17 +++++++++--------
gdb/tui/tui-layout.h | 20 ++++++++++++++++----
3 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 3604d7e06bc..be6c754d022 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -487,7 +487,7 @@ tui_layout_split::set_weights_from_heights ()
/* 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
@@ -496,10 +496,11 @@ tui_layout_split::adjust_size (const char *name, int new_height)
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;
@@ -507,9 +508,9 @@ tui_layout_split::adjust_size (const char *name, int new_height)
}
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;
@@ -557,7 +558,7 @@ tui_layout_split::adjust_size (const char *name, int new_height)
apply (x, y, width, height);
}
- return true;
+ return HANDLED;
}
/* See tui-layout.h. */
diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h
index 4351e260720..969e4dfd231 100644
--- a/gdb/tui/tui-layout.h
+++ b/gdb/tui/tui-layout.h
@@ -27,6 +27,18 @@
#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. */
@@ -64,7 +76,7 @@ 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. */
@@ -111,9 +123,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;
@@ -165,7 +177,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;
--
2.17.2
next prev parent reply other threads:[~2020-01-04 18:34 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-04 18:34 [PATCH 00/24] Horizontal TUI layout + windows in Python Tom Tromey
2020-01-04 18:34 ` [PATCH 11/24] Add horizontal splitting to TUI layout Tom Tromey
2020-01-04 18:47 ` Eli Zaretskii
2020-01-04 18:34 ` [PATCH 06/24] Reimplement "tui reg" command Tom Tromey
2020-01-04 18:34 ` [PATCH 04/24] Simplify TUI C-x 2 binding Tom Tromey
2020-01-04 18:34 ` Tom Tromey [this message]
2020-01-04 18:34 ` [PATCH 20/24] Allow TUI windows in Python Tom Tromey
2020-01-04 18:57 ` Eli Zaretskii
2020-02-22 19:57 ` Tom Tromey
2020-02-22 20:18 ` Eli Zaretskii
2020-03-10 22:23 ` Simon Marchi
2020-03-11 0:23 ` Tom Tromey
2020-03-11 4:47 ` Simon Marchi
2020-03-11 5:07 ` Simon Marchi
2020-03-11 18:05 ` Tom Tromey
2020-01-04 18:34 ` [PATCH 07/24] Remove hard-coded TUI layouts Tom Tromey
2020-01-04 18:34 ` [PATCH 01/24] Use TUI_DISASM_WIN instead of tui_win_list array Tom Tromey
2020-01-04 18:34 ` [PATCH 21/24] Make some tui_source_window_base members "protected" Tom Tromey
2020-01-04 18:34 ` [PATCH 09/24] Allow TUI sub-layouts in "new-layout" command Tom Tromey
2020-01-04 18:34 ` [PATCH 02/24] Simplify tui_add_win_to_layout Tom Tromey
2020-01-04 18:34 ` [PATCH 12/24] Change TUI window iteration Tom Tromey
2020-01-04 18:34 ` [PATCH 15/24] Remove tui_delete_invisible_windows and tui_make_all_invisible Tom Tromey
2020-01-04 18:34 ` [PATCH 19/24] Remove the TUI annotation hack Tom Tromey
2020-01-04 18:34 ` [PATCH 14/24] Handle ambiguity in tui_partial_win_by_name Tom Tromey
2020-01-04 18:34 ` [PATCH 23/24] Add "usage" text to all TUI command help Tom Tromey
2020-01-04 18:34 ` [PATCH 16/24] TUI windows do not need to store their type Tom Tromey
2020-01-04 18:34 ` [PATCH 03/24] Fix latent display bug in tui_data_window Tom Tromey
2020-01-04 18:34 ` [PATCH 05/24] Reimplement TUI "C-x 1" binding Tom Tromey
2020-01-04 18:34 ` [PATCH 13/24] Reimplement tui_next_win and tui_prev_win Tom Tromey
2020-01-04 18:34 ` [PATCH 24/24] Fix cast in TUI_DISASM_WIN Tom Tromey
2020-01-04 18:34 ` [PATCH 18/24] Remove tui_set_win_focus_to Tom Tromey
2020-01-04 18:34 ` [PATCH 08/24] Add the "tui new-layout" command Tom Tromey
2020-01-04 18:44 ` Eli Zaretskii
2020-01-04 18:34 ` [PATCH 22/24] Use error_no_arg in TUI Tom Tromey
2020-01-04 18:54 ` [PATCH 17/24] Change how TUI windows are instantiated Tom Tromey
2020-02-22 20:22 ` [PATCH 00/24] Horizontal TUI layout + windows in Python Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200104183410.17114-11-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox