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.133.124]) by sourceware.org (Postfix) with ESMTPS id 83B9D3858402 for ; Sun, 6 Feb 2022 14:13:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 83B9D3858402 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-KtIyoUfxOQKErk6za6wopw-1; Sun, 06 Feb 2022 09:13:14 -0500 X-MC-Unique: KtIyoUfxOQKErk6za6wopw-1 Received: by mail-ed1-f70.google.com with SMTP id f6-20020a0564021e8600b0040f662b99ffso170890edf.7 for ; Sun, 06 Feb 2022 06:13:14 -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=bjeLVOqw6wIUcUwbWDLeRon2yvHi2m4Un0NN7eGSn0c=; b=JNBNJqlajJ170jaiBys7RNF8CyGXX+PyM+QQMZaXJsSEu/MlP8uc0gSBdtnpKnT3/s nyHZxoVeA2AXB/4JoiscB/nBrfwuYIT8lYcNEg9TgRi1JLjUkp4tpe9NKuanU0Z7MuOh 1bpKkBHHl9uLGFRQyRLSMWfLGAxiEOEMsdeUpkbJ60humrCo7+HhwrCZ7rJcQaYP91pn xGDVyeYXOG7/mIn5YLQyc8Y5mPWrc+lQFXTUcQSGf5xYgMHRPYNr8m6EUXtKqjR4ygAP M7E6tcHLcY3N9KtrFuR7ca3Mo9YYUbLF3rLlEXoDNOLAU1Rf2IWqzztbGoCV4hthVMtv EcUQ== X-Gm-Message-State: AOAM53162h8uBKrNXV++SlJhDXitrwM/hmA55UBWDB30+gQA+2mcWFNQ MPs5ybTs3eD4pNq6UZs2kDe7D5HGBpc2fZU4Fnk2R71Y+uvhKxsalmfoY2jSJX3LlNExMhMptVx njd08bPklLhEq9lEEtqOdyOWbfeG2mx9rhgTZHxhxMIuBs3Bqryu8aWgIhAJ1n/paaOS0qiGOYg == X-Received: by 2002:a05:6402:348b:: with SMTP id v11mr9088145edc.58.1644156792616; Sun, 06 Feb 2022 06:13:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6G7hmmjUNESgA+EoE/7avTGxRtyiEkT03Ao/oxZnYUl8Qzc+RLLpjxhyYgpx8Czp9yw8JIA== X-Received: by 2002:a05:6402:348b:: with SMTP id v11mr9088123edc.58.1644156792306; Sun, 06 Feb 2022 06:13:12 -0800 (PST) Received: from localhost (92.40.178.36.threembb.co.uk. [92.40.178.36]) by smtp.gmail.com with ESMTPSA id eo7sm1374843edb.97.2022.02.06.06.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 06:13:11 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 07/15] gdb/tui: add left_boxed_p and right_boxed_p member functions Date: Sun, 6 Feb 2022 14:12:45 +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=-10.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_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, 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: Sun, 06 Feb 2022 14:13:17 -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, 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. I did consider just adding a comment about this to the above code, but this still doesn't feel great. So, in this commit, I've just filled in the API to add right_boxed_p and left_boxed_p, and now I call these instead of bottom_boxed_p and top_boxed_p if appropriate. Maybe it's just pointless noise.... ... I'd rather the main apply function not have to have special knowledge about the implementation of these things coded into it. There should be no user visible changes after this commit. --- gdb/tui/tui-layout.c | 46 ++++++++++++++++++++++++++++++++++++++++++-- gdb/tui/tui-layout.h | 14 ++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 1ce912b3cdb..ca901e5c85d 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -468,6 +468,24 @@ tui_layout_window::bottom_boxed_p () const /* See tui-layout.h. */ +bool +tui_layout_window::left_boxed_p () const +{ + gdb_assert (m_window != nullptr); + return m_window->can_box (); +} + +/* See tui-layout.h. */ + +bool +tui_layout_window::right_boxed_p () const +{ + gdb_assert (m_window != nullptr); + return m_window->can_box (); +} + +/* See tui-layout.h. */ + void tui_layout_window::replace_window (const char *name, const char *new_window) { @@ -580,6 +598,26 @@ tui_layout_split::bottom_boxed_p () const /* See tui-layout.h. */ +bool +tui_layout_split::left_boxed_p () const +{ + if (m_splits.empty ()) + return false; + return m_splits[0].layout->left_boxed_p (); +} + +/* See tui-layout.h. */ + +bool +tui_layout_split::right_boxed_p () const +{ + if (m_splits.empty ()) + return false; + return m_splits.back ().layout->right_boxed_p (); +} + +/* See tui-layout.h. */ + void tui_layout_split::set_weights_from_sizes () { @@ -777,8 +815,12 @@ 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_vertical + && m_splits[i - 1].layout->bottom_boxed_p () + && m_splits[i].layout->top_boxed_p ()) + || (!m_vertical + && m_splits[i - 1].layout->right_boxed_p () + && m_splits[i].layout->left_boxed_p ()))) info[i].share_box = true; } diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h index ebfcae74356..e160eaa2256 100644 --- a/gdb/tui/tui-layout.h +++ b/gdb/tui/tui-layout.h @@ -68,6 +68,12 @@ class tui_layout_base /* True if the bottommost item in this layout is boxed. */ virtual bool bottom_boxed_p () const = 0; + /* True if the leftmost item in this layout is boxed. */ + virtual bool left_boxed_p () const = 0; + + /* True if the rightmost item in this layout is boxed. */ + virtual bool right_boxed_p () const = 0; + /* Return the name of this layout's window, or nullptr if this layout does not represent a single window. */ virtual const char *get_name () const @@ -145,6 +151,10 @@ class tui_layout_window : public tui_layout_base bool bottom_boxed_p () const override; + bool left_boxed_p () const override; + + bool right_boxed_p () const override; + void remove_windows (const char *name) override { } @@ -215,6 +225,10 @@ class tui_layout_split : public tui_layout_base bool bottom_boxed_p () const override; + bool left_boxed_p () const override; + + bool right_boxed_p () const override; + void remove_windows (const char *name) override; void replace_window (const char *name, const char *new_window) override; -- 2.25.4