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

Image Preview vifm #1308

Closed
JohnJohnstone opened this issue Jan 15, 2019 · 14 comments
Closed

Image Preview vifm #1308

JohnJohnstone opened this issue Jan 15, 2019 · 14 comments

Comments

@JohnJohnstone
Copy link

Hi @kovidgoyal, I'm having an issue with previewing images inside vifm using the --place option. I am able to use kitty +kitten icat filename without any issue but when i use the place option i get the error "The --place option can only be used with a single image". I have written a few differenct scripts attempting to address the issue i am certain that only one filename is being passed. My solution was to comment out the if statement in the icat kitten and now image preview works as expected.

https://github.com/kovidgoyal/kitty/blob/master/kittens/icat/main.py#L309

   ``` if len(items) > 1 or (isinstance(items[0], str) and os.path.isdir(items[0])):
        raise SystemExit('The --place option can only be used with a single image')```

Thank you for your efforts with this great terminal emulator :)

@kovidgoyal
Copy link
Owner

I dont see anything wrong with the code and running

kitty +kitten icat --place 10x10@0x0 resources/images/lt.png

works as expected. I need some way to reproduce the problem you are having.

@andpalmier
Copy link

I am not sure I am in the right place to post this, but I tried to do the same.
I managed to preview the file without issues, but the clear option does not work as expected. I added in the vifmrc this:

fileviewer *.jpg,*.jpeg,*png,
	\ kitty icat --place=%pwx%ph@%pxx%py %c 
	\ %pc
	\ kitty icat --clear

It seems like the left part of the screen of vifm moves down at every refresh.

@kovidgoyal
Copy link
Owner

I doubt this has anything to do with icat or kitty. icat --clear simply
sends a graphics command to delete all images, it does not affect the
scroll position in any way. As you can test by running it yourself. The
only exception is if you run it and also provide some images, in which
case those images will be displayed after the clear and without --place,
displaying images causes scrolling.

@kovidgoyal
Copy link
Owner

As for the original issue, the problem is that vifm set the stdin of the filviewer program to null instead of the terminal, which breaks icat. I have added a --stdin option to icat to tell it not to try to read images from stding to workaround that. As fo rthe screen moveing after icat, I have no idea, you will need to ask the vifm developers.

@p-kolacz
Copy link

@andpalmier try this

fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
		   \ kitty icat --transfer-mode=file --place=%pwx%ph@%pxx%py %c
		   \ %pc
		   \ kitty icat --transfer-mode=file --clear

The problem is that icat sends "Detecting..." to stdout which breaks vifm. Setting --transfer-mode disable detection.

kovidgoyal added a commit that referenced this issue Feb 27, 2019
@kovidgoyal
Copy link
Owner

I have added --silent to icat

@andpalmier
Copy link

Thanks, now i do not have my Mac anymore, so I cannot test it there.

@FollieHiyuki
Copy link

FollieHiyuki commented Jul 25, 2020

Hi. Is reopening this issue alright? I only moved to vifm recently and got this issue: whenever I turn view mode off then on again the terminal "freaks out" and throws stuff onto the screen endlessly.
My setting for previewing is like this:

fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
               \ kitty icat --silent --place=%pwx%ph@%pxx%py %c
               \ %pc
               \ kitty icat --silent --clear

I can work around this by creating a command to manually do kitty icat --clear instead of putting it into the preview command, but it leaves behind a black frame like this
screen2
My system info:

  • Arch Linux
  • kitty v0.18.1
  • vifm v0.10.1

@GeorgeHJ
Copy link

GeorgeHJ commented Dec 20, 2020

Hi @FollieHiyuki, in case it's useful.

Have you tried using the %pd macro? I just gave it a go and it works for me albeit a little slowly.

From the docs, here:

  %pd   Marks a preview command as one that directly communicates with the terminal. Beware that this is for things like sixel which are self-contained sequences that depend only on current cursor position, using this with anything else is likely to mangle terminal state.
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
\ kitty +icat --place %pwx%ph@%pxx%py  --silent %c
\ %pc
\ kitty icat --clear --silent %pd

@FollieHiyuki
Copy link

Thanks @GeorgeHJ that does fix the issue

@LamprosPitsillos
Copy link

Using the exact snippet that @GeorgeHJ gave above , i get this error.

Traceback (most recent call last):                                                           
	File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main                       
	return _run_code(code, main_globals, None,                                               
			File "/usr/lib/python3.9/runpy.py", line 87, in _run_code                                  
			exec(code, run_globals)                                                                  
			File "/usr/bin/../lib/kitty/__main__.py", line 153, in <module>                            
			main()                                                                                   
			File "/usr/bin/../lib/kitty/__main__.py", line 144, in main                                
			namespaced(['+', first_arg[1:]] + sys.argv[2:])                                          
			File "/usr/bin/../lib/kitty/__main__.py", line 99, in namespaced                           
			func(args[1:])                                                                           
			File "/usr/bin/../lib/kitty/__main__.py", line 13, in icat                                 
			rk('icat')                                                                               
			File "/usr/bin/../lib/kitty/kittens/runner.py", line 122, in run_kitten                    
			runpy.run_module('kittens.{}.main'.format(kitten), run_name=run_name)                    
			File "/usr/lib/python3.9/runpy.py", line 213, in run_module                                
			return _run_code(code, {}, init_globals, run_name, mod_spec)                             
			File "/usr/lib/python3.9/runpy.py", line 87, in _run_code                                  
			exec(code, run_globals)                                                                  
			File "/usr/bin/../lib/kitty/kittens/icat/main.py", line 583, in <module>                   
			main()                                                                                   
			File "/usr/bin/../lib/kitty/kittens/icat/main.py", line 507, in main                       
			sys.stdout = open(os.ctermid(), 'w')                                                     
	OSError: [Errno 6] No such device or address: '/dev/tty' 

Info

Kitty: kitty 0.23.1
Vifm:

Version: 0.12
Git info: built out of repository
Compiled at: Oct  3 2021 09:59:56

Support of extended keys is on
Parsing of .desktop files is enabled
Without GTK+ library
With magic library
Without X11 library
Without dynamic loading of X11 library
With file program
With -n option for cp and mv
With remote command execution

Os: Artix Linux

@hutou
Copy link

hutou commented Oct 25, 2021

Hi,
Exactly same error for me (running on Archlinux)

@Danielgb23
Copy link

Same here. Exact same error running:

filetype *.bmp,*.jpg,*.jpeg,*.png,*.xpm open -a Preview %f &
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.xpm
    \ kitty +kitten icat --clear --transfer-mode=file --place=%pwx%ph@%pxx%py %c
    \ %pc
    \ kitty +kitten icat --transfer-mode=file --place=%pwx%ph@%pxx%py --clear

@cd-a
Copy link

cd-a commented Nov 25, 2021

same issue on macOS

edit: vifm/vifm#731 has a fix

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

10 participants