1 /* Output generating routines for GDB CLI.
3 Copyright (C) 1999-2014 Free Software Foundation, Inc.
5 Contributed by Cygnus Solutions.
6 Written by Fernando Nasser for Cygnus.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
28 #include "gdb_assert.h"
30 struct tui_ui_out_data
32 struct cli_ui_out_data base;
37 typedef struct tui_ui_out_data tui_out_data;
39 /* This is the TUI ui-out implementation functions vector. It is
40 initialized below in _initialize_tui_out, inheriting the CLI
41 version, and overriding a few methods. */
43 static struct ui_out_impl tui_ui_out_impl;
45 /* Output an int field. */
48 tui_field_int (struct ui_out *uiout,
50 enum ui_align alignment,
54 tui_out_data *data = ui_out_data (uiout);
56 if (data->base.suppress_output)
59 /* Don't print line number, keep it for later. */
60 if (data->start_of_line == 0 && strcmp (fldname, "line") == 0)
62 data->start_of_line ++;
66 data->start_of_line ++;
68 (*cli_ui_out_impl.field_int) (uiout, fldno,
69 width, alignment, fldname, value);
72 /* Other cli_field_* end up here so alignment and field separators are
73 both handled by tui_field_string. */
76 tui_field_string (struct ui_out *uiout,
82 tui_out_data *data = ui_out_data (uiout);
84 if (data->base.suppress_output)
87 if (fldname && data->line > 0 && strcmp (fldname, "fullname") == 0)
89 data->start_of_line ++;
92 tui_show_source (string, data->line);
97 data->start_of_line++;
99 (*cli_ui_out_impl.field_string) (uiout, fldno,
104 /* This is the only field function that does not align. */
107 tui_field_fmt (struct ui_out *uiout, int fldno,
108 int width, enum ui_align align,
113 tui_out_data *data = ui_out_data (uiout);
115 if (data->base.suppress_output)
118 data->start_of_line++;
120 (*cli_ui_out_impl.field_fmt) (uiout, fldno,
122 fldname, format, args);
126 tui_text (struct ui_out *uiout, const char *string)
128 tui_out_data *data = ui_out_data (uiout);
130 if (data->base.suppress_output)
132 data->start_of_line ++;
135 if (strchr (string, '\n') != 0)
138 data->start_of_line = 0;
142 if (strchr (string, '\n'))
143 data->start_of_line = 0;
145 (*cli_ui_out_impl.text) (uiout, string);
149 tui_out_new (struct ui_file *stream)
153 tui_out_data *data = XNEW (tui_out_data);
155 /* Initialize base "class". */
156 cli_out_data_ctor (&data->base, stream);
158 /* Initialize our fields. */
160 data->start_of_line = 0;
162 return ui_out_new (&tui_ui_out_impl, data, flags);
165 /* Standard gdb initialization hook. */
167 extern void _initialize_tui_out (void);
170 _initialize_tui_out (void)
172 /* Inherit the CLI version. */
173 tui_ui_out_impl = cli_ui_out_impl;
175 /* Override a few methods. */
176 tui_ui_out_impl.field_int = tui_field_int;
177 tui_ui_out_impl.field_string = tui_field_string;
178 tui_ui_out_impl.field_fmt = tui_field_fmt;
179 tui_ui_out_impl.text = tui_text;