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

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

index 41df513fe244fc43ae0995f2ccc31deb9ef729d4..6c55847a85b958d36600328d4bbbb0ec793a839a 100644 (file)
@@ -312,6 +312,17 @@ html_ostream::end_span (html_ostream_t stream, const char *classname)
   abort ();
 }
 
+static void
+html_ostream::flush_to_current_style (html_ostream_t stream)
+{
+  verify_invariants (stream);
+  /* stream->buf[] contains only a few bytes that don't correspond to a
+     character.  Can't flush it.  */
+  /* Open all requested <span> tags.  */
+  emit_pending_spans (stream, true);
+  verify_invariants (stream);
+}
+
 /* Constructor.  */
 
 html_ostream_t
index 72aa156908e1772a60b08f907cff08c84773bff3..dd25aabacc9d699ef33e51d4f45409a467a3032c 100644 (file)
@@ -1,5 +1,5 @@
 /* Output stream that produces HTML output.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2019 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2006.
 
    This program is free software: you can redistribute it and/or modify
@@ -33,6 +33,14 @@ methods:
   /* End a <span class="CLASSNAME"> element.
      The begin_span / end_span calls must match properly.  */
   void end_span (html_ostream_t stream, const char *classname);
+
+  /* Like html_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 (html_ostream_t stream);
 };
 
 
index 0887045111635a4c384611d35730e5b7f81cd965..1ecb72c37b36690f0b2966d3d5092fb7c85cbe85 100644 (file)
@@ -3,6 +3,8 @@ New in 0.6:
   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 in 0.5:
 
index 6f62281ab7e29eda1e3ce9b1cd67327a67413947..fd4beb2396622341bdc135421678763acfaa62da 100644 (file)
@@ -855,6 +855,16 @@ The @code{html_ostream_begin_span} / @code{html_ostream_end_span} calls
 must match properly.
 @end deftypefn
 
+@deftypefn Function void html_ostream_flush_to_current_style (html_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 The memory_ostream class
 @subsubsection The @code{memory_ostream} class
 
index 013a8b41b06abb997b0b961f3e22b13aa068c7c4..7450fbbb1e1e2c9cfd47495ada067ad02134e9f4 100644 (file)
@@ -348,6 +348,13 @@ extern void html_ostream_flush (html_ostream_t first_arg, ostream_flush_scope_t
 extern void html_ostream_free (html_ostream_t first_arg);
 extern void html_ostream_begin_span (html_ostream_t first_arg, const char *classname);
 extern void html_ostream_end_span (html_ostream_t first_arg, const char *classname);
+/* Like html_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 html_ostream_flush_to_current_style (html_ostream_t stream);
 #ifdef __cplusplus
 }
 #endif