Skip to content

[feature] Terminal Graphics Protocol support #771

Description

@SlyCedix

I am currently working on a plugin which provides a native previewer for all kinds of files, including images. My plan was to utilize Kitty's Terminal Graphics Protocol and to just pass the rendering string directly through the body of a Dynamic ui element.

Despite the text being correctly formatted, as could be verified by saving it to a file and then using cat, when rendered in xplr it appears as text and runs off the screen.

Image

By running xplr -c repro.lua you can see the issue. The body of the ui element displays unescaped text, but upon exiting, you can see that the image which was printed using io.write works. I'm testing this in kitty 0.45.0

repro.lua:

version = "1.1.0"

local tgptext = "\x1B_Ga=T,q=2,f=100,s=32,v=32;iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGUExURf8AAP///0EdNBEAAAABYktHRAH/Ai3eAAAAB3RJTUUH6gIBBRoi2vHflQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyNi0wMi0wMVQwNToyNjozNCswMDowMJYs8ncAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjYtMDItMDFUMDU6MjY6MzQrMDA6MDDncUrLAAAAKHRFWHRkYXRlOnRpbWVzdGFtcAAyMDI2LTAyLTAxVDA1OjI2OjM0KzAwOjAwsGRrFAAAAAxJREFUCNdjYBjcAAAAoAABYSV9RwAAAABJRU5ErkJggg==\x1B"
io.write(tgptext)
xplr.config.layouts.builtin.default = {
	Static = {
		CustomParagraph = {
			ui = { title = { format = "This should be an image!" } },
			body = tgptext,
		},
	},
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions