-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dashboard): introducing support for full resolution dashboard images in terminals that support Kitty graphics protocol #1586
base: main
Are you sure you want to change the base?
Conversation
…s that support kitty graphics protocol
lua/snacks/dashboard.lua
Outdated
-- hash to prevent randomizing the same image url twice | ||
local randomized_urls = {} | ||
|
||
---@param opts {src:string, height?:number, width?:number, random_src_param?:boolean}|snacks.dashboard.Item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the last param field be randomize_src
instead of random_src_param
?
I'm just asking genuinely as I'm not good at programming and might totally misunderstand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good point! I'll fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
It's not up to me, but the randomized URL functionality seems better to not be in this. Maybe something like the following would be better:
That way the function can do whatever it wants, including randomizing. Does this support files on the local file system? (Note: I used the name |
This is a great idea and, in fact, allows for simpler implementation. I'll implement that today. And, yes, the code supports local images because Folke's Image class supports that out of the box. Thanks for the tip! |
…(path or URL) or a function that returns location
@saxon1964 I'm just a simple user with very limited programming knowledge as a hobby of mine. I'm not a programmer. I haven't even looked at The maintainer will review this properly. |
I'd be very happy to see this or something like this added. I am not a programmer, so this could just be a skill issue, but is it not feasible to add the align property the image section for the dashboard? |
(as of 23 March, all suggestions and changes have been implemented and the following text has been updated accordingly)
Current dashboard implementation does not allow "real" images on snacks dashboard. All that you can get is chafa-like images that are just plain ugly (unless you are happy with character blocks colored with some almost random color). The real image is almost unrecognizable. In Kitty and several other terminals it is possible to render image natively. And all support for it is already there, built into snacks. I have just connected some simple dots.
Isn't it nice? :)
Here is my dashboard configuration:
Notice that there is a new section ("image"). Image source is a web URL or a path to a local image, or a function that returns URL or path. In this particular case image is obtained from "picsum" online service. Snacks cashes images so by calling the same URL you'll get the same image from the cache. Because of that source key is a function that appends some random parameter to the URL. You always get one new image per session because URLs do not match strictly!
To function properly, a bug in placement.lua file has to be fixed as well (which I did). The code places extmark while image is being converted but it does not do proper cleanup when the conversion is over. That leaves an ugly image processing message on the screen above the image.
I believe this is a logical addition to snacks.dashboard - why stay limited to chafa in the era of kitty and other terminals that handle native images perfectly?