This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2] [PR gdb/16762] Fixes for properly resizing TUI
- From: CustaiCo <custaico at openmailbox dot org>
- To: <gdb-patches at sourceware dot org>
- Date: Thu, 9 Oct 2014 22:08:27 +0000
- Subject: [PATCH v2] [PR gdb/16762] Fixes for properly resizing TUI
- Authentication-results: sourceware.org; auth=none
- In-relpy-to: <a14c4f96f4ab462f28ce3a2fb84e2526>
A bit more work on this and I was able to get it so the prompt in
the command window came up without having to give it any inputs first.
The changes that were specific to readline 4.3 have also been removed.
It seems to have no regressions compared to git as it stood earlier today.
=== Patched == === git Fri Oct 10 17:52:57 2014 ==
# of expected passes 28631 | # of expected passes 28630
# of unexpected failures 94 | # of unexpected failures 95
# of unexpected successes 1 # of unexpected successes 1
# of expected failures 58 # of expected failures 58
# of known failures 55 # of known failures 55
# of unresolved testcases 12 # of unresolved testcases 12
# of untested testcases 46 # of untested testcases 46
# of unsupported tests 184 # of unsupported tests 184
Pictures show the difference better than automated tests.
Fills space
* http://www.hostpic.org/images/1410110259430109.jpg
Resizes without errors
* http://www.hostpic.org/images/1410110259430119.png
Non-curses side is also aware of the changes
* http://www.hostpic.org/images/1410110303260126.jpg
* http://www.hostpic.org/images/1410110303260103.png
Compared to
http://www.hostpic.org/images/1410110259430112.png
or
http://www.hostpic.org/images/1410110259430114.png
CustaiCo
gdb/Changelog
2014-10-10
PR gdb/16762
* gdb/tui/tui-win.c (tui_sigwinch_handler): adds callback to
(tui_handle_resize): which will handle the resize event
* gdb/tui/tui-data.c (tui_win_resized): not needed, removed
(tui_set_win_resized_to): not needed, removed
* gdb/tui/tui-io.c (tui_getc): no need for check if resized
(tui_handle_resize_during_io): not needed
* gdb/utils.c (set_screen_size): Prevent using wrong size
---
gdb/tui/tui-data.c | 16 ----------------
gdb/tui/tui-io.c | 21 ---------------------
gdb/tui/tui-win.c | 40 +++++++++++++++++++++++++++++++++++-----
gdb/utils.c | 7 +++++--
4 files changed, 40 insertions(+), 44 deletions(-)
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 7e51b3e..06ea29b 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -98,22 +98,6 @@ tui_set_win_highlight (struct tui_win_info *win_info,
** ACCESSORS & MUTATORS FOR PRIVATE DATA
******************************************/
-/* Answer a whether the terminal window has been resized or not. */
-int
-tui_win_resized (void)
-{
- return win_resized;
-}
-
-
-/* Set a whether the terminal window has been resized or not. */
-void
-tui_set_win_resized_to (int resized)
-{
- win_resized = resized;
-}
-
-
/* Answer a pointer to the current layout definition. */
struct tui_layout_def *
tui_layout_def (void)
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 601d278..4c7fca8 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -146,8 +146,6 @@ static int tui_readline_pipe[2];
This may be the main gdb prompt or a secondary prompt. */
static char *tui_rl_saved_prompt;
-static unsigned int tui_handle_resize_during_io (unsigned int);
-
static void
tui_putc (char c)
{
@@ -653,7 +651,6 @@ tui_getc (FILE *fp)
#endif
ch = wgetch (w);
- ch = tui_handle_resize_during_io (ch);
/* The \n must be echoed because it will not be printed by
readline. */
@@ -694,21 +691,3 @@ tui_getc (FILE *fp)
return ch;
}
-
-
-/* Cleanup when a resize has occured.
- Returns the character that must be processed. */
-static unsigned int
-tui_handle_resize_during_io (unsigned int original_ch)
-{
- if (tui_win_resized ())
- {
- tui_resize_all ();
- tui_refresh_all_win ();
- dont_repeat ();
- tui_set_win_resized_to (FALSE);
- return '\n';
- }
- else
- return original_ch;
-}
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 9c7a23f..095097a 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -29,6 +29,7 @@
#include "symtab.h"
#include "breakpoint.h"
#include "frame.h"
+#include "event-loop.h"
#include "cli/cli-cmds.h"
#include "top.h"
#include "source.h"
@@ -72,7 +73,7 @@ static void tui_scroll_right_command (char *, int);
static void parse_scrolling_args (char *,
struct tui_win_info **,
int *);
-
+static void tui_handle_resize (void *);
/***************************************
** DEFINITIONS
@@ -457,6 +458,31 @@ bold-standout use extra bright or bold with standout mode"),
&tui_setlist, &tui_showlist);
}
+/* This is called from the main event loop after we catch SIGWINCH */
+void
+tui_handle_resize (void *signal)
+{
+ char cmd[50];
+ int col, row;
+ if (tui_active)
+ {
+ tui_resize_all ();
+ tui_refresh_all_win ();
+ xsnprintf (cmd, sizeof (cmd), "set width %d", TUI_CMD_WIN->generic.width);
+ execute_command (cmd, 0);
+ xsnprintf (cmd, sizeof (cmd), "set height %d", TUI_CMD_WIN->generic.height);
+ execute_command (cmd, 0);
+ }
+ else
+ {
+ rl_get_screen_size (&row, &col);
+ xsnprintf (cmd, sizeof (cmd), "set width %d", col);
+ execute_command (cmd, 0);
+ xsnprintf (cmd, sizeof (cmd), "set height %d", row);
+ execute_command (cmd, 0);
+ }
+}
+
/* Update gdb's knowledge of the terminal size. */
void
tui_update_gdb_sizes (void)
@@ -670,7 +696,7 @@ tui_resize_all (void)
#ifdef HAVE_RESIZE_TERM
resize_term (screenheight, screenwidth);
-#endif
+#endif
/* Turn keypad off while we resize. */
if (win_with_focus != TUI_CMD_WIN)
keypad (TUI_CMD_WIN->generic.handle, FALSE);
@@ -818,9 +844,13 @@ tui_resize_all (void)
static void
tui_sigwinch_handler (int signal)
{
- /* Say that a resize was done so that the readline can do it later
- when appropriate. */
- tui_set_win_resized_to (TRUE);
+ /* Say that a resize was done so that the we can update
+ the UI when appropriate. */
+ struct tui_translate data;
+ data.value = signal;
+ rl_cleanup_after_signal ();
+ rl_resize_terminal ();
+ mark_async_signal_handler (create_async_signal_handler (tui_handle_resize, &data));
}
#endif
diff --git a/gdb/utils.c b/gdb/utils.c
index 3915b58..ae0342a 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1775,8 +1777,9 @@ set_screen_size (void)
if (cols <= 0)
cols = INT_MAX;
- /* Update Readline's idea of the terminal size. */
- rl_set_screen_size (rows, cols);
+ /* Don't update with tui active or it will be too large */
+ if (!tui_active)
+ rl_set_screen_size (rows, cols);
}
/* Reinitialize WRAP_BUFFER according to the current value of
--
2.1.2