From patchwork Wed Aug 14 16:21:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34101 Received: (qmail 72342 invoked by alias); 14 Aug 2019 16:21:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 72231 invoked by uid 89); 14 Aug 2019 16:21:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, LIKELY_SPAM_SUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=truly X-HELO: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.45.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Aug 2019 16:21:42 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway21.websitewelcome.com (Postfix) with ESMTP id D3856400D1FE1 for ; Wed, 14 Aug 2019 11:21:40 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id xw1shyKLI4FKpxw1sh581b; Wed, 14 Aug 2019 11:21:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=rfsaz7IiFsAiEgKAvqCHNuDaVUwhhl9PZgC0h/sUysU=; b=yFYSYn9s/hr3b1Xaqn+1Wu1bKG fLBo1nyLyTtmjKS1tG7ol2hKD/KRIEyZm7JZEzA3obD7cubPUb+1GDGZMtdz3I4lzAyRPEbKccOXv IsRTw2RDGi6Bv0GfYiG+/OsQU; Received: from 97-122-178-82.hlrn.qwest.net ([97.122.178.82]:38600 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hxw1s-002Cwq-FO; Wed, 14 Aug 2019 11:21:40 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 15/15] TUI window resize should not need invisibility Date: Wed, 14 Aug 2019 10:21:32 -0600 Message-Id: <20190814162132.31424-16-tom@tromey.com> In-Reply-To: <20190814162132.31424-1-tom@tromey.com> References: <20190814162132.31424-1-tom@tromey.com> 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. 2019-08-14 Tom Tromey * 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) : Declare. : New method. * tui/tui-command.c (tui_cmd_window::resize): New method. --- gdb/ChangeLog | 12 ++++++++++++ gdb/tui/tui-command.c | 35 ++++++++++++++++++++++++++++++++++ gdb/tui/tui-command.h | 7 +++++++ gdb/tui/tui-layout.c | 44 +++++++++++++++++++++---------------------- 4 files changed, 75 insertions(+), 23 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 diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h index 1892956fe77..1fce0a18126 100644 --- a/gdb/tui/tui-command.h +++ b/gdb/tui/tui-command.h @@ -56,6 +56,13 @@ struct tui_cmd_window : public tui_win_info return false; } + void resize (int height, int width, int origin_x, int origin_y) override; + + void make_visible (bool visible) override + { + /* The command window can't be made invisible. */ + } + int start_line = 0; protected: diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 4ea604a1017..e0e804bac2a 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -76,9 +76,7 @@ show_layout (enum tui_layout_type layout) if (layout != cur_layout) { - /* First make the current layout be invisible. */ tui_make_all_invisible (); - tui_locator_win_info_ptr ()->make_visible (false); switch (layout) { case SRC_DATA_COMMAND: @@ -506,7 +504,6 @@ show_source_disasm_command (void) tui_term_width (), 0, 0); - TUI_SRC_WIN->make_visible (true); TUI_SRC_WIN->m_has_locator = false; struct tui_locator_window *locator = tui_locator_win_info_ptr (); @@ -519,14 +516,12 @@ show_source_disasm_command (void) tui_term_width (), 0, src_height - 1); - TUI_DISASM_WIN->make_visible (true); locator->resize (2 /* 1 */ , tui_term_width (), 0, (src_height + asm_height) - 1); TUI_SRC_WIN->m_has_locator = false; TUI_DISASM_WIN->m_has_locator = true; - locator->make_visible (true); tui_show_locator_content (); TUI_DISASM_WIN->show_source_content (); @@ -536,7 +531,6 @@ show_source_disasm_command (void) tui_term_width (), 0, tui_term_height () - cmd_height); - TUI_CMD_WIN->make_visible (true); current_layout = SRC_DISASSEM_COMMAND; } @@ -558,7 +552,6 @@ show_data (enum tui_layout_type new_layout) if (tui_win_list[DATA_WIN] == nullptr) tui_win_list[DATA_WIN] = new tui_data_window (); tui_win_list[DATA_WIN]->resize (data_height, tui_term_width (), 0, 0); - tui_win_list[DATA_WIN]->make_visible (true); if (new_layout == SRC_DATA_COMMAND) win_type = SRC_WIN; @@ -583,11 +576,11 @@ show_data (enum tui_layout_type new_layout) tui_term_width (), 0, total_height - 1); - base->make_visible (true); + TUI_CMD_WIN->resize (TUI_CMD_WIN->height, tui_term_width (), + 0, total_height); + base->m_has_locator = true; - locator->make_visible (true); tui_show_locator_content (); - TUI_CMD_WIN->make_visible (true); current_layout = new_layout; } @@ -595,20 +588,29 @@ void tui_gen_win_info::resize (int height_, int width_, int origin_x_, int origin_y_) { - int h = height_; - width = width_; - height = h; - if (h > 1) - { - viewport_height = h - 1; - if (type != CMD_WIN) - viewport_height--; - } + height = height_; + if (height > 1) + viewport_height = height - 2; else viewport_height = 1; origin.x = origin_x_; origin.y = origin_y_; + + if (handle != nullptr) + { +#ifdef HAVE_WRESIZE + wresize (handle, height, width); + mvwin (handle, origin.y, origin.x); + wmove (handle, 0, 0); +#else + tui_delete_win (handle); + handle = NULL; +#endif + } + + if (handle == nullptr) + tui_make_window (this); } /* Show the Source/Command or the Disassem layout. */ @@ -647,11 +649,8 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type) tui_term_width (), 0, 0); - win_info->make_visible (true); - win_info->m_has_locator = true; - locator->make_visible (true); tui_show_locator_content (); win_info->show_source_content (); @@ -661,6 +660,5 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type) tui_term_width (), 0, src_height); - TUI_CMD_WIN->make_visible (true); current_layout = layout_type; }