Module stdout_formatter_utils

This module contains utility functions used by other modules in this library.

Description

This module contains utility functions used by other modules in this library.

Function Index

compute_text_block_size/1 Computes the size of the rectangle which contains the given list of lines.
displayed_length/1
expand_tabs/1 Expands tab characters to spaces.
merge_inherited_props/1 Prepares the properties map to pass to the child terms.
remove_escape_sequences/1
set_default_props/3 Fills the initial properties map with default and inherited values.
split_lines/1 Splits a text into a list of lines.

Function Details

compute_text_block_size/1

compute_text_block_size(Lines::[unicode:chardata()]) -> {ColumnsCount::non_neg_integer(), RowsCount::non_neg_integer()}

Lines: List of text lines.

returns: the columns and rows count of the rectangle containing the lines.

Computes the size of the rectangle which contains the given list of lines.

The size is returned as the number of columns and rows.

displayed_length/1

displayed_length(Line) -> any()

expand_tabs/1

expand_tabs(Line::unicode:chardata()) -> unicode:chardata()

Line: Line of text to expand.

returns: the same line with tab characters expanded.

Expands tab characters to spaces.

Tab characters are replaced by spaces so that the content is aligned on 8-column boundaries.

merge_inherited_props/1

merge_inherited_props(Props::map()) -> map()

Props: Current term's properties map.

returns: the computed inherited properties map to pass to child terms.

Prepares the properties map to pass to the child terms.

The current term's properties are merged with the inherited properties map it initially received (as stored in the inherited key), the current term's properties having precedence.

The result can be used to pass to child terms' formatting function.

remove_escape_sequences/1

remove_escape_sequences(Line) -> any()

set_default_props/3

set_default_props(Props::map(), Defaults::map(), InheritedProps::map()) -> map()

Props: Initial properties map.
Defaults: Default properties map.
InheritedProps: Inherited properties map.

returns: the completed properties map.

Fills the initial properties map with default and inherited values.

For each property, the value comes from the first source which provides one, with the following order of precedence:
  1. the initial properties map
  2. the inherited properties
  3. the default properties
In the end, the final properties map contains exactly the same keys as those in the default properties map, plus the inherited key which contains the inherited properties map.

split_lines/1

split_lines(Text::unicode:chardata()) -> [unicode:chardata()]

Text: Text to split into lines.

returns: the list of lines.

Splits a text into a list of lines.


Generated by EDoc