public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Preserve "set height 0" when resizing terminal
@ 2020-09-23 19:39 Tom Tromey
  2020-09-24  3:40 ` Simon Marchi
  2020-09-24 11:01 ` Andrew Burgess
  0 siblings, 2 replies; 3+ messages in thread
From: Tom Tromey @ 2020-09-23 19:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

PR cli/26650 points out that if "set height 0" is specified, then it
is forgotten on SIGWINCH.  This patch arranges to preserve this
setting (but not other values of "set height").

gdb/ChangeLog
2020-09-23  Tom Tromey  <tromey@adacore.com>

	PR cli/26650:
	* utils.c (set_screen_width_and_height): Preserve "set height 0".
---
 gdb/ChangeLog | 5 +++++
 gdb/utils.c   | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/gdb/utils.c b/gdb/utils.c
index fb1308ac9ae..2e8b2a5bdc9 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1378,11 +1378,18 @@ set_height_command (const char *args, int from_tty, struct cmd_list_element *c)
 void
 set_screen_width_and_height (int width, int height)
 {
+  /* If the user did "set height 0", make sure to preserve it after
+     handling the height change.  */
+  unsigned int saved_lines = lines_per_page;
+
   lines_per_page = height;
   chars_per_line = width;
 
   set_screen_size ();
   set_width ();
+
+  if (saved_lines == UINT_MAX)
+    lines_per_page = UINT_MAX;
 }
 
 /* The currently applied style.  */
-- 
2.26.2


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

* Re: [PATCH] Preserve "set height 0" when resizing terminal
  2020-09-23 19:39 [PATCH] Preserve "set height 0" when resizing terminal Tom Tromey
@ 2020-09-24  3:40 ` Simon Marchi
  2020-09-24 11:01 ` Andrew Burgess
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2020-09-24  3:40 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2020-09-23 3:39 p.m., Tom Tromey wrote:
> PR cli/26650 points out that if "set height 0" is specified, then it
> is forgotten on SIGWINCH.  This patch arranges to preserve this
> setting (but not other values of "set height").
>
> gdb/ChangeLog
> 2020-09-23  Tom Tromey  <tromey@adacore.com>
>
> 	PR cli/26650:
> 	* utils.c (set_screen_width_and_height): Preserve "set height 0".

This LGTM.

Simon


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

* Re: [PATCH] Preserve "set height 0" when resizing terminal
  2020-09-23 19:39 [PATCH] Preserve "set height 0" when resizing terminal Tom Tromey
  2020-09-24  3:40 ` Simon Marchi
@ 2020-09-24 11:01 ` Andrew Burgess
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2020-09-24 11:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

* Tom Tromey <tromey@adacore.com> [2020-09-23 13:39:45 -0600]:

> PR cli/26650 points out that if "set height 0" is specified, then it
> is forgotten on SIGWINCH.  This patch arranges to preserve this
> setting (but not other values of "set height").
> 
> gdb/ChangeLog
> 2020-09-23  Tom Tromey  <tromey@adacore.com>
> 
> 	PR cli/26650:
> 	* utils.c (set_screen_width_and_height): Preserve "set height 0".
> ---
>  gdb/ChangeLog | 5 +++++
>  gdb/utils.c   | 7 +++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/gdb/utils.c b/gdb/utils.c
> index fb1308ac9ae..2e8b2a5bdc9 100644
> --- a/gdb/utils.c
> +++ b/gdb/utils.c
> @@ -1378,11 +1378,18 @@ set_height_command (const char *args, int from_tty, struct cmd_list_element *c)
>  void
>  set_screen_width_and_height (int width, int height)
>  {
> +  /* If the user did "set height 0", make sure to preserve it after
> +     handling the height change.  */
> +  unsigned int saved_lines = lines_per_page;
> +
>    lines_per_page = height;
>    chars_per_line = width;
>  
>    set_screen_size ();
>    set_width ();
> +
> +  if (saved_lines == UINT_MAX)
> +    lines_per_page = UINT_MAX;
>  }

What if the user does `set height 10` does that not deserve to be
preserved?  What about `set width 0` should that not be preserved?  Or
`set width 60`?

It almost feels like for both height and width we should track if the
value is the default, or user specified.

The we should allow `set height auto` and `set width auto`...

We might want/need something like that anyway to allow the user to get
back from `set height 0` to something sane without having to just guess
- previously they could just resize the window and boom they had the
height set to the "default", but now a user has to play guess the
window height...

Either way we should probably decide what we support and don't support
and document it I think.

Thanks,
Andrew


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

end of thread, other threads:[~2020-09-24 11:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-23 19:39 [PATCH] Preserve "set height 0" when resizing terminal Tom Tromey
2020-09-24  3:40 ` Simon Marchi
2020-09-24 11:01 ` Andrew Burgess

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).