icat: Add --clear to clear all display images
This commit is contained in:
parent
076658a1e8
commit
0b3a5a7d45
1 changed files with 17 additions and 4 deletions
|
|
@ -56,6 +56,11 @@ def __init__(self, path, message):
|
|||
the top-left corner of the screen.
|
||||
|
||||
|
||||
--clear
|
||||
type=bool-set
|
||||
Remove all images currently displayed on the screen.
|
||||
|
||||
|
||||
--transfer-mode
|
||||
type=choices
|
||||
choices=detect,file,stream
|
||||
|
|
@ -101,10 +106,14 @@ def screen_size(refresh=False):
|
|||
return screen_size.ans
|
||||
|
||||
|
||||
def write_gr_cmd(cmd, payload):
|
||||
def write_gr_cmd(cmd, payload=None):
|
||||
cmd = ','.join('{}={}'.format(k, v) for k, v in cmd.items())
|
||||
w = sys.stdout.buffer.write
|
||||
w(b'\033_G'), w(cmd.encode('ascii')), w(b';'), w(payload), w(b'\033\\')
|
||||
w(b'\033_G'), w(cmd.encode('ascii'))
|
||||
if payload:
|
||||
w(b';')
|
||||
w(payload)
|
||||
w(b'\033\\')
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
|
|
@ -336,14 +345,18 @@ def main(args=sys.argv):
|
|||
raise SystemExit(1)
|
||||
print('file' if detect_support.has_files else 'stream', end='', file=sys.stderr)
|
||||
return
|
||||
if not items:
|
||||
raise SystemExit('You must specify at least one file to cat')
|
||||
if args.transfer_mode == 'detect':
|
||||
if not detect_support(wait_for=args.detection_timeout):
|
||||
raise SystemExit('This terminal emulator does not support the graphics protocol, use a terminal emulator such as kitty that does support it')
|
||||
else:
|
||||
detect_support.has_files = args.transfer_mode == 'file'
|
||||
errors = []
|
||||
if args.clear:
|
||||
write_gr_cmd({'a': 'd'})
|
||||
if not items:
|
||||
return
|
||||
if not items:
|
||||
raise SystemExit('You must specify at least one file to cat')
|
||||
if args.place:
|
||||
if len(items) > 1 or os.path.isdir(items[0]):
|
||||
raise SystemExit('The --place option can only be used with a single image')
|
||||
|
|
|
|||
Loading…
Reference in a new issue