mrcrowbar.ansi module¶
-
mrcrowbar.ansi.ANSI_CURSOR_MOVE_BACKWARD= '\x1b[{}D'¶ ANSI escape sequence to move the cursor backward.
-
mrcrowbar.ansi.ANSI_CURSOR_MOVE_DOWN= '\x1b[{}B'¶ ANSI escape sequence to move the cursor down.
-
mrcrowbar.ansi.ANSI_CURSOR_MOVE_FORWARD= '\x1b[{}C'¶ ANSI escape sequence to move the cursor forward.
-
mrcrowbar.ansi.ANSI_CURSOR_MOVE_UP= '\x1b[{}A'¶ ANSI escape sequence to move the cursor up.
-
mrcrowbar.ansi.ANSI_CURSOR_SET_POSITION= '\x1b[{};{}H'¶ ANSI escape sequence to set the cursor position. (1, 1) is the top left.
-
mrcrowbar.ansi.ANSI_ERASE_BASE= '\x1b[{}J'¶ Container for ANSI escape sequence screen erasing
-
mrcrowbar.ansi.ANSI_ERASE_SCREEN= '\x1b[2J'¶ ANSI escape sequence for clearing the visible terminal
-
mrcrowbar.ansi.ANSI_ERASE_SCROLLBACK= '\x1b[3J'¶ ANSI escape sequence for clearing the scrollback of the terminal
-
mrcrowbar.ansi.ANSI_FORMAT_BACKGROUND_CMD= '48;2;{};{};{}'¶ ANSI escape sequence for setting the background colour (24-bit).
-
mrcrowbar.ansi.ANSI_FORMAT_BACKGROUND_XTERM_CMD= '48;5;{}'¶ ANSI escape sequence for setting the background colour (xterm).
-
mrcrowbar.ansi.ANSI_FORMAT_BASE= '\x1b[{}m'¶ Container for ANSI escape sequences for text formatting
-
mrcrowbar.ansi.ANSI_FORMAT_BLINK_CMD= '5'¶ ANSI escape sequence for bold text
-
mrcrowbar.ansi.ANSI_FORMAT_BOLD_CMD= '1'¶ ANSI escape sequence for bold text
-
mrcrowbar.ansi.ANSI_FORMAT_FAINT_CMD= '2'¶ ANSI escape sequence for faint text
-
mrcrowbar.ansi.ANSI_FORMAT_FOREGROUND_CMD= '38;2;{};{};{}'¶ ANSI escape sequence for setting the foreground colour (24-bit).
-
mrcrowbar.ansi.ANSI_FORMAT_FOREGROUND_XTERM_CMD= '38;5;{}'¶ ANSI escape sequence for setting the foreground colour (xterm).
-
mrcrowbar.ansi.ANSI_FORMAT_INVERTED_CMD= '7'¶ ANSI escape sequence for inverted text
-
mrcrowbar.ansi.ANSI_FORMAT_ITALIC_CMD= '3'¶ ANSI escape sequence for bold text
-
mrcrowbar.ansi.ANSI_FORMAT_RESET_CMD= '0'¶ ANSI escape sequence for resetting the colour settings to the default.
-
mrcrowbar.ansi.ANSI_FORMAT_UNDERLINE_CMD= '4'¶ ANSI escape sequence for bold text
-
mrcrowbar.ansi.BAR_HORIZ= ' ▏▎▍▌▋▊▉█'¶ Unicode representation of a horizontal bar graph.
-
mrcrowbar.ansi.BAR_VERT= ' ▁▂▃▄▅▆▇█'¶ Unicode representation of a vertical bar graph.
-
class
mrcrowbar.ansi.HexdumpHighlightBuffer(source: BytesReadType, start: int | None = None, end: int | None = None, length: int | None = None, major_len: int = 8, minor_len: int = 4, use_colour: bool = True, address_base: int | None = None, before: int = 2, after: int = 2, title: str | None = None)[source]¶ Bases:
object
-
mrcrowbar.ansi.format_bar_graph_iter(data: Sequence[int], width: int = 64, height: int = 12, y_min: int | None = None, y_max: int | None = None)[source]¶
-
mrcrowbar.ansi.format_escape(foreground: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], mrcrowbar.colour.BaseColour, None] = None, background: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], mrcrowbar.colour.BaseColour, None] = None, bold: bool = False, faint: bool = False, italic: bool = False, underline: bool = False, blink: bool = False, inverted: bool = False)[source]¶ Returns the ANSI escape sequence to set character formatting.
- foreground
- Foreground colour to use. Accepted types: None, int (xterm palette ID), tuple (RGB, RGBA), Colour
- background
- Background colour to use. Accepted types: None, int (xterm palette ID), tuple (RGB, RGBA), Colour
- bold
- Enable bold text (default: False)
- faint
- Enable faint text (default: False)
- italic
- Enable italic text (default: False)
- underline
- Enable underlined text (default: False)
- blink
- Enable blinky text (default: False)
- inverted
- Enable inverted text (default: False)
-
mrcrowbar.ansi.format_hexdump_line(source: BytesReadType, offset: int, end: int | None = None, major_len: int = 8, minor_len: int = 4, colour: bool = True, prefix: str = '', highlight_addr: int | None = None, highlight_map: dict[int, colour.ColourType] | None = None, address_base_offset: int = 0, show_offsets: bool = True, show_glyphs: bool = True)[source]¶
-
mrcrowbar.ansi.format_histdump_line(source: BytesReadType, offset: int, length: int | None = None, end: int | None = None, width: int = 64, address_base_offset: int = 0, palette: Sequence[colour.ColourType] | None = None)[source]¶
-
mrcrowbar.ansi.format_histogram_line(buckets: Sequence[int], palette: Sequence[colour.ColourType] | None = None) → str[source]¶
-
mrcrowbar.ansi.format_image_iter(data_fetch: Callable[[int, int, int], colour.ColourType], x_start: int = 0, y_start: int = 0, width: int = 32, height: int = 32, frame: int | Sequence[int] = 0, columns: int = 1, downsample: int = 1)[source]¶ Return the ANSI escape sequence to render a bitmap image.
- data_fetch
- Function that takes three arguments (x position, y position, and frame) and returns a Colour corresponding to the pixel stored there, or Transparent if the requested pixel is out of bounds.
- x_start
- Offset from the left of the image data to render from. Defaults to 0.
- y_start
- Offset from the top of the image data to render from. Defaults to 0.
- width
- Width of the image data to render. Defaults to 32.
- height
- Height of the image data to render. Defaults to 32.
- frame
- Single frame number/object, or a list to render in sequence. Defaults to frame 0.
- columns
- Number of frames to render per line (useful for printing tilemaps!). Defaults to 1.
- downsample
- Shrink larger images by printing every nth pixel only. Defaults to 1.
-
mrcrowbar.ansi.format_pixels(top: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], mrcrowbar.colour.BaseColour, None], bottom: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], mrcrowbar.colour.BaseColour, None], reset: bool = True, repeat: int = 1)[source]¶ Return the ANSI escape sequence to render two vertically-stacked pixels as a single monospace character.
- top
- Top colour to use. Accepted types: None, int (xterm palette ID), tuple (RGB, RGBA), Colour
- bottom
- Bottom colour to use. Accepted types: None, int (xterm palette ID), tuple (RGB, RGBA), Colour
- reset
- Reset the formatting at the end (default: True)
- repeat
- Number of horizontal pixels to render (default: 1)
-
mrcrowbar.ansi.format_string(string: str, foreground: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], mrcrowbar.colour.BaseColour, None] = None, background: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], mrcrowbar.colour.BaseColour, None] = None, reset: bool = True, bold: bool = False, faint: bool = False, italic: bool = False, underline: bool = False, blink: bool = False, inverted: bool = False) → str[source]¶ Returns a Unicode string formatted with an ANSI escape sequence.
- string
- String to format
- foreground
- Foreground colour to use. Accepted types: None, int (xterm palette ID), tuple (RGB, RGBA), Colour
- background
- Background colour to use. Accepted types: None, int (xterm palette ID), tuple (RGB, RGBA), Colour
- reset
- Reset the formatting at the end (default: True)
- bold
- Enable bold text (default: False)
- faint
- Enable faint text (default: False)
- italic
- Enable italic text (default: False)
- underline
- Enable underlined text (default: False)
- blink
- Enable blinky text (default: False)
- inverted
- Enable inverted text (default: False)