summaryrefslogtreecommitdiff
path: root/gdb/tui/tui-command.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-07-09 15:35:17 -0600
committerTom Tromey <tom@tromey.com>2019-08-15 12:29:28 -0600
commitdb502012fc46b4dd068461aaeafeaa421489c562 (patch)
tree90e36ac3f6252a2d262ba78ad04efe1d23eaa96e /gdb/tui/tui-command.c
parent3891b65efe614fe2e2f7e75e7f5ec8964f7fd96b (diff)
downloadbinutils-gdb-db502012fc46b4dd068461aaeafeaa421489c562.tar.gz
TUI window resize should not need invisibility
When resizing a window, the TUI currently first makes it invisible, then changes the size, and then restores its visibility. I think this is done because curses doesn't truly support resizing a window -- there is a "wresize" extension, but the man page says it isn't available in all versions of curses. First, this is probably not a major problem any more. I imagine most of those old systems are gone now. Second, I think it's a better API to have this detail hidden inside of the resize method. This patch changes the code to follow this idea, and changes the ordinary resize method to use wresize when it is available. The special case for the command window is also moved to methods on the command window. gdb/ChangeLog 2019-08-15 Tom Tromey <tom@tromey.com> * tui/tui-layout.c (show_layout, show_source_disasm_command) (show_data): Don't change window visibility. (tui_gen_win_info::resize): Remove special case for command window. Use wresize, when available. (show_source_or_disasm_and_command): Don't change window visibility. * tui/tui-command.h (struct tui_cmd_window) <resize>: Declare. <make_visible>: New method. * tui/tui-command.c (tui_cmd_window::resize): New method.
Diffstat (limited to 'gdb/tui/tui-command.c')
-rw-r--r--gdb/tui/tui-command.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index 034abd57982..ddbd8bccea5 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -25,6 +25,7 @@
#include "tui/tui-win.h"
#include "tui/tui-io.h"
#include "tui/tui-command.h"
+#include "tui/tui-wingeneral.h"
#include "gdb_curses.h"
@@ -48,6 +49,40 @@ tui_cmd_window::max_height () const
return tui_term_height () - 4;
}
+void
+tui_cmd_window::resize (int height_, int width_, int origin_x, int origin_y)
+{
+ width = width_;
+ height = height_;
+ if (height > 1)
+ {
+ /* Note this differs from the base class implementation, because
+ this window can't be boxed. */
+ viewport_height = height - 1;
+ }
+ else
+ viewport_height = 1;
+ origin.x = origin_x;
+ origin.y = origin_y;
+
+ if (handle == nullptr)
+ tui_make_window (this);
+ else
+ {
+ /* Another reason we don't call the base class method here is
+ that for the command window in particular, we want to avoid
+ destroying the underlying handle. We don't currently track
+ the contents of this window, and so have no way to re-render
+ it. However we can at least move it and keep the old size if
+ wresize isn't available. */
+#ifdef HAVE_WRESIZE
+ wresize (handle, height, width);
+#endif
+ mvwin (handle, origin.y, origin.x);
+ wmove (handle, 0, 0);
+ }
+}
+
/* See tui-command.h. */
void