xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/tui/tui-out.c (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1 /* Output generating routines for GDB CLI.
2 
3    Copyright (C) 1999-2023 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_signed (int fldno, int width, ui_align alignment,
32 			     const char *fldname, LONGEST 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     {
40       m_start_of_line++;
41       m_line = value;
42       return;
43     }
44   m_start_of_line++;
45 
46   cli_ui_out::do_field_signed (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
53 tui_ui_out::do_field_string (int fldno, int width, ui_align align,
54 			     const char *fldname, const char *string,
55 			     const ui_file_style &style)
56 {
57   if (suppress_output ())
58     return;
59 
60   m_start_of_line++;
61 
62   if (fldname && m_line > 0 && strcmp (fldname, "fullname") == 0)
63     return;
64 
65   cli_ui_out::do_field_string (fldno, width, align, fldname, string, style);
66 }
67 
68 void
69 tui_ui_out::do_field_fmt (int fldno, int width, ui_align align,
70 			  const char *fldname, const ui_file_style &style,
71 			  const char *format, va_list args)
72 {
73   if (suppress_output ())
74     return;
75 
76   m_start_of_line++;
77 
78   cli_ui_out::do_field_fmt (fldno, width, align, fldname, style, format, args);
79 }
80 
81 void
82 tui_ui_out::do_text (const char *string)
83 {
84   if (suppress_output ())
85     return;
86 
87   m_start_of_line++;
88   if (m_line > 0)
89     {
90       /* Printing a source line, so suppress regular output -- the
91 	 line was shown on the TUI's source window by tui_show_source
92 	 above instead.  */
93       if (strchr (string, '\n') != 0)
94 	{
95 	  /* We've reached the end of the line, so go back to letting
96 	     text output go to the console.  */
97 	  m_line = 0;
98 	  m_start_of_line = 0;
99 	}
100       return;
101     }
102   if (strchr (string, '\n'))
103     m_start_of_line = 0;
104 
105   cli_ui_out::do_text (string);
106 }
107 
108 tui_ui_out::tui_ui_out (ui_file *stream)
109   : cli_ui_out (stream, 0)
110 {
111 }
112