Terminal Utilities¶
Utilities for working with the terminal.
Module Overview:
encoding - provides the ANSI escape sequence for a terminal attribute
format - wrap text with ANSI for the given colors or attributes
- stem.util.term.Color(enum)¶
- stem.util.term.BgColor(enum)¶
Foreground or background terminal colors.
Color Description BLACK black color BLUE blue color CYAN cyan color GREEN green color MAGENTA magenta color RED red color WHITE white color YELLOW yellow color
- stem.util.term.Attr(enum)¶
Terminal text attributes.
Changed in version 1.5.0: Added the LINES attribute.
Attr Description BOLD heavy typeface HIGHLIGHT inverted foreground and background UNDERLINE underlined text READLINE_ESCAPE wrap encodings in RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE sequences LINES formats lines individually
- stem.util.term.encoding(*attrs)[source]¶
Provides the ANSI escape sequence for these terminal color or attributes.
New in version 1.5.0.
Parameters: attr (list) -- Color, BgColor, or Attr to provide an ecoding for Returns: str of the ANSI escape sequence, None no attributes are recognized
- stem.util.term.format(msg, *attr)[source]¶
Simple terminal text formatting using ANSI escape sequences. The following are some toolkits providing similar capabilities:
Changed in version 1.6.0: Normalized return value to be unicode to better support python 2/3 compatibility.
Parameters: Returns: unicode wrapped with ANSI escape encodings, starting with the given attributes and ending with a reset