Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lua/image/backends/sixel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ local send_sixel = function(sixel_data, x, y)
if not has_st_end then wrapped_data = wrapped_data .. "\27\\" end

-- tmux passthrough: wrap DCS sequence so tmux forwards it to the terminal
if utils.tmux.is_tmux then
wrapped_data = utils.tmux.escape(wrapped_data)
end
if utils.tmux.is_tmux and not utils.tmux.has_native_sixel then wrapped_data = utils.tmux.escape(wrapped_data) end

-- build sequence
local sequence = ""
Expand Down Expand Up @@ -259,7 +257,7 @@ function backend.setup(state)
end

-- tmux check
if utils.tmux.is_tmux and not utils.tmux.has_passthrough then
if utils.tmux.is_tmux and not utils.tmux.has_native_sixel and not utils.tmux.has_passthrough then
log.warn("tmux detected but passthrough may not be enabled for sixel")
end

Expand Down
6 changes: 6 additions & 0 deletions lua/image/utils/tmux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ local pane_position = nil
local pane_position_clear_scheduled = false

local has_passthrough = false
local has_native_sixel = false
if is_tmux then
local ok, result = pcall(vim.fn.system, { "tmux", "show", "-Apv", "allow-passthrough" })
if ok and (result:sub(-3) == "on\n" or result:sub(-4) == "all\n") then has_passthrough = true end
local features_ok, features = pcall(vim.fn.system, { "tmux", "display-message", "-p", "#{client_termfeatures}" })
if features_ok and vim.v.shell_error == 0 then
has_native_sixel = ("," .. vim.trim(features) .. ","):find(",sixel,", 1, true) ~= nil
end
end

local create_dm_getter = function(name)
Expand Down Expand Up @@ -91,6 +96,7 @@ end

return {
is_tmux = is_tmux,
has_native_sixel = has_native_sixel,
has_passthrough = has_passthrough,
get_pid = create_dm_getter("pid"),
get_socket_path = create_dm_getter("socket_path"),
Expand Down