hpjansson / chafa

📺🗿 Terminal graphics for the 21st century.
https://hpjansson.org/chafa/
GNU Lesser General Public License v3.0
2.97k stars 64 forks source link

[Feature request]Add the ability to remove individual images. #219

Open Sem1Rose opened 1 month ago

Sem1Rose commented 1 month ago

The --clear option clears the entire terminal window, but i want to keep the terminal contents and only remove a specific image, similar to Ueberzugpp's identifier option. OS: Arch linux Terminal: kitty

hpjansson commented 1 month ago

Thanks for filing the issue. This wouldn't be too hard to do, since we already support identifiers at the API level. However, it would only work with the Kitty protocol. The command line could look something like this:

Show image(s): chafa -f kitty --image-id 5 (shown images would be assigned IDs in ascending order starting at 5). Remove image: chafa -f kitty --image-id 5 --remove-image

Would this do what you want, or are you using --clear with multiple images (e.g. a slideshow) and need it to remove the image before showing the next, instead of clearing everything?

Sem1Rose commented 1 month ago

Thanks for the reply, I think what I'm trying to achieve isn't about clearing the images, it's more about "don't display that specific image anymore." So for example, i have a bunch of images, each with its own description. Now, what i want to achieve is that for one of these images to just "cease to exist" without affecting the other images or their descriptions. I'm not really home atm to test these commands, but as soon as im back I'll give them a go, hopefully this'll be exactly what I'm trying to achieve.

hpjansson commented 1 month ago

Ah, the options don't exist yet, it's just my suggestion for how we could implement this. Based on your description of the issue, it sounds like what you need.

Are you calling chafa from another program?

Sem1Rose commented 1 month ago

the options don't exist yet

Bummer, i hope you have time to implement it soon, fingers crossed it doesn't take too much time.

Are you calling chafa from another program?

yeah, i am, it's a rust program i've been working on for a while now. In a nutshell, i'm not directly using chafa to display images in the terminal, since this would take too much time. Instead, i'm caching the output of chafa for each image, and then to display the image i just print the cached output to the terminal, which takes significantly less time than just directly using chafa.

Edit: Actually, now that i think about it, will this method work with the --remove-image option? i'm not really sure, i think it depends on the implementation.

hpjansson commented 1 month ago

I think it could work, but only with the Kitty protocol. Chafa also supports symbol mosaics, sixels and iTerm, and it wouldn't work with those.