tui-file.c 2.0 KB

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