icat: Allow easily specifying z-index values below background threshold

This commit is contained in:
Kovid Goyal 2020-01-12 09:36:11 +05:30
parent fee08d746c
commit 91673642b3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -96,9 +96,10 @@ Do not print out anything to stdout during operation.
--z-index -z --z-index -z
type=int
default=0 default=0
Z-index of the image. When negative, text will be displayed on top of the image. Z-index of the image. When negative, text will be displayed on top of the image. Use
a double minus for values under the threshold for drawing images under cell background
colors. For example, --1 evaluates as -1,073,741,825.
''' '''
@ -207,6 +208,14 @@ def show(outfile, width, height, zindex, fmt, transmit_mode='t', align='center',
write_chunked(cmd, data) write_chunked(cmd, data)
def parse_z_index(val):
origin = 0
if val.startswith('--'):
val = val[1:]
origin = -1073741824
return origin + int(val)
def process(path, args, is_tempfile): def process(path, args, is_tempfile):
m = identify(path) m = identify(path)
ss = get_screen_size() ss = get_screen_size()
@ -366,6 +375,11 @@ def main(args=sys.argv):
except Exception: except Exception:
raise SystemExit('Not a valid place specification: {}'.format(args.place)) raise SystemExit('Not a valid place specification: {}'.format(args.place))
try:
args.z_index = parse_z_index(args.z_index)
except Exception:
raise SystemExit('Not a valid z-index specification: {}'.format(args.z_index))
if args.detect_support: if args.detect_support:
if not detect_support(wait_for=args.detection_timeout, silent=True): if not detect_support(wait_for=args.detection_timeout, silent=True):
raise SystemExit(1) raise SystemExit(1)