• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Abstract output stream for CSS styled text.
2    Copyright (C) 2006, 2019 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 "ostream.h"
22 
23 
24 /* A styled output stream is an object to which one can feed a sequence of
25    bytes, marking some runs of text as belonging to specific CSS classes,
26    where the rendering of the CSS classes is defined through a CSS (cascading
27    style sheet).  */
28 
29 struct styled_ostream : struct ostream
30 {
31 methods:
32 
33   /* Start a run of text belonging to CLASSNAME.  The CLASSNAME is the name
34      of a CSS class.  It can be chosen arbitrarily and customized through
35      an inline or external CSS.  */
36   void begin_use_class (styled_ostream_t stream, const char *classname);
37 
38   /* End a run of text belonging to CLASSNAME.
39      The begin_use_class / end_use_class calls must match properly.  */
40   void end_use_class (styled_ostream_t stream, const char *classname);
41 
42   /* Get/set the hyperlink attribute and its id.  */
43   const char * get_hyperlink_ref (styled_ostream_t stream);
44   const char * get_hyperlink_id (styled_ostream_t stream);
45   void         set_hyperlink (styled_ostream_t stream,
46                               const char *ref, const char *id);
47 
48   /* Like styled_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it
49      leaves the destination with the current text style enabled, instead
50      of with the default text style.
51      After calling this function, you can output strings without newlines(!)
52      to the underlying stream, and they will be rendered like strings passed
53      to 'ostream_write_mem', 'ostream_write_str', or 'ostream_write_printf'.  */
54   void flush_to_current_style (styled_ostream_t stream);
55 };
56 
57 
58 #endif /* _STYLED_OSTREAM_H */
59