Next: , Previous: , Up: Concrete ostream subclasses without styling   [Contents][Index]


3.5.3.3 The term_ostream class

The term_ostream class supports output to a file descriptor that is connected to a terminal emulator or console. Its type is ‘term_ostream_t’. It is a subclass of ‘ostream_t’.

It can be instantiated through this function:

Function: term_ostream_t term_ostream_create (int fd, const char *filename, ttyctl_t tty_control)

Creates an output stream referring to the file descriptor fd.

filename is used only for error messages.

tty_control specifies the amount of control to take over the underlying tty.

The resulting stream will be line-buffered.

Note: The resulting stream must be closed before fd can be closed.

The class adds the following methods:

Function: term_color_t term_ostream_rgb_to_color (term_ostream_t stream, int red, int green, int blue)

Converts an RGB value (red, green, blue in [0..255]) to a color, valid for this stream only.

Function: term_color_t term_ostream_get_color (term_ostream_t stream)
Function: void term_ostream_set_color (term_ostream_t stream, term_color_t color)

Gets/sets the text color.

Function: term_color_t term_ostream_get_bgcolor (term_ostream_t stream)
Function: void term_ostream_set_bgcolor (term_ostream_t stream, term_color_t color)

Gets/sets the background color.

Function: term_weight_t term_ostream_get_weight (term_ostream_t stream)
Function: void term_ostream_set_weight (term_ostream_t stream, term_weight_t weight)

Gets/sets the font weight.

Function: term_posture_t term_ostream_get_posture (term_ostream_t stream)
Function: void term_ostream_set_posture (term_ostream_t stream, term_posture_t posture)

Gets/sets the font posture.

Function: term_underline_t term_ostream_get_underline (term_ostream_t stream)
Function: void term_ostream_set_underline (term_ostream_t stream, term_underline_t underline)

Gets/sets the text underline decoration.

Returns the referred URL of the currently set hyperlink, or NULL if no hyperlink attribute is currently set.

Note: The returned string is only valid up to the next invocation of term_ostream_set_hyperlink.

Returns the id of the currently set hyperlink, or NULL if no hyperlink attribute is currently set.

Note: The returned string is only valid up to the next invocation of term_ostream_set_hyperlink.

Sets or removes a hyperlink attribute.

To set a hyperlink attribute, pass a non-NULL ref. ref is an URL; it should be at most 2083 bytes long. Non-ASCII characters should be URI-escaped (using the %nn syntax). id is an optional identifier. Multiple hyperlinks with the same id will be highlighted together. If specified, id should be at most 250 bytes long.

To remove a hyperlink attribute, pass NULL for ref and id.

Hyperlinks don’t nest. That is, a hyperlink attribute is enabled only up to the next invocation of styled_ostream_set_hyperlink.

Function: void term_ostream_flush_to_current_style (term_ostream_t stream)

This function acts like ostream_flush (stream, FLUSH_THIS_STREAM), except that it leaves the terminal with the current text attributes enabled, instead of with the default text attributes.

After calling this function, you can output strings without newlines(!) to the underlying file descriptor, and they will be rendered like strings passed to ostream_write_mem, ostream_write_str, or ostream_printf.


Next: The html_ostream class, Previous: The fd_ostream class, Up: Concrete ostream subclasses without styling   [Contents][Index]