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 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 "ostream.h"
25
26
27 /* Querying and setting of text attributes.
28 The stream has a notion of the current text attributes; they apply
29 implicitly to all following output. The attributes are automatically
30 reset when the stream is closed.
31 Note: Not all terminal types can actually render all attributes adequately.
32 For example, xterm cannot render POSTURE_ITALIC nor the combination of
33 WEIGHT_BOLD and UNDERLINE_ON. */
34
35 /* Colors are represented by indices >= 0 in a stream dependent format. */
36 typedef int term_color_t;
37 /* The value -1 denotes the default (foreground or background) color. */
38 enum
39 {
40 COLOR_DEFAULT = -1 /* unknown */
41 };
42
43 typedef enum
44 {
45 WEIGHT_NORMAL = 0,
46 WEIGHT_BOLD,
47 WEIGHT_DEFAULT = WEIGHT_NORMAL
48 } term_weight_t;
49
50 typedef enum
51 {
52 POSTURE_NORMAL = 0,
53 POSTURE_ITALIC, /* same as oblique */
54 POSTURE_DEFAULT = POSTURE_NORMAL
55 } term_posture_t;
56
57 typedef enum
58 {
59 UNDERLINE_OFF = 0,
60 UNDERLINE_ON,
61 UNDERLINE_DEFAULT = UNDERLINE_OFF
62 } term_underline_t;
63
64 #line 65 "term-ostream.h"
65 struct term_ostream_representation;
66 /* term_ostream_t is defined as a pointer to struct term_ostream_representation.
67 In C++ mode, we use a smart pointer class.
68 In C mode, we have no other choice than a typedef to the root class type. */
69 #if IS_CPLUSPLUS
70 struct term_ostream_t
71 {
72 private:
73 struct term_ostream_representation *_pointer;
74 public:
term_ostream_tterm_ostream_t75 term_ostream_t () : _pointer (NULL) {}
term_ostream_tterm_ostream_t76 term_ostream_t (struct term_ostream_representation *pointer) : _pointer (pointer) {}
77 struct term_ostream_representation * operator -> () { return _pointer; }
78 operator struct term_ostream_representation * () { return _pointer; }
79 operator struct any_ostream_representation * () { return (struct any_ostream_representation *) _pointer; }
80 operator void * () { return _pointer; }
81 bool operator == (const void *p) { return _pointer == p; }
82 bool operator != (const void *p) { return _pointer != p; }
ostream_tterm_ostream_t83 operator ostream_t () { return (ostream_t) (struct any_ostream_representation *) _pointer; }
term_ostream_tterm_ostream_t84 explicit term_ostream_t (ostream_t x) : _pointer ((struct term_ostream_representation *) (void *) x) {}
85 };
86 #else
87 typedef ostream_t term_ostream_t;
88 #endif
89
90 /* Functions that invoke the methods. */
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 extern void term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len);
95 extern void term_ostream_flush (term_ostream_t first_arg, ostream_flush_scope_t scope);
96 extern void term_ostream_free (term_ostream_t first_arg);
97 extern term_color_t term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue);
98 extern term_color_t term_ostream_get_color (term_ostream_t first_arg);
99 extern void term_ostream_set_color (term_ostream_t first_arg, term_color_t color);
100 extern term_color_t term_ostream_get_bgcolor (term_ostream_t first_arg);
101 extern void term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color);
102 extern term_weight_t term_ostream_get_weight (term_ostream_t first_arg);
103 extern void term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight);
104 extern term_posture_t term_ostream_get_posture (term_ostream_t first_arg);
105 extern void term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture);
106 extern term_underline_t term_ostream_get_underline (term_ostream_t first_arg);
107 extern void term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline);
108 extern const char * term_ostream_get_hyperlink_ref (term_ostream_t first_arg);
109 extern const char * term_ostream_get_hyperlink_id (term_ostream_t first_arg);
110 extern void term_ostream_set_hyperlink (term_ostream_t first_arg, const char *ref, const char *id);
111 extern void term_ostream_flush_to_current_style (term_ostream_t first_arg);
112 #ifdef __cplusplus
113 }
114 #endif
115
116 /* Type representing an implementation of term_ostream_t. */
117 struct term_ostream_implementation
118 {
119 const typeinfo_t * const *superclasses;
120 size_t superclasses_length;
121 size_t instance_size;
122 #define THIS_ARG term_ostream_t first_arg
123 #include "term_ostream.vt.h"
124 #undef THIS_ARG
125 };
126
127 /* Public portion of the object pointed to by a term_ostream_t. */
128 struct term_ostream_representation_header
129 {
130 const struct term_ostream_implementation *vtable;
131 };
132
133 #if HAVE_INLINE
134
135 /* Define the functions that invoke the methods as inline accesses to
136 the term_ostream_implementation.
137 Use #define to avoid a warning because of extern vs. static. */
138
139 # define term_ostream_write_mem term_ostream_write_mem_inline
140 static inline void
term_ostream_write_mem(term_ostream_t first_arg,const void * data,size_t len)141 term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len)
142 {
143 const struct term_ostream_implementation *vtable =
144 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
145 vtable->write_mem (first_arg,data,len);
146 }
147
148 # define term_ostream_flush term_ostream_flush_inline
149 static inline void
term_ostream_flush(term_ostream_t first_arg,ostream_flush_scope_t scope)150 term_ostream_flush (term_ostream_t first_arg, ostream_flush_scope_t scope)
151 {
152 const struct term_ostream_implementation *vtable =
153 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
154 vtable->flush (first_arg,scope);
155 }
156
157 # define term_ostream_free term_ostream_free_inline
158 static inline void
term_ostream_free(term_ostream_t first_arg)159 term_ostream_free (term_ostream_t first_arg)
160 {
161 const struct term_ostream_implementation *vtable =
162 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
163 vtable->free (first_arg);
164 }
165
166 # define term_ostream_rgb_to_color term_ostream_rgb_to_color_inline
167 static inline term_color_t
term_ostream_rgb_to_color(term_ostream_t first_arg,int red,int green,int blue)168 term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue)
169 {
170 const struct term_ostream_implementation *vtable =
171 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
172 return vtable->rgb_to_color (first_arg,red,green,blue);
173 }
174
175 # define term_ostream_get_color term_ostream_get_color_inline
176 static inline term_color_t
term_ostream_get_color(term_ostream_t first_arg)177 term_ostream_get_color (term_ostream_t first_arg)
178 {
179 const struct term_ostream_implementation *vtable =
180 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
181 return vtable->get_color (first_arg);
182 }
183
184 # define term_ostream_set_color term_ostream_set_color_inline
185 static inline void
term_ostream_set_color(term_ostream_t first_arg,term_color_t color)186 term_ostream_set_color (term_ostream_t first_arg, term_color_t color)
187 {
188 const struct term_ostream_implementation *vtable =
189 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
190 vtable->set_color (first_arg,color);
191 }
192
193 # define term_ostream_get_bgcolor term_ostream_get_bgcolor_inline
194 static inline term_color_t
term_ostream_get_bgcolor(term_ostream_t first_arg)195 term_ostream_get_bgcolor (term_ostream_t first_arg)
196 {
197 const struct term_ostream_implementation *vtable =
198 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
199 return vtable->get_bgcolor (first_arg);
200 }
201
202 # define term_ostream_set_bgcolor term_ostream_set_bgcolor_inline
203 static inline void
term_ostream_set_bgcolor(term_ostream_t first_arg,term_color_t color)204 term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color)
205 {
206 const struct term_ostream_implementation *vtable =
207 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
208 vtable->set_bgcolor (first_arg,color);
209 }
210
211 # define term_ostream_get_weight term_ostream_get_weight_inline
212 static inline term_weight_t
term_ostream_get_weight(term_ostream_t first_arg)213 term_ostream_get_weight (term_ostream_t first_arg)
214 {
215 const struct term_ostream_implementation *vtable =
216 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
217 return vtable->get_weight (first_arg);
218 }
219
220 # define term_ostream_set_weight term_ostream_set_weight_inline
221 static inline void
term_ostream_set_weight(term_ostream_t first_arg,term_weight_t weight)222 term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight)
223 {
224 const struct term_ostream_implementation *vtable =
225 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
226 vtable->set_weight (first_arg,weight);
227 }
228
229 # define term_ostream_get_posture term_ostream_get_posture_inline
230 static inline term_posture_t
term_ostream_get_posture(term_ostream_t first_arg)231 term_ostream_get_posture (term_ostream_t first_arg)
232 {
233 const struct term_ostream_implementation *vtable =
234 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
235 return vtable->get_posture (first_arg);
236 }
237
238 # define term_ostream_set_posture term_ostream_set_posture_inline
239 static inline void
term_ostream_set_posture(term_ostream_t first_arg,term_posture_t posture)240 term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture)
241 {
242 const struct term_ostream_implementation *vtable =
243 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
244 vtable->set_posture (first_arg,posture);
245 }
246
247 # define term_ostream_get_underline term_ostream_get_underline_inline
248 static inline term_underline_t
term_ostream_get_underline(term_ostream_t first_arg)249 term_ostream_get_underline (term_ostream_t first_arg)
250 {
251 const struct term_ostream_implementation *vtable =
252 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
253 return vtable->get_underline (first_arg);
254 }
255
256 # define term_ostream_set_underline term_ostream_set_underline_inline
257 static inline void
term_ostream_set_underline(term_ostream_t first_arg,term_underline_t underline)258 term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline)
259 {
260 const struct term_ostream_implementation *vtable =
261 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
262 vtable->set_underline (first_arg,underline);
263 }
264
265 # define term_ostream_get_hyperlink_ref term_ostream_get_hyperlink_ref_inline
266 static inline const char *
term_ostream_get_hyperlink_ref(term_ostream_t first_arg)267 term_ostream_get_hyperlink_ref (term_ostream_t first_arg)
268 {
269 const struct term_ostream_implementation *vtable =
270 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
271 return vtable->get_hyperlink_ref (first_arg);
272 }
273
274 # define term_ostream_get_hyperlink_id term_ostream_get_hyperlink_id_inline
275 static inline const char *
term_ostream_get_hyperlink_id(term_ostream_t first_arg)276 term_ostream_get_hyperlink_id (term_ostream_t first_arg)
277 {
278 const struct term_ostream_implementation *vtable =
279 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
280 return vtable->get_hyperlink_id (first_arg);
281 }
282
283 # define term_ostream_set_hyperlink term_ostream_set_hyperlink_inline
284 static inline void
term_ostream_set_hyperlink(term_ostream_t first_arg,const char * ref,const char * id)285 term_ostream_set_hyperlink (term_ostream_t first_arg, const char *ref, const char *id)
286 {
287 const struct term_ostream_implementation *vtable =
288 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
289 vtable->set_hyperlink (first_arg,ref,id);
290 }
291
292 # define term_ostream_flush_to_current_style term_ostream_flush_to_current_style_inline
293 static inline void
term_ostream_flush_to_current_style(term_ostream_t first_arg)294 term_ostream_flush_to_current_style (term_ostream_t first_arg)
295 {
296 const struct term_ostream_implementation *vtable =
297 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
298 vtable->flush_to_current_style (first_arg);
299 }
300
301 #endif
302
303 extern const typeinfo_t term_ostream_typeinfo;
304 #define term_ostream_SUPERCLASSES &term_ostream_typeinfo, ostream_SUPERCLASSES
305 #define term_ostream_SUPERCLASSES_LENGTH (1 + ostream_SUPERCLASSES_LENGTH)
306
307 extern const struct term_ostream_implementation term_ostream_vtable;
308
309 #line 106 "term-ostream.oo.h"
310
311 /* Get ttyctl_t. */
312 #define term_style_user_data term_ostream_representation
313 #include "term-style-control.h"
314
315
316 #ifdef __cplusplus
317 extern "C" {
318 #endif
319
320
321 /* Create an output stream referring to the file descriptor FD.
322 FILENAME is used only for error messages.
323 TTY_CONTROL specifies the amount of control to take over the underlying tty.
324 The resulting stream will be line-buffered.
325 Note that the resulting stream must be closed before FD can be closed. */
326 extern term_ostream_t
327 term_ostream_create (int fd, const char *filename, ttyctl_t tty_control);
328
329
330 #ifdef __cplusplus
331 }
332 #endif
333
334 #endif /* _TERM_OSTREAM_H */
335