Class-ify ui_out
[deliverable/binutils-gdb.git] / gdb / tui / tui-out.c
CommitLineData
2611b1a5 1/* Output generating routines for GDB CLI.
349c5d5f 2
618f726f 3 Copyright (C) 1999-2016 Free Software Foundation, Inc.
349c5d5f 4
2611b1a5
SC
5 Contributed by Cygnus Solutions.
6 Written by Fernando Nasser for Cygnus.
7
8 This file is part of GDB.
9
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
a9762ec7 12 the Free Software Foundation; either version 3 of the License, or
2611b1a5
SC
13 (at your option) any later version.
14
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.
19
20 You should have received a copy of the GNU General Public License
a9762ec7 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
2611b1a5
SC
22
23#include "defs.h"
24#include "ui-out.h"
112e8700 25#include "tui-out.h"
2611b1a5 26#include "tui.h"
2611b1a5 27
1cc6d956 28/* Output an int field. */
2611b1a5 29
112e8700
SM
30void
31tui_ui_out::do_field_int (int fldno, int width, ui_align alignment,
32 const char *fldname, int value)
2611b1a5 33{
112e8700 34 if (suppress_output ())
2611b1a5
SC
35 return;
36
37 /* Don't print line number, keep it for later. */
112e8700 38 if (m_start_of_line == 0 && strcmp (fldname, "line") == 0)
2611b1a5 39 {
112e8700
SM
40 m_start_of_line++;
41 m_line = value;
2611b1a5
SC
42 return;
43 }
112e8700 44 m_start_of_line++;
2611b1a5 45
112e8700 46 cli_ui_out::do_field_int (fldno, width, alignment, fldname, value);
2611b1a5
SC
47}
48
0a8fce9a
PA
49/* Other cli_field_* end up here so alignment and field separators are
50 both handled by tui_field_string. */
2611b1a5 51
112e8700
SM
52void
53tui_ui_out::do_field_string (int fldno, int width, ui_align align,
54 const char *fldname, const char *string)
2611b1a5 55{
112e8700 56 if (suppress_output ())
2611b1a5
SC
57 return;
58
112e8700 59 if (fldname && m_line > 0 && strcmp (fldname, "fullname") == 0)
2611b1a5 60 {
112e8700
SM
61 m_start_of_line++;
62 if (m_line > 0)
2611b1a5 63 {
112e8700 64 tui_show_source (string, m_line);
2611b1a5
SC
65 }
66 return;
67 }
68
112e8700 69 m_start_of_line++;
2611b1a5 70
112e8700 71 cli_ui_out::do_field_string (fldno, width, align, fldname, string);
2611b1a5
SC
72}
73
1cc6d956 74/* This is the only field function that does not align. */
2611b1a5 75
112e8700
SM
76void
77tui_ui_out::do_field_fmt (int fldno, int width, ui_align align,
78 const char *fldname, const char *format,
79 va_list args)
2611b1a5 80{
112e8700 81 if (suppress_output ())
2611b1a5
SC
82 return;
83
112e8700 84 m_start_of_line++;
2611b1a5 85
112e8700 86 cli_ui_out::do_field_fmt (fldno, width, align, fldname, format, args);
2611b1a5
SC
87}
88
112e8700
SM
89void
90tui_ui_out::do_text (const char *string)
2611b1a5 91{
112e8700 92 if (suppress_output ())
2611b1a5 93 return;
112e8700
SM
94
95 m_start_of_line++;
96 if (m_line > 0)
2611b1a5
SC
97 {
98 if (strchr (string, '\n') != 0)
99 {
112e8700
SM
100 m_line = -1;
101 m_start_of_line = 0;
2611b1a5
SC
102 }
103 return;
104 }
105 if (strchr (string, '\n'))
112e8700 106 m_start_of_line = 0;
2611b1a5 107
112e8700 108 cli_ui_out::do_text (string);
2611b1a5
SC
109}
110
112e8700
SM
111tui_ui_out::tui_ui_out (ui_file *stream)
112: cli_ui_out (stream, 0),
113 m_line (0),
114 m_start_of_line (-1)
2611b1a5 115{
2611b1a5
SC
116}
117
112e8700
SM
118tui_ui_out *
119tui_out_new (struct ui_file *stream)
2611b1a5 120{
112e8700 121 return new tui_ui_out (stream);
2611b1a5 122}
This page took 1.618994 seconds and 4 git commands to generate.