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 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 <http://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. */ 36typedef int term_color_t; 37/* The value -1 denotes the default (foreground or background) color. */ 38enum 39{ 40 COLOR_DEFAULT = -1 /* unknown */ 41}; 42 43typedef enum 44{ 45 WEIGHT_NORMAL = 0, 46 WEIGHT_BOLD, 47 WEIGHT_DEFAULT = WEIGHT_NORMAL 48} term_weight_t; 49 50typedef enum 51{ 52 POSTURE_NORMAL = 0, 53 POSTURE_ITALIC, /* same as oblique */ 54 POSTURE_DEFAULT = POSTURE_NORMAL 55} term_posture_t; 56 57typedef 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" 65struct 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 70struct term_ostream_t 71{ 72private: 73 struct term_ostream_representation *_pointer; 74public: 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) {} 85}; 86#else 87typedef ostream_t term_ostream_t; 88#endif 89 90/* Functions that invoke the methods. */ 91extern void term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len); 92extern void term_ostream_flush (term_ostream_t first_arg); 93extern void term_ostream_free (term_ostream_t first_arg); 94extern term_color_t term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue); 95extern term_color_t term_ostream_get_color (term_ostream_t first_arg); 96extern void term_ostream_set_color (term_ostream_t first_arg, term_color_t color); 97extern term_color_t term_ostream_get_bgcolor (term_ostream_t first_arg); 98extern void term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color); 99extern term_weight_t term_ostream_get_weight (term_ostream_t first_arg); 100extern void term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight); 101extern term_posture_t term_ostream_get_posture (term_ostream_t first_arg); 102extern void term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture); 103extern term_underline_t term_ostream_get_underline (term_ostream_t first_arg); 104extern void term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline); 105 106/* Type representing an implementation of term_ostream_t. */ 107struct term_ostream_implementation 108{ 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" 114#undef THIS_ARG 115}; 116 117/* Public portion of the object pointed to by a term_ostream_t. */ 118struct term_ostream_representation_header 119{ 120 const struct term_ostream_implementation *vtable; 121}; 122 123#if HAVE_INLINE 124 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. */ 128 129# define term_ostream_write_mem term_ostream_write_mem_inline 130static inline void 131term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len) 132{ 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); 136} 137 138# define term_ostream_flush term_ostream_flush_inline 139static inline void 140term_ostream_flush (term_ostream_t first_arg) 141{ 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); 145} 146 147# define term_ostream_free term_ostream_free_inline 148static inline void 149term_ostream_free (term_ostream_t first_arg) 150{ 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); 154} 155 156# define term_ostream_rgb_to_color term_ostream_rgb_to_color_inline 157static inline term_color_t 158term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue) 159{ 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); 163} 164 165# define term_ostream_get_color term_ostream_get_color_inline 166static inline term_color_t 167term_ostream_get_color (term_ostream_t first_arg) 168{ 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); 172} 173 174# define term_ostream_set_color term_ostream_set_color_inline 175static inline void 176term_ostream_set_color (term_ostream_t first_arg, term_color_t color) 177{ 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); 181} 182 183# define term_ostream_get_bgcolor term_ostream_get_bgcolor_inline 184static inline term_color_t 185term_ostream_get_bgcolor (term_ostream_t first_arg) 186{ 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); 190} 191 192# define term_ostream_set_bgcolor term_ostream_set_bgcolor_inline 193static inline void 194term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color) 195{ 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); 199} 200 201# define term_ostream_get_weight term_ostream_get_weight_inline 202static inline term_weight_t 203term_ostream_get_weight (term_ostream_t first_arg) 204{ 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); 208} 209 210# define term_ostream_set_weight term_ostream_set_weight_inline 211static inline void 212term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight) 213{ 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); 217} 218 219# define term_ostream_get_posture term_ostream_get_posture_inline 220static inline term_posture_t 221term_ostream_get_posture (term_ostream_t first_arg) 222{ 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); 226} 227 228# define term_ostream_set_posture term_ostream_set_posture_inline 229static inline void 230term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture) 231{ 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); 235} 236 237# define term_ostream_get_underline term_ostream_get_underline_inline 238static inline term_underline_t 239term_ostream_get_underline (term_ostream_t first_arg) 240{ 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); 244} 245 246# define term_ostream_set_underline term_ostream_set_underline_inline 247static inline void 248term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline) 249{ 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); 253} 254 255#endif 256 257extern 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) 260 261extern const struct term_ostream_implementation term_ostream_vtable; 262 263#line 91 "term-ostream.oo.h" 264 265 266#ifdef __cplusplus 267extern "C" { 268#endif 269 270 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. */ 275extern term_ostream_t term_ostream_create (int fd, const char *filename); 276 277 278#ifdef __cplusplus 279} 280#endif 281 282#endif /* _TERM_OSTREAM_H */ 283