]>
Commit | Line | Data |
---|---|---|
3cd52293 | 1 | /* Output pager for gdb |
1d506c26 | 2 | Copyright (C) 2021-2024 Free Software Foundation, Inc. |
3cd52293 TT |
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 | |
8 | the Free Software Foundation; either version 3 of the License, or | |
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 | |
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
18 | ||
19 | #ifndef GDB_PAGER_H | |
20 | #define GDB_PAGER_H | |
21 | ||
22 | #include "ui-file.h" | |
23 | ||
24 | /* A ui_file that implements output paging and unfiltered output. */ | |
25 | ||
c269d90a | 26 | class pager_file : public wrapped_file |
3cd52293 TT |
27 | { |
28 | public: | |
29 | /* Create a new pager_file. The new object takes ownership of | |
30 | STREAM. */ | |
31 | explicit pager_file (ui_file *stream) | |
c269d90a | 32 | : wrapped_file (stream) |
3cd52293 TT |
33 | { |
34 | } | |
35 | ||
c269d90a TT |
36 | ~pager_file () |
37 | { | |
38 | delete m_stream; | |
39 | } | |
40 | ||
3cd52293 TT |
41 | DISABLE_COPY_AND_ASSIGN (pager_file); |
42 | ||
43 | void write (const char *buf, long length_buf) override; | |
44 | ||
45 | void puts (const char *str) override; | |
46 | ||
47 | void write_async_safe (const char *buf, long length_buf) override | |
48 | { | |
49 | m_stream->write_async_safe (buf, length_buf); | |
50 | } | |
51 | ||
3cd52293 TT |
52 | void emit_style_escape (const ui_file_style &style) override; |
53 | void reset_style () override; | |
54 | ||
55 | void flush () override; | |
56 | ||
3cd52293 TT |
57 | void wrap_here (int indent) override; |
58 | ||
59 | void puts_unfiltered (const char *str) override | |
60 | { | |
61 | flush_wrap_buffer (); | |
62 | m_stream->puts_unfiltered (str); | |
63 | } | |
64 | ||
65 | private: | |
66 | ||
67 | void prompt_for_continue (); | |
68 | ||
69 | /* Flush the wrap buffer to STREAM, if necessary. */ | |
70 | void flush_wrap_buffer (); | |
71 | ||
72 | /* Contains characters which are waiting to be output (they have | |
73 | already been counted in chars_printed). */ | |
74 | std::string m_wrap_buffer; | |
75 | ||
76 | /* Amount to indent by if the wrap occurs. */ | |
77 | int m_wrap_indent = 0; | |
78 | ||
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; | |
82 | ||
83 | /* The style applied at the time that wrap_here was called. */ | |
84 | ui_file_style m_wrap_style; | |
85 | ||
3cd52293 TT |
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; | |
89 | }; | |
90 | ||
91 | #endif /* GDB_PAGER_H */ |