Commit | Line | Data |
---|---|---|
d9fcf2fb | 1 | /* UI_FILE - a generic STDIO like output stream. |
b811d2c2 | 2 | Copyright (C) 1999-2020 Free Software Foundation, Inc. |
da59e081 JM |
3 | |
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
da59e081 JM |
9 | (at your option) any later version. |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
da59e081 JM |
18 | |
19 | #include "defs.h" | |
da59e081 | 20 | #include "tui/tui-file.h" |
d7b2e967 | 21 | #include "tui/tui-io.h" |
518be979 | 22 | #include "tui/tui-command.h" |
fbc75a32 | 23 | #include "tui.h" |
fbc75a32 | 24 | |
d7e74731 PA |
25 | tui_file::tui_file (FILE *stream) |
26 | : stdio_file (stream) | |
27 | {} | |
da59e081 JM |
28 | |
29 | /* All TUI I/O sent to the *_filtered and *_unfiltered functions | |
30 | eventually ends up here. The fputs_unfiltered_hook is primarily | |
31 | used by GUIs to collect all output and send it to the GUI, instead | |
32 | of the controlling terminal. Only output to gdb_stdout and | |
33 | gdb_stderr are sent to the hook. Everything else is sent on to | |
34 | fputs to allow file I/O to be handled appropriately. */ | |
35 | ||
da59e081 | 36 | void |
d7e74731 | 37 | tui_file::puts (const char *linebuffer) |
da59e081 | 38 | { |
d7e74731 PA |
39 | tui_puts (linebuffer); |
40 | /* gdb_stdout is buffered, and the caller must gdb_flush it at | |
41 | appropriate times. Other streams are not so buffered. */ | |
42 | if (this != gdb_stdout) | |
43 | tui_refresh_cmd_win (); | |
da59e081 JM |
44 | } |
45 | ||
9753a2f6 PA |
46 | void |
47 | tui_file::write (const char *buf, long length_buf) | |
48 | { | |
49 | tui_write (buf, length_buf); | |
50 | /* gdb_stdout is buffered, and the caller must gdb_flush it at | |
51 | appropriate times. Other streams are not so buffered. */ | |
52 | if (this != gdb_stdout) | |
53 | tui_refresh_cmd_win (); | |
54 | } | |
55 | ||
da59e081 | 56 | void |
d7e74731 | 57 | tui_file::flush () |
da59e081 | 58 | { |
d7e74731 PA |
59 | /* gdb_stdout is buffered. Other files are always flushed on |
60 | every write. */ | |
61 | if (this == gdb_stdout) | |
62 | tui_refresh_cmd_win (); | |
63 | stdio_file::flush (); | |
da59e081 | 64 | } |