diff --git a/pyte/escape.py b/pyte/escape.py index 7dfd6b8..5397a4b 100644 --- a/pyte/escape.py +++ b/pyte/escape.py @@ -113,6 +113,9 @@ #: *Horizontal position relative*: Same as :data:`CUF`. HPR = "a" +#: *Repeat*: Repeat the preceding graphic character # times +REP = "b" + #: *Device Attributes*. DA = "c" diff --git a/pyte/screens.py b/pyte/screens.py index ebbac7c..d106a57 100644 --- a/pyte/screens.py +++ b/pyte/screens.py @@ -222,6 +222,7 @@ def __init__(self, columns: int, lines: int) -> None: self.reset() self.mode = _DEFAULT_MODE.copy() self.margins: Optional[Margins] = None + self.last_char: str = "" def __repr__(self) -> str: return ("{0}({1}, {2})".format(self.__class__.__name__, @@ -479,6 +480,7 @@ def draw(self, data: str) -> None: self.g1_charset if self.charset else self.g0_charset) for char in data: + self.last_char = char char_width = wcwidth(char) # If this was the last column in a line and auto wrap mode is @@ -698,6 +700,14 @@ def insert_characters(self, count: Optional[int] = None) -> None: line[x + count] = line[x] line.pop(x, None) + def repeat_character(self, count: Optional[int] = None) -> None: + """Repeat drawing the last drawn character # times. + + :param int count: number of characters to insert. + """ + if self.last_char: + self.draw(self.last_char * (count or 1)) + def delete_characters(self, count: Optional[int] = None) -> None: """Delete the indicated # of characters, starting with the character at cursor position. When a character is deleted, all diff --git a/pyte/streams.py b/pyte/streams.py index cd0f51c..d6d1a99 100644 --- a/pyte/streams.py +++ b/pyte/streams.py @@ -111,6 +111,7 @@ class Stream: esc.DCH: "delete_characters", esc.ECH: "erase_characters", esc.HPR: "cursor_forward", + esc.REP: "repeat_character", esc.DA: "report_device_attributes", esc.VPA: "cursor_to_line", esc.VPR: "cursor_down",