Giter Site home page Giter Site logo

Comments (18)

dankamongmen avatar dankamongmen commented on June 10, 2024 1

@dankamongmen does notcurses do anything special to handle switching panes in tmux?

nope, very little tmux-specific code

from image.nvim.

3rd avatar 3rd commented on June 10, 2024 1

Yes, it only handles window switching, with a massive hack. In theory it could handle panes as well, need to check.

from image.nvim.

3rd avatar 3rd commented on June 10, 2024

Hey, yes, there's no handling for tmux pane switching yet, but it's on the list!

from image.nvim.

benlubas avatar benlubas commented on June 10, 2024

@3rd have you looked into this at all? If you have any info on where to start supporting something like this I'd be more than happy to tackle it.

Starting to grow tired of switching tabs and then having to go back to close an image

If you haven't looked at this at all I'm also happy to look into it, just thought I'd ask first.

from image.nvim.

3rd avatar 3rd commented on June 10, 2024

Couldn't find a way to do it without adding a tmux script, still exploring.

from image.nvim.

3rd avatar 3rd commented on June 10, 2024

@benlubas would it be acceptable to hide/show the images on nvim focus lost/gained? It would also hide them when switching to a different pane in the same window.

from image.nvim.

benlubas avatar benlubas commented on June 10, 2024

Yeah my first thought was focus lost/gained, personally I wouldn't have a problem with images disappearing when switching panes but I could see why others might.

I wonder what notcurses does.. maybe we can ask dank

from image.nvim.

benlubas avatar benlubas commented on June 10, 2024

I've tried a simple implementation with focus lost, and it's unfortunately not working.

(P() is a function that prints using vim.inspect)

if state.options.tmux_mode then
  local held_images = {}
  print("tmux mode")
  -- hide all images on focus lost
  vim.api.nvim_create_autocmd("FocusLost", {
    group = group,
    callback = function(_au)
      print("focus lost")
      vim.schedule(function()
        held_images = api.get_images()
        P(held_images)
        for _, current_image in ipairs(held_images) do
          current_image:clear()
        end
      end)
    end,
  })
  -- re-render on focus gained
  vim.api.nvim_create_autocmd("FocusGained", {
    group = group,
    callback = function(_au)
      print("focus gained")
      for _, current_image in ipairs(held_images) do
        current_image:render()
      end
    end,
  })
end

from image.nvim.

3rd avatar 3rd commented on June 10, 2024

Added a new option editor_only_render_when_focused in 133926c that should be an ok workaround until we figure something else out ; it's not tied to Tmux in any way, just a general option.

The more advanced way would be to make a plugin for Tmux that sends a message to nvim, either through the remote protocol (would require remote control enabled), by sending keys (yuck), or by writing to a socket file (probably).

I think it's good enough for now.

from image.nvim.

3rd avatar 3rd commented on June 10, 2024

Reopening, doesn't seem to work properly, looking into it.

from image.nvim.

benlubas avatar benlubas commented on June 10, 2024

Haha, I beat you to it. That implementation works for focus via window manager, but tmux switching, while it triggers the auto command, doesn't actually clear the image.

from image.nvim.

3rd avatar 3rd commented on June 10, 2024

The Neovim part seems ok, it's a clearing issue, which is better than the events not working. I think it doesn't have time to output the escape codes for clearing.

image-focus.mp4

from image.nvim.

3rd avatar 3rd commented on June 10, 2024

damn
tmux/tmux#3265
tmux/tmux#3274
tmux/tmux#3001

from image.nvim.

benlubas avatar benlubas commented on June 10, 2024

@dankamongmen does notcurses do anything special to handle switching panes in tmux?

from image.nvim.

3rd avatar 3rd commented on June 10, 2024

Found a way to do it by finding the active tty for the current tmux session and writing Kitty's clear-all control sequence in that one. It's hacky, but it works. Just needs some changes to make the "restore" work.

from image.nvim.

3rd avatar 3rd commented on June 10, 2024

Linking PR: #45

from image.nvim.

3rd avatar 3rd commented on June 10, 2024

This is now in master, needs tmux_show_only_in_active_window = true and set -g visual-activity off in Tmux 🎉

from image.nvim.

petobens avatar petobens commented on June 10, 2024

Hi! In the following gif I open a split (pane) I see the image in the pane below (even though I'm using the tmux_show_only_in_active_window setting):

Peek 2023-10-31 19-10

from image.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.