1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2
3 #line 1 "term-ostream.oo.h"
4 /* Output stream for attributed text, producing ANSI escape sequences.
5 Copyright (C) 2006, 2019-2020 Free Software Foundation, Inc.
6 Written by Bruno Haible <bruno@clisp.org>, 2006.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
20
21 #ifndef _TERM_OSTREAM_H
22 #define _TERM_OSTREAM_H
23
24 #include <stdbool.h>
25
26 #include "ostream.h"
27
28
29 /* Querying and setting of text attributes.
30 The stream has a notion of the current text attributes; they apply
31 implicitly to all following output. The attributes are automatically
32 reset when the stream is closed.
33 Note: Not all terminal types can actually render all attributes adequately.
34 For example, xterm cannot render POSTURE_ITALIC nor the combination of
35 WEIGHT_BOLD and UNDERLINE_ON. */
36
37 /* Colors are represented by indices >= 0 in a stream dependent format. */
38 typedef int term_color_t;
39 /* The value -1 denotes the default (foreground or background) color. */
40 enum
41 {
42 COLOR_DEFAULT = -1 /* unknown */
43 };
44
45 typedef enum
46 {
47 WEIGHT_NORMAL = 0,
48 WEIGHT_BOLD,
49 WEIGHT_DEFAULT = WEIGHT_NORMAL
50 } term_weight_t;
51
52 typedef enum
53 {
54 POSTURE_NORMAL = 0,
55 POSTURE_ITALIC, /* same as oblique */
56 POSTURE_DEFAULT = POSTURE_NORMAL
57 } term_posture_t;
58
59 typedef enum
60 {
61 UNDERLINE_OFF = 0,
62 UNDERLINE_ON,
63 UNDERLINE_DEFAULT = UNDERLINE_OFF
64 } term_underline_t;
65
66 /* Get ttyctl_t. */
67 #define term_style_user_data term_ostream_representation
68 #include "term-style-control.h"
69
70 #line 71 "term-ostream.h"
71 struct term_ostream_representation;
72 /* term_ostream_t is defined as a pointer to struct term_ostream_representation.
73 In C++ mode, we use a smart pointer class.
74 In C mode, we have no other choice than a typedef to the root class type. */
75 #if IS_CPLUSPLUS
76 struct term_ostream_t
77 {
78 private:
79 struct term_ostream_representation *_pointer;
80 public:
81 term_ostream_t () : _pointer (NULL) {}
82 term_ostream_t (struct term_ostream_representation *pointer) : _pointer (pointer) {}
83 struct term_ostream_representation * operator -> () { return _pointer; }
84 operator struct term_ostream_representation * () { return _pointer; }
85 operator struct any_ostream_representation * () { return (struct any_ostream_representation *) _pointer; }
86 operator void * () { return _pointer; }
87 bool operator == (const void *p) { return _pointer == p; }
88 bool operator != (const void *p) { return _pointer != p; }
89 operator ostream_t () { return (ostream_t) (struct any_ostream_representation *) _pointer; }
90 explicit term_ostream_t (ostream_t x) : _pointer ((struct term_ostream_representation *) (void *) x) {}
91 };
92 #else
93 typedef ostream_t term_ostream_t;
94 #endif
95
96 /* Functions that invoke the methods. */
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 extern void term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len);
101 extern void term_ostream_flush (term_ostream_t first_arg, ostream_flush_scope_t scope);
102 extern void term_ostream_free (term_ostream_t first_arg);
103 extern term_color_t term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue);
104 extern term_color_t term_ostream_get_color (term_ostream_t first_arg);
105 extern void term_ostream_set_color (term_ostream_t first_arg, term_color_t color);
106 extern term_color_t term_ostream_get_bgcolor (term_ostream_t first_arg);
107 extern void term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color);
108 extern term_weight_t term_ostream_get_weight (term_ostream_t first_arg);
109 extern void term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight);
110 extern term_posture_t term_ostream_get_posture (term_ostream_t first_arg);
111 extern void term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture);
112 extern term_underline_t term_ostream_get_underline (term_ostream_t first_arg);
113 extern void term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline);
114 extern const char * term_ostream_get_hyperlink_ref (term_ostream_t first_arg);
115 extern const char * term_ostream_get_hyperlink_id (term_ostream_t first_arg);
116 extern void term_ostream_set_hyperlink (term_ostream_t first_arg, const char *ref, const char *id);
117 extern void term_ostream_flush_to_current_style (term_ostream_t first_arg);
118 extern int term_ostream_get_descriptor (term_ostream_t first_arg);
119 extern const char * term_ostream_get_filename (term_ostream_t first_arg);
120 extern ttyctl_t term_ostream_get_tty_control (term_ostream_t first_arg);
121 extern ttyctl_t term_ostream_get_effective_tty_control (term_ostream_t first_arg);
122 #ifdef __cplusplus
123 }
124 #endif
125
126 /* Type representing an implementation of term_ostream_t. */
127 struct term_ostream_implementation
128 {
129 const typeinfo_t * const *superclasses;
130 size_t superclasses_length;
131 size_t instance_size;
132 #define THIS_ARG term_ostream_t first_arg
133 #include "term_ostream.vt.h"
134 #undef THIS_ARG
135 };
136
137 /* Public portion of the object pointed to by a term_ostream_t. */
138 struct term_ostream_representation_header
139 {
140 const struct term_ostream_implementation *vtable;
141 };
142
143 #if HAVE_INLINE
144
145 /* Define the functions that invoke the methods as inline accesses to
146 the term_ostream_implementation.
147 Use #define to avoid a warning because of extern vs. static. */
148
149 # define term_ostream_write_mem term_ostream_write_mem_inline
150 static inline void
151 term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len)
152 {
153 const struct term_ostream_implementation *vtable =
154 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
155 vtable->write_mem (first_arg,data,len);
156 }
157
158 # define term_ostream_flush term_ostream_flush_inline
159 static inline void
160 term_ostream_flush (term_ostream_t first_arg, ostream_flush_scope_t scope)
161 {
162 const struct term_ostream_implementation *vtable =
163 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
164 vtable->flush (first_arg,scope);
165 }
166
167 # define term_ostream_free term_ostream_free_inline
168 static inline void
169 term_ostream_free (term_ostream_t first_arg)
170 {
171 const struct term_ostream_implementation *vtable =
172 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
173 vtable->free (first_arg);
174 }
175
176 # define term_ostream_rgb_to_color term_ostream_rgb_to_color_inline
177 static inline term_color_t
178 term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue)
179 {
180 const struct term_ostream_implementation *vtable =
181 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
182 return vtable->rgb_to_color (first_arg,red,green,blue);
183 }
184
185 # define term_ostream_get_color term_ostream_get_color_inline
186 static inline term_color_t
187 term_ostream_get_color (term_ostream_t first_arg)
188 {
189 const struct term_ostream_implementation *vtable =
190 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
191 return vtable->get_color (first_arg);
192 }
193
194 # define term_ostream_set_color term_ostream_set_color_inline
195 static inline void
196 term_ostream_set_color (term_ostream_t first_arg, term_color_t color)
197 {
198 const struct term_ostream_implementation *vtable =
199 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
200 vtable->set_color (first_arg,color);
201 }
202
203 # define term_ostream_get_bgcolor term_ostream_get_bgcolor_inline
204 static inline term_color_t
205 term_ostream_get_bgcolor (term_ostream_t first_arg)
206 {
207 const struct term_ostream_implementation *vtable =
208 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
209 return vtable->get_bgcolor (first_arg);
210 }
211
212 # define term_ostream_set_bgcolor term_ostream_set_bgcolor_inline
213 static inline void
214 term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color)
215 {
216 const struct term_ostream_implementation *vtable =
217 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
218 vtable->set_bgcolor (first_arg,color);
219 }
220
221 # define term_ostream_get_weight term_ostream_get_weight_inline
222 static inline term_weight_t
223 term_ostream_get_weight (term_ostream_t first_arg)
224 {
225 const struct term_ostream_implementation *vtable =
226 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
227 return vtable->get_weight (first_arg);
228 }
229
230 # define term_ostream_set_weight term_ostream_set_weight_inline
231 static inline void
232 term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight)
233 {
234 const struct term_ostream_implementation *vtable =
235 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
236 vtable->set_weight (first_arg,weight);
237 }
238
239 # define term_ostream_get_posture term_ostream_get_posture_inline
240 static inline term_posture_t
241 term_ostream_get_posture (term_ostream_t first_arg)
242 {
243 const struct term_ostream_implementation *vtable =
244 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
245 return vtable->get_posture (first_arg);
246 }
247
248 # define term_ostream_set_posture term_ostream_set_posture_inline
249 static inline void
250 term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture)
251 {
252 const struct term_ostream_implementation *vtable =
253 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
254 vtable->set_posture (first_arg,posture);
255 }
256
257 # define term_ostream_get_underline term_ostream_get_underline_inline
258 static inline term_underline_t
259 term_ostream_get_underline (term_ostream_t first_arg)
260 {
261 const struct term_ostream_implementation *vtable =
262 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
263 return vtable->get_underline (first_arg);
264 }
265
266 # define term_ostream_set_underline term_ostream_set_underline_inline
267 static inline void
268 term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline)
269 {
270 const struct term_ostream_implementation *vtable =
271 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
272 vtable->set_underline (first_arg,underline);
273 }
274
275 # define term_ostream_get_hyperlink_ref term_ostream_get_hyperlink_ref_inline
276 static inline const char *
277 term_ostream_get_hyperlink_ref (term_ostream_t first_arg)
278 {
279 const struct term_ostream_implementation *vtable =
280 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
281 return vtable->get_hyperlink_ref (first_arg);
282 }
283
284 # define term_ostream_get_hyperlink_id term_ostream_get_hyperlink_id_inline
285 static inline const char *
286 term_ostream_get_hyperlink_id (term_ostream_t first_arg)
287 {
288 const struct term_ostream_implementation *vtable =
289 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
290 return vtable->get_hyperlink_id (first_arg);
291 }
292
293 # define term_ostream_set_hyperlink term_ostream_set_hyperlink_inline
294 static inline void
295 term_ostream_set_hyperlink (term_ostream_t first_arg, const char *ref, const char *id)
296 {
297 const struct term_ostream_implementation *vtable =
298 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
299 vtable->set_hyperlink (first_arg,ref,id);
300 }
301
302 # define term_ostream_flush_to_current_style term_ostream_flush_to_current_style_inline
303 static inline void
304 term_ostream_flush_to_current_style (term_ostream_t first_arg)
305 {
306 const struct term_ostream_implementation *vtable =
307 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
308 vtable->flush_to_current_style (first_arg);
309 }
310
311 # define term_ostream_get_descriptor term_ostream_get_descriptor_inline
312 static inline int
313 term_ostream_get_descriptor (term_ostream_t first_arg)
314 {
315 const struct term_ostream_implementation *vtable =
316 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
317 return vtable->get_descriptor (first_arg);
318 }
319
320 # define term_ostream_get_filename term_ostream_get_filename_inline
321 static inline const char *
322 term_ostream_get_filename (term_ostream_t first_arg)
323 {
324 const struct term_ostream_implementation *vtable =
325 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
326 return vtable->get_filename (first_arg);
327 }
328
329 # define term_ostream_get_tty_control term_ostream_get_tty_control_inline
330 static inline ttyctl_t
331 term_ostream_get_tty_control (term_ostream_t first_arg)
332 {
333 const struct term_ostream_implementation *vtable =
334 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
335 return vtable->get_tty_control (first_arg);
336 }
337
338 # define term_ostream_get_effective_tty_control term_ostream_get_effective_tty_control_inline
339 static inline ttyctl_t
340 term_ostream_get_effective_tty_control (term_ostream_t first_arg)
341 {
342 const struct term_ostream_implementation *vtable =
343 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
344 return vtable->get_effective_tty_control (first_arg);
345 }
346
347 #endif
348
349 extern const typeinfo_t term_ostream_typeinfo;
350 #define term_ostream_SUPERCLASSES &term_ostream_typeinfo, ostream_SUPERCLASSES
351 #define term_ostream_SUPERCLASSES_LENGTH (1 + ostream_SUPERCLASSES_LENGTH)
352
353 extern const struct term_ostream_implementation term_ostream_vtable;
354
355 #line 118 "term-ostream.oo.h"
356
357
358 #ifdef __cplusplus
359 extern "C" {
360 #endif
361
362
363 /* Create an output stream referring to the file descriptor FD.
364 FILENAME is used only for error messages.
365 TTY_CONTROL specifies the amount of control to take over the underlying tty.
366 The resulting stream will be line-buffered.
367 Note that the resulting stream must be closed before FD can be closed. */
368 extern term_ostream_t
369 term_ostream_create (int fd, const char *filename, ttyctl_t tty_control);
370
371
372 /* Test whether a given output stream is a term_ostream. */
373 extern bool is_instance_of_term_ostream (ostream_t stream);
374
375
376 #ifdef __cplusplus
377 }
378 #endif
379
380 #endif /* _TERM_OSTREAM_H */