jpayne@69: /* Public API of the libtextstyle library. jpayne@69: Copyright (C) 2006-2007, 2019-2021 Free Software Foundation, Inc. jpayne@69: jpayne@69: This program is free software: you can redistribute it and/or modify jpayne@69: it under the terms of the GNU General Public License as published by jpayne@69: the Free Software Foundation; either version 3 of the License, or jpayne@69: (at your option) any later version. jpayne@69: jpayne@69: This program is distributed in the hope that it will be useful, jpayne@69: but WITHOUT ANY WARRANTY; without even the implied warranty of jpayne@69: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jpayne@69: GNU General Public License for more details. jpayne@69: jpayne@69: You should have received a copy of the GNU General Public License jpayne@69: along with this program. If not, see . */ jpayne@69: jpayne@69: /* Written by Bruno Haible , 2006, 2019. */ jpayne@69: jpayne@69: #ifndef _TEXTSTYLE_H jpayne@69: #define _TEXTSTYLE_H jpayne@69: jpayne@69: #include jpayne@69: #include jpayne@69: #include jpayne@69: #include jpayne@69: #include jpayne@69: jpayne@69: /* Meta information. */ jpayne@69: #include jpayne@69: jpayne@69: /* ----------------------------- From ostream.h ----------------------------- */ jpayne@69: jpayne@69: /* Describes the scope of a flush operation. */ jpayne@69: typedef enum jpayne@69: { jpayne@69: /* Flushes buffers in this ostream_t. jpayne@69: Use this value if you want to write to the underlying ostream_t. */ jpayne@69: FLUSH_THIS_STREAM = 0, jpayne@69: /* Flushes all buffers in the current process. jpayne@69: Use this value if you want to write to the same target through a jpayne@69: different file descriptor or a FILE stream. */ jpayne@69: FLUSH_THIS_PROCESS = 1, jpayne@69: /* Flushes buffers in the current process and attempts to flush the buffers jpayne@69: in the kernel. jpayne@69: Use this value so that some other process (or the kernel itself) jpayne@69: may write to the same target. */ jpayne@69: FLUSH_ALL = 2 jpayne@69: } ostream_flush_scope_t; jpayne@69: jpayne@69: jpayne@69: /* An output stream is an object to which one can feed a sequence of bytes. */ jpayne@69: jpayne@69: struct any_ostream_representation; jpayne@69: typedef struct any_ostream_representation * ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void ostream_write_mem (ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void ostream_flush (ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void ostream_free (ostream_t first_arg); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /* Write a string's contents to a stream. */ jpayne@69: extern void ostream_write_str (ostream_t stream, const char *string); jpayne@69: jpayne@69: /* Writes formatted output to a stream. jpayne@69: Returns the size of formatted output, or a negative value in case of an jpayne@69: error. */ jpayne@69: extern ptrdiff_t ostream_printf (ostream_t stream, const char *format, ...) jpayne@69: #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3 jpayne@69: __attribute__ ((__format__ (__printf__, 2, 3))) jpayne@69: #endif jpayne@69: ; jpayne@69: extern ptrdiff_t ostream_vprintf (ostream_t stream, jpayne@69: const char *format, va_list args) jpayne@69: #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3 jpayne@69: __attribute__ ((__format__ (__printf__, 2, 0))) jpayne@69: #endif jpayne@69: ; jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* ------------------------- From styled-ostream.h ------------------------- */ jpayne@69: jpayne@69: /* A styled output stream is an object to which one can feed a sequence of jpayne@69: bytes, marking some runs of text as belonging to specific CSS classes, jpayne@69: where the rendering of the CSS classes is defined through a CSS (cascading jpayne@69: style sheet). */ jpayne@69: jpayne@69: /* styled_ostream_t is a subtype of ostream_t. */ jpayne@69: typedef ostream_t styled_ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void styled_ostream_write_mem (styled_ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void styled_ostream_flush (styled_ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void styled_ostream_free (styled_ostream_t first_arg); jpayne@69: extern void styled_ostream_begin_use_class (styled_ostream_t first_arg, const char *classname); jpayne@69: extern void styled_ostream_end_use_class (styled_ostream_t first_arg, const char *classname); jpayne@69: extern const char *styled_ostream_get_hyperlink_ref (styled_ostream_t first_arg); jpayne@69: extern const char *styled_ostream_get_hyperlink_id (styled_ostream_t first_arg); jpayne@69: extern void styled_ostream_set_hyperlink (styled_ostream_t first_arg, const char *ref, const char *id); jpayne@69: /* Like styled_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it jpayne@69: leaves the destination with the current text style enabled, instead jpayne@69: of with the default text style. jpayne@69: After calling this function, you can output strings without newlines(!) jpayne@69: to the underlying stream, and they will be rendered like strings passed jpayne@69: to 'ostream_write_mem', 'ostream_write_str', or 'ostream_write_printf'. */ jpayne@69: extern void styled_ostream_flush_to_current_style (styled_ostream_t stream); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Test whether a given output stream is a styled_ostream. */ jpayne@69: extern bool is_instance_of_styled_ostream (ostream_t stream); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* -------------------------- From file-ostream.h -------------------------- */ jpayne@69: jpayne@69: /* file_ostream_t is a subtype of ostream_t. */ jpayne@69: typedef ostream_t file_ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void file_ostream_write_mem (file_ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void file_ostream_flush (file_ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void file_ostream_free (file_ostream_t first_arg); jpayne@69: /* Accessors. */ jpayne@69: extern FILE *file_ostream_get_stdio_stream (file_ostream_t stream); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Create an output stream referring to FP. jpayne@69: Note that the resulting stream must be closed before FP can be closed. */ jpayne@69: extern file_ostream_t file_ostream_create (FILE *fp); jpayne@69: jpayne@69: jpayne@69: /* Test whether a given output stream is a file_ostream. */ jpayne@69: extern bool is_instance_of_file_ostream (ostream_t stream); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* --------------------------- From fd-ostream.h --------------------------- */ jpayne@69: jpayne@69: /* fd_ostream_t is a subtype of ostream_t. */ jpayne@69: typedef ostream_t fd_ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void fd_ostream_write_mem (fd_ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void fd_ostream_flush (fd_ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void fd_ostream_free (fd_ostream_t first_arg); jpayne@69: /* Accessors. */ jpayne@69: extern int fd_ostream_get_descriptor (fd_ostream_t stream); jpayne@69: extern const char *fd_ostream_get_filename (fd_ostream_t stream); jpayne@69: extern bool fd_ostream_is_buffered (fd_ostream_t stream); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Create an output stream referring to the file descriptor FD. jpayne@69: FILENAME is used only for error messages. jpayne@69: Note that the resulting stream must be closed before FD can be closed. */ jpayne@69: extern fd_ostream_t fd_ostream_create (int fd, const char *filename, jpayne@69: bool buffered); jpayne@69: jpayne@69: jpayne@69: /* Test whether a given output stream is a fd_ostream. */ jpayne@69: extern bool is_instance_of_fd_ostream (ostream_t stream); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* -------------------------- From term-ostream.h -------------------------- */ jpayne@69: jpayne@69: /* Querying and setting of text attributes. jpayne@69: The stream has a notion of the current text attributes; they apply jpayne@69: implicitly to all following output. The attributes are automatically jpayne@69: reset when the stream is closed. jpayne@69: Note: Not all terminal types can actually render all attributes adequately. jpayne@69: For example, xterm cannot render POSTURE_ITALIC nor the combination of jpayne@69: WEIGHT_BOLD and UNDERLINE_ON. */ jpayne@69: jpayne@69: /* Colors are represented by indices >= 0 in a stream dependent format. */ jpayne@69: typedef int term_color_t; jpayne@69: /* The value -1 denotes the default (foreground or background) color. */ jpayne@69: enum jpayne@69: { jpayne@69: COLOR_DEFAULT = -1 /* unknown */ jpayne@69: }; jpayne@69: jpayne@69: typedef enum jpayne@69: { jpayne@69: WEIGHT_NORMAL = 0, jpayne@69: WEIGHT_BOLD, jpayne@69: WEIGHT_DEFAULT = WEIGHT_NORMAL jpayne@69: } term_weight_t; jpayne@69: jpayne@69: typedef enum jpayne@69: { jpayne@69: POSTURE_NORMAL = 0, jpayne@69: POSTURE_ITALIC, /* same as oblique */ jpayne@69: POSTURE_DEFAULT = POSTURE_NORMAL jpayne@69: } term_posture_t; jpayne@69: jpayne@69: typedef enum jpayne@69: { jpayne@69: UNDERLINE_OFF = 0, jpayne@69: UNDERLINE_ON, jpayne@69: UNDERLINE_DEFAULT = UNDERLINE_OFF jpayne@69: } term_underline_t; jpayne@69: jpayne@69: /* The amount of control to take over the underlying tty in order to avoid jpayne@69: garbled output on the screen, due to interleaved output of escape sequences jpayne@69: and output from the kernel (such as when the kernel echoes user's input jpayne@69: or when the kernel prints '^C' after the user pressed Ctrl-C). */ jpayne@69: typedef enum jpayne@69: { jpayne@69: TTYCTL_AUTO = 0, /* Automatic best-possible choice. */ jpayne@69: TTYCTL_NONE, /* No control. jpayne@69: Result: Garbled output can occur, and the terminal can jpayne@69: be left in any state when the program is interrupted. */ jpayne@69: TTYCTL_PARTIAL, /* Signal handling. jpayne@69: Result: Garbled output can occur, but the terminal will jpayne@69: be left in the default state when the program is jpayne@69: interrupted. */ jpayne@69: TTYCTL_FULL /* Signal handling and disabling echo and flush-upon-signal. jpayne@69: Result: No garbled output, and the the terminal will jpayne@69: be left in the default state when the program is jpayne@69: interrupted. */ jpayne@69: } ttyctl_t; jpayne@69: jpayne@69: /* term_ostream_t is a subtype of ostream_t. */ jpayne@69: typedef ostream_t term_ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void term_ostream_flush (term_ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void term_ostream_free (term_ostream_t first_arg); jpayne@69: extern term_color_t term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue); jpayne@69: extern term_color_t term_ostream_get_color (term_ostream_t first_arg); jpayne@69: extern void term_ostream_set_color (term_ostream_t first_arg, term_color_t color); jpayne@69: extern term_color_t term_ostream_get_bgcolor (term_ostream_t first_arg); jpayne@69: extern void term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color); jpayne@69: extern term_weight_t term_ostream_get_weight (term_ostream_t first_arg); jpayne@69: extern void term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight); jpayne@69: extern term_posture_t term_ostream_get_posture (term_ostream_t first_arg); jpayne@69: extern void term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture); jpayne@69: extern term_underline_t term_ostream_get_underline (term_ostream_t first_arg); jpayne@69: extern void term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline); jpayne@69: extern const char *term_ostream_get_hyperlink_ref (term_ostream_t first_arg); jpayne@69: extern const char *term_ostream_get_hyperlink_id (term_ostream_t first_arg); jpayne@69: extern void term_ostream_set_hyperlink (term_ostream_t first_arg, const char *ref, const char *id); jpayne@69: /* Like term_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it jpayne@69: leaves the terminal with the current text attributes enabled, instead of jpayne@69: with the default text attributes. jpayne@69: After calling this function, you can output strings without newlines(!) jpayne@69: to the underlying file descriptor, and they will be rendered like strings jpayne@69: passed to 'ostream_write_mem', 'ostream_write_str', or jpayne@69: 'ostream_write_printf'. */ jpayne@69: extern void term_ostream_flush_to_current_style (term_ostream_t first_arg); jpayne@69: /* Accessors. */ jpayne@69: extern int term_ostream_get_descriptor (term_ostream_t stream); jpayne@69: extern const char *term_ostream_get_filename (term_ostream_t stream); jpayne@69: extern ttyctl_t term_ostream_get_tty_control (term_ostream_t stream); jpayne@69: extern ttyctl_t term_ostream_get_effective_tty_control (term_ostream_t stream); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Create an output stream referring to the file descriptor FD. jpayne@69: FILENAME is used only for error messages. jpayne@69: TTY_CONTROL specifies the amount of control to take over the underlying tty. jpayne@69: The resulting stream will be line-buffered. jpayne@69: Note that the resulting stream must be closed before FD can be closed. */ jpayne@69: extern term_ostream_t jpayne@69: term_ostream_create (int fd, const char *filename, ttyctl_t tty_control); jpayne@69: jpayne@69: jpayne@69: /* Test whether a given output stream is a term_ostream. */ jpayne@69: extern bool is_instance_of_term_ostream (ostream_t stream); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* ------------------------- From memory-ostream.h ------------------------- */ jpayne@69: jpayne@69: /* memory_ostream_t is a subtype of ostream_t. */ jpayne@69: typedef ostream_t memory_ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void memory_ostream_write_mem (memory_ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void memory_ostream_flush (memory_ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void memory_ostream_free (memory_ostream_t first_arg); jpayne@69: extern void memory_ostream_contents (memory_ostream_t first_arg, const void **bufp, size_t *buflenp); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Create an output stream that accumulates the output in a memory buffer. */ jpayne@69: extern memory_ostream_t memory_ostream_create (void); jpayne@69: jpayne@69: jpayne@69: /* Test whether a given output stream is a memory_ostream. */ jpayne@69: extern bool is_instance_of_memory_ostream (ostream_t stream); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* -------------------------- From iconv-ostream.h -------------------------- */ jpayne@69: jpayne@69: #if LIBTEXTSTYLE_USES_ICONV jpayne@69: jpayne@69: /* iconv_ostream_t is a subtype of ostream_t. */ jpayne@69: typedef ostream_t iconv_ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void iconv_ostream_write_mem (iconv_ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void iconv_ostream_flush (iconv_ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void iconv_ostream_free (iconv_ostream_t first_arg); jpayne@69: /* Accessors. */ jpayne@69: extern const char *iconv_ostream_get_from_encoding (iconv_ostream_t stream); jpayne@69: extern const char *iconv_ostream_get_to_encoding (iconv_ostream_t stream); jpayne@69: extern ostream_t iconv_ostream_get_destination (iconv_ostream_t stream); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Create an output stream that converts from FROM_ENCODING to TO_ENCODING, jpayne@69: writing the result to DESTINATION. */ jpayne@69: extern iconv_ostream_t iconv_ostream_create (const char *from_encoding, jpayne@69: const char *to_encoding, jpayne@69: ostream_t destination); jpayne@69: jpayne@69: jpayne@69: /* Test whether a given output stream is an iconv_ostream. */ jpayne@69: extern bool is_instance_of_iconv_ostream (ostream_t stream); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #endif /* LIBTEXTSTYLE_USES_ICONV */ jpayne@69: jpayne@69: /* -------------------------- From html-ostream.h -------------------------- */ jpayne@69: jpayne@69: /* html_ostream_t is a subtype of ostream_t. */ jpayne@69: typedef ostream_t html_ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void html_ostream_write_mem (html_ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void html_ostream_flush (html_ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void html_ostream_free (html_ostream_t first_arg); jpayne@69: extern void html_ostream_begin_span (html_ostream_t first_arg, const char *classname); jpayne@69: extern void html_ostream_end_span (html_ostream_t first_arg, const char *classname); jpayne@69: extern const char *html_ostream_get_hyperlink_ref (html_ostream_t first_arg); jpayne@69: extern void html_ostream_set_hyperlink_ref (html_ostream_t first_arg, const char *ref); jpayne@69: /* Like html_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it jpayne@69: leaves the destination with the current text style enabled, instead jpayne@69: of with the default text style. jpayne@69: After calling this function, you can output strings without newlines(!) jpayne@69: to the underlying stream, and they will be rendered like strings passed jpayne@69: to 'ostream_write_mem', 'ostream_write_str', or 'ostream_write_printf'. */ jpayne@69: extern void html_ostream_flush_to_current_style (html_ostream_t stream); jpayne@69: /* Accessors. */ jpayne@69: extern ostream_t html_ostream_get_destination (html_ostream_t stream); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Create an output stream that takes input in the UTF-8 encoding and jpayne@69: writes it in HTML form on DESTINATION. jpayne@69: This stream produces a sequence of lines. The caller is responsible jpayne@69: for opening the elements before and for closing them after jpayne@69: the use of this stream. jpayne@69: Note that the resulting stream must be closed before DESTINATION can be jpayne@69: closed. */ jpayne@69: extern html_ostream_t html_ostream_create (ostream_t destination); jpayne@69: jpayne@69: jpayne@69: /* Test whether a given output stream is a html_ostream. */ jpayne@69: extern bool is_instance_of_html_ostream (ostream_t stream); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* ----------------------- From term-styled-ostream.h ----------------------- */ jpayne@69: jpayne@69: /* term_styled_ostream_t is a subtype of styled_ostream_t. */ jpayne@69: typedef styled_ostream_t term_styled_ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void term_styled_ostream_write_mem (term_styled_ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void term_styled_ostream_flush (term_styled_ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void term_styled_ostream_free (term_styled_ostream_t first_arg); jpayne@69: extern void term_styled_ostream_begin_use_class (term_styled_ostream_t first_arg, const char *classname); jpayne@69: extern void term_styled_ostream_end_use_class (term_styled_ostream_t first_arg, const char *classname); jpayne@69: extern const char *term_styled_ostream_get_hyperlink_ref (term_styled_ostream_t first_arg); jpayne@69: extern const char *term_styled_ostream_get_hyperlink_id (term_styled_ostream_t first_arg); jpayne@69: extern void term_styled_ostream_set_hyperlink (term_styled_ostream_t first_arg, const char *ref, const char *id); jpayne@69: extern void term_styled_ostream_flush_to_current_style (term_styled_ostream_t first_arg); jpayne@69: /* Accessors. */ jpayne@69: extern term_ostream_t term_styled_ostream_get_destination (term_styled_ostream_t stream); jpayne@69: extern const char *term_styled_ostream_get_css_filename (term_styled_ostream_t stream); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Create an output stream referring to the file descriptor FD, styled with jpayne@69: the file CSS_FILENAME. jpayne@69: FILENAME is used only for error messages. jpayne@69: TTY_CONTROL specifies the amount of control to take over the underlying tty. jpayne@69: Note that the resulting stream must be closed before FD can be closed. jpayne@69: Return NULL upon failure. */ jpayne@69: extern term_styled_ostream_t jpayne@69: term_styled_ostream_create (int fd, const char *filename, jpayne@69: ttyctl_t tty_control, jpayne@69: const char *css_filename); jpayne@69: jpayne@69: jpayne@69: /* Test whether a given output stream is a term_styled_ostream. */ jpayne@69: extern bool is_instance_of_term_styled_ostream (ostream_t stream); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* ----------------------- From html-styled-ostream.h ----------------------- */ jpayne@69: jpayne@69: /* html_styled_ostream_t is a subtype of styled_ostream_t. */ jpayne@69: typedef styled_ostream_t html_styled_ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void html_styled_ostream_write_mem (html_styled_ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void html_styled_ostream_flush (html_styled_ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void html_styled_ostream_free (html_styled_ostream_t first_arg); jpayne@69: extern void html_styled_ostream_begin_use_class (html_styled_ostream_t first_arg, const char *classname); jpayne@69: extern void html_styled_ostream_end_use_class (html_styled_ostream_t first_arg, const char *classname); jpayne@69: extern const char *html_styled_ostream_get_hyperlink_ref (html_styled_ostream_t first_arg); jpayne@69: extern const char *html_styled_ostream_get_hyperlink_id (html_styled_ostream_t first_arg); jpayne@69: extern void html_styled_ostream_set_hyperlink (html_styled_ostream_t first_arg, const char *ref, const char *id); jpayne@69: extern void html_styled_ostream_flush_to_current_style (html_styled_ostream_t first_arg); jpayne@69: /* Accessors. */ jpayne@69: extern ostream_t html_styled_ostream_get_destination (html_styled_ostream_t stream); jpayne@69: extern html_ostream_t html_styled_ostream_get_html_destination (html_styled_ostream_t stream); jpayne@69: extern const char *html_styled_ostream_get_css_filename (html_styled_ostream_t stream); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Create an output stream that takes input in the UTF-8 encoding and jpayne@69: writes it in HTML form on DESTINATION, styled with the file CSS_FILENAME. jpayne@69: Note that the resulting stream must be closed before DESTINATION can be jpayne@69: closed. */ jpayne@69: extern html_styled_ostream_t jpayne@69: html_styled_ostream_create (ostream_t destination, jpayne@69: const char *css_filename); jpayne@69: jpayne@69: jpayne@69: /* Test whether a given output stream is a html_styled_ostream. */ jpayne@69: extern bool is_instance_of_html_styled_ostream (ostream_t stream); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* ----------------------- From noop-styled-ostream.h ----------------------- */ jpayne@69: jpayne@69: /* noop_styled_ostream_t is a subtype of styled_ostream_t. */ jpayne@69: typedef styled_ostream_t noop_styled_ostream_t; jpayne@69: jpayne@69: /* Functions that invoke the methods. */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern void noop_styled_ostream_write_mem (noop_styled_ostream_t first_arg, const void *data, size_t len); jpayne@69: extern void noop_styled_ostream_flush (noop_styled_ostream_t first_arg, ostream_flush_scope_t scope); jpayne@69: extern void noop_styled_ostream_free (noop_styled_ostream_t first_arg); jpayne@69: extern void noop_styled_ostream_begin_use_class (noop_styled_ostream_t first_arg, const char *classname); jpayne@69: extern void noop_styled_ostream_end_use_class (noop_styled_ostream_t first_arg, const char *classname); jpayne@69: extern const char *noop_styled_ostream_get_hyperlink_ref (noop_styled_ostream_t first_arg); jpayne@69: extern const char *noop_styled_ostream_get_hyperlink_id (noop_styled_ostream_t first_arg); jpayne@69: extern void noop_styled_ostream_set_hyperlink (noop_styled_ostream_t first_arg, const char *ref, const char *id); jpayne@69: extern void noop_styled_ostream_flush_to_current_style (noop_styled_ostream_t first_arg); jpayne@69: /* Accessors. */ jpayne@69: extern ostream_t noop_styled_ostream_get_destination (noop_styled_ostream_t stream); jpayne@69: extern bool noop_styled_ostream_is_owning_destination (noop_styled_ostream_t stream); jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Create an output stream that delegates to DESTINATION and that supports jpayne@69: the styling operations as no-ops. jpayne@69: If PASS_OWNERSHIP is true, closing the resulting stream will automatically jpayne@69: close the DESTINATION. jpayne@69: Note that if PASS_OWNERSHIP is false, the resulting stream must be closed jpayne@69: before DESTINATION can be closed. */ jpayne@69: extern noop_styled_ostream_t jpayne@69: noop_styled_ostream_create (ostream_t destination, bool pass_ownership); jpayne@69: jpayne@69: jpayne@69: /* Test whether a given output stream is a noop_styled_ostream. */ jpayne@69: extern bool is_instance_of_noop_styled_ostream (ostream_t stream); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* ------------------------------ From color.h ------------------------------ */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Whether to output a test page. */ jpayne@69: extern LIBTEXTSTYLE_DLL_VARIABLE bool color_test_mode; jpayne@69: jpayne@69: /* Color option. */ jpayne@69: enum color_option { color_no, color_tty, color_yes, color_html }; jpayne@69: extern LIBTEXTSTYLE_DLL_VARIABLE enum color_option color_mode; jpayne@69: jpayne@69: /* Style to use when coloring. */ jpayne@69: extern LIBTEXTSTYLE_DLL_VARIABLE const char *style_file_name; jpayne@69: jpayne@69: /* --color argument handling. Return an error indicator. */ jpayne@69: extern bool handle_color_option (const char *option); jpayne@69: jpayne@69: /* --style argument handling. */ jpayne@69: extern void handle_style_option (const char *option); jpayne@69: jpayne@69: /* Print a color test page. */ jpayne@69: extern void print_color_test (void); jpayne@69: jpayne@69: /* Assign a default value to style_file_name if necessary. jpayne@69: STYLE_FILE_ENVVAR is an environment variable that, when set to a non-empty jpayne@69: value, specifies the style file to use. This environment variable is meant jpayne@69: to be set by the user. jpayne@69: STYLESDIR_ENVVAR is an environment variable that, when set to a non-empty jpayne@69: value, specifies the directory with the style files, or NULL. This is jpayne@69: necessary for running the testsuite before "make install". jpayne@69: STYLESDIR_AFTER_INSTALL is the directory with the style files after jpayne@69: "make install". jpayne@69: DEFAULT_STYLE_FILE is the file name of the default style file, relative to jpayne@69: STYLESDIR. */ jpayne@69: extern void style_file_prepare (const char *style_file_envvar, jpayne@69: const char *stylesdir_envvar, jpayne@69: const char *stylesdir_after_install, jpayne@69: const char *default_style_file); jpayne@69: jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* ------------------------------ From misc.h ------------------------------ */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /* Create an output stream referring to the file descriptor FD, styled with jpayne@69: the file CSS_FILENAME if possible. jpayne@69: FILENAME is used only for error messages. jpayne@69: TTY_CONTROL specifies the amount of control to take over the underlying tty. jpayne@69: Note that the resulting stream must be closed before FD can be closed. */ jpayne@69: extern styled_ostream_t jpayne@69: styled_ostream_create (int fd, const char *filename, jpayne@69: ttyctl_t tty_control, jpayne@69: const char *css_filename); jpayne@69: jpayne@69: /* Set the exit value upon failure within libtextstyle. */ jpayne@69: extern void libtextstyle_set_failure_exit_code (int exit_code); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /* ----------------------- Exported gnulib overrides ----------------------- */ jpayne@69: jpayne@69: #if defined _WIN32 && ! defined __CYGWIN__ jpayne@69: jpayne@69: # include jpayne@69: jpayne@69: # ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: # endif jpayne@69: jpayne@69: # if !((defined isatty && defined _GL_UNISTD_H) || defined GNULIB_overrides_isatty) /* don't override gnulib */ jpayne@69: extern int libtextstyle_isatty (int fd); jpayne@69: # undef isatty jpayne@69: # define isatty libtextstyle_isatty jpayne@69: # endif jpayne@69: jpayne@69: # ifdef __cplusplus jpayne@69: } jpayne@69: # endif jpayne@69: jpayne@69: #endif jpayne@69: jpayne@69: /* ------------------------------------------------------------------------- */ jpayne@69: jpayne@69: #endif /* _TEXTSTYLE_H */