public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/tui] Handle shared border in fixed-sized layout
@ 2023-11-10 16:54 Tom de Vries
  2023-12-08 15:57 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2023-11-10 16:54 UTC (permalink / raw)
  To: gdb-patches

In tui_layout_split::apply I noticed that for variable-size layouts we take
share_box into account by decreasing used_size:
...
          used_size += info[i].size;
          if (info[i].share_box)
	    --used_size;
...
but not for fixed-size layouts:
...
      if (info[i].min_size == info[i].max_size)
	available_size -= info[i].min_size;
...

Fix this by increasing available_size for fixed-size layouts with shared box.

Tested on x86_64-linux.
---
 gdb/tui/tui-layout.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 159445dc520..0edc225b0d8 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -864,20 +864,26 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_,
 	  info[i].max_size = info[i].min_size;
 	}
 
+      /* Two adjacent boxed windows will share a border.  */
+      if (i > 0
+	  && m_splits[i - 1].layout->last_edge_has_border_p ()
+	  && m_splits[i].layout->first_edge_has_border_p ())
+	info[i].share_box = true;
+
       if (info[i].min_size == info[i].max_size)
-	available_size -= info[i].min_size;
+	{
+	  available_size -= info[i].min_size;
+	  if (info[i].share_box)
+	    {
+	      /* A shared border makes a bit more size available.  */
+	      ++available_size;
+	    }
+	}
       else
 	{
 	  last_index = i;
 	  total_weight += m_splits[i].weight;
 	}
-
-      /* Two adjacent boxed windows will share a border, making a bit
-	 more size available.  */
-      if (i > 0
-	  && m_splits[i - 1].layout->last_edge_has_border_p ()
-	  && m_splits[i].layout->first_edge_has_border_p ())
-	info[i].share_box = true;
     }
 
   /* If last_index is set then we have a window that is not of a fixed
@@ -907,7 +913,10 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_,
 	     this function.  */
 	  used_size += info[i].size;
 	  if (info[i].share_box)
-	    --used_size;
+	    {
+	      /* A shared border makes a bit more size available.  */
+	      --used_size;
+	    }
 	}
       else
 	info[i].size = info[i].min_size;

base-commit: e922d1eaa3774a68c96eae01e0fd08f8a30cda8c
-- 
2.35.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [gdb/tui] Handle shared border in fixed-sized layout
  2023-11-10 16:54 [PATCH] [gdb/tui] Handle shared border in fixed-sized layout Tom de Vries
@ 2023-12-08 15:57 ` Tom Tromey
  2023-12-09 13:47   ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-12-08 15:57 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> In tui_layout_split::apply I noticed that for variable-size layouts we take
Tom> share_box into account by decreasing used_size:
Tom> ...
Tom>           used_size += info[i].size;
Tom>           if (info[i].share_box)
Tom> 	    --used_size;
Tom> ...
Tom> but not for fixed-size layouts:
Tom> ...
Tom>       if (info[i].min_size == info[i].max_size)
Tom> 	available_size -= info[i].min_size;
Tom> ...

Tom> Fix this by increasing available_size for fixed-size layouts with shared box.

This looks good to me.

Is there any window with a fixed size other than the status line?
I wouldn't expect this to be hit currently.

Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [gdb/tui] Handle shared border in fixed-sized layout
  2023-12-08 15:57 ` Tom Tromey
@ 2023-12-09 13:47   ` Tom de Vries
  0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-12-09 13:47 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 12/8/23 16:57, Tom Tromey wrote:
> Is there any window with a fixed size other than the status line?

I don't think so, no.

> I wouldn't expect this to be hit currently.

Agreed.

However, I managed to trigger the behaviour using a trigger patch.

Say I have a terminal with 24 lines:
...
$ echo $LINES
24
...
and I show the window sizes of the split layout:
...
$ gdb -q -ex "layout split" -ex "info win"
...
and get:
...
Name       Lines Columns Focus
src            8      80 (has focus)
asm            8      80
status         1      80
cmd            8      80
(gdb)
...

Note that 8 + 8 + 1 + 8 == 25 == 24 + 1, this is due to the shared box 
between src and asm.

Now let's make src and asm fixed-size windows of 8 lines:
...
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 523d0ea832b..61f00b6f6d8 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -91,6 +91,15 @@ struct tui_source_element

  struct tui_source_window_base : public tui_win_info
  {
+  int max_height () const final override
+  {
+    return 8;
+  }
+
+  int min_height () const final override
+  {
+    return 8;
+  }
  protected:
    tui_source_window_base ();
    ~tui_source_window_base ();
...

Instead, we get:
...
Name       Lines Columns Focus
src            8      80 (has focus)
asm            8      80
status         1      80
cmd            7      80
(gdb)
...
and the last line of the terminal is unused.

Then after applying this patch, we're back to the expected:
...
Name       Lines Columns Focus
src            8      80 (has focus)
asm            8      80
status         1      80
cmd            8      80
...

Pushed.

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-09 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-10 16:54 [PATCH] [gdb/tui] Handle shared border in fixed-sized layout Tom de Vries
2023-12-08 15:57 ` Tom Tromey
2023-12-09 13:47   ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).