term: add functions for detecting Sixel support + example #21665
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds 2 functions (and an example) to the
term
module that can query the terminal's graphics attributes.One for detecting Sixel support and one for how many color registers the graphics device has in use. The later is useful if you later want to try to set a higher number of colors, depending on how many colors the Sixel image have.
Running the example in a Sixel compatible terminal should look something like this:
Konsole:
![image](https://private-user-images.githubusercontent.com/768942/338527089-55feba55-fcc7-4caf-8611-29b6c383fc19.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMjkzMTEsIm5iZiI6MTczOTEyOTAxMSwicGF0aCI6Ii83Njg5NDIvMzM4NTI3MDg5LTU1ZmViYTU1LWZjYzctNGNhZi04NjExLTI5YjZjMzgzZmMxOS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQxOTIzMzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02YjkyZTc4ODVmOWVlNGUwMTQ2MGI1ZjNhMjUyZGY0N2ZmYjQ3YTI1N2RhYTNkYmJjNGJhNzg0YWUwNGIxNTZmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.tLTt8P8ijpnj8ilWm77h6LzGWcvLovCTviNO3vutXAY)
Xterm in
![image](https://private-user-images.githubusercontent.com/768942/338554034-2787ded3-0844-48ba-8d47-e920973b6f7b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMjkzMTEsIm5iZiI6MTczOTEyOTAxMSwicGF0aCI6Ii83Njg5NDIvMzM4NTU0MDM0LTI3ODdkZWQzLTA4NDQtNDhiYS04ZDQ3LWU5MjA5NzNiNmY3Yi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQxOTIzMzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05MGQ0NmRhMjE4MDliMDU2M2VlYzVkZThjYzNkMTYyYmVlM2UyN2E0MWU1NzAwODQ1ZDY5OTJkNTY1MjkwZDhmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.jOYUHhuoBq9C5-v7ajWNEbcDZyKWnse-4ZhQWPC0DKs)
vt340
mode:Vanilla
xterm
needs this in~/.Xresources
:To apply run:
xrdb -merge ~/.Xresources
Terminal Sixel support is tracked here: https://www.arewesixelyet.com
ImageMagick can convert regular images to sixel format, if you want to play around:
Bonus tip: it also works over ssh