1 /* Abstract output stream for CSS styled text.
2 Copyright (C) 2006, 2019-2020 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2006.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18 #ifndef _STYLED_OSTREAM_H
19 #define _STYLED_OSTREAM_H
20
21 #include <stdbool.h>
22
23 #include "ostream.h"
24
25
26 /* A styled output stream is an object to which one can feed a sequence of
27 bytes, marking some runs of text as belonging to specific CSS classes,
28 where the rendering of the CSS classes is defined through a CSS (cascading
29 style sheet). */
30
31 struct styled_ostream : struct ostream
32 {
33 methods:
34
35 /* Start a run of text belonging to CLASSNAME. The CLASSNAME is the name
36 of a CSS class. It can be chosen arbitrarily and customized through
37 an inline or external CSS. */
38 void begin_use_class (styled_ostream_t stream, const char *classname);
39
40 /* End a run of text belonging to CLASSNAME.
41 The begin_use_class / end_use_class calls must match properly. */
42 void end_use_class (styled_ostream_t stream, const char *classname);
43
44 /* Get/set the hyperlink attribute and its id. */
45 const char * get_hyperlink_ref (styled_ostream_t stream);
46 const char * get_hyperlink_id (styled_ostream_t stream);
47 void set_hyperlink (styled_ostream_t stream,
48 const char *ref, const char *id);
49
50 /* Like styled_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it
51 leaves the destination with the current text style enabled, instead
52 of with the default text style.
53 After calling this function, you can output strings without newlines(!)
54 to the underlying stream, and they will be rendered like strings passed
55 to 'ostream_write_mem', 'ostream_write_str', or 'ostream_write_printf'. */
56 void flush_to_current_style (styled_ostream_t stream);
57 };
58
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62
63
64 /* Test whether a given output stream is a styled_ostream. */
65 extern bool is_instance_of_styled_ostream (ostream_t stream);
66
67
68 #ifdef __cplusplus
69 }
70 #endif
71
72 #endif /* _STYLED_OSTREAM_H */