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