annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/textstyle.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /* Public API of the libtextstyle library.
jpayne@69 2 Copyright (C) 2006-2007, 2019-2021 Free Software Foundation, Inc.
jpayne@69 3
jpayne@69 4 This program is free software: you can redistribute it and/or modify
jpayne@69 5 it under the terms of the GNU General Public License as published by
jpayne@69 6 the Free Software Foundation; either version 3 of the License, or
jpayne@69 7 (at your option) any later version.
jpayne@69 8
jpayne@69 9 This program is distributed in the hope that it will be useful,
jpayne@69 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
jpayne@69 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
jpayne@69 12 GNU General Public License for more details.
jpayne@69 13
jpayne@69 14 You should have received a copy of the GNU General Public License
jpayne@69 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
jpayne@69 16
jpayne@69 17 /* Written by Bruno Haible <bruno@clisp.org>, 2006, 2019. */
jpayne@69 18
jpayne@69 19 #ifndef _TEXTSTYLE_H
jpayne@69 20 #define _TEXTSTYLE_H
jpayne@69 21
jpayne@69 22 #include <stdarg.h>
jpayne@69 23 #include <stddef.h>
jpayne@69 24 #include <stdio.h>
jpayne@69 25 #include <textstyle/stdbool.h>
jpayne@69 26 #include <textstyle/woe32dll.h>
jpayne@69 27
jpayne@69 28 /* Meta information. */
jpayne@69 29 #include <textstyle/version.h>
jpayne@69 30
jpayne@69 31 /* ----------------------------- From ostream.h ----------------------------- */
jpayne@69 32
jpayne@69 33 /* Describes the scope of a flush operation. */
jpayne@69 34 typedef enum
jpayne@69 35 {
jpayne@69 36 /* Flushes buffers in this ostream_t.
jpayne@69 37 Use this value if you want to write to the underlying ostream_t. */
jpayne@69 38 FLUSH_THIS_STREAM = 0,
jpayne@69 39 /* Flushes all buffers in the current process.
jpayne@69 40 Use this value if you want to write to the same target through a
jpayne@69 41 different file descriptor or a FILE stream. */
jpayne@69 42 FLUSH_THIS_PROCESS = 1,
jpayne@69 43 /* Flushes buffers in the current process and attempts to flush the buffers
jpayne@69 44 in the kernel.
jpayne@69 45 Use this value so that some other process (or the kernel itself)
jpayne@69 46 may write to the same target. */
jpayne@69 47 FLUSH_ALL = 2
jpayne@69 48 } ostream_flush_scope_t;
jpayne@69 49
jpayne@69 50
jpayne@69 51 /* An output stream is an object to which one can feed a sequence of bytes. */
jpayne@69 52
jpayne@69 53 struct any_ostream_representation;
jpayne@69 54 typedef struct any_ostream_representation * ostream_t;
jpayne@69 55
jpayne@69 56 /* Functions that invoke the methods. */
jpayne@69 57 #ifdef __cplusplus
jpayne@69 58 extern "C" {
jpayne@69 59 #endif
jpayne@69 60 extern void ostream_write_mem (ostream_t first_arg, const void *data, size_t len);
jpayne@69 61 extern void ostream_flush (ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 62 extern void ostream_free (ostream_t first_arg);
jpayne@69 63 #ifdef __cplusplus
jpayne@69 64 }
jpayne@69 65 #endif
jpayne@69 66
jpayne@69 67 #ifdef __cplusplus
jpayne@69 68 extern "C" {
jpayne@69 69 #endif
jpayne@69 70
jpayne@69 71 /* Write a string's contents to a stream. */
jpayne@69 72 extern void ostream_write_str (ostream_t stream, const char *string);
jpayne@69 73
jpayne@69 74 /* Writes formatted output to a stream.
jpayne@69 75 Returns the size of formatted output, or a negative value in case of an
jpayne@69 76 error. */
jpayne@69 77 extern ptrdiff_t ostream_printf (ostream_t stream, const char *format, ...)
jpayne@69 78 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3
jpayne@69 79 __attribute__ ((__format__ (__printf__, 2, 3)))
jpayne@69 80 #endif
jpayne@69 81 ;
jpayne@69 82 extern ptrdiff_t ostream_vprintf (ostream_t stream,
jpayne@69 83 const char *format, va_list args)
jpayne@69 84 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3
jpayne@69 85 __attribute__ ((__format__ (__printf__, 2, 0)))
jpayne@69 86 #endif
jpayne@69 87 ;
jpayne@69 88
jpayne@69 89 #ifdef __cplusplus
jpayne@69 90 }
jpayne@69 91 #endif
jpayne@69 92
jpayne@69 93 /* ------------------------- From styled-ostream.h ------------------------- */
jpayne@69 94
jpayne@69 95 /* A styled output stream is an object to which one can feed a sequence of
jpayne@69 96 bytes, marking some runs of text as belonging to specific CSS classes,
jpayne@69 97 where the rendering of the CSS classes is defined through a CSS (cascading
jpayne@69 98 style sheet). */
jpayne@69 99
jpayne@69 100 /* styled_ostream_t is a subtype of ostream_t. */
jpayne@69 101 typedef ostream_t styled_ostream_t;
jpayne@69 102
jpayne@69 103 /* Functions that invoke the methods. */
jpayne@69 104 #ifdef __cplusplus
jpayne@69 105 extern "C" {
jpayne@69 106 #endif
jpayne@69 107 extern void styled_ostream_write_mem (styled_ostream_t first_arg, const void *data, size_t len);
jpayne@69 108 extern void styled_ostream_flush (styled_ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 109 extern void styled_ostream_free (styled_ostream_t first_arg);
jpayne@69 110 extern void styled_ostream_begin_use_class (styled_ostream_t first_arg, const char *classname);
jpayne@69 111 extern void styled_ostream_end_use_class (styled_ostream_t first_arg, const char *classname);
jpayne@69 112 extern const char *styled_ostream_get_hyperlink_ref (styled_ostream_t first_arg);
jpayne@69 113 extern const char *styled_ostream_get_hyperlink_id (styled_ostream_t first_arg);
jpayne@69 114 extern void styled_ostream_set_hyperlink (styled_ostream_t first_arg, const char *ref, const char *id);
jpayne@69 115 /* Like styled_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it
jpayne@69 116 leaves the destination with the current text style enabled, instead
jpayne@69 117 of with the default text style.
jpayne@69 118 After calling this function, you can output strings without newlines(!)
jpayne@69 119 to the underlying stream, and they will be rendered like strings passed
jpayne@69 120 to 'ostream_write_mem', 'ostream_write_str', or 'ostream_write_printf'. */
jpayne@69 121 extern void styled_ostream_flush_to_current_style (styled_ostream_t stream);
jpayne@69 122 #ifdef __cplusplus
jpayne@69 123 }
jpayne@69 124 #endif
jpayne@69 125
jpayne@69 126 #ifdef __cplusplus
jpayne@69 127 extern "C" {
jpayne@69 128 #endif
jpayne@69 129
jpayne@69 130
jpayne@69 131 /* Test whether a given output stream is a styled_ostream. */
jpayne@69 132 extern bool is_instance_of_styled_ostream (ostream_t stream);
jpayne@69 133
jpayne@69 134
jpayne@69 135 #ifdef __cplusplus
jpayne@69 136 }
jpayne@69 137 #endif
jpayne@69 138
jpayne@69 139 /* -------------------------- From file-ostream.h -------------------------- */
jpayne@69 140
jpayne@69 141 /* file_ostream_t is a subtype of ostream_t. */
jpayne@69 142 typedef ostream_t file_ostream_t;
jpayne@69 143
jpayne@69 144 /* Functions that invoke the methods. */
jpayne@69 145 #ifdef __cplusplus
jpayne@69 146 extern "C" {
jpayne@69 147 #endif
jpayne@69 148 extern void file_ostream_write_mem (file_ostream_t first_arg, const void *data, size_t len);
jpayne@69 149 extern void file_ostream_flush (file_ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 150 extern void file_ostream_free (file_ostream_t first_arg);
jpayne@69 151 /* Accessors. */
jpayne@69 152 extern FILE *file_ostream_get_stdio_stream (file_ostream_t stream);
jpayne@69 153 #ifdef __cplusplus
jpayne@69 154 }
jpayne@69 155 #endif
jpayne@69 156
jpayne@69 157 #ifdef __cplusplus
jpayne@69 158 extern "C" {
jpayne@69 159 #endif
jpayne@69 160
jpayne@69 161
jpayne@69 162 /* Create an output stream referring to FP.
jpayne@69 163 Note that the resulting stream must be closed before FP can be closed. */
jpayne@69 164 extern file_ostream_t file_ostream_create (FILE *fp);
jpayne@69 165
jpayne@69 166
jpayne@69 167 /* Test whether a given output stream is a file_ostream. */
jpayne@69 168 extern bool is_instance_of_file_ostream (ostream_t stream);
jpayne@69 169
jpayne@69 170
jpayne@69 171 #ifdef __cplusplus
jpayne@69 172 }
jpayne@69 173 #endif
jpayne@69 174
jpayne@69 175 /* --------------------------- From fd-ostream.h --------------------------- */
jpayne@69 176
jpayne@69 177 /* fd_ostream_t is a subtype of ostream_t. */
jpayne@69 178 typedef ostream_t fd_ostream_t;
jpayne@69 179
jpayne@69 180 /* Functions that invoke the methods. */
jpayne@69 181 #ifdef __cplusplus
jpayne@69 182 extern "C" {
jpayne@69 183 #endif
jpayne@69 184 extern void fd_ostream_write_mem (fd_ostream_t first_arg, const void *data, size_t len);
jpayne@69 185 extern void fd_ostream_flush (fd_ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 186 extern void fd_ostream_free (fd_ostream_t first_arg);
jpayne@69 187 /* Accessors. */
jpayne@69 188 extern int fd_ostream_get_descriptor (fd_ostream_t stream);
jpayne@69 189 extern const char *fd_ostream_get_filename (fd_ostream_t stream);
jpayne@69 190 extern bool fd_ostream_is_buffered (fd_ostream_t stream);
jpayne@69 191 #ifdef __cplusplus
jpayne@69 192 }
jpayne@69 193 #endif
jpayne@69 194
jpayne@69 195 #ifdef __cplusplus
jpayne@69 196 extern "C" {
jpayne@69 197 #endif
jpayne@69 198
jpayne@69 199
jpayne@69 200 /* Create an output stream referring to the file descriptor FD.
jpayne@69 201 FILENAME is used only for error messages.
jpayne@69 202 Note that the resulting stream must be closed before FD can be closed. */
jpayne@69 203 extern fd_ostream_t fd_ostream_create (int fd, const char *filename,
jpayne@69 204 bool buffered);
jpayne@69 205
jpayne@69 206
jpayne@69 207 /* Test whether a given output stream is a fd_ostream. */
jpayne@69 208 extern bool is_instance_of_fd_ostream (ostream_t stream);
jpayne@69 209
jpayne@69 210
jpayne@69 211 #ifdef __cplusplus
jpayne@69 212 }
jpayne@69 213 #endif
jpayne@69 214
jpayne@69 215 /* -------------------------- From term-ostream.h -------------------------- */
jpayne@69 216
jpayne@69 217 /* Querying and setting of text attributes.
jpayne@69 218 The stream has a notion of the current text attributes; they apply
jpayne@69 219 implicitly to all following output. The attributes are automatically
jpayne@69 220 reset when the stream is closed.
jpayne@69 221 Note: Not all terminal types can actually render all attributes adequately.
jpayne@69 222 For example, xterm cannot render POSTURE_ITALIC nor the combination of
jpayne@69 223 WEIGHT_BOLD and UNDERLINE_ON. */
jpayne@69 224
jpayne@69 225 /* Colors are represented by indices >= 0 in a stream dependent format. */
jpayne@69 226 typedef int term_color_t;
jpayne@69 227 /* The value -1 denotes the default (foreground or background) color. */
jpayne@69 228 enum
jpayne@69 229 {
jpayne@69 230 COLOR_DEFAULT = -1 /* unknown */
jpayne@69 231 };
jpayne@69 232
jpayne@69 233 typedef enum
jpayne@69 234 {
jpayne@69 235 WEIGHT_NORMAL = 0,
jpayne@69 236 WEIGHT_BOLD,
jpayne@69 237 WEIGHT_DEFAULT = WEIGHT_NORMAL
jpayne@69 238 } term_weight_t;
jpayne@69 239
jpayne@69 240 typedef enum
jpayne@69 241 {
jpayne@69 242 POSTURE_NORMAL = 0,
jpayne@69 243 POSTURE_ITALIC, /* same as oblique */
jpayne@69 244 POSTURE_DEFAULT = POSTURE_NORMAL
jpayne@69 245 } term_posture_t;
jpayne@69 246
jpayne@69 247 typedef enum
jpayne@69 248 {
jpayne@69 249 UNDERLINE_OFF = 0,
jpayne@69 250 UNDERLINE_ON,
jpayne@69 251 UNDERLINE_DEFAULT = UNDERLINE_OFF
jpayne@69 252 } term_underline_t;
jpayne@69 253
jpayne@69 254 /* The amount of control to take over the underlying tty in order to avoid
jpayne@69 255 garbled output on the screen, due to interleaved output of escape sequences
jpayne@69 256 and output from the kernel (such as when the kernel echoes user's input
jpayne@69 257 or when the kernel prints '^C' after the user pressed Ctrl-C). */
jpayne@69 258 typedef enum
jpayne@69 259 {
jpayne@69 260 TTYCTL_AUTO = 0, /* Automatic best-possible choice. */
jpayne@69 261 TTYCTL_NONE, /* No control.
jpayne@69 262 Result: Garbled output can occur, and the terminal can
jpayne@69 263 be left in any state when the program is interrupted. */
jpayne@69 264 TTYCTL_PARTIAL, /* Signal handling.
jpayne@69 265 Result: Garbled output can occur, but the terminal will
jpayne@69 266 be left in the default state when the program is
jpayne@69 267 interrupted. */
jpayne@69 268 TTYCTL_FULL /* Signal handling and disabling echo and flush-upon-signal.
jpayne@69 269 Result: No garbled output, and the the terminal will
jpayne@69 270 be left in the default state when the program is
jpayne@69 271 interrupted. */
jpayne@69 272 } ttyctl_t;
jpayne@69 273
jpayne@69 274 /* term_ostream_t is a subtype of ostream_t. */
jpayne@69 275 typedef ostream_t term_ostream_t;
jpayne@69 276
jpayne@69 277 /* Functions that invoke the methods. */
jpayne@69 278 #ifdef __cplusplus
jpayne@69 279 extern "C" {
jpayne@69 280 #endif
jpayne@69 281 extern void term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len);
jpayne@69 282 extern void term_ostream_flush (term_ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 283 extern void term_ostream_free (term_ostream_t first_arg);
jpayne@69 284 extern term_color_t term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue);
jpayne@69 285 extern term_color_t term_ostream_get_color (term_ostream_t first_arg);
jpayne@69 286 extern void term_ostream_set_color (term_ostream_t first_arg, term_color_t color);
jpayne@69 287 extern term_color_t term_ostream_get_bgcolor (term_ostream_t first_arg);
jpayne@69 288 extern void term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color);
jpayne@69 289 extern term_weight_t term_ostream_get_weight (term_ostream_t first_arg);
jpayne@69 290 extern void term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight);
jpayne@69 291 extern term_posture_t term_ostream_get_posture (term_ostream_t first_arg);
jpayne@69 292 extern void term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture);
jpayne@69 293 extern term_underline_t term_ostream_get_underline (term_ostream_t first_arg);
jpayne@69 294 extern void term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline);
jpayne@69 295 extern const char *term_ostream_get_hyperlink_ref (term_ostream_t first_arg);
jpayne@69 296 extern const char *term_ostream_get_hyperlink_id (term_ostream_t first_arg);
jpayne@69 297 extern void term_ostream_set_hyperlink (term_ostream_t first_arg, const char *ref, const char *id);
jpayne@69 298 /* Like term_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it
jpayne@69 299 leaves the terminal with the current text attributes enabled, instead of
jpayne@69 300 with the default text attributes.
jpayne@69 301 After calling this function, you can output strings without newlines(!)
jpayne@69 302 to the underlying file descriptor, and they will be rendered like strings
jpayne@69 303 passed to 'ostream_write_mem', 'ostream_write_str', or
jpayne@69 304 'ostream_write_printf'. */
jpayne@69 305 extern void term_ostream_flush_to_current_style (term_ostream_t first_arg);
jpayne@69 306 /* Accessors. */
jpayne@69 307 extern int term_ostream_get_descriptor (term_ostream_t stream);
jpayne@69 308 extern const char *term_ostream_get_filename (term_ostream_t stream);
jpayne@69 309 extern ttyctl_t term_ostream_get_tty_control (term_ostream_t stream);
jpayne@69 310 extern ttyctl_t term_ostream_get_effective_tty_control (term_ostream_t stream);
jpayne@69 311 #ifdef __cplusplus
jpayne@69 312 }
jpayne@69 313 #endif
jpayne@69 314
jpayne@69 315 #ifdef __cplusplus
jpayne@69 316 extern "C" {
jpayne@69 317 #endif
jpayne@69 318
jpayne@69 319
jpayne@69 320 /* Create an output stream referring to the file descriptor FD.
jpayne@69 321 FILENAME is used only for error messages.
jpayne@69 322 TTY_CONTROL specifies the amount of control to take over the underlying tty.
jpayne@69 323 The resulting stream will be line-buffered.
jpayne@69 324 Note that the resulting stream must be closed before FD can be closed. */
jpayne@69 325 extern term_ostream_t
jpayne@69 326 term_ostream_create (int fd, const char *filename, ttyctl_t tty_control);
jpayne@69 327
jpayne@69 328
jpayne@69 329 /* Test whether a given output stream is a term_ostream. */
jpayne@69 330 extern bool is_instance_of_term_ostream (ostream_t stream);
jpayne@69 331
jpayne@69 332
jpayne@69 333 #ifdef __cplusplus
jpayne@69 334 }
jpayne@69 335 #endif
jpayne@69 336
jpayne@69 337 /* ------------------------- From memory-ostream.h ------------------------- */
jpayne@69 338
jpayne@69 339 /* memory_ostream_t is a subtype of ostream_t. */
jpayne@69 340 typedef ostream_t memory_ostream_t;
jpayne@69 341
jpayne@69 342 /* Functions that invoke the methods. */
jpayne@69 343 #ifdef __cplusplus
jpayne@69 344 extern "C" {
jpayne@69 345 #endif
jpayne@69 346 extern void memory_ostream_write_mem (memory_ostream_t first_arg, const void *data, size_t len);
jpayne@69 347 extern void memory_ostream_flush (memory_ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 348 extern void memory_ostream_free (memory_ostream_t first_arg);
jpayne@69 349 extern void memory_ostream_contents (memory_ostream_t first_arg, const void **bufp, size_t *buflenp);
jpayne@69 350 #ifdef __cplusplus
jpayne@69 351 }
jpayne@69 352 #endif
jpayne@69 353
jpayne@69 354 #ifdef __cplusplus
jpayne@69 355 extern "C" {
jpayne@69 356 #endif
jpayne@69 357
jpayne@69 358
jpayne@69 359 /* Create an output stream that accumulates the output in a memory buffer. */
jpayne@69 360 extern memory_ostream_t memory_ostream_create (void);
jpayne@69 361
jpayne@69 362
jpayne@69 363 /* Test whether a given output stream is a memory_ostream. */
jpayne@69 364 extern bool is_instance_of_memory_ostream (ostream_t stream);
jpayne@69 365
jpayne@69 366
jpayne@69 367 #ifdef __cplusplus
jpayne@69 368 }
jpayne@69 369 #endif
jpayne@69 370
jpayne@69 371 /* -------------------------- From iconv-ostream.h -------------------------- */
jpayne@69 372
jpayne@69 373 #if LIBTEXTSTYLE_USES_ICONV
jpayne@69 374
jpayne@69 375 /* iconv_ostream_t is a subtype of ostream_t. */
jpayne@69 376 typedef ostream_t iconv_ostream_t;
jpayne@69 377
jpayne@69 378 /* Functions that invoke the methods. */
jpayne@69 379 #ifdef __cplusplus
jpayne@69 380 extern "C" {
jpayne@69 381 #endif
jpayne@69 382 extern void iconv_ostream_write_mem (iconv_ostream_t first_arg, const void *data, size_t len);
jpayne@69 383 extern void iconv_ostream_flush (iconv_ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 384 extern void iconv_ostream_free (iconv_ostream_t first_arg);
jpayne@69 385 /* Accessors. */
jpayne@69 386 extern const char *iconv_ostream_get_from_encoding (iconv_ostream_t stream);
jpayne@69 387 extern const char *iconv_ostream_get_to_encoding (iconv_ostream_t stream);
jpayne@69 388 extern ostream_t iconv_ostream_get_destination (iconv_ostream_t stream);
jpayne@69 389 #ifdef __cplusplus
jpayne@69 390 }
jpayne@69 391 #endif
jpayne@69 392
jpayne@69 393 #ifdef __cplusplus
jpayne@69 394 extern "C" {
jpayne@69 395 #endif
jpayne@69 396
jpayne@69 397
jpayne@69 398 /* Create an output stream that converts from FROM_ENCODING to TO_ENCODING,
jpayne@69 399 writing the result to DESTINATION. */
jpayne@69 400 extern iconv_ostream_t iconv_ostream_create (const char *from_encoding,
jpayne@69 401 const char *to_encoding,
jpayne@69 402 ostream_t destination);
jpayne@69 403
jpayne@69 404
jpayne@69 405 /* Test whether a given output stream is an iconv_ostream. */
jpayne@69 406 extern bool is_instance_of_iconv_ostream (ostream_t stream);
jpayne@69 407
jpayne@69 408
jpayne@69 409 #ifdef __cplusplus
jpayne@69 410 }
jpayne@69 411 #endif
jpayne@69 412
jpayne@69 413 #endif /* LIBTEXTSTYLE_USES_ICONV */
jpayne@69 414
jpayne@69 415 /* -------------------------- From html-ostream.h -------------------------- */
jpayne@69 416
jpayne@69 417 /* html_ostream_t is a subtype of ostream_t. */
jpayne@69 418 typedef ostream_t html_ostream_t;
jpayne@69 419
jpayne@69 420 /* Functions that invoke the methods. */
jpayne@69 421 #ifdef __cplusplus
jpayne@69 422 extern "C" {
jpayne@69 423 #endif
jpayne@69 424 extern void html_ostream_write_mem (html_ostream_t first_arg, const void *data, size_t len);
jpayne@69 425 extern void html_ostream_flush (html_ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 426 extern void html_ostream_free (html_ostream_t first_arg);
jpayne@69 427 extern void html_ostream_begin_span (html_ostream_t first_arg, const char *classname);
jpayne@69 428 extern void html_ostream_end_span (html_ostream_t first_arg, const char *classname);
jpayne@69 429 extern const char *html_ostream_get_hyperlink_ref (html_ostream_t first_arg);
jpayne@69 430 extern void html_ostream_set_hyperlink_ref (html_ostream_t first_arg, const char *ref);
jpayne@69 431 /* Like html_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it
jpayne@69 432 leaves the destination with the current text style enabled, instead
jpayne@69 433 of with the default text style.
jpayne@69 434 After calling this function, you can output strings without newlines(!)
jpayne@69 435 to the underlying stream, and they will be rendered like strings passed
jpayne@69 436 to 'ostream_write_mem', 'ostream_write_str', or 'ostream_write_printf'. */
jpayne@69 437 extern void html_ostream_flush_to_current_style (html_ostream_t stream);
jpayne@69 438 /* Accessors. */
jpayne@69 439 extern ostream_t html_ostream_get_destination (html_ostream_t stream);
jpayne@69 440 #ifdef __cplusplus
jpayne@69 441 }
jpayne@69 442 #endif
jpayne@69 443
jpayne@69 444 #ifdef __cplusplus
jpayne@69 445 extern "C" {
jpayne@69 446 #endif
jpayne@69 447
jpayne@69 448
jpayne@69 449 /* Create an output stream that takes input in the UTF-8 encoding and
jpayne@69 450 writes it in HTML form on DESTINATION.
jpayne@69 451 This stream produces a sequence of lines. The caller is responsible
jpayne@69 452 for opening the <body><html> elements before and for closing them after
jpayne@69 453 the use of this stream.
jpayne@69 454 Note that the resulting stream must be closed before DESTINATION can be
jpayne@69 455 closed. */
jpayne@69 456 extern html_ostream_t html_ostream_create (ostream_t destination);
jpayne@69 457
jpayne@69 458
jpayne@69 459 /* Test whether a given output stream is a html_ostream. */
jpayne@69 460 extern bool is_instance_of_html_ostream (ostream_t stream);
jpayne@69 461
jpayne@69 462
jpayne@69 463 #ifdef __cplusplus
jpayne@69 464 }
jpayne@69 465 #endif
jpayne@69 466
jpayne@69 467 /* ----------------------- From term-styled-ostream.h ----------------------- */
jpayne@69 468
jpayne@69 469 /* term_styled_ostream_t is a subtype of styled_ostream_t. */
jpayne@69 470 typedef styled_ostream_t term_styled_ostream_t;
jpayne@69 471
jpayne@69 472 /* Functions that invoke the methods. */
jpayne@69 473 #ifdef __cplusplus
jpayne@69 474 extern "C" {
jpayne@69 475 #endif
jpayne@69 476 extern void term_styled_ostream_write_mem (term_styled_ostream_t first_arg, const void *data, size_t len);
jpayne@69 477 extern void term_styled_ostream_flush (term_styled_ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 478 extern void term_styled_ostream_free (term_styled_ostream_t first_arg);
jpayne@69 479 extern void term_styled_ostream_begin_use_class (term_styled_ostream_t first_arg, const char *classname);
jpayne@69 480 extern void term_styled_ostream_end_use_class (term_styled_ostream_t first_arg, const char *classname);
jpayne@69 481 extern const char *term_styled_ostream_get_hyperlink_ref (term_styled_ostream_t first_arg);
jpayne@69 482 extern const char *term_styled_ostream_get_hyperlink_id (term_styled_ostream_t first_arg);
jpayne@69 483 extern void term_styled_ostream_set_hyperlink (term_styled_ostream_t first_arg, const char *ref, const char *id);
jpayne@69 484 extern void term_styled_ostream_flush_to_current_style (term_styled_ostream_t first_arg);
jpayne@69 485 /* Accessors. */
jpayne@69 486 extern term_ostream_t term_styled_ostream_get_destination (term_styled_ostream_t stream);
jpayne@69 487 extern const char *term_styled_ostream_get_css_filename (term_styled_ostream_t stream);
jpayne@69 488 #ifdef __cplusplus
jpayne@69 489 }
jpayne@69 490 #endif
jpayne@69 491
jpayne@69 492 #ifdef __cplusplus
jpayne@69 493 extern "C" {
jpayne@69 494 #endif
jpayne@69 495
jpayne@69 496
jpayne@69 497 /* Create an output stream referring to the file descriptor FD, styled with
jpayne@69 498 the file CSS_FILENAME.
jpayne@69 499 FILENAME is used only for error messages.
jpayne@69 500 TTY_CONTROL specifies the amount of control to take over the underlying tty.
jpayne@69 501 Note that the resulting stream must be closed before FD can be closed.
jpayne@69 502 Return NULL upon failure. */
jpayne@69 503 extern term_styled_ostream_t
jpayne@69 504 term_styled_ostream_create (int fd, const char *filename,
jpayne@69 505 ttyctl_t tty_control,
jpayne@69 506 const char *css_filename);
jpayne@69 507
jpayne@69 508
jpayne@69 509 /* Test whether a given output stream is a term_styled_ostream. */
jpayne@69 510 extern bool is_instance_of_term_styled_ostream (ostream_t stream);
jpayne@69 511
jpayne@69 512
jpayne@69 513 #ifdef __cplusplus
jpayne@69 514 }
jpayne@69 515 #endif
jpayne@69 516
jpayne@69 517 /* ----------------------- From html-styled-ostream.h ----------------------- */
jpayne@69 518
jpayne@69 519 /* html_styled_ostream_t is a subtype of styled_ostream_t. */
jpayne@69 520 typedef styled_ostream_t html_styled_ostream_t;
jpayne@69 521
jpayne@69 522 /* Functions that invoke the methods. */
jpayne@69 523 #ifdef __cplusplus
jpayne@69 524 extern "C" {
jpayne@69 525 #endif
jpayne@69 526 extern void html_styled_ostream_write_mem (html_styled_ostream_t first_arg, const void *data, size_t len);
jpayne@69 527 extern void html_styled_ostream_flush (html_styled_ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 528 extern void html_styled_ostream_free (html_styled_ostream_t first_arg);
jpayne@69 529 extern void html_styled_ostream_begin_use_class (html_styled_ostream_t first_arg, const char *classname);
jpayne@69 530 extern void html_styled_ostream_end_use_class (html_styled_ostream_t first_arg, const char *classname);
jpayne@69 531 extern const char *html_styled_ostream_get_hyperlink_ref (html_styled_ostream_t first_arg);
jpayne@69 532 extern const char *html_styled_ostream_get_hyperlink_id (html_styled_ostream_t first_arg);
jpayne@69 533 extern void html_styled_ostream_set_hyperlink (html_styled_ostream_t first_arg, const char *ref, const char *id);
jpayne@69 534 extern void html_styled_ostream_flush_to_current_style (html_styled_ostream_t first_arg);
jpayne@69 535 /* Accessors. */
jpayne@69 536 extern ostream_t html_styled_ostream_get_destination (html_styled_ostream_t stream);
jpayne@69 537 extern html_ostream_t html_styled_ostream_get_html_destination (html_styled_ostream_t stream);
jpayne@69 538 extern const char *html_styled_ostream_get_css_filename (html_styled_ostream_t stream);
jpayne@69 539 #ifdef __cplusplus
jpayne@69 540 }
jpayne@69 541 #endif
jpayne@69 542
jpayne@69 543 #ifdef __cplusplus
jpayne@69 544 extern "C" {
jpayne@69 545 #endif
jpayne@69 546
jpayne@69 547
jpayne@69 548 /* Create an output stream that takes input in the UTF-8 encoding and
jpayne@69 549 writes it in HTML form on DESTINATION, styled with the file CSS_FILENAME.
jpayne@69 550 Note that the resulting stream must be closed before DESTINATION can be
jpayne@69 551 closed. */
jpayne@69 552 extern html_styled_ostream_t
jpayne@69 553 html_styled_ostream_create (ostream_t destination,
jpayne@69 554 const char *css_filename);
jpayne@69 555
jpayne@69 556
jpayne@69 557 /* Test whether a given output stream is a html_styled_ostream. */
jpayne@69 558 extern bool is_instance_of_html_styled_ostream (ostream_t stream);
jpayne@69 559
jpayne@69 560
jpayne@69 561 #ifdef __cplusplus
jpayne@69 562 }
jpayne@69 563 #endif
jpayne@69 564
jpayne@69 565 /* ----------------------- From noop-styled-ostream.h ----------------------- */
jpayne@69 566
jpayne@69 567 /* noop_styled_ostream_t is a subtype of styled_ostream_t. */
jpayne@69 568 typedef styled_ostream_t noop_styled_ostream_t;
jpayne@69 569
jpayne@69 570 /* Functions that invoke the methods. */
jpayne@69 571 #ifdef __cplusplus
jpayne@69 572 extern "C" {
jpayne@69 573 #endif
jpayne@69 574 extern void noop_styled_ostream_write_mem (noop_styled_ostream_t first_arg, const void *data, size_t len);
jpayne@69 575 extern void noop_styled_ostream_flush (noop_styled_ostream_t first_arg, ostream_flush_scope_t scope);
jpayne@69 576 extern void noop_styled_ostream_free (noop_styled_ostream_t first_arg);
jpayne@69 577 extern void noop_styled_ostream_begin_use_class (noop_styled_ostream_t first_arg, const char *classname);
jpayne@69 578 extern void noop_styled_ostream_end_use_class (noop_styled_ostream_t first_arg, const char *classname);
jpayne@69 579 extern const char *noop_styled_ostream_get_hyperlink_ref (noop_styled_ostream_t first_arg);
jpayne@69 580 extern const char *noop_styled_ostream_get_hyperlink_id (noop_styled_ostream_t first_arg);
jpayne@69 581 extern void noop_styled_ostream_set_hyperlink (noop_styled_ostream_t first_arg, const char *ref, const char *id);
jpayne@69 582 extern void noop_styled_ostream_flush_to_current_style (noop_styled_ostream_t first_arg);
jpayne@69 583 /* Accessors. */
jpayne@69 584 extern ostream_t noop_styled_ostream_get_destination (noop_styled_ostream_t stream);
jpayne@69 585 extern bool noop_styled_ostream_is_owning_destination (noop_styled_ostream_t stream);
jpayne@69 586 #ifdef __cplusplus
jpayne@69 587 }
jpayne@69 588 #endif
jpayne@69 589
jpayne@69 590 #ifdef __cplusplus
jpayne@69 591 extern "C" {
jpayne@69 592 #endif
jpayne@69 593
jpayne@69 594
jpayne@69 595 /* Create an output stream that delegates to DESTINATION and that supports
jpayne@69 596 the styling operations as no-ops.
jpayne@69 597 If PASS_OWNERSHIP is true, closing the resulting stream will automatically
jpayne@69 598 close the DESTINATION.
jpayne@69 599 Note that if PASS_OWNERSHIP is false, the resulting stream must be closed
jpayne@69 600 before DESTINATION can be closed. */
jpayne@69 601 extern noop_styled_ostream_t
jpayne@69 602 noop_styled_ostream_create (ostream_t destination, bool pass_ownership);
jpayne@69 603
jpayne@69 604
jpayne@69 605 /* Test whether a given output stream is a noop_styled_ostream. */
jpayne@69 606 extern bool is_instance_of_noop_styled_ostream (ostream_t stream);
jpayne@69 607
jpayne@69 608
jpayne@69 609 #ifdef __cplusplus
jpayne@69 610 }
jpayne@69 611 #endif
jpayne@69 612
jpayne@69 613 /* ------------------------------ From color.h ------------------------------ */
jpayne@69 614
jpayne@69 615 #ifdef __cplusplus
jpayne@69 616 extern "C" {
jpayne@69 617 #endif
jpayne@69 618
jpayne@69 619
jpayne@69 620 /* Whether to output a test page. */
jpayne@69 621 extern LIBTEXTSTYLE_DLL_VARIABLE bool color_test_mode;
jpayne@69 622
jpayne@69 623 /* Color option. */
jpayne@69 624 enum color_option { color_no, color_tty, color_yes, color_html };
jpayne@69 625 extern LIBTEXTSTYLE_DLL_VARIABLE enum color_option color_mode;
jpayne@69 626
jpayne@69 627 /* Style to use when coloring. */
jpayne@69 628 extern LIBTEXTSTYLE_DLL_VARIABLE const char *style_file_name;
jpayne@69 629
jpayne@69 630 /* --color argument handling. Return an error indicator. */
jpayne@69 631 extern bool handle_color_option (const char *option);
jpayne@69 632
jpayne@69 633 /* --style argument handling. */
jpayne@69 634 extern void handle_style_option (const char *option);
jpayne@69 635
jpayne@69 636 /* Print a color test page. */
jpayne@69 637 extern void print_color_test (void);
jpayne@69 638
jpayne@69 639 /* Assign a default value to style_file_name if necessary.
jpayne@69 640 STYLE_FILE_ENVVAR is an environment variable that, when set to a non-empty
jpayne@69 641 value, specifies the style file to use. This environment variable is meant
jpayne@69 642 to be set by the user.
jpayne@69 643 STYLESDIR_ENVVAR is an environment variable that, when set to a non-empty
jpayne@69 644 value, specifies the directory with the style files, or NULL. This is
jpayne@69 645 necessary for running the testsuite before "make install".
jpayne@69 646 STYLESDIR_AFTER_INSTALL is the directory with the style files after
jpayne@69 647 "make install".
jpayne@69 648 DEFAULT_STYLE_FILE is the file name of the default style file, relative to
jpayne@69 649 STYLESDIR. */
jpayne@69 650 extern void style_file_prepare (const char *style_file_envvar,
jpayne@69 651 const char *stylesdir_envvar,
jpayne@69 652 const char *stylesdir_after_install,
jpayne@69 653 const char *default_style_file);
jpayne@69 654
jpayne@69 655
jpayne@69 656 #ifdef __cplusplus
jpayne@69 657 }
jpayne@69 658 #endif
jpayne@69 659
jpayne@69 660 /* ------------------------------ From misc.h ------------------------------ */
jpayne@69 661
jpayne@69 662 #ifdef __cplusplus
jpayne@69 663 extern "C" {
jpayne@69 664 #endif
jpayne@69 665
jpayne@69 666 /* Create an output stream referring to the file descriptor FD, styled with
jpayne@69 667 the file CSS_FILENAME if possible.
jpayne@69 668 FILENAME is used only for error messages.
jpayne@69 669 TTY_CONTROL specifies the amount of control to take over the underlying tty.
jpayne@69 670 Note that the resulting stream must be closed before FD can be closed. */
jpayne@69 671 extern styled_ostream_t
jpayne@69 672 styled_ostream_create (int fd, const char *filename,
jpayne@69 673 ttyctl_t tty_control,
jpayne@69 674 const char *css_filename);
jpayne@69 675
jpayne@69 676 /* Set the exit value upon failure within libtextstyle. */
jpayne@69 677 extern void libtextstyle_set_failure_exit_code (int exit_code);
jpayne@69 678
jpayne@69 679 #ifdef __cplusplus
jpayne@69 680 }
jpayne@69 681 #endif
jpayne@69 682
jpayne@69 683 /* ----------------------- Exported gnulib overrides ----------------------- */
jpayne@69 684
jpayne@69 685 #if defined _WIN32 && ! defined __CYGWIN__
jpayne@69 686
jpayne@69 687 # include <io.h>
jpayne@69 688
jpayne@69 689 # ifdef __cplusplus
jpayne@69 690 extern "C" {
jpayne@69 691 # endif
jpayne@69 692
jpayne@69 693 # if !((defined isatty && defined _GL_UNISTD_H) || defined GNULIB_overrides_isatty) /* don't override gnulib */
jpayne@69 694 extern int libtextstyle_isatty (int fd);
jpayne@69 695 # undef isatty
jpayne@69 696 # define isatty libtextstyle_isatty
jpayne@69 697 # endif
jpayne@69 698
jpayne@69 699 # ifdef __cplusplus
jpayne@69 700 }
jpayne@69 701 # endif
jpayne@69 702
jpayne@69 703 #endif
jpayne@69 704
jpayne@69 705 /* ------------------------------------------------------------------------- */
jpayne@69 706
jpayne@69 707 #endif /* _TEXTSTYLE_H */