1 /* Output generating routines for GDB CLI.
3 Copyright (C) 1999-2015 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/>. */
27 struct tui_ui_out_data
29 struct cli_ui_out_data base
;
34 typedef struct tui_ui_out_data tui_out_data
;
36 /* This is the TUI ui-out implementation functions vector. It is
37 initialized below in _initialize_tui_out, inheriting the CLI
38 version, and overriding a few methods. */
40 static struct ui_out_impl tui_ui_out_impl
;
42 /* Output an int field. */
45 tui_field_int (struct ui_out
*uiout
,
47 enum ui_align alignment
,
51 tui_out_data
*data
= ui_out_data (uiout
);
53 if (data
->base
.suppress_output
)
56 /* Don't print line number, keep it for later. */
57 if (data
->start_of_line
== 0 && strcmp (fldname
, "line") == 0)
59 data
->start_of_line
++;
63 data
->start_of_line
++;
65 (*cli_ui_out_impl
.field_int
) (uiout
, fldno
,
66 width
, alignment
, fldname
, value
);
69 /* Other cli_field_* end up here so alignment and field separators are
70 both handled by tui_field_string. */
73 tui_field_string (struct ui_out
*uiout
,
79 tui_out_data
*data
= ui_out_data (uiout
);
81 if (data
->base
.suppress_output
)
84 if (fldname
&& data
->line
> 0 && strcmp (fldname
, "fullname") == 0)
86 data
->start_of_line
++;
89 tui_show_source (string
, data
->line
);
94 data
->start_of_line
++;
96 (*cli_ui_out_impl
.field_string
) (uiout
, fldno
,
101 /* This is the only field function that does not align. */
104 tui_field_fmt (struct ui_out
*uiout
, int fldno
,
105 int width
, enum ui_align align
,
110 tui_out_data
*data
= ui_out_data (uiout
);
112 if (data
->base
.suppress_output
)
115 data
->start_of_line
++;
117 (*cli_ui_out_impl
.field_fmt
) (uiout
, fldno
,
119 fldname
, format
, args
);
123 tui_text (struct ui_out
*uiout
, const char *string
)
125 tui_out_data
*data
= ui_out_data (uiout
);
127 if (data
->base
.suppress_output
)
129 data
->start_of_line
++;
132 if (strchr (string
, '\n') != 0)
135 data
->start_of_line
= 0;
139 if (strchr (string
, '\n'))
140 data
->start_of_line
= 0;
142 (*cli_ui_out_impl
.text
) (uiout
, string
);
146 tui_out_new (struct ui_file
*stream
)
150 tui_out_data
*data
= XNEW (tui_out_data
);
152 /* Initialize base "class". */
153 cli_out_data_ctor (&data
->base
, stream
);
155 /* Initialize our fields. */
157 data
->start_of_line
= 0;
159 return ui_out_new (&tui_ui_out_impl
, data
, flags
);
162 /* Standard gdb initialization hook. */
164 extern void _initialize_tui_out (void);
167 _initialize_tui_out (void)
169 /* Inherit the CLI version. */
170 tui_ui_out_impl
= cli_ui_out_impl
;
172 /* Override a few methods. */
173 tui_ui_out_impl
.field_int
= tui_field_int
;
174 tui_ui_out_impl
.field_string
= tui_field_string
;
175 tui_ui_out_impl
.field_fmt
= tui_field_fmt
;
176 tui_ui_out_impl
.text
= tui_text
;