Patchwork Use ui_out for "info win"

login
register
mail settings
Submitter Tom Tromey
Date Aug. 30, 2019, 8:06 p.m.
Message ID <20190830200644.18619-1-tom@tromey.com>
Download mbox | patch
Permalink /patch/34362/
State New
Headers show

Comments

Tom Tromey - Aug. 30, 2019, 8:06 p.m.
This changes the "info win" command to use ui-out.  This yields
somewhat nicer table output.

gdb/ChangeLog
2019-08-30  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_all_windows_info): Use ui_out.
---
 gdb/ChangeLog     |  4 ++++
 gdb/tui/tui-win.c | 20 ++++++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)
Tom Tromey - Sept. 9, 2019, 11:10 p.m.
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> This changes the "info win" command to use ui-out.  This yields
Tom> somewhat nicer table output.

Tom> gdb/ChangeLog
Tom> 2019-08-30  Tom Tromey  <tom@tromey.com>

Tom> 	* tui/tui-win.c (tui_all_windows_info): Use ui_out.

I'm checking this in now.

Tom

Patch

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 8d41372cf90..bf84cdac442 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -828,18 +828,26 @@  static void
 tui_all_windows_info (const char *arg, int from_tty)
 {
   struct tui_win_info *win_with_focus = tui_win_with_focus ();
+  struct ui_out *uiout = current_uiout;
+
+  ui_out_emit_table table_emitter (uiout, 3, -1, "tui-windows");
+  uiout->table_header (10, ui_left, "name", "Name");
+  uiout->table_header (5, ui_right, "lines", "Lines");
+  uiout->table_header (10, ui_left, "focus", "Focus");
+  uiout->table_body ();
 
   for (tui_win_info *win_info : all_tui_windows ())
     if (win_info->is_visible ())
       {
+	ui_out_emit_tuple tuple_emitter (uiout, nullptr);
+
+	uiout->field_string ("name", win_info->name ());
+	uiout->field_signed ("lines", win_info->height);
 	if (win_with_focus == win_info)
-	  printf_filtered ("        %s\t(%d lines)  <has focus>\n",
-			   win_info->name (),
-			   win_info->height);
+	  uiout->field_string ("focus", _("(has focus)"));
 	else
-	  printf_filtered ("        %s\t(%d lines)\n",
-			   win_info->name (),
-			   win_info->height);
+	  uiout->field_skip ("focus");
+	uiout->text ("\n");
       }
 }