]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
libtextstyle: New function styled_ostream_flush_to_current_style.
authorBruno Haible <bruno@clisp.org>
Tue, 12 Mar 2019 18:28:25 +0000 (19:28 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 12 Mar 2019 18:28:25 +0000 (19:28 +0100)
* gnulib-local/lib/styled-ostream.oo.h (struct styled_ostream): Add method
flush_to_current_style.
* gnulib-local/lib/fd-styled-ostream.oo.c
(fd_styled_ostream::flush_to_current_style): New method.
* gnulib-local/lib/term-styled-ostream.oo.c
(term_styled_ostream::flush_to_current_style): New method.
* gnulib-local/lib/html-styled-ostream.oo.c
(html_styled_ostream::flush_to_current_style): New method.
* libtextstyle/lib/textstyle.h (styled_ostream_flush_to_current_style): New
declaration.
* libtextstyle/doc/libtextstyle.texi (The styled_ostream class): Document
styled_ostream_flush_to_current_style.
* libtextstyle/NEWS: Mention the change.

gnulib-local/lib/fd-styled-ostream.oo.c
gnulib-local/lib/html-styled-ostream.oo.c
gnulib-local/lib/styled-ostream.oo.h
gnulib-local/lib/term-styled-ostream.oo.c
libtextstyle/NEWS
libtextstyle/doc/libtextstyle.texi
libtextstyle/lib/textstyle.h

index d3bb1e96eae1651cab7fc92a78f638ebc6a60f2d..8cf64621a172dbf69e0ea25091cd0e71a17a8959 100644 (file)
@@ -68,6 +68,12 @@ fd_styled_ostream::end_use_class (fd_styled_ostream_t stream,
 {
 }
 
+static void
+fd_styled_ostream::flush_to_current_style (fd_styled_ostream_t stream)
+{
+  fd_ostream_flush (stream->destination, FLUSH_THIS_STREAM);
+}
+
 /* Constructor.  */
 
 fd_styled_ostream_t
index 77201e1711156d88b9e2a55ba1147f9abb6b4c42..41aa170e13595951bb567b54ca4f9075009fe40b 100644 (file)
@@ -89,6 +89,12 @@ html_styled_ostream::end_use_class (html_styled_ostream_t stream,
   html_ostream_end_span (stream->html_destination, classname);
 }
 
+static void
+html_styled_ostream::flush_to_current_style (html_styled_ostream_t stream)
+{
+  html_ostream_flush_to_current_style (stream->html_destination);
+}
+
 /* Constructor.  */
 
 html_styled_ostream_t
index b612d9ef8c83c0a66da2e2dbecc7cf79fb7de4ea..2daa87c28e9ae4e0e481c351ec19a8e6df5c8a71 100644 (file)
@@ -38,6 +38,14 @@ methods:
   /* End a run of text belonging to CLASSNAME.
      The begin_use_class / end_use_class calls must match properly.  */
   void end_use_class (styled_ostream_t stream, const char *classname);
+
+  /* Like styled_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it
+     leaves the destination with the current text style enabled, instead
+     of with the default text style.
+     After calling this function, you can output strings without newlines(!)
+     to the underlying stream, and they will be rendered like strings passed
+     to 'ostream_write_mem' or 'ostream_write_str'.  */
+  void flush_to_current_style (styled_ostream_t stream);
 };
 
 
index 9ab96d702034bfdec00183da4dcd1687b4c54688..2cfd4a8546ef3790c258616d1b08e314e26a2a23 100644 (file)
@@ -595,6 +595,18 @@ term_styled_ostream::end_use_class (term_styled_ostream_t stream,
   stream->curr_attr = (attributes_t *) found;
 }
 
+static void
+term_styled_ostream::flush_to_current_style (term_styled_ostream_t stream)
+{
+  term_ostream_set_color (stream->destination, stream->curr_attr->color);
+  term_ostream_set_bgcolor (stream->destination, stream->curr_attr->bgcolor);
+  term_ostream_set_weight (stream->destination, stream->curr_attr->weight);
+  term_ostream_set_posture (stream->destination, stream->curr_attr->posture);
+  term_ostream_set_underline (stream->destination, stream->curr_attr->underline);
+
+  term_ostream_flush_to_current_style (stream->destination);
+}
+
 /* Constructor.  */
 
 term_styled_ostream_t
index 1ecb72c37b36690f0b2966d3d5092fb7c85cbe85..b22a1c4089b39955ff1a21bc81943902d5696675 100644 (file)
@@ -1,10 +1,11 @@
 New in 0.6:
 * The ostream_t operation 'flush' now takes an additional argument, of type
   ostream_flush_scope_t.
-* The term_ostream_t type supports a new function
-  term_ostream_flush_to_current_style.
-* The html_ostream_t type supports a new function
-  html_ostream_flush_to_current_style.
+* New functions:
+       TYPE                               FUNCTION
+  styled_ostream_t          styled_ostream_flush_to_current_style
+  term_ostream_t            term_ostream_flush_to_current_style
+  html_ostream_t            html_ostream_flush_to_current_style
 
 New in 0.5:
 
index fd4beb2396622341bdc135421678763acfaa62da..91c68585430a568612c999e5c95b3c130967d1fd 100644 (file)
@@ -707,6 +707,16 @@ Ends a run of text belonging to @code{@var{classname}}.  The
 @code{styled_ostream_end_use_class} calls must match properly.
 @end deftypefn
 
+@deftypefn Function void styled_ostream_flush_to_current_style (styled_ostream_t@tie{}@var{stream})
+This function acts like @code{ostream_flush (@var{stream}, FLUSH_THIS_STREAM)},
+except that it leaves the destination with the current text style enabled,
+instead of with the default text style.
+
+After calling this function, you can output strings without newlines(!) to the
+underlying stream, and they will be rendered like strings passed to
+@code{ostream_write_mem} or @code{ostream_write_str}.
+@end deftypefn
+
 @node ostream subclasses without styling
 @subsection Concrete ostream subclasses without styling
 
index 7450fbbb1e1e2c9cfd47495ada067ad02134e9f4..f905fe6ccb4d42b66dbd525a1ea71c7f43036938 100644 (file)
@@ -93,6 +93,13 @@ extern void styled_ostream_flush (styled_ostream_t first_arg, ostream_flush_scop
 extern void styled_ostream_free (styled_ostream_t first_arg);
 extern void styled_ostream_begin_use_class (styled_ostream_t first_arg, const char *classname);
 extern void styled_ostream_end_use_class (styled_ostream_t first_arg, const char *classname);
+/* Like styled_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it
+   leaves the destination with the current text style enabled, instead
+   of with the default text style.
+   After calling this function, you can output strings without newlines(!)
+   to the underlying stream, and they will be rendered like strings passed
+   to 'ostream_write_mem' or 'ostream_write_str'.  */
+extern void styled_ostream_flush_to_current_style (styled_ostream_t stream);
 #ifdef __cplusplus
 }
 #endif