From 2a266a019749dc4b621f26a5855bc5cb398b237f Mon Sep 17 00:00:00 2001 From: erentar Date: Wed, 23 Apr 2025 18:04:04 +0200 Subject: [PATCH] add a go_back option, as returning will ruin the image on kde konsole --- sixel/sixel.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sixel/sixel.py b/sixel/sixel.py index b8a184a..06d77dd 100644 --- a/sixel/sixel.py +++ b/sixel/sixel.py @@ -25,9 +25,9 @@ def save_position(self, output): output.write('\x1b7') # DECSC def restore_position(self, output): - if not self._body_only: - if os.isatty(output.fileno()): - output.write('\x1b8') # DECRC + if not self._body_only \ + and os.isatty(output.fileno()): + output.write('\x1b8') # DECRC def move_x(self, n, fabsolute, output): if not self._body_only: @@ -60,7 +60,8 @@ def draw(self, ncolor=256, alpha_threshold=0, chromakey=False, - fast=True): + fast=True, + go_back=True): try: filename.seek(0) @@ -86,4 +87,5 @@ def draw(self, sixel_converter.write(output, body_only=self._body_only) finally: - self.restore_position(output) + if go_back: + self.restore_position(output)