From patchwork Thu Jul 4 17:02:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33580 Received: (qmail 111223 invoked by alias); 4 Jul 2019 17:04:05 -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 107109 invoked by uid 89); 4 Jul 2019 17:03:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=H*RU:esmtpa, H*r:esmtpa X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.46.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 17:03:31 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway22.websitewelcome.com (Postfix) with ESMTP id BCB8D228E3 for ; Thu, 4 Jul 2019 12:03:29 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58rhGinf2qH7j58rhNqDt; Thu, 04 Jul 2019 12:03:29 -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=BFxH4eWRxSdkgyD2/mNT3ZVVcVXccISfnxvqm+mIoxk=; b=vxH3K5X1aJNNoiS1XMK4IrYa5N R/qxPf1tg3KvouBUoW66P6a8sm24C/olkWjQ+arpINodtX3lDcZH/NwU7bqJeBpwtcYTvcnljFvu8 R8E1Z3SiXGKJH2fv1nmVO1920; Received: from 174-29-58-150.hlrn.qwest.net ([174.29.58.150]:34702 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1hj58r-002sKm-G8; Thu, 04 Jul 2019 12:03:29 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 42/61] Simplify show_source_disasm_command Date: Thu, 4 Jul 2019 11:02:52 -0600 Message-Id: <20190704170311.15982-43-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> This is the first of a few patches to further simplify window (re-)initialization in tui-layout.c. When changing the layout, a window may be created or, if it already exists, simply resized. These two cases normally are identical, but this was obscured by the way the code was written. This patch changes show_source_disasm_command to unify the creation and re-initialization cases. 2019-07-04 Tom Tromey * tui/tui-layout.c (show_source_disasm_command): Simplify window resetting. --- gdb/ChangeLog | 5 +++++ gdb/tui/tui-layout.c | 48 ++++++++++++++++---------------------------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 0ed7b29ce4b..4e914b79ea0 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -559,43 +559,29 @@ show_source_disasm_command (void) asm_height = tui_term_height () - (src_height + cmd_height); if (TUI_SRC_WIN == NULL) - tui_win_list[SRC_WIN] = make_source_window (src_height, 0); - else - { - TUI_SRC_WIN->reset (src_height, - tui_term_width (), - 0, - 0); - tui_make_visible (TUI_SRC_WIN); - TUI_SRC_WIN->m_has_locator = false; - } + tui_win_list[SRC_WIN] = new tui_source_window (); + TUI_SRC_WIN->reset (src_height, + tui_term_width (), + 0, + 0); + tui_make_visible (TUI_SRC_WIN); + TUI_SRC_WIN->m_has_locator = false; struct tui_locator_window *locator = tui_locator_win_info_ptr (); gdb_assert (locator != nullptr); tui_show_source_content (TUI_SRC_WIN); if (TUI_DISASM_WIN == NULL) - { - tui_win_list[DISASSEM_WIN] - = make_disasm_window (asm_height, src_height - 1); - locator->reset (2 /* 1 */ , - tui_term_width (), - 0, - (src_height + asm_height) - 1); - } - else - { - locator->reset (2 /* 1 */ , - tui_term_width (), - 0, - (src_height + asm_height) - 1); - TUI_DISASM_WIN->m_has_locator = true; - TUI_DISASM_WIN->reset (asm_height, - tui_term_width (), - 0, - src_height - 1); - tui_make_visible (TUI_DISASM_WIN); - } + tui_win_list[DISASSEM_WIN] = new tui_disasm_window (); + TUI_DISASM_WIN->reset (asm_height, + tui_term_width (), + 0, + src_height - 1); + tui_make_visible (TUI_DISASM_WIN); + locator->reset (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; tui_make_visible (locator);