diff options
author | Patrick Palka <patrick@parcs.ath.cx> | 2015-04-23 18:31:38 -0400 |
---|---|---|
committer | Patrick Palka <patrick@parcs.ath.cx> | 2015-04-28 08:46:28 -0400 |
commit | d6e5e7f7fd90baad9cbfaa5a187b5f0b1a0b8cf6 (patch) | |
tree | 47a4511a2f7106e5e3ce6e2fa7766aed2e6c45f4 | |
parent | ff862be47e7acf51e4abaf0f121d5961adb1845a (diff) | |
download | gdb-d6e5e7f7fd90baad9cbfaa5a187b5f0b1a0b8cf6.zip gdb-d6e5e7f7fd90baad9cbfaa5a187b5f0b1a0b8cf6.tar.gz gdb-d6e5e7f7fd90baad9cbfaa5a187b5f0b1a0b8cf6.tar.bz2 |
Introduce function for directly updating GDB's screen dimensions
... 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.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/tui/tui-win.c | 23 | ||||
-rw-r--r-- | gdb/utils.c | 12 | ||||
-rw-r--r-- | gdb/utils.h | 4 |
4 files changed, 36 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a22b7f8..eadf493 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2015-04-28 Patrick Palka <patrick@parcs.ath.cx> + + * 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. + 2015-04-28 Gary Benson <gbenson@redhat.com> * infrun.c (solist.h): New include. 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]; - - /* 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); + int width, height; + + 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..70708bf 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 (); } +/* See utils.h. */ + +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..cae1ac0 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -174,6 +174,10 @@ extern struct ui_file *gdb_stdtarg; extern struct ui_file *gdb_stdtargerr; extern struct ui_file *gdb_stdtargin; +/* Set the screen dimensions to WIDTH and HEIGHT. */ + +extern void set_screen_width_and_height (int width, int height); + /* More generic printf like operations. Filtered versions may return non-locally on error. */ |