From patchwork Sat Jan 4 18:33:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37178 Received: (qmail 130962 invoked by alias); 4 Jan 2020 18:34: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 130709 invoked by uid 89); 4 Jan 2020 18:34:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 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=estate, FOUND, screen X-HELO: gateway24.websitewelcome.com Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.51.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 04 Jan 2020 18:34:16 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 1F570B5B61 for ; Sat, 4 Jan 2020 12:34:15 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id noFbi0exK4kpjnoFbiV4J9; Sat, 04 Jan 2020 12:34:15 -0600 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=oz+L4lDyeQA4OL6l1nUIKcy2CNrTjAnKIkSCJjFNAlk=; b=XMUhb9ZbBmeZvPIMa/tKzO97Yt gXKPt6uNkWI6dt10gdI33AGb7erxiNPFmk34434EuU7BBlYqudN0ZneDoQ7xpdYaBAhWWL0kYlYhQ NVtd2UeiYE0QrZ6MSt3rpxgo/; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:48942 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1inoFa-0026Lh-VN; Sat, 04 Jan 2020 11:34:15 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 10/24] Change return type of tui_layout_base::adjust_size Date: Sat, 4 Jan 2020 11:33:56 -0700 Message-Id: <20200104183410.17114-11-tom@tromey.com> In-Reply-To: <20200104183410.17114-1-tom@tromey.com> References: <20200104183410.17114-1-tom@tromey.com> This changes tui_layout_base::adjust_size to return a new enum type. I broke this out into a separate patch because it simplifies a subsequent patch. gdb/ChangeLog 2020-01-04 Tom Tromey * tui/tui-layout.h (enum tui_adjust_result): New. (class tui_layout_base) : Return tui_adjust_result. (class tui_layout_window) : Return tui_adjust_result. Rewrite. (class tui_layout_split) : Return tui_adjust_result. * tui/tui-layout.c (tui_layout_split::adjust_size): Update. Change-Id: I821b48ab06a9b9485875e147bd08a3bc46b900a0 --- gdb/ChangeLog | 9 +++++++++ gdb/tui/tui-layout.c | 17 +++++++++-------- gdb/tui/tui-layout.h | 20 ++++++++++++++++---- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 3604d7e06bc..be6c754d022 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -487,7 +487,7 @@ tui_layout_split::set_weights_from_heights () /* See tui-layout.h. */ -bool +tui_adjust_result tui_layout_split::adjust_size (const char *name, int new_height) { /* Look through the children. If one is a layout holding the named @@ -496,10 +496,11 @@ tui_layout_split::adjust_size (const char *name, int new_height) int found_index = -1; for (int i = 0; i < m_splits.size (); ++i) { - if (m_splits[i].layout->adjust_size (name, new_height)) - return true; - const char *win_name = m_splits[i].layout->get_name (); - if (win_name != nullptr && strcmp (name, win_name) == 0) + tui_adjust_result adjusted + = m_splits[i].layout->adjust_size (name, new_height); + if (adjusted == HANDLED) + return HANDLED; + if (adjusted == FOUND) { found_index = i; break; @@ -507,9 +508,9 @@ tui_layout_split::adjust_size (const char *name, int new_height) } if (found_index == -1) - return false; + return NOT_FOUND; if (m_splits[found_index].layout->height == new_height) - return true; + return HANDLED; set_weights_from_heights (); int delta = m_splits[found_index].weight - new_height; @@ -557,7 +558,7 @@ tui_layout_split::adjust_size (const char *name, int new_height) apply (x, y, width, height); } - return true; + return HANDLED; } /* See tui-layout.h. */ diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h index 4351e260720..969e4dfd231 100644 --- a/gdb/tui/tui-layout.h +++ b/gdb/tui/tui-layout.h @@ -27,6 +27,18 @@ #include "tui/tui.h" #include "tui/tui-data.h" +/* Values that can be returned when handling a request to adjust a + window's size. */ +enum tui_adjust_result +{ + /* Requested window was not found here. */ + NOT_FOUND, + /* Window was found but not handled. */ + FOUND, + /* Window was found and handled. */ + HANDLED +}; + /* The basic object in a TUI layout. This represents a single piece of screen real estate. Subclasses determine the exact behavior. */ @@ -64,7 +76,7 @@ public: /* Adjust the size of the window named NAME to NEW_HEIGHT, updating the sizes of the other windows around it. */ - virtual bool adjust_size (const char *name, int new_height) = 0; + virtual tui_adjust_result adjust_size (const char *name, int new_height) = 0; /* Remove some windows from the layout, leaving the command window and the window being passed in here. */ @@ -111,9 +123,9 @@ public: return m_contents.c_str (); } - bool adjust_size (const char *name, int new_height) override + tui_adjust_result adjust_size (const char *name, int new_height) override { - return false; + return m_contents == name ? FOUND : NOT_FOUND; } bool top_boxed_p () const override; @@ -165,7 +177,7 @@ public: void apply (int x, int y, int width, int height) override; - bool adjust_size (const char *name, int new_height) override; + tui_adjust_result adjust_size (const char *name, int new_height) override; bool top_boxed_p () const override;