public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Introduce function for directly updating GDB's screen dimensions
@ 2015-04-24  0:53 Patrick Palka
  2015-04-24  0:54 ` [PATCH 2/3] Update our idea of our terminal's dimensions even outside of TUI Patrick Palka
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Patrick Palka @ 2015-04-24  0:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

... to replace the roundabout pattern of

  execute_command ("set width %d");
  execute_command ("set height %d");

for doing the same thing.

gdb/ChangeLog

	* utils.h (set_screen_width_and_height): Declare.
	* utils.c (set_screen_width_and_height): Define.
	* tui/tui-win.c (tui_update_gdb_sizes): Use it.
---
 gdb/tui/tui-win.c | 21 +++++++++++++--------
 gdb/utils.c       | 12 ++++++++++++
 gdb/utils.h       |  2 ++
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 3cf38fc..6830977 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -465,15 +465,20 @@ bold-standout   use extra bright or bold with standout mode"),
 void
 tui_update_gdb_sizes (void)
 {
-  char cmd[50];
+  int width, height;
 
-  /* Set to TUI command window dimension or use readline values.  */
-  xsnprintf (cmd, sizeof (cmd), "set width %d",
-           tui_active ? TUI_CMD_WIN->generic.width : tui_term_width());
-  execute_command (cmd, 0);
-  xsnprintf (cmd, sizeof (cmd), "set height %d",
-           tui_active ? TUI_CMD_WIN->generic.height : tui_term_height());
-  execute_command (cmd, 0);
+  if (tui_active)
+    {
+      width = TUI_CMD_WIN->generic.width;
+      height = TUI_CMD_WIN->generic.height;
+    }
+  else
+    {
+      width = tui_term_width ();
+      height = tui_term_height ();
+    }
+
+  set_screen_width_and_height (width, height);
 }
 
 
diff --git a/gdb/utils.c b/gdb/utils.c
index a9350d9..ec2fd87 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1795,6 +1795,18 @@ set_height_command (char *args, int from_tty, struct cmd_list_element *c)
   set_screen_size ();
 }
 
+/* Set the screen dimensions to WIDTH and HEIGHT.  */
+
+void
+set_screen_width_and_height (int width, int height)
+{
+  lines_per_page = height;
+  chars_per_line = width;
+
+  set_screen_size ();
+  set_width ();
+}
+
 /* Wait, so the user can read what's on the screen.  Prompt the user
    to continue by pressing RETURN.  */
 
diff --git a/gdb/utils.h b/gdb/utils.h
index b8e1aff..9c1af78 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -174,6 +174,8 @@ extern struct ui_file *gdb_stdtarg;
 extern struct ui_file *gdb_stdtargerr;
 extern struct ui_file *gdb_stdtargin;
 
+extern void set_screen_width_and_height (int width, int height);
+
 /* More generic printf like operations.  Filtered versions may return
    non-locally on error.  */
 
-- 
2.4.0.rc2.31.g7c597ef

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

end of thread, other threads:[~2015-04-28 12:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-24  0:53 [PATCH 1/3] Introduce function for directly updating GDB's screen dimensions Patrick Palka
2015-04-24  0:54 ` [PATCH 2/3] Update our idea of our terminal's dimensions even outside of TUI Patrick Palka
2015-04-24 16:49   ` Joel Brobecker
2015-04-27 16:35   ` Pedro Alves
2015-04-28  9:17     ` Patrick Palka
2015-04-28 13:15       ` Pedro Alves
2015-04-24  0:54 ` [PATCH 3/3] Disable readline's SIGWINCH handler Patrick Palka
2015-04-27 16:35   ` Pedro Alves
2015-04-28 12:31 ` [PATCH 1/3] Introduce function for directly updating GDB's screen dimensions Pedro Alves

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