Skip to content

Commit

Permalink
Updated docs and stubs for terminal_colours
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Oct 16, 2020
1 parent 1ed1ebe commit c724d37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
2 changes: 2 additions & 0 deletions domdf_python_tools/terminal_colours.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def strip_ansi(value: str) -> str:
Strip ANSI colour codes from the given string to return a plaintext output.
:param value:
.. versionadded:: 1.1.0
"""

return _ansi_re.sub("", value)
Expand Down
29 changes: 14 additions & 15 deletions domdf_python_tools/terminal_colours.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ See: http://en.wikipedia.org/wiki/ANSI_escape_code
# Based on colorama
# https://github.com/tartley/colorama
# Copyright Jonathan Hartley 2013
# Distrubuted under the BSD 3-Clause license.
# Distributed under the BSD 3-Clause license.
# | Redistribution and use in source and binary forms, with or without
# | modification, are permitted provided that the following conditions are met:
# |
Expand Down Expand Up @@ -64,13 +64,13 @@ from typing import List
# 3rd party
from typing_extensions import Final

CSI: Final[str] = '\033['
OSC: Final[str] = '\033]'
BEL: Final[str] = '\a'
CSI: Final[str]
OSC: Final[str]
BEL: Final[str]

fore_stack: List[str] = []
back_stack: List[str] = []
style_stack: List[str] = []
fore_stack: List[str]
back_stack: List[str]
style_stack: List[str]


def code_to_chars(code) -> str: ...
Expand All @@ -79,6 +79,9 @@ def clear_screen(mode: int = 2) -> str: ...
def clear_line(mode: int = 2) -> str: ...


def strip_ansi(value: str) -> str: ...


class Colour(str):
style: str
reset: str
Expand Down Expand Up @@ -134,8 +137,8 @@ class AnsiFore(AnsiCodes):

class AnsiBack(AnsiCodes):

_stack = back_stack
_reset = "\033[49m"
_stack: List[str]
_reset: str

BLACK: Colour
RED: Colour
Expand All @@ -160,8 +163,8 @@ class AnsiBack(AnsiCodes):

class AnsiStyle(AnsiCodes):

_stack = style_stack
_reset = "\033[22m"
_stack: List[str]
_reset: str

BRIGHT: Colour
DIM: Colour
Expand All @@ -173,7 +176,3 @@ Fore = AnsiFore()
Back = AnsiBack()
Style = AnsiStyle()
Cursor = AnsiCursor()

fore_stack.append(Fore.RESET)
back_stack.append(Back.RESET)
style_stack.append(Style.NORMAL)

0 comments on commit c724d37

Please sign in to comment.