Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions sixel/sixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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)