From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15732 invoked by alias); 19 Jul 2010 21:20:48 -0000 Received: (qmail 15723 invoked by uid 22791); 19 Jul 2010 21:20:47 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM X-Spam-Check-By: sourceware.org Received: from mail-bw0-f41.google.com (HELO mail-bw0-f41.google.com) (209.85.214.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Jul 2010 21:20:41 +0000 Received: by bwz9 with SMTP id 9so3227274bwz.0 for ; Mon, 19 Jul 2010 14:20:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.76.205 with SMTP id d13mr4392099bkk.93.1279574438483; Mon, 19 Jul 2010 14:20:38 -0700 (PDT) Received: by 10.204.119.2 with HTTP; Mon, 19 Jul 2010 14:20:38 -0700 (PDT) Date: Mon, 19 Jul 2010 21:20:00 -0000 Message-ID: Subject: [patch] Slightly better resize support in TUI mode From: Balazs Kezes To: gdb-patches Content-Type: text/plain; charset=ISO-8859-1 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 X-SW-Source: 2010-07/txt/msg00292.txt.bz2 Hi, Resizing doesn't work when in TUI mode (at least on my computer). I now present a patch which adds a minimal support to it, although there are lots of issues with it which won't be handled yet. This makes sure that TUI users can make their terminal a line bigger or smaller without messing up the whole screen. First of all we need to make sure that readline works with correct screen sizes. When readline is not echoing it doesn't update its internal variables about the screen size. This is an issue because TUI uses curses functions to echo a character back so readline is in noecho mode. Here's the patch for that: Changelog 2010-07-19 Balazs Kezes (rlblaster@gmail.com) * terminal.c (rl_resize_terminal): Make sure terminal size is updated even when readline is not echoing. Index: terminal.c =================================================================== RCS file: /cvs/src/src/readline/terminal.c,v retrieving revision 1.11 diff -c -p -r1.11 terminal.c *** terminal.c 13 Nov 2006 09:33:30 -0000 1.11 --- terminal.c 19 Jul 2010 20:11:05 -0000 *************** rl_reset_screen_size () *** 347,355 **** void rl_resize_terminal () { if (readline_echoing_p) { - _rl_get_screen_size (fileno (rl_instream), 1); if (CUSTOM_REDISPLAY_FUNC ()) rl_forced_update_display (); else --- 347,355 ---- void rl_resize_terminal () { + _rl_get_screen_size (fileno (rl_instream), 1); if (readline_echoing_p) { if (CUSTOM_REDISPLAY_FUNC ()) rl_forced_update_display (); else This is important to make sure readline works even after a resize in TUI mode when switched back to normal mode. The other issue is that in TUI's SIGWINCH handler the resize code is not called at all. In the resize code you need to call resize_term which is ncurses function in order to update its internal structures. This was placed into a #ifdef HAVE_RESIZE_TERM but I have not found any references to that macro so I removed the it. Also it seems to me that wresize is not called for the command window so I added a call to it too. Cheers, Balazs 2010-07-19 Balazs Kezes (rlblaster@gmail.com) * tui/tui-win.c (tui_resize_all): Make sure resize_term is called and resize the command window after the dimensions are set. (tui_sigwinch_handler): Call resize in the SIGWINCH handler but only when in TUI mode. Index: tui-win.c =================================================================== RCS file: /cvs/src/src/gdb/tui/tui-win.c,v retrieving revision 1.47 diff -c -p -r1.47 tui-win.c *** tui-win.c 17 May 2010 22:21:43 -0000 1.47 --- tui-win.c 19 Jul 2010 20:13:08 -0000 *************** tui_resize_all (void) *** 669,677 **** enum tui_win_type win_type; int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2; - #ifdef HAVE_RESIZE_TERM resize_term (screenheight, screenwidth); ! #endif /* Turn keypad off while we resize. */ if (win_with_focus != TUI_CMD_WIN) keypad (TUI_CMD_WIN->generic.handle, FALSE); --- 669,676 ---- enum tui_win_type win_type; int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2; resize_term (screenheight, screenwidth); ! /* Turn keypad off while we resize. */ if (win_with_focus != TUI_CMD_WIN) keypad (TUI_CMD_WIN->generic.handle, FALSE); *************** tui_resize_all (void) *** 804,809 **** --- 803,812 ---- window. */ if (win_with_focus != TUI_CMD_WIN) keypad (TUI_CMD_WIN->generic.handle, TRUE); + + wresize(TUI_CMD_WIN->generic.handle, + TUI_CMD_WIN->generic.height, + TUI_CMD_WIN->generic.width); } } *************** tui_sigwinch_handler (int signal) *** 817,822 **** --- 820,831 ---- /* Say that a resize was done so that the readline can do it later when appropriate. */ tui_set_win_resized_to (TRUE); + + if (tui_active) + { + tui_resize_all (); + tui_refresh_all_win (); + } } #endif