From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5421 invoked by alias); 10 Oct 2014 21:56:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 5406 invoked by uid 89); 10 Oct 2014 21:56:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,DATE_IN_PAST_12_24,MISSING_MID,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail.openmailbox.org Received: from mail.openmailbox.org (HELO mail.openmailbox.org) (212.129.10.237) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 10 Oct 2014 21:56:06 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.openmailbox.org (Postfix) with ESMTP id D63272E0263 for ; Fri, 10 Oct 2014 23:56:02 +0200 (CEST) Received: from mail.openmailbox.org ([212.129.10.237]) by localhost (mail.openmailbox.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4dtX4ltDoOqr for ; Fri, 10 Oct 2014 23:56:01 +0200 (CEST) X-Mailbox-Line: From dec4bba85a4e33dcbc2aab97f506e58d05053814 Mon Sep 17 00:00:00 2001 From: CustaiCo To: Date: Fri, 10 Oct 2014 21:56:00 -0000 In-Relpy-To: Subject: [PATCH v2] [PR gdb/16762] Fixes for properly resizing TUI X-SW-Source: 2014-10/txt/msg00282.txt.bz2 Message-ID: <20141010215600.Tcmky0es6NaVUPuqUzOEfl4D0kGlfG2q46P5jEGbYck@z> 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