Skip to content
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

w3mimgdisplay command 6 (clear image) is not sent #67

Open
sersorrel opened this issue Aug 6, 2019 · 10 comments
Open

w3mimgdisplay command 6 (clear image) is not sent #67

sersorrel opened this issue Aug 6, 2019 · 10 comments

Comments

@sersorrel
Copy link

I'm running into an issue that patat doesn't tell w3mimgdisplay when it should remove images from the screen – it would be ideal if patat could emit a w3mimgdisplay command (apparently it should look something like 6;x;y;w;h) when the current slide is an image and the slide is changed.

(the reason I noticed this is because I'm writing a pair of wrapper scripts for ueberzug that means it can be used as a drop-in replacement for w3mimgdisplay, but when used in patat my script doesn't have any way to know when to erase the image)

@jaspervdj
Copy link
Owner

I was thinking about this for a bit and it shouldn't be too hard, although it does require significantly changing the Images API.

Basically, right here I'd need to update the type be:

hDrawImage :: FilePath -> IO (IO ())

where the method not only draws the image, but also returns a cleanup function. We then collect those cleanup methods and run them after we change the slide.

@anowlcalledjosh Is this something you are interested in working on, or should I give it a stab?

@jaspervdj
Copy link
Owner

I've created #69 where I define such a cleanup action; I don't actually implement the cleanup action yet though.

@sersorrel
Copy link
Author

Awesome! I'm unlikely to be able to help, sorry – I've got a lot on my plate at the moment and I barely know Haskell, but maybe eventually I'll get around to it.

@jaspervdj
Copy link
Owner

@anowlcalledjosh My branch at #69 now calls w3mimgdisplay again to clear the image. I'll see if I can try it out with ueberzug at some point -- the fact that it doesn't work in tmux is also mildly annoying for me personally.

@sersorrel
Copy link
Author

Nice!

My wrapper script is now available on GitHub, if you want to test with that: https://github.com/anowlcalledjosh/uberw3m

You should be able to use something like this in a presentation header:

patat:
  images:
    backend: w3m
    path: /path/to/uberw3m

then use a command line like uberwrap patat /path/to/presentation.

@sersorrel
Copy link
Author

Right, I had time to install Stack and test your PR; I made some changes to my wrapper script, and now it works perfectly for me. I've not tested in tmux, though.

@jaspervdj
Copy link
Owner

Great! In that case I'll merge it in.

@silky
Copy link

silky commented Jan 10, 2021

FWIW, this doesn't seem to erase the image in konsole ; has anyone else noticed this?

at least the image can be displayed though!

-- edit:

i guess it's because the command

echo -e "6;0;0;$width;$height"|/usr/lib/w3m/w3mimgdisplay

doesn't work

(bafflingly, i think i did work briefly, but i certainly can't reproduce it working now)

@silky
Copy link

silky commented Jan 14, 2021

for any poor desperate souls investigating this, i have some notes from the totally inappropriate amount of time i spent looking into it:

  1. on konsole, the clear doesn't work. it does clear if another konsole action forces a redraw; such as: 1) return is pressed after an image display; forcing the terminal to redraw; 2) the terminal is resized, 3) zoom in or out ( this is why in my comment above i was a bit confused about wither it was clearing or not )

  2. i got totally desparate and finally figured out that i can just return, as the cleanup command, a blank draw image command. i just redraw an image of the same size as the original, in the colour of my terminal background. it might work as a transparent image; i haven't bothered to check. it has to be the same size.

  3. probably one could build this into the library; but it feels too hacky to do that.

-- edit: ps, thanks for such a neat library @jaspervdj - it was really easy to hack around in this codebase!

@vantreeseba
Copy link

vantreeseba commented Apr 28, 2021

I don't know if this helps (since this seems a bit old) but if you send the command for clear, you need to sync and sync the draw.

so
echo -e "6;0;0;$width;$height;\n4;\n3; | /usr/lib/w3m/w3mimgdisplay"

apparently the \n4; is redundant, but yeah.

@jaspervdj jaspervdj reopened this Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants