Style
Term.Style.MarkupStyle
Term.Style.MarkupStyle
Term.Style.apply_style
Term.Style.get_style_codes
Term.Style.is_mode
Term.Style.MarkupStyle
— TypeMarkupStyle
Holds information about the style specification set out by a MarkupTag
.
Term.Style.MarkupStyle
— MethodMarkupStyle(tag::MarkupTag)
Builds a MarkupStyle definition from a MarkupTag.
Term.Style.apply_style
— Methodapply_style(text)
Apply style to a piece of text.
Extract markup style information and insert the appropriate ANSI codes to style a string.
When multiple, nested color tags are present, like in" "{red} abcd {green} asd {/green} eadsa {/red}" extra care should be put to ensure that when green
is closed the text is rendered as red. To this end, this function keeps track of the last color style information and where it occurred in the input text. If the current markup tag is nested in the previous, it changes, for example "{/green}" to "{/green}{red}". The same in parallel has to be done for background colors.
By default, "orphaned" tags (i.e. open/close markup tags without the corresponding tag) are removed from the string. Use leave_orphan_tags
to change this behavior.
Term.Style.get_style_codes
— Methodget_style_codes(style::MarkupStyle)
Get ANSICode
s corresponding to a MarkupStyle
.
Term.Style.is_mode
— MethodCheck if a string is a mode name