You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importsysfrombase64importstandard_b64encode# --- this is copied from https://sw.kovidgoyal.net/kitty/graphics-protocol/#a-minimal-exampledefserialize_gr_command(**cmd):
payload=cmd.pop('payload', None)
cmd=','.join(f'{k}={v}'fork, vincmd.items())
ans= []
w=ans.appendw(b'\033_G'), w(cmd.encode('ascii'))
ifpayload:
w(b';')
w(payload)
w(b'\033\\')
returnb''.join(ans)
defwrite_chunked(**cmd):
data=standard_b64encode(cmd.pop('data'))
whiledata:
chunk, data=data[:4096], data[4096:]
m=1ifdataelse0sys.stdout.buffer.write(serialize_gr_command(payload=chunk, m=m,
**cmd))
sys.stdout.flush()
cmd.clear()
# -----------------------------------------------------------------------------defmove_cursor(x,y):
cmd="\x1b[{};{}H".format(y,x)
sys.stdout.write(cmd)
sys.stdout.flush()
defset_bg_color():
cmd="\x1b[41m"sys.stdout.write(cmd)
sys.stdout.flush()
defrun_example(image_path):
x=0y=0offset=5# draw some text with red backgroundforiinrange(10):
move_cursor(x, y+i)
set_bg_color()
print("this is some text on top of the image")
# draw image at an offsetmove_cursor(x+offset, y+offset)
# Negative z-index values below INT32_MIN/2 (-1,073,741,824) will be drawn under cells with non-default background colors.INT32_MIN_2=-1_073_741_824z=INT32_MIN_2-100withopen(image_path, 'rb') asf:
write_chunked(a='T', f=100, data=f.read(), z=z)
# path to a png image:image_path="/path/to/image.png"run_example(image_path)
Here's the result:
As you see, the image is below the text, but not below the background color.
How do I use z-index correctly to draw cells with background color over the image?
The text was updated successfully, but these errors were encountered:
So it was a bug. I thought I did something wrong. How is it that no one found this before?
Anyway, thanks for the fix. But I did not test your patch yet, because I don't want to build this from source.
I'm going to wait for the next release.
@page-down Thanks for the info. That patch wasn't in nightly when I wrote it.
But now I did install the newest nightly and can confirm that this issue is fixed.
The documentation states:
"Negative z-index values below INT32_MIN/2 (-1,073,741,824) will be drawn under cells with non-default background colors."
(https://sw.kovidgoyal.net/kitty/graphics-protocol/#controlling-displayed-image-layout)
Here's is an example code that attempts to do this.
Here's the result:

As you see, the image is below the text, but not below the background color.
How do I use z-index correctly to draw cells with background color over the image?
The text was updated successfully, but these errors were encountered: