1 /* Output pager for gdb
2 Copyright (C) 2021-2024 Free Software Foundation, Inc.
4 This file is part of GDB.
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
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 /* A ui_file that implements output paging and unfiltered output. */
26 class pager_file
: public wrapped_file
29 /* Create a new pager_file. The new object takes ownership of
31 explicit pager_file (ui_file
*stream
)
32 : wrapped_file (stream
)
41 DISABLE_COPY_AND_ASSIGN (pager_file
);
43 void write (const char *buf
, long length_buf
) override
;
45 void puts (const char *str
) override
;
47 void write_async_safe (const char *buf
, long length_buf
) override
49 m_stream
->write_async_safe (buf
, length_buf
);
52 void emit_style_escape (const ui_file_style
&style
) override
;
53 void reset_style () override
;
55 void flush () override
;
57 void wrap_here (int indent
) override
;
59 void puts_unfiltered (const char *str
) override
62 m_stream
->puts_unfiltered (str
);
67 void prompt_for_continue ();
69 /* Flush the wrap buffer to STREAM, if necessary. */
70 void flush_wrap_buffer ();
72 /* Contains characters which are waiting to be output (they have
73 already been counted in chars_printed). */
74 std::string m_wrap_buffer
;
76 /* Amount to indent by if the wrap occurs. */
77 int m_wrap_indent
= 0;
79 /* Column number on the screen where wrap_buffer begins, or 0 if
80 wrapping is not in effect. */
81 int m_wrap_column
= 0;
83 /* The style applied at the time that wrap_here was called. */
84 ui_file_style m_wrap_style
;
86 /* This is temporarily set when paging. This will cause some
87 methods to change their behavior to ignore the wrap buffer. */
88 bool m_paging
= false;
91 #endif /* GDB_PAGER_H */