feat: switch to inline images protocol for VSCode, Tabby, and Hyper

This commit is contained in:
sxyazi 2024-03-01 10:22:12 +08:00
parent 73b7e5acf7
commit c3a1103529
No known key found for this signature in database
8 changed files with 22 additions and 21 deletions

View File

@ -12,10 +12,10 @@ Yazi (means "duck") is a terminal file manager written in Rust, based on non-blo
- 💪 **Powerful Async Task Scheduling and Management**: Provides real-time progress updates, task cancellation, and internal task priority assignment.
- 🖼️ **Built-in Support for Multiple Image Protocols**: Also integrated with Überzug++, covering almost all terminals.
- 🌟 **Built-in Code Highlighting and Image Decoding**: Combined with the pre-loading mechanism, greatly accelerates image and normal file loading.
- 🔌 **Concurrent Plugin System**: UI plugins (rewriting most of the UI), functional plugins (coming soon), custom previewer, and custom preloader; Just some pieces of Lua.
- 🔌 **Concurrent Plugin System**: UI plugins (rewriting most of the UI), functional plugins, custom previewer, and custom preloader; Just some pieces of Lua.
- 🧰 Integration with fd, rg, fzf, zoxide
- 💫 Vim-like input/select component, auto-completion for cd paths
- 🏷️ Multi-Tab Support, Scrollable Preview (for videos, PDFs, archives, directories, code, etc.)
- 💫 Vim-like input/select/notify component, auto-completion for cd paths
- 🏷️ Multi-Tab Support, Cross-directory selection, Scrollable Preview (for videos, PDFs, archives, directories, code, etc.)
- 🔄 Bulk Renaming, Visual Mode, File Chooser
- 🎨 Theme System, Custom Layouts, Trash Bin, CSI u
- ... and more!
@ -46,8 +46,9 @@ https://github.com/sxyazi/yazi/assets/17523360/92ff23fa-0cd5-4f04-b387-894c12265
| foot | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in |
| Ghostty | [Kitty old protocol](https://github.com/sxyazi/yazi/blob/main/yazi-adaptor/src/kitty_old.rs) | ✅ Built-in |
| Black Box | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in |
| Tabby | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in |
| Hyper | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in |
| VSCode | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
| Tabby | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
| Hyper | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
| X11 / Wayland | Window system protocol | ☑️ Überzug++ required |
| Fallback | [Chafa](https://hpjansson.org/chafa/) | ☑️ Überzug++ required |

View File

@ -92,9 +92,9 @@ impl Adaptor {
Emulator::Foot => vec![Self::Sixel],
Emulator::Ghostty => vec![Self::KittyOld],
Emulator::BlackBox => vec![Self::Sixel],
Emulator::VSCode => vec![Self::Sixel],
Emulator::Tabby => vec![Self::Sixel],
Emulator::Hyper => vec![Self::Sixel],
Emulator::VSCode => vec![Self::Iterm2, Self::Sixel],
Emulator::Tabby => vec![Self::Iterm2, Self::Sixel],
Emulator::Hyper => vec![Self::Iterm2, Self::Sixel],
Emulator::Mintty => vec![Self::Iterm2],
Emulator::Neovim => vec![],
};

View File

@ -3,7 +3,7 @@ local M = {}
function M:peek()
local _, bound = ya.preview_archive(self)
if bound then
ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" })
ya.manager_emit("peek", { bound, only_if = tostring(self.file.url), upper_bound = true })
end
end
@ -12,7 +12,7 @@ function M:seek(units)
if h and h.url == self.file.url then
local step = math.floor(units * self.area.h / 10)
ya.manager_emit("peek", {
tostring(math.max(0, cx.active.preview.skip + step)),
math.max(0, cx.active.preview.skip + step),
only_if = tostring(self.file.url),
})
end

View File

@ -3,7 +3,7 @@ local M = {}
function M:peek()
local _, bound = ya.preview_code(self)
if bound then
ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" })
ya.manager_emit("peek", { bound, only_if = tostring(self.file.url), upper_bound = true })
end
end
@ -12,7 +12,7 @@ function M:seek(units)
if h and h.url == self.file.url then
local step = math.floor(units * self.area.h / 10)
ya.manager_emit("peek", {
tostring(math.max(0, cx.active.preview.skip + step)),
math.max(0, cx.active.preview.skip + step),
only_if = tostring(self.file.url),
})
end

View File

@ -8,7 +8,7 @@ function M:peek()
local bound = math.max(0, #folder.files - self.area.h)
if self.skip > bound then
ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" })
ya.manager_emit("peek", { bound, only_if = tostring(self.file.url), upper_bound = true })
end
local items, markers = {}, {}
@ -37,7 +37,7 @@ function M:seek(units)
local step = math.floor(units * self.area.h / 10)
local bound = math.max(0, #folder.files - self.area.h)
ya.manager_emit("peek", {
tostring(ya.clamp(0, cx.active.preview.skip + step, bound)),
ya.clamp(0, cx.active.preview.skip + step, bound),
only_if = tostring(self.file.url),
})
end

View File

@ -34,7 +34,7 @@ function M:peek()
child:start_kill()
if self.skip > 0 and i < self.skip + limit then
ya.manager_emit("peek", { tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" })
ya.manager_emit("peek", { math.max(0, i - limit), only_if = tostring(self.file.url), upper_bound = true })
else
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) })
@ -46,7 +46,7 @@ function M:seek(units)
if h and h.url == self.file.url then
local step = math.floor(units * self.area.h / 10)
ya.manager_emit("peek", {
tostring(math.max(0, cx.active.preview.skip + step)),
math.max(0, cx.active.preview.skip + step),
only_if = tostring(self.file.url),
})
end
@ -55,7 +55,7 @@ end
function M:fallback_to_builtin()
local _, bound = ya.preview_code(self)
if bound then
ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" })
ya.manager_emit("peek", { bound, only_if = tostring(self.file.url), upper_bound = true })
end
end

View File

@ -16,7 +16,7 @@ function M:seek(units)
local h = cx.active.current.hovered
if h and h.url == self.file.url then
local step = ya.clamp(-1, units, 1)
ya.manager_emit("peek", { tostring(math.max(0, cx.active.preview.skip + step)), only_if = tostring(self.file.url) })
ya.manager_emit("peek", { math.max(0, cx.active.preview.skip + step), only_if = tostring(self.file.url) })
end
end
@ -37,7 +37,7 @@ function M:preload()
elseif not output.status:success() then
local pages = tonumber(output.stderr:match("the last page %((%d+)%)")) or 0
if self.skip > 0 and pages > 0 then
ya.manager_emit("peek", { tostring(math.max(0, pages - 1)), only_if = tostring(self.file.url), upper_bound = "" })
ya.manager_emit("peek", { math.max(0, pages - 1), only_if = tostring(self.file.url), upper_bound = true })
end
return 0
end

View File

@ -16,7 +16,7 @@ function M:seek(units)
local h = cx.active.current.hovered
if h and h.url == self.file.url then
ya.manager_emit("peek", {
tostring(math.max(0, cx.active.preview.skip + units)),
math.max(0, cx.active.preview.skip + units),
only_if = tostring(self.file.url),
})
end
@ -25,7 +25,7 @@ end
function M:preload()
local percentage = 5 + self.skip
if percentage > 95 then
ya.manager_emit("peek", { "90", only_if = tostring(self.file.url), upper_bound = "" })
ya.manager_emit("peek", { 90, only_if = tostring(self.file.url), upper_bound = true })
return 2
end