GDB (xrefs)
tui-out.c
Go to the documentation of this file.
1 /* Output generating routines for GDB CLI.
2 
3  Copyright (C) 1999-2018 Free Software Foundation, Inc.
4 
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
12  the Free Software Foundation; either version 3 of the License, or
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
21  along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 
23 #include "defs.h"
24 #include "ui-out.h"
25 #include "tui-out.h"
26 #include "tui.h"
27 
28 /* Output an int field. */
29 
30 void
31 tui_ui_out::do_field_int (int fldno, int width, ui_align alignment,
32  const char *fldname, int value)
33 {
34  if (suppress_output ())
35  return;
36 
37  /* Don't print line number, keep it for later. */
38  if (m_start_of_line == 0 && strcmp (fldname, "line") == 0)
39  {
41  m_line = value;
42  return;
43  }
45 
46  cli_ui_out::do_field_int (fldno, width, alignment, fldname, value);
47 }
48 
49 /* Other cli_field_* end up here so alignment and field separators are
50  both handled by tui_field_string. */
51 
52 void
54  const char *fldname, const char *string)
55 {
56  if (suppress_output ())
57  return;
58 
59  if (fldname && m_line > 0 && strcmp (fldname, "fullname") == 0)
60  {
62  if (m_line > 0)
63  {
64  tui_show_source (string, m_line);
65  }
66  return;
67  }
68 
70 
71  cli_ui_out::do_field_string (fldno, width, align, fldname, string);
72 }
73 
74 /* This is the only field function that does not align. */
75 
76 void
77 tui_ui_out::do_field_fmt (int fldno, int width, ui_align align,
78  const char *fldname, const char *format,
79  va_list args)
80 {
81  if (suppress_output ())
82  return;
83 
85 
86  cli_ui_out::do_field_fmt (fldno, width, align, fldname, format, args);
87 }
88 
89 void
90 tui_ui_out::do_text (const char *string)
91 {
92  if (suppress_output ())
93  return;
94 
96  if (m_line > 0)
97  {
98  if (strchr (string, '\n') != 0)
99  {
100  m_line = -1;
101  m_start_of_line = 0;
102  }
103  return;
104  }
105  if (strchr (string, '\n'))
106  m_start_of_line = 0;
107 
108  cli_ui_out::do_text (string);
109 }
110 
112 : cli_ui_out (stream, 0),
113  m_line (0),
114  m_start_of_line (-1)
115 {
116 }
117 
118 tui_ui_out *
119 tui_out_new (struct ui_file *stream)
120 {
121  return new tui_ui_out (stream);
122 }
virtual void do_field_int(int fldno, int width, ui_align align, const char *fldname, int value) override
Definition: cli-out.c:94
void do_field_fmt(int fldno, int width, ui_align align, const char *fldname, const char *format, va_list args) override ATTRIBUTE_PRINTF(6
Definition: tui-out.c:77
int m_start_of_line
Definition: tui-out.h:43
void do_field_string(int fldno, int width, ui_align align, const char *fldname, const char *string) override
Definition: tui-out.c:53
virtual void do_field_fmt(int fldno, int width, ui_align align, const char *fldname, const char *format, va_list args) override ATTRIBUTE_PRINTF(6
Definition: cli-out.c:171
void tui_show_source(const char *fullname, int line)
Definition: tui.c:630
tui_ui_out * tui_out_new(struct ui_file *stream)
Definition: tui-out.c:119
virtual void do_text(const char *string) override
Definition: cli-out.c:194
void do_field_int(int fldno, int width, ui_align align, const char *fldname, int value) override
Definition: tui-out.c:31
Definition: value.c:169
bool suppress_output()
Definition: cli-out.h:65
ui_align
Definition: ui-out.h:42
virtual void do_field_string(int fldno, int width, ui_align align, const char *fldname, const char *string) override
Definition: cli-out.c:123
int m_line
Definition: tui-out.h:42
void void do_text(const char *string) override
Definition: tui-out.c:90
tui_ui_out(ui_file *stream)
Definition: tui-out.c:111