From patchwork Wed Oct 2 23:11:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34808 Received: (qmail 52090 invoked by alias); 2 Oct 2019 23:22:22 -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 51997 invoked by uid 89); 2 Oct 2019 23:22:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 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=viewport, Answer X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.143.40) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Oct 2019 23:22:21 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 19FDBCE603F for ; Wed, 2 Oct 2019 18:12:06 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id FnmwiTeSaW4frFnmwi9yXo; Wed, 02 Oct 2019 18:12:06 -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=msjr/8N3qnsin47lV5V8R/xbFuGUI8ylNHQYfPT0IwU=; b=OYuQO60WEKKArT4aeI40zZ4/iI CG6UbyT9l3rEazXYQEbIbrG7zWlSQuBklsH6yeA1Mdbgx3jQxDtotrRNWkPNMsqbZaWmPwzZFHfKA kJnnMBUtnb1cd9Q0rmSz0mgBM; Received: from 75-166-72-156.hlrn.qwest.net ([75.166.72.156]:42570 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iFnmv-003VLt-Ry; Wed, 02 Oct 2019 17:12:05 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/6] Remove tui_default_win_viewport_height Date: Wed, 2 Oct 2019 17:11:58 -0600 Message-Id: <20191002231202.10940-3-tom@tromey.com> In-Reply-To: <20191002231202.10940-1-tom@tromey.com> References: <20191002231202.10940-1-tom@tromey.com> tui_default_win_viewport_height was only called from a single spot, for a single type of window. This patch removes the function and moves the logic into the sole caller. gdb/ChangeLog 2019-10-02 Tom Tromey * tui/tui-disasm.c (tui_get_low_disassembly_address): Compute window height directly. * tui/tui-layout.h (tui_default_win_viewport_height): Don't declare. * tui/tui-layout.c (tui_default_win_height): Remove. (tui_default_win_viewport_height): Remove. --- gdb/ChangeLog | 9 +++++++ gdb/tui/tui-disasm.c | 10 +++++++- gdb/tui/tui-layout.c | 60 -------------------------------------------- gdb/tui/tui-layout.h | 2 -- 4 files changed, 18 insertions(+), 63 deletions(-) diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 51616bcf874..33a3ba12d47 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -28,6 +28,7 @@ #include "source.h" #include "disasm.h" #include "tui/tui.h" +#include "tui/tui-command.h" #include "tui/tui-data.h" #include "tui/tui-win.h" #include "tui/tui-layout.h" @@ -325,7 +326,14 @@ tui_get_low_disassembly_address (struct gdbarch *gdbarch, /* Determine where to start the disassembly so that the pc is about in the middle of the viewport. */ - pos = tui_default_win_viewport_height (DISASSEM_WIN, DISASSEM_COMMAND) / 2; + if (tui_win_list[DISASSEM_WIN] != NULL) + pos = tui_win_list[DISASSEM_WIN]->height; + else if (TUI_CMD_WIN == NULL) + pos = tui_term_height () / 2 - 2; + else + pos = tui_term_height () - TUI_CMD_WIN->height - 2; + pos = (pos - 2) / 2; + pc = tui_find_disassembly_address (gdbarch, pc, -pos); if (pc < low) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 7aa670ec69d..ccc750e1db4 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -233,66 +233,6 @@ tui_add_win_to_layout (enum tui_win_type type) } } - -/* Answer the height of a window. If it hasn't been created yet, - answer what the height of a window would be based upon its type and - the layout. */ -static int -tui_default_win_height (enum tui_win_type type, - enum tui_layout_type layout) -{ - int h; - - if (tui_win_list[type] != NULL) - h = tui_win_list[type]->height; - else - { - switch (layout) - { - case SRC_COMMAND: - case DISASSEM_COMMAND: - if (TUI_CMD_WIN == NULL) - h = tui_term_height () / 2; - else - h = tui_term_height () - TUI_CMD_WIN->height; - break; - case SRC_DISASSEM_COMMAND: - case SRC_DATA_COMMAND: - case DISASSEM_DATA_COMMAND: - if (TUI_CMD_WIN == NULL) - h = tui_term_height () / 3; - else - h = (tui_term_height () - TUI_CMD_WIN->height) / 2; - break; - default: - h = 0; - break; - } - } - - return h; -} - - -/* Answer the height of a window. If it hasn't been created yet, - answer what the height of a window would be based upon its type and - the layout. */ -int -tui_default_win_viewport_height (enum tui_win_type type, - enum tui_layout_type layout) -{ - int h; - - h = tui_default_win_height (type, layout); - - if (type == CMD_WIN) - h -= 1; - else - h -= 2; - - return h; -} - /* Complete possible layout names. TEXT is the complete text entered so far, WORD is the word currently being completed. */ diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h index a7e1e908983..23f05f34aa2 100644 --- a/gdb/tui/tui-layout.h +++ b/gdb/tui/tui-layout.h @@ -26,8 +26,6 @@ #include "tui/tui-data.h" extern void tui_add_win_to_layout (enum tui_win_type); -extern int tui_default_win_viewport_height (enum tui_win_type, - enum tui_layout_type); extern void tui_set_layout (enum tui_layout_type); #endif /* TUI_TUI_LAYOUT_H */