1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 #line 1 "term-ostream.oo.h"
4 /* Output stream for attributed text, producing ANSI escape sequences.
5 Copyright (C) 2006, 2015 Free Software Foundation, Inc.
6 Written by Bruno Haible <bruno@clisp.org>, 2006.
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.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #ifndef _TERM_OSTREAM_H
22 #define _TERM_OSTREAM_H
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. */
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. */
40 COLOR_DEFAULT = -1 /* unknown */
47 WEIGHT_DEFAULT = WEIGHT_NORMAL
53 POSTURE_ITALIC, /* same as oblique */
54 POSTURE_DEFAULT = POSTURE_NORMAL
61 UNDERLINE_DEFAULT = UNDERLINE_OFF
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. */
73 struct term_ostream_representation *_pointer;
75 term_ostream_t () : _pointer (NULL) {}
76 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; }
83 operator ostream_t () { return (ostream_t) (struct any_ostream_representation *) _pointer; }
84 explicit term_ostream_t (ostream_t x) : _pointer ((struct term_ostream_representation *) (void *) x) {}
87 typedef ostream_t term_ostream_t;
90 /* Functions that invoke the methods. */
91 extern void term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len);
92 extern void term_ostream_flush (term_ostream_t first_arg);
93 extern void term_ostream_free (term_ostream_t first_arg);
94 extern term_color_t term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue);
95 extern term_color_t term_ostream_get_color (term_ostream_t first_arg);
96 extern void term_ostream_set_color (term_ostream_t first_arg, term_color_t color);
97 extern term_color_t term_ostream_get_bgcolor (term_ostream_t first_arg);
98 extern void term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color);
99 extern term_weight_t term_ostream_get_weight (term_ostream_t first_arg);
100 extern void term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight);
101 extern term_posture_t term_ostream_get_posture (term_ostream_t first_arg);
102 extern void term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture);
103 extern term_underline_t term_ostream_get_underline (term_ostream_t first_arg);
104 extern void term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline);
106 /* Type representing an implementation of term_ostream_t. */
107 struct term_ostream_implementation
109 const typeinfo_t * const *superclasses;
110 size_t superclasses_length;
111 size_t instance_size;
112 #define THIS_ARG term_ostream_t first_arg
113 #include "term_ostream.vt.h"
117 /* Public portion of the object pointed to by a term_ostream_t. */
118 struct term_ostream_representation_header
120 const struct term_ostream_implementation *vtable;
125 /* Define the functions that invoke the methods as inline accesses to
126 the term_ostream_implementation.
127 Use #define to avoid a warning because of extern vs. static. */
129 # define term_ostream_write_mem term_ostream_write_mem_inline
131 term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len)
133 const struct term_ostream_implementation *vtable =
134 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
135 vtable->write_mem (first_arg,data,len);
138 # define term_ostream_flush term_ostream_flush_inline
140 term_ostream_flush (term_ostream_t first_arg)
142 const struct term_ostream_implementation *vtable =
143 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
144 vtable->flush (first_arg);
147 # define term_ostream_free term_ostream_free_inline
149 term_ostream_free (term_ostream_t first_arg)
151 const struct term_ostream_implementation *vtable =
152 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
153 vtable->free (first_arg);
156 # define term_ostream_rgb_to_color term_ostream_rgb_to_color_inline
157 static inline term_color_t
158 term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue)
160 const struct term_ostream_implementation *vtable =
161 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
162 return vtable->rgb_to_color (first_arg,red,green,blue);
165 # define term_ostream_get_color term_ostream_get_color_inline
166 static inline term_color_t
167 term_ostream_get_color (term_ostream_t first_arg)
169 const struct term_ostream_implementation *vtable =
170 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
171 return vtable->get_color (first_arg);
174 # define term_ostream_set_color term_ostream_set_color_inline
176 term_ostream_set_color (term_ostream_t first_arg, term_color_t color)
178 const struct term_ostream_implementation *vtable =
179 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
180 vtable->set_color (first_arg,color);
183 # define term_ostream_get_bgcolor term_ostream_get_bgcolor_inline
184 static inline term_color_t
185 term_ostream_get_bgcolor (term_ostream_t first_arg)
187 const struct term_ostream_implementation *vtable =
188 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
189 return vtable->get_bgcolor (first_arg);
192 # define term_ostream_set_bgcolor term_ostream_set_bgcolor_inline
194 term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color)
196 const struct term_ostream_implementation *vtable =
197 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
198 vtable->set_bgcolor (first_arg,color);
201 # define term_ostream_get_weight term_ostream_get_weight_inline
202 static inline term_weight_t
203 term_ostream_get_weight (term_ostream_t first_arg)
205 const struct term_ostream_implementation *vtable =
206 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
207 return vtable->get_weight (first_arg);
210 # define term_ostream_set_weight term_ostream_set_weight_inline
212 term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight)
214 const struct term_ostream_implementation *vtable =
215 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
216 vtable->set_weight (first_arg,weight);
219 # define term_ostream_get_posture term_ostream_get_posture_inline
220 static inline term_posture_t
221 term_ostream_get_posture (term_ostream_t first_arg)
223 const struct term_ostream_implementation *vtable =
224 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
225 return vtable->get_posture (first_arg);
228 # define term_ostream_set_posture term_ostream_set_posture_inline
230 term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture)
232 const struct term_ostream_implementation *vtable =
233 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
234 vtable->set_posture (first_arg,posture);
237 # define term_ostream_get_underline term_ostream_get_underline_inline
238 static inline term_underline_t
239 term_ostream_get_underline (term_ostream_t first_arg)
241 const struct term_ostream_implementation *vtable =
242 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
243 return vtable->get_underline (first_arg);
246 # define term_ostream_set_underline term_ostream_set_underline_inline
248 term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline)
250 const struct term_ostream_implementation *vtable =
251 ((struct term_ostream_representation_header *) (struct term_ostream_representation *) first_arg)->vtable;
252 vtable->set_underline (first_arg,underline);
257 extern const typeinfo_t term_ostream_typeinfo;
258 #define term_ostream_SUPERCLASSES &term_ostream_typeinfo, ostream_SUPERCLASSES
259 #define term_ostream_SUPERCLASSES_LENGTH (1 + ostream_SUPERCLASSES_LENGTH)
261 extern const struct term_ostream_implementation term_ostream_vtable;
263 #line 91 "term-ostream.oo.h"
271 /* Create an output stream referring to the file descriptor FD.
272 FILENAME is used only for error messages.
273 The resulting stream will be line-buffered.
274 Note that the resulting stream must be closed before FD can be closed. */
275 extern term_ostream_t term_ostream_create (int fd, const char *filename);
282 #endif /* _TERM_OSTREAM_H */