From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 64ED73857832 for ; Mon, 7 Mar 2022 22:14:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 64ED73857832 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-151-Mx-VkdIxP8KqaGEfBCNNqg-1; Mon, 07 Mar 2022 17:14:01 -0500 X-MC-Unique: Mx-VkdIxP8KqaGEfBCNNqg-1 Received: by mail-wr1-f69.google.com with SMTP id a5-20020adfdd05000000b001f023fe32ffso4937415wrm.18 for ; Mon, 07 Mar 2022 14:14:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=das0S6ecgexHtD5sn9NQxxQWNwvU5VtM+QxVN3ZtP3s=; b=78AQ2YxCpgtVa4NGsh0L984uSOL/ZMwWislJEm5GnBXvJL0TqS2J6+tfd5Qpi1MDSe Ru3O0ESkk+9VysqiswfO6vH9DqBsVgMxQHiwbBfxA6EQTk6qqDrMTS12KbrT2MQySa8O H3yfF3C8fjbP3VjkAMjz9q/ugo21ttzXUbr1s0ZWNwopVSOQZYuOfhGgu6Ycw17YKc8p 6mTnEyV2T/YzlvcxFD95PNaJS08pDpenEhATb4ot5PlCOA5JBeQ9FnS5tKJLzD+TsYbT 2pQ1KZHhR11ZLK1ejw/0MeD0WUXqloxu7EN/B8FQZaksq3g4wf7Zy47Lxc9SbIdeGhOe PY4Q== X-Gm-Message-State: AOAM532Cqn5Ar0SPDDXrQk8kBTQIYexT/WZS1k5BFKt42gVVX0V8+eki NZkNwzqan3DQf8xO3u20ocoVALnbRlnghyEL7K1/1EptYKBstUz9m8ovlTvuMB2YM5aLYrjHaOc Cz8h8diuJIkenVCq4CXtTIRHR9Mc4fYcfKcrzd2HrIux8gYSaz3vWmghUhvm56BabjDY8HrjofA == X-Received: by 2002:a5d:47c8:0:b0:1ef:8e97:2b8c with SMTP id o8-20020a5d47c8000000b001ef8e972b8cmr10234791wrc.545.1646691240266; Mon, 07 Mar 2022 14:14:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6QCnRe59wm1Dyh5A2f18eOAH1fQburbXNMmdSSUHqhi1XRZ585qe5fPYpsYsIMvnacgaqEQ== X-Received: by 2002:a5d:47c8:0:b0:1ef:8e97:2b8c with SMTP id o8-20020a5d47c8000000b001ef8e972b8cmr10234776wrc.545.1646691239965; Mon, 07 Mar 2022 14:13:59 -0800 (PST) Received: from localhost (host86-134-151-205.range86-134.btcentralplus.com. [86.134.151.205]) by smtp.gmail.com with ESMTPSA id h12-20020a5d548c000000b001f1f99e7792sm3209415wrv.111.2022.03.07.14.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:13:59 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 07/15] gdb/tui: add left_boxed_p and right_boxed_p member functions Date: Mon, 7 Mar 2022 22:13:39 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Mar 2022 22:14:04 -0000 When I initially saw this code in tui_layout_split::apply, I assumed that this must be a bug: /* Two adjacent boxed windows will share a border, making a bit more size available. */ if (i > 0 && m_splits[i - 1].layout->bottom_boxed_p () && m_splits[i].layout->top_boxed_p ()) ... After all, the apply might be laying out a horizontal layout, right? So checking bottom_boxed_p and top_boxed_p is clearly wrong. Well, it turns on, that due to the implementations of these things, bottom_boxed_p is equivalent to an imagined right_boxed_p, and top_boxed_p is equivalent to an imagined left_boxed_p. In this commit I've renamed both top_boxed_p and bottom_boxed_p to first_edge_has_border_p and last_edge_has_border_p respectively, and extended the comments in tui_layout_base to mention that these methods handle both horizontal and vertical layouts. Now, hopefully, the code shouldn't look like it only applies for vertical layouts. There should be no user visible changes after this commit. --- gdb/tui/tui-layout.c | 16 ++++++++-------- gdb/tui/tui-layout.h | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 8e8b4538c7e..3e1c5804460 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -451,7 +451,7 @@ tui_layout_window::get_sizes (bool height, int *min_value, int *max_value) /* See tui-layout.h. */ bool -tui_layout_window::top_boxed_p () const +tui_layout_window::first_edge_has_border_p () const { gdb_assert (m_window != nullptr); return m_window->can_box (); @@ -460,7 +460,7 @@ tui_layout_window::top_boxed_p () const /* See tui-layout.h. */ bool -tui_layout_window::bottom_boxed_p () const +tui_layout_window::last_edge_has_border_p () const { gdb_assert (m_window != nullptr); return m_window->can_box (); @@ -561,21 +561,21 @@ tui_layout_split::get_sizes (bool height, int *min_value, int *max_value) /* See tui-layout.h. */ bool -tui_layout_split::top_boxed_p () const +tui_layout_split::first_edge_has_border_p () const { if (m_splits.empty ()) return false; - return m_splits[0].layout->top_boxed_p (); + return m_splits[0].layout->first_edge_has_border_p (); } /* See tui-layout.h. */ bool -tui_layout_split::bottom_boxed_p () const +tui_layout_split::last_edge_has_border_p () const { if (m_splits.empty ()) return false; - return m_splits.back ().layout->top_boxed_p (); + return m_splits.back ().layout->last_edge_has_border_p (); } /* See tui-layout.h. */ @@ -785,8 +785,8 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_) /* Two adjacent boxed windows will share a border, making a bit more size available. */ if (i > 0 - && m_splits[i - 1].layout->bottom_boxed_p () - && m_splits[i].layout->top_boxed_p ()) + && m_splits[i - 1].layout->last_edge_has_border_p () + && m_splits[i].layout->first_edge_has_border_p ()) info[i].share_box = true; } diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h index 26de3c3a979..9cfcfb8e81f 100644 --- a/gdb/tui/tui-layout.h +++ b/gdb/tui/tui-layout.h @@ -62,11 +62,13 @@ class tui_layout_base HEIGHT is true to fetch height, false to fetch width. */ virtual void get_sizes (bool height, int *min_value, int *max_value) = 0; - /* True if the topmost item in this layout is boxed. */ - virtual bool top_boxed_p () const = 0; + /* True if the topmost (for vertical layouts), or the leftmost (for + horizontal layouts) item in this layout is boxed. */ + virtual bool first_edge_has_border_p () const = 0; - /* True if the bottommost item in this layout is boxed. */ - virtual bool bottom_boxed_p () const = 0; + /* True if the bottommost (for vertical layouts), or the rightmost (for + horizontal layouts) item in this layout is boxed. */ + virtual bool last_edge_has_border_p () const = 0; /* Return the name of this layout's window, or nullptr if this layout does not represent a single window. */ @@ -141,9 +143,9 @@ class tui_layout_window : public tui_layout_base return m_contents == name ? FOUND : NOT_FOUND; } - bool top_boxed_p () const override; + bool first_edge_has_border_p () const override; - bool bottom_boxed_p () const override; + bool last_edge_has_border_p () const override; void remove_windows (const char *name) override { @@ -213,9 +215,9 @@ class tui_layout_split : public tui_layout_base return set_size (name, new_width, true); } - bool top_boxed_p () const override; + bool first_edge_has_border_p () const override; - bool bottom_boxed_p () const override; + bool last_edge_has_border_p () const override; void remove_windows (const char *name) override; -- 2.25.4