From patchwork Sun Jun 23 22:42:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33306 Received: (qmail 50940 invoked by alias); 23 Jun 2019 22:44:08 -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 49090 invoked by uid 89); 23 Jun 2019 22:43:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 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=4298 X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.149.105) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Jun 2019 22:43:46 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway34.websitewelcome.com (Postfix) with ESMTP id 870152ABAA for ; Sun, 23 Jun 2019 17:43:45 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id fBD7hdbxB90onfBD7hbzWj; Sun, 23 Jun 2019 17:43:45 -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=Q3RwaBYhH5rR8kCYr7v2QuR4/MJfm+RQbB2cfExH6ck=; b=VPQgr1NUKg9+Yd1pZ/ZibdbYKY 6Ks8ZzWjAkXbN2DWfnA72AaNyjUpZtQQ3JQPQR5UcWNP4cVCEi+rkWS9duRDGWAmHftJtJ3QtVfmM yYXm+Ygx0g+9tYOwLxBeBsbnk; Received: from 75-166-12-78.hlrn.qwest.net ([75.166.12.78]:54396 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hfBD7-000vDQ-Az; Sun, 23 Jun 2019 17:43:45 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 27/66] Introduce max_height method Date: Sun, 23 Jun 2019 16:42:50 -0600 Message-Id: <20190623224329.16060-28-tom@tromey.com> In-Reply-To: <20190623224329.16060-1-tom@tromey.com> References: <20190623224329.16060-1-tom@tromey.com> This introduces the tui_win_info::max_height method and changes new_height_ok to use it, rather than checking the window type directly. gdb/ChangeLog 2019-06-23 Tom Tromey * tui/tui-win.c (tui_win_info::max_height) (tui_cmd_window::max_height): New methods. (new_height_ok): Call max_height. * tui/tui-data.h (struct tui_win_info, struct tui_cmd_window) : New method. --- gdb/ChangeLog | 8 ++++++++ gdb/tui/tui-data.h | 5 +++++ gdb/tui/tui-win.c | 24 ++++++++++++++++++------ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index e0d94d645be..bed28f64b19 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -273,6 +273,9 @@ public: { } + /* Compute the maximum height of this window. */ + virtual int max_height () const; + /* Methods to scroll the contents of this window. Note that they are named with "_scroll" coming at the end because the more obvious "scroll_forward" is defined as a macro in term.h. */ @@ -426,6 +429,8 @@ struct tui_cmd_window : public tui_win_info { } + int max_height () const override; + int start_line = 0; protected: diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index fe1e901c741..dc40ab7736d 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -1377,6 +1377,22 @@ make_visible_with_new_height (struct tui_win_info *win_info) } +/* See tui-data.h. */ + +int +tui_win_info::max_height () const +{ + return tui_term_height () - 2; +} + +/* See tui-data.h. */ + +int +tui_cmd_window::max_height () const +{ + return tui_term_height () - 4; +} + static int new_height_ok (struct tui_win_info *primary_win_info, int new_height) @@ -1391,12 +1407,8 @@ new_height_ok (struct tui_win_info *primary_win_info, diff = (new_height - primary_win_info->generic.height) * (-1); if (cur_layout == SRC_COMMAND || cur_layout == DISASSEM_COMMAND) { - ok = ((primary_win_info->generic.type == CMD_WIN - && new_height <= (tui_term_height () - 4) - && new_height >= MIN_CMD_WIN_HEIGHT) - || (primary_win_info->generic.type != CMD_WIN - && new_height <= (tui_term_height () - 2) - && new_height >= MIN_WIN_HEIGHT)); + ok = (new_height <= primary_win_info->max_height () + && new_height >= MIN_CMD_WIN_HEIGHT); if (ok) { /* Check the total height. */ struct tui_win_info *win_info;