feat: adapt for https://github.com/sxyazi/yazi/pull/2939
This commit is contained in:
@@ -108,7 +108,12 @@ local add = ya.sync(function(st, cwd, repo, changed)
|
|||||||
st.repos[repo][path] = code
|
st.repos[repo][path] = code
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ya.render()
|
-- TODO: remove this
|
||||||
|
if ui.render then
|
||||||
|
ui.render()
|
||||||
|
else
|
||||||
|
ya.render()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local remove = ya.sync(function(st, cwd)
|
local remove = ya.sync(function(st, cwd)
|
||||||
@@ -117,7 +122,12 @@ local remove = ya.sync(function(st, cwd)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
ya.render()
|
-- TODO: remove this
|
||||||
|
if ui.render then
|
||||||
|
ui.render()
|
||||||
|
else
|
||||||
|
ya.render()
|
||||||
|
end
|
||||||
st.dirs[cwd] = nil
|
st.dirs[cwd] = nil
|
||||||
if not st.repos[repo] then
|
if not st.repos[repo] then
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ local update = ya.sync(function(st, tags)
|
|||||||
for path, tag in pairs(tags) do
|
for path, tag in pairs(tags) do
|
||||||
st.tags[path] = #tag > 0 and tag or nil
|
st.tags[path] = #tag > 0 and tag or nil
|
||||||
end
|
end
|
||||||
ya.render()
|
-- TODO: remove this
|
||||||
|
if ui.render then
|
||||||
|
ui.render()
|
||||||
|
else
|
||||||
|
ya.render()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local selected_or_hovered = ya.sync(function()
|
local selected_or_hovered = ya.sync(function()
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ local toggle_ui = ya.sync(function(self)
|
|||||||
else
|
else
|
||||||
self.children = Modal:children_add(self, 10)
|
self.children = Modal:children_add(self, 10)
|
||||||
end
|
end
|
||||||
ya.render()
|
-- TODO: remove this
|
||||||
|
if ui.render then
|
||||||
|
ui.render()
|
||||||
|
else
|
||||||
|
ya.render()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local subscribe = ya.sync(function(self)
|
local subscribe = ya.sync(function(self)
|
||||||
@@ -18,7 +23,12 @@ end)
|
|||||||
local update_partitions = ya.sync(function(self, partitions)
|
local update_partitions = ya.sync(function(self, partitions)
|
||||||
self.partitions = partitions
|
self.partitions = partitions
|
||||||
self.cursor = math.max(0, math.min(self.cursor or 0, #self.partitions - 1))
|
self.cursor = math.max(0, math.min(self.cursor or 0, #self.partitions - 1))
|
||||||
ya.render()
|
-- TODO: remove this
|
||||||
|
if ui.render then
|
||||||
|
ui.render()
|
||||||
|
else
|
||||||
|
ya.render()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local active_partition = ya.sync(function(self) return self.partitions[self.cursor + 1] end)
|
local active_partition = ya.sync(function(self) return self.partitions[self.cursor + 1] end)
|
||||||
@@ -29,7 +39,12 @@ local update_cursor = ya.sync(function(self, cursor)
|
|||||||
else
|
else
|
||||||
self.cursor = ya.clamp(0, self.cursor + cursor, #self.partitions - 1)
|
self.cursor = ya.clamp(0, self.cursor + cursor, #self.partitions - 1)
|
||||||
end
|
end
|
||||||
ya.render()
|
-- TODO: remove this
|
||||||
|
if ui.render then
|
||||||
|
ui.render()
|
||||||
|
else
|
||||||
|
ya.render()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local M = {
|
local M = {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ local function run_with_sudo(program, args)
|
|||||||
return cmd:output()
|
return cmd:output()
|
||||||
end
|
end
|
||||||
|
|
||||||
local permit = ya.hide()
|
local permit = ui.hide and ui.hide() or ya.hide() -- TODO: remove this
|
||||||
print(string.format("Sudo password required to run: `%s %s`", program, table.concat(args)))
|
print(string.format("Sudo password required to run: `%s %s`", program, table.concat(args)))
|
||||||
local output = cmd:output()
|
local output = cmd:output()
|
||||||
permit:drop()
|
permit:drop()
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
-- luacheck: globals Command Url cx fs ps rt th ui ya
|
-- luacheck: globals Command Url cx fs ps rt th ui ya
|
||||||
|
|
||||||
---@alias Color string|"reset"|"black"|"white"|"red"|"lightred"|"green"|"lightgreen"|"yellow"|"lightyellow"|"blue"|"lightblue"|"magenta"|"lightmagenta"|"cyan"|"lightcyan"|"gray"|"darkgray"
|
|
||||||
---@alias Stdio integer
|
---@alias Stdio integer
|
||||||
|
|
||||||
---@alias Sendable nil|boolean|number|string|Url|{ [Sendable]: Sendable }
|
|
||||||
---@alias Renderable ui.Bar|ui.Border|ui.Clear|ui.Gauge|ui.Line|ui.List|ui.Text
|
|
||||||
|
|
||||||
---@class (exact) Recv
|
---@class (exact) Recv
|
||||||
---@field recv fun(self: self): string
|
---@field recv fun(self: self): string
|
||||||
|
|
||||||
@@ -28,6 +24,21 @@ ui = ui
|
|||||||
---@type ya
|
---@type ya
|
||||||
ya = ya
|
ya = ya
|
||||||
|
|
||||||
|
-- A set of constants representing the origin of a position.
|
||||||
|
-- | | |
|
||||||
|
-- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
-- | Alias | `"top-left"` \| `"top-center"` \| `"top-right"` \| `"bottom-left"` \| `"bottom-center"` \| `"bottom-right"` \| `"center"` \| `"hovered"` |
|
||||||
|
---@alias Origin "top-left"|"top-center"|"top-right"|"bottom-left"|"bottom-center"|"bottom-right"|"center"|"hovered"
|
||||||
|
-- A value that can be sent across threads. See [Sendable value](/docs/plugins/overview#sendable) for more details.
|
||||||
|
-- | | |
|
||||||
|
-- | ----- | --------------------------------------------------------------------------------- |
|
||||||
|
-- | Alias | `nil` \| `boolean` \| `number` \| `string` \| `Url` \| `{ [Sendable]: Sendable }` |
|
||||||
|
---@alias Sendable nil|boolean|number|string|Url|{ [Sendable]: Sendable }
|
||||||
|
-- An element that can be rendered.
|
||||||
|
-- | | |
|
||||||
|
-- | ----- | --------------------------------------------------------------------- |
|
||||||
|
-- | Alias | `Bar` \| `Border` \| `Clear` \| `Gauge` \| `Line` \| `List` \| `Text` |
|
||||||
|
---@alias Renderable ui.Bar|ui.Border|ui.Clear|ui.Gauge|ui.Line|ui.List|ui.Text
|
||||||
-- A value that can be covariantly treated as a [`Pos`](/docs/plugins/layout#pos).
|
-- A value that can be covariantly treated as a [`Pos`](/docs/plugins/layout#pos).
|
||||||
-- | | |
|
-- | | |
|
||||||
-- | ----- | ------------------------------------------------------------------------------ |
|
-- | ----- | ------------------------------------------------------------------------------ |
|
||||||
@@ -48,11 +59,11 @@ ya = ya
|
|||||||
-- | ----- | -------------------------------------------------------- |
|
-- | ----- | -------------------------------------------------------- |
|
||||||
-- | Alias | `string` \| `Span` \| `Line` \| `(string\|Span\|Line)[]` |
|
-- | Alias | `string` \| `Span` \| `Line` \| `(string\|Span\|Line)[]` |
|
||||||
---@alias AsText string|ui.Span|ui.Line|(string|ui.Span|ui.Line)[]
|
---@alias AsText string|ui.Span|ui.Line|(string|ui.Span|ui.Line)[]
|
||||||
-- Origin is a set of constants representing the origin of a position.
|
-- A set of constants representing colors.
|
||||||
-- | | |
|
-- | | |
|
||||||
-- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
-- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
-- | Alias | `"top-left"` \| `"top-center"` \| `"top-right"` \| `"bottom-left"` \| `"bottom-center"` \| `"bottom-right"` \| `"center"` \| `"hovered"` |
|
-- | Alias | `"black"` \| `"white"` \| `"red"` \| `"lightred"` \| `"green"` \| `"lightgreen"` \| `"yellow"` \| `"lightyellow"` \| `"blue"` \| `"lightblue"` \| `"magenta"` \| `"lightmagenta"` \| `"cyan"` \| `"lightcyan"` \| `"gray"` \| `"darkgray"` \| `"reset"` \| `string` |
|
||||||
---@alias Origin "top-left"|"top-center"|"top-right"|"bottom-left"|"bottom-center"|"bottom-right"|"center"|"hovered"
|
---@alias AsColor "black"|"white"|"red"|"lightred"|"green"|"lightgreen"|"yellow"|"lightyellow"|"blue"|"lightblue"|"magenta"|"lightmagenta"|"cyan"|"lightcyan"|"gray"|"darkgray"|"reset"|string
|
||||||
|
|
||||||
-- Create a Url:
|
-- Create a Url:
|
||||||
-- ```lua
|
-- ```lua
|
||||||
@@ -526,19 +537,19 @@ ya = ya
|
|||||||
-- ```
|
-- ```
|
||||||
---@class (exact) ui.Style
|
---@class (exact) ui.Style
|
||||||
-- Apply a foreground color.
|
-- Apply a foreground color.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------- | ------------------------------------------------ |
|
-- | ------- | ------------------------------------------- |
|
||||||
-- | `self` | `Self` |
|
-- | `self` | `Self` |
|
||||||
-- | `color` | [`Color`](/docs/configuration/theme#types.color) |
|
-- | `color` | [`AsColor`](/docs/plugins/aliases#as-color) |
|
||||||
-- | Return | `self` |
|
-- | Return | `self` |
|
||||||
---@field fg fun(self: self, color: Color): self
|
---@field fg fun(self: self, color: AsColor): self
|
||||||
-- Apply a background color.
|
-- Apply a background color.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------- | ------------------------------------------------ |
|
-- | ------- | ------------------------------------------- |
|
||||||
-- | `self` | `Self` |
|
-- | `self` | `Self` |
|
||||||
-- | `color` | [`Color`](/docs/configuration/theme#types.color) |
|
-- | `color` | [`AsColor`](/docs/plugins/aliases#as-color) |
|
||||||
-- | Return | `self` |
|
-- | Return | `self` |
|
||||||
---@field bg fun(self: self, color: Color): self
|
---@field bg fun(self: self, color: AsColor): self
|
||||||
-- Apply a bold style.
|
-- Apply a bold style.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------ | ------ |
|
-- | ------ | ------ |
|
||||||
@@ -650,19 +661,19 @@ ya = ya
|
|||||||
-- ```
|
-- ```
|
||||||
---@field style fun(self: self, style: ui.Style): self
|
---@field style fun(self: self, style: ui.Style): self
|
||||||
-- Apply a foreground color.
|
-- Apply a foreground color.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------- | ------------------------------------------------ |
|
-- | ------- | ------------------------------------------- |
|
||||||
-- | `self` | `Self` |
|
-- | `self` | `Self` |
|
||||||
-- | `color` | [`Color`](/docs/configuration/theme#types.color) |
|
-- | `color` | [`AsColor`](/docs/plugins/aliases#as-color) |
|
||||||
-- | Return | `self` |
|
-- | Return | `self` |
|
||||||
---@field fg fun(self: self, color: Color): self
|
---@field fg fun(self: self, color: AsColor): self
|
||||||
-- Apply a background color.
|
-- Apply a background color.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------- | ------------------------------------------------ |
|
-- | ------- | ------------------------------------------- |
|
||||||
-- | `self` | `Self` |
|
-- | `self` | `Self` |
|
||||||
-- | `color` | [`Color`](/docs/configuration/theme#types.color) |
|
-- | `color` | [`AsColor`](/docs/plugins/aliases#as-color) |
|
||||||
-- | Return | `self` |
|
-- | Return | `self` |
|
||||||
---@field bg fun(self: self, color: Color): self
|
---@field bg fun(self: self, color: AsColor): self
|
||||||
-- Apply a bold style.
|
-- Apply a bold style.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------ | ------ |
|
-- | ------ | ------ |
|
||||||
@@ -790,19 +801,19 @@ ya = ya
|
|||||||
-- ```
|
-- ```
|
||||||
---@field style fun(self: self, style: ui.Style): self
|
---@field style fun(self: self, style: ui.Style): self
|
||||||
-- Apply a foreground color.
|
-- Apply a foreground color.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------- | ------------------------------------------------ |
|
-- | ------- | ------------------------------------------- |
|
||||||
-- | `self` | `Self` |
|
-- | `self` | `Self` |
|
||||||
-- | `color` | [`Color`](/docs/configuration/theme#types.color) |
|
-- | `color` | [`AsColor`](/docs/plugins/aliases#as-color) |
|
||||||
-- | Return | `self` |
|
-- | Return | `self` |
|
||||||
---@field fg fun(self: self, color: Color): self
|
---@field fg fun(self: self, color: AsColor): self
|
||||||
-- Apply a background color.
|
-- Apply a background color.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------- | ------------------------------------------------ |
|
-- | ------- | ------------------------------------------- |
|
||||||
-- | `self` | `Self` |
|
-- | `self` | `Self` |
|
||||||
-- | `color` | [`Color`](/docs/configuration/theme#types.color) |
|
-- | `color` | [`AsColor`](/docs/plugins/aliases#as-color) |
|
||||||
-- | Return | `self` |
|
-- | Return | `self` |
|
||||||
---@field bg fun(self: self, color: Color): self
|
---@field bg fun(self: self, color: AsColor): self
|
||||||
-- Apply a bold style.
|
-- Apply a bold style.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------ | ------ |
|
-- | ------ | ------ |
|
||||||
@@ -932,19 +943,19 @@ ya = ya
|
|||||||
-- ```
|
-- ```
|
||||||
---@field style fun(self: self, style: ui.Style): self
|
---@field style fun(self: self, style: ui.Style): self
|
||||||
-- Apply a foreground color.
|
-- Apply a foreground color.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------- | ------------------------------------------------ |
|
-- | ------- | ------------------------------------------- |
|
||||||
-- | `self` | `Self` |
|
-- | `self` | `Self` |
|
||||||
-- | `color` | [`Color`](/docs/configuration/theme#types.color) |
|
-- | `color` | [`AsColor`](/docs/plugins/aliases#as-color) |
|
||||||
-- | Return | `self` |
|
-- | Return | `self` |
|
||||||
---@field fg fun(self: self, color: Color): self
|
---@field fg fun(self: self, color: AsColor): self
|
||||||
-- Apply a background color.
|
-- Apply a background color.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------- | ------------------------------------------------ |
|
-- | ------- | ------------------------------------------- |
|
||||||
-- | `self` | `Self` |
|
-- | `self` | `Self` |
|
||||||
-- | `color` | [`Color`](/docs/configuration/theme#types.color) |
|
-- | `color` | [`AsColor`](/docs/plugins/aliases#as-color) |
|
||||||
-- | Return | `self` |
|
-- | Return | `self` |
|
||||||
---@field bg fun(self: self, color: Color): self
|
---@field bg fun(self: self, color: AsColor): self
|
||||||
-- Apply a bold style.
|
-- Apply a bold style.
|
||||||
-- | In/Out | Type |
|
-- | In/Out | Type |
|
||||||
-- | ------ | ------ |
|
-- | ------ | ------ |
|
||||||
|
|||||||
Reference in New Issue
Block a user