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

Making kitty icat work in tmux popup #7165

Closed
junegunn opened this issue Feb 27, 2024 · 4 comments
Closed

Making kitty icat work in tmux popup #7165

junegunn opened this issue Feb 27, 2024 · 4 comments

Comments

@junegunn
Copy link

Is your feature request related to a problem? Please describe.

Currently, kitty icat does not work inside a tmux popup.

Error: Terminal does not support reporting screen sizes in pixels, use a terminal such as kitty, WezTerm, Konsole, etc. that does.

This is probably due to a limitation of the tmux popup implementation. It doesn't report the correct pixel sizes.

tmux popup 'kitty icat --print-window-size'
  # Gives 0x0

Describe the solution you'd like

However, tmux does know the pixel size of a cell even from inside the popup.

tmux popup 'tmux display -p "#{client_cell_width}x#{client_cell_height}"'
  # Gives something like 17x37

(See tmux/tmux@067604b)

So maybe we could pass the information to kitty icat (e.g. something like kitty icat --cell-size 17x37 ...) and make it work even with the current limitation of tmux popup.

Describe alternatives you've considered
Ideally, we could report the problem to the tmux team and wait for the fix. But they don't seem to be as responsive and cooperative as you are, so I'm contacting you first to see how you feel about the workaround.

@kovidgoyal
Copy link
Owner

This is clearly a bug in tmux, with a trivial fix there. I suggest
reporting it there first, and if they refuse to fix it, then I will add
yet another workaround for tmux brokenness.

@junegunn
Copy link
Author

I understand. And, thank you for the patch!

@junegunn
Copy link
Author

junegunn commented Mar 5, 2024

Update:

I've installed Kitty nightly and tested kitty icat inside a tmux popup. But unfortunately it doesn't work as expected.

# Works
kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place=202x13@0x0 --use-window-size=202,13,3434,481 $PWD/fzf.png

# Doesn't display the image
tmux popup -w 202 -h 13 "kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place=202x13@0x0 --use-window-size=202,13,3434,481 $PWD/fzf.png"

I believe this is an issue of the tmux popup not of kitty. Thanks for the help.


One more thing. This is a user error, but icat fails with divide by zero error when the specified pixel width is smaller than the column count. e.g. --use-window-size=202,13,201,481

kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place=202x13@0x0 --use-window-size=202,13,201,481 $PWD/fzf.png
panic: runtime error: integer divide by zero

goroutine 1 [running]:
kitty/kittens/icat.calculate_in_cell_x_offset(...)
        /private/var/folders/wj/cqy1nsyn4wn94d96btkldt0r0000gn/C/t/plugins-daba4sw5/src/kittens/icat/transmit.go:198
kitty/kittens/icat.place_cursor(0x103287580?)
        /private/var/folders/wj/cqy1nsyn4wn94d96btkldt0r0000gn/C/t/plugins-daba4sw5/src/kittens/icat/transmit.go:215 +0x284
kitty/kittens/icat.transmit_image(0x140000b80d0)
        /private/var/folders/wj/cqy1nsyn4wn94d96btkldt0r0000gn/C/t/plugins-daba4sw5/src/kittens/icat/transmit.go:338 +0x224
kitty/kittens/icat.main(0x140001ca200?, 0x1400036a0f0?, {0x140001bab00, 0x1, 0x8})
        /private/var/folders/wj/cqy1nsyn4wn94d96btkldt0r0000gn/C/t/plugins-daba4sw5/src/kittens/icat/main.go:289 +0xd8c
kitty/kittens/icat.create_cmd.func1(0x140001ca200, {0x140001bab00, 0x1, 0x8})
        /private/var/folders/wj/cqy1nsyn4wn94d96btkldt0r0000gn/C/t/plugins-daba4sw5/src/kittens/icat/cli_generated.go:15 +0x90
kitty/tools/cli.(*Command).ExecArgs(0x1400013c000?, {0x140000dc000?, 0x0?, 0x140001cba00?})
        /private/var/folders/wj/cqy1nsyn4wn94d96btkldt0r0000gn/C/t/plugins-daba4sw5/src/tools/cli/command.go:546 +0x244
kitty/tools/cli.(*Command).Exec(0x1400013c000?, {0x0?, 0x60?, 0x0?})
        /private/var/folders/wj/cqy1nsyn4wn94d96btkldt0r0000gn/C/t/plugins-daba4sw5/src/tools/cli/command.go:564 +0x3c
main.main()
        /private/var/folders/wj/cqy1nsyn4wn94d96btkldt0r0000gn/C/t/plugins-daba4sw5/src/tools/cmd/main.go:34 +0x13c

@kovidgoyal
Copy link
Owner

a3d8be5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants