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/>. */
29 struct tui_ui_out_data
31 struct cli_ui_out_data base
;
36 typedef struct tui_ui_out_data tui_out_data
;
38 /* This is the TUI ui-out implementation functions vector. It is
39 initialized below in _initialize_tui_out, inheriting the CLI
40 version, and overriding a few methods. */
42 static struct ui_out_impl tui_ui_out_impl
;
44 /* Output an int field. */
47 tui_field_int (struct ui_out
*uiout
,
49 enum ui_align alignment
,
53 tui_out_data
*data
= ui_out_data (uiout
);
55 if (data
->base
.suppress_output
)
58 /* Don't print line number, keep it for later. */
59 if (data
->start_of_line
== 0 && strcmp (fldname
, "line") == 0)
61 data
->start_of_line
++;
65 data
->start_of_line
++;
67 (*cli_ui_out_impl
.field_int
) (uiout
, fldno
,
68 width
, alignment
, fldname
, value
);
71 /* Other cli_field_* end up here so alignment and field separators are
72 both handled by tui_field_string. */
75 tui_field_string (struct ui_out
*uiout
,
81 tui_out_data
*data
= ui_out_data (uiout
);
83 if (data
->base
.suppress_output
)
86 if (fldname
&& data
->line
> 0 && strcmp (fldname
, "fullname") == 0)
88 data
->start_of_line
++;
91 tui_show_source (string
, data
->line
);
96 data
->start_of_line
++;
98 (*cli_ui_out_impl
.field_string
) (uiout
, fldno
,
103 /* This is the only field function that does not align. */
106 tui_field_fmt (struct ui_out
*uiout
, int fldno
,
107 int width
, enum ui_align align
,
112 tui_out_data
*data
= ui_out_data (uiout
);
114 if (data
->base
.suppress_output
)
117 data
->start_of_line
++;
119 (*cli_ui_out_impl
.field_fmt
) (uiout
, fldno
,
121 fldname
, format
, args
);
125 tui_text (struct ui_out
*uiout
, const char *string
)
127 tui_out_data
*data
= ui_out_data (uiout
);
129 if (data
->base
.suppress_output
)
131 data
->start_of_line
++;
134 if (strchr (string
, '\n') != 0)
137 data
->start_of_line
= 0;
141 if (strchr (string
, '\n'))
142 data
->start_of_line
= 0;
144 (*cli_ui_out_impl
.text
) (uiout
, string
);
148 tui_out_new (struct ui_file
*stream
)
152 tui_out_data
*data
= XNEW (tui_out_data
);
154 /* Initialize base "class". */
155 cli_out_data_ctor (&data
->base
, stream
);
157 /* Initialize our fields. */
159 data
->start_of_line
= 0;
161 return ui_out_new (&tui_ui_out_impl
, data
, flags
);
164 /* Standard gdb initialization hook. */
166 extern void _initialize_tui_out (void);
169 _initialize_tui_out (void)
171 /* Inherit the CLI version. */
172 tui_ui_out_impl
= cli_ui_out_impl
;
174 /* Override a few methods. */
175 tui_ui_out_impl
.field_int
= tui_field_int
;
176 tui_ui_out_impl
.field_string
= tui_field_string
;
177 tui_ui_out_impl
.field_fmt
= tui_field_fmt
;
178 tui_ui_out_impl
.text
= tui_text
;