feat: add filter_keyword style to header indicator

defaults to red, bold can me changed by filter_keyword = { fg = "red",
bold = true } in the [mgr] section of the config
This commit is contained in:
Yahddyyp 2026-06-26 19:16:18 +05:30
parent ef654f4420
commit d80b920cf8
6 changed files with 328 additions and 282 deletions

View file

@ -15,7 +15,6 @@ light = ""
# : }}}
# : App {{{
[app]
@ -28,6 +27,7 @@ overall = {}
[mgr]
cwd = { fg = "cyan" }
filter_keyword = { fg = "red", bold = true }
# Find
find_keyword = { fg = "yellow", bold = true, italic = true, underline = true }

View file

@ -28,6 +28,7 @@ overall = {}
[mgr]
cwd = { fg = "cyan" }
filter_keyword = { fg = "red", bold = true }
# Find
find_keyword = { fg = "yellow", bold = true, italic = true, underline = true }

View file

@ -13,26 +13,26 @@ use crate::YAZI;
#[derive(Deserialize, DeserializeOver, DeserializeOver1, Overlay)]
pub struct Theme {
pub flavor: Flavor,
pub app: App,
pub mgr: Mgr,
pub tabs: Tabs,
pub mode: Mode,
pub flavor: Flavor,
pub app: App,
pub mgr: Mgr,
pub tabs: Tabs,
pub mode: Mode,
pub indicator: Indicator,
pub status: Status,
pub which: Which,
pub confirm: Confirm,
pub spot: Spot,
pub notify: Notify,
pub pick: Pick,
pub input: Input,
pub cmp: Cmp,
pub tasks: Tasks,
pub help: Help,
pub status: Status,
pub which: Which,
pub confirm: Confirm,
pub spot: Spot,
pub notify: Notify,
pub pick: Pick,
pub input: Input,
pub cmp: Cmp,
pub tasks: Tasks,
pub help: Help,
// File-specific styles
pub filetype: Filetype,
pub icon: Icon,
pub icon: Icon,
// User-defined custom sections
#[serde(flatten, default)]
@ -68,27 +68,30 @@ pub struct Mgr {
pub cwd: SyncCell<StyleFlat>,
// Find
pub find_keyword: SyncCell<StyleFlat>,
pub find_keyword: SyncCell<StyleFlat>,
pub find_position: SyncCell<StyleFlat>,
// Filter
pub filter_keyword: SyncCell<StyleFlat>,
// Symlink
pub symlink_target: SyncCell<StyleFlat>,
// Marker
pub marker_copied: SyncCell<StyleFlat>,
pub marker_cut: SyncCell<StyleFlat>,
pub marker_marked: SyncCell<StyleFlat>,
pub marker_copied: SyncCell<StyleFlat>,
pub marker_cut: SyncCell<StyleFlat>,
pub marker_marked: SyncCell<StyleFlat>,
pub marker_selected: SyncCell<StyleFlat>,
pub marker_symbol: ArcSwap<String>,
pub marker_symbol: ArcSwap<String>,
// Count
pub count_copied: SyncCell<StyleFlat>,
pub count_cut: SyncCell<StyleFlat>,
pub count_copied: SyncCell<StyleFlat>,
pub count_cut: SyncCell<StyleFlat>,
pub count_selected: SyncCell<StyleFlat>,
// Border
pub border_symbol: ArcSwap<String>,
pub border_style: SyncCell<StyleFlat>,
pub border_style: SyncCell<StyleFlat>,
// Highlighting
#[serde(deserialize_with = "deserialize_syntect_theme")]
@ -98,7 +101,7 @@ pub struct Mgr {
// --- Tabs
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Tabs {
pub active: SyncCell<StyleFlat>,
pub active: SyncCell<StyleFlat>,
pub inactive: SyncCell<StyleFlat>,
pub sep_inner: ArcSwap<TabsSep>,
@ -107,7 +110,7 @@ pub struct Tabs {
#[derive(Deserialize)]
pub struct TabsSep {
pub open: String,
pub open: String,
pub close: String,
}
@ -115,19 +118,19 @@ pub struct TabsSep {
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Mode {
pub normal_main: SyncCell<StyleFlat>,
pub normal_alt: SyncCell<StyleFlat>,
pub normal_alt: SyncCell<StyleFlat>,
pub select_main: SyncCell<StyleFlat>,
pub select_alt: SyncCell<StyleFlat>,
pub select_alt: SyncCell<StyleFlat>,
pub unset_main: SyncCell<StyleFlat>,
pub unset_alt: SyncCell<StyleFlat>,
pub unset_alt: SyncCell<StyleFlat>,
}
// --- Indicator
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Indicator {
pub parent: SyncCell<StyleFlat>,
pub parent: SyncCell<StyleFlat>,
pub current: SyncCell<StyleFlat>,
pub preview: SyncCell<StyleFlat>,
pub padding: ArcSwap<IndicatorPadding>,
@ -135,33 +138,33 @@ pub struct Indicator {
#[derive(Deserialize)]
pub struct IndicatorPadding {
pub open: String,
pub open: String,
pub close: String,
}
// --- Status
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Status {
pub overall: SyncCell<StyleFlat>,
pub sep_left: ArcSwap<StatusSep>,
pub overall: SyncCell<StyleFlat>,
pub sep_left: ArcSwap<StatusSep>,
pub sep_right: ArcSwap<StatusSep>,
// Permissions
pub perm_sep: SyncCell<StyleFlat>,
pub perm_type: SyncCell<StyleFlat>,
pub perm_read: SyncCell<StyleFlat>,
pub perm_sep: SyncCell<StyleFlat>,
pub perm_type: SyncCell<StyleFlat>,
pub perm_read: SyncCell<StyleFlat>,
pub perm_write: SyncCell<StyleFlat>,
pub perm_exec: SyncCell<StyleFlat>,
pub perm_exec: SyncCell<StyleFlat>,
// Progress
pub progress_label: SyncCell<StyleFlat>,
pub progress_label: SyncCell<StyleFlat>,
pub progress_normal: SyncCell<StyleFlat>,
pub progress_error: SyncCell<StyleFlat>,
pub progress_error: SyncCell<StyleFlat>,
}
#[derive(Deserialize)]
pub struct StatusSep {
pub open: String,
pub open: String,
pub close: String,
}
@ -175,7 +178,7 @@ pub struct Which {
pub rest: SyncCell<StyleFlat>,
pub desc: SyncCell<StyleFlat>,
pub separator: ArcSwap<String>,
pub separator: ArcSwap<String>,
pub separator_style: SyncCell<StyleFlat>,
}
@ -183,12 +186,12 @@ pub struct Which {
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Confirm {
pub border: SyncCell<StyleFlat>,
pub title: SyncCell<StyleFlat>,
pub body: SyncCell<StyleFlat>,
pub list: SyncCell<StyleFlat>,
pub title: SyncCell<StyleFlat>,
pub body: SyncCell<StyleFlat>,
pub list: SyncCell<StyleFlat>,
pub btn_yes: SyncCell<StyleFlat>,
pub btn_no: SyncCell<StyleFlat>,
pub btn_yes: SyncCell<StyleFlat>,
pub btn_no: SyncCell<StyleFlat>,
pub btn_labels: ArcSwap<[String; 2]>,
}
@ -196,47 +199,47 @@ pub struct Confirm {
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Spot {
pub border: SyncCell<StyleFlat>,
pub title: SyncCell<StyleFlat>,
pub title: SyncCell<StyleFlat>,
pub tbl_col: SyncCell<StyleFlat>,
pub tbl_col: SyncCell<StyleFlat>,
pub tbl_cell: SyncCell<StyleFlat>,
}
// --- Notify
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Notify {
pub title_info: SyncCell<StyleFlat>,
pub title_warn: SyncCell<StyleFlat>,
pub title_info: SyncCell<StyleFlat>,
pub title_warn: SyncCell<StyleFlat>,
pub title_error: SyncCell<StyleFlat>,
pub icon_info: ArcSwap<String>,
pub icon_warn: ArcSwap<String>,
pub icon_info: ArcSwap<String>,
pub icon_warn: ArcSwap<String>,
pub icon_error: ArcSwap<String>,
}
// --- Pick
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Pick {
pub border: SyncCell<StyleFlat>,
pub active: SyncCell<StyleFlat>,
pub border: SyncCell<StyleFlat>,
pub active: SyncCell<StyleFlat>,
pub inactive: SyncCell<StyleFlat>,
}
// --- Input
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Input {
pub border: SyncCell<StyleFlat>,
pub title: SyncCell<StyleFlat>,
pub value: SyncCell<StyleFlat>,
pub border: SyncCell<StyleFlat>,
pub title: SyncCell<StyleFlat>,
pub value: SyncCell<StyleFlat>,
pub selected: SyncCell<StyleFlat>,
}
impl From<&Input> for yazi_widgets::input::InputStyles {
fn from(input: &Input) -> Self {
Self {
normal: Some(input.value.get().into()),
normal: Some(input.value.get().into()),
selected: Some(input.selected.get().into()),
blink: Some(YAZI.input.cursor_blink),
blink: Some(YAZI.input.cursor_blink),
}
}
}
@ -244,29 +247,29 @@ impl From<&Input> for yazi_widgets::input::InputStyles {
// --- Cmp
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Cmp {
pub border: SyncCell<StyleFlat>,
pub active: SyncCell<StyleFlat>,
pub border: SyncCell<StyleFlat>,
pub active: SyncCell<StyleFlat>,
pub inactive: SyncCell<StyleFlat>,
pub icon_file: ArcSwap<String>,
pub icon_folder: ArcSwap<String>,
pub icon_file: ArcSwap<String>,
pub icon_folder: ArcSwap<String>,
pub icon_command: ArcSwap<String>,
}
// --- Tasks
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Tasks {
pub border: SyncCell<StyleFlat>,
pub title: SyncCell<StyleFlat>,
pub border: SyncCell<StyleFlat>,
pub title: SyncCell<StyleFlat>,
pub hovered: SyncCell<StyleFlat>,
}
// --- Help
#[derive(Deserialize, DeserializeOver, DeserializeOver2, Overlay)]
pub struct Help {
pub border: SyncCell<StyleFlat>,
pub chord: SyncCell<StyleFlat>,
pub action: SyncCell<StyleFlat>,
pub border: SyncCell<StyleFlat>,
pub chord: SyncCell<StyleFlat>,
pub action: SyncCell<StyleFlat>,
pub hovered: SyncCell<StyleFlat>,
}

View file

@ -1,84 +1,90 @@
Header = {
-- TODO: remove these two constants
LEFT = 0,
RIGHT = 1,
-- TODO: remove these two constants
LEFT = 0,
RIGHT = 1,
_id = "header",
_inc = 1000,
_left = {
{ "cwd", id = 1, order = 1000 },
},
_right = {
{ "count", id = 1, order = 1000 },
},
_id = "header",
_inc = 1000,
_left = {
{ "cwd", id = 1, order = 1000 },
},
_right = {
{ "count", id = 1, order = 1000 },
},
}
function Header:new(area, tab)
return setmetatable({
_area = area,
_tab = tab,
_current = tab.current,
}, { __index = self })
return setmetatable({
_area = area,
_tab = tab,
_current = tab.current,
}, { __index = self })
end
function Header:cwd()
local max = self._area.w - self._right_width
if max <= 0 then
return ""
end
local max = self._area.w - self._right_width
if max <= 0 then
return ""
end
local s = ya.readable_path(tostring(self._current.cwd)) .. self:flags()
return ui.Span(ui.truncate(s, { max = max, rtl = true })):style(th.mgr.cwd)
local path = ya.readable_path(tostring(self._current.cwd))
local flags = self:flags()
local flag_str = #flags == 0 and "" or " (" .. table.concat(flags, ", ") .. ")"
return ui.Line {
ui.Span(ui.truncate(path, { max = max - #flag_str, rtl = true })):style(th.mgr.cwd),
ui.Span(flag_str):style(th.mgr.filter_keyword),
}
end
function Header:flags()
local cwd = self._current.cwd
local filter = self._current.files.filter
local finder = self._tab.finder
local cwd = self._current.cwd
local filter = self._current.files.filter
local finder = self._tab.finder
local t = {}
if cwd.is_search then
t[#t + 1] = string.format("search: %s", cwd.domain)
end
if filter then
t[#t + 1] = string.format("filter: %s", filter)
end
if finder then
t[#t + 1] = string.format("find: %s", finder)
end
return #t == 0 and "" or " (" .. table.concat(t, ", ") .. ")"
local t = {}
if cwd.is_search then
t[#t + 1] = string.format("search: %s", cwd.domain)
end
if filter then
t[#t + 1] = string.format("filter: %s", filter)
end
if finder then
t[#t + 1] = string.format("find: %s", finder)
end
return t
end
function Header:count()
local selected = #self._tab.selected
local yanked = selected > 0 and 0 or #cx.yanked
local selected = #self._tab.selected
local yanked = selected > 0 and 0 or #cx.yanked
local span
if selected > 0 then
span = ui.Span(" " .. selected .. " "):style(th.mgr.count_selected)
elseif yanked <= 0 then
return ""
elseif cx.yanked.is_cut then
span = ui.Span(" " .. yanked .. " "):style(th.mgr.count_cut)
else
span = ui.Span(" " .. yanked .. " "):style(th.mgr.count_copied)
end
local span
if selected > 0 then
span = ui.Span(" " .. selected .. " "):style(th.mgr.count_selected)
elseif yanked <= 0 then
return ""
elseif cx.yanked.is_cut then
span = ui.Span(" " .. yanked .. " "):style(th.mgr.count_cut)
else
span = ui.Span(" " .. yanked .. " "):style(th.mgr.count_copied)
end
return ui.Line { span, " " }
return ui.Line { span, " " }
end
function Header:reflow() return { self } end
function Header:redraw()
local right = self:children_redraw(self.RIGHT)
self._right_width = right:width()
local right = self:children_redraw(self.RIGHT)
self._right_width = right:width()
local left = self:children_redraw(self.LEFT)
local left = self:children_redraw(self.LEFT)
return {
ui.Line(left):area(self._area),
ui.Line(right):area(self._area):align(ui.Align.RIGHT),
}
return {
ui.Line(left):area(self._area),
ui.Line(right):area(self._area):align(ui.Align.RIGHT),
}
end
-- Mouse events
@ -90,29 +96,29 @@ function Header:touch(event, step) end
-- Children
function Header:children_add(fn, order, side)
self._inc = self._inc + 1
local children = side == self.RIGHT and self._right or self._left
self._inc = self._inc + 1
local children = side == self.RIGHT and self._right or self._left
children[#children + 1] = { fn, id = self._inc, order = order }
table.sort(children, function(a, b) return a.order < b.order end)
children[#children + 1] = { fn, id = self._inc, order = order }
table.sort(children, function(a, b) return a.order < b.order end)
return self._inc
return self._inc
end
function Header:children_remove(id, side)
local children = side == self.RIGHT and self._right or self._left
for i, child in ipairs(children) do
if child.id == id then
table.remove(children, i)
break
end
end
local children = side == self.RIGHT and self._right or self._left
for i, child in ipairs(children) do
if child.id == id then
table.remove(children, i)
break
end
end
end
function Header:children_redraw(side)
local lines = {}
for _, c in ipairs(side == self.RIGHT and self._right or self._left) do
lines[#lines + 1] = (type(c[1]) == "string" and self[c[1]] or c[1])(self)
end
return ui.Line(lines)
local lines = {}
for _, c in ipairs(side == self.RIGHT and self._right or self._left) do
lines[#lines + 1] = (type(c[1]) == "string" and self[c[1]] or c[1])(self)
end
return ui.Line(lines)
end

View file

@ -1,150 +1,150 @@
Status = {
-- TODO: remove these two constants
LEFT = 0,
RIGHT = 1,
-- TODO: remove these two constants
LEFT = 0,
RIGHT = 1,
_id = "status",
_inc = 1000,
_left = {
{ "mode", id = 1, order = 1000 },
{ "length", id = 2, order = 2000 },
{ "name", id = 3, order = 3000 },
},
_right = {
{ "perm", id = 4, order = 1000 },
{ "percent", id = 5, order = 2000 },
{ "position", id = 6, order = 3000 },
},
_id = "status",
_inc = 1000,
_left = {
{ "mode", id = 1, order = 1000 },
{ "length", id = 2, order = 2000 },
{ "name", id = 3, order = 3000 },
},
_right = {
{ "perm", id = 4, order = 1000 },
{ "percent", id = 5, order = 2000 },
{ "position", id = 6, order = 3000 },
},
}
function Status:new(area, tab)
return setmetatable({
_area = area,
_tab = tab,
_current = tab.current,
}, { __index = self })
return setmetatable({
_area = area,
_tab = tab,
_current = tab.current,
}, { __index = self })
end
function Status:style()
local m, s = th.mode, ui.Style():fg("reset"):bg("reset")
if self._tab.mode.is_select then
return { main = s:patch(m.select_main), alt = s:patch(m.select_alt) }
elseif self._tab.mode.is_unset then
return { main = s:patch(m.unset_main), alt = s:patch(m.unset_alt) }
else
return { main = s:patch(m.normal_main), alt = s:patch(m.normal_alt) }
end
local m, s = th.mode, ui.Style():fg("reset"):bg("reset")
if self._tab.mode.is_select then
return { main = s:patch(m.select_main), alt = s:patch(m.select_alt) }
elseif self._tab.mode.is_unset then
return { main = s:patch(m.unset_main), alt = s:patch(m.unset_alt) }
else
return { main = s:patch(m.normal_main), alt = s:patch(m.normal_alt) }
end
end
function Status:mode()
local mode = tostring(self._tab.mode):sub(1, 3):upper()
local mode = tostring(self._tab.mode):sub(1, 3):upper()
local style = self:style()
return ui.Line {
ui.Span(th.status.sep_left.open):fg(style.main:bg()):bg(App.bg()),
ui.Span(" " .. mode .. " "):style(style.main),
ui.Span(th.status.sep_left.close):fg(style.main:bg()):bg(style.alt:bg()),
}
local style = self:style()
return ui.Line {
ui.Span(th.status.sep_left.open):fg(style.main:bg()):bg(App.bg()),
ui.Span(" " .. mode .. " "):style(style.main),
ui.Span(th.status.sep_left.close):fg(style.main:bg()):bg(style.alt:bg()),
}
end
function Status:length()
local h = self._current.hovered
local len = h and h.cha.len or 0
local h = self._current.hovered
local len = h and h.cha.len or 0
local style = self:style()
return ui.Line {
ui.Span(" " .. ya.readable_size(len) .. " "):style(style.alt),
ui.Span(th.status.sep_left.close):fg(style.alt:bg()),
}
local style = self:style()
return ui.Line {
ui.Span(" " .. ya.readable_size(len) .. " "):style(style.alt),
ui.Span(th.status.sep_left.close):fg(style.alt:bg()),
}
end
function Status:name()
local h = self._current.hovered
if not h then
return ""
end
local h = self._current.hovered
if not h then
return ""
end
return " " .. ui.printable(h.name)
return " " .. ui.printable(h.name)
end
function Status:perm()
local h = self._current.hovered
if not h then
return ""
end
local h = self._current.hovered
if not h then
return ""
end
local perm = h.cha:perm()
if not perm then
return ""
end
local perm = h.cha:perm()
if not perm then
return ""
end
local spans = {}
for i = 1, #perm do
local c = perm:sub(i, i)
local style = th.status.perm_type
if c == "-" or c == "?" then
style = th.status.perm_sep
elseif c == "r" then
style = th.status.perm_read
elseif c == "w" then
style = th.status.perm_write
elseif c == "x" or c == "s" or c == "S" or c == "t" or c == "T" then
style = th.status.perm_exec
end
spans[i] = ui.Span(c):style(style)
end
return ui.Line(spans)
local spans = {}
for i = 1, #perm do
local c = perm:sub(i, i)
local style = th.status.perm_type
if c == "-" or c == "?" then
style = th.status.perm_sep
elseif c == "r" then
style = th.status.perm_read
elseif c == "w" then
style = th.status.perm_write
elseif c == "x" or c == "s" or c == "S" or c == "t" or c == "T" then
style = th.status.perm_exec
end
spans[i] = ui.Span(c):style(style)
end
return ui.Line(spans)
end
function Status:percent()
local percent = 0
local cursor = self._current.cursor
local length = #self._current.files
if cursor ~= 0 and length ~= 0 then
percent = math.floor((cursor + 1) * 100 / length)
end
local percent = 0
local cursor = self._current.cursor
local length = #self._current.files
if cursor ~= 0 and length ~= 0 then
percent = math.floor((cursor + 1) * 100 / length)
end
if percent == 0 then
percent = " Top "
elseif percent == 100 then
percent = " Bot "
else
percent = string.format(" %2d%% ", percent)
end
if percent == 0 then
percent = " Top "
elseif percent == 100 then
percent = " Bot "
else
percent = string.format(" %2d%% ", percent)
end
local style = self:style()
return ui.Line {
ui.Span(" " .. th.status.sep_right.open):fg(style.alt:bg()),
ui.Span(percent):style(style.alt),
}
local style = self:style()
return ui.Line {
ui.Span(" " .. th.status.sep_right.open):fg(style.alt:bg()),
ui.Span(percent):style(style.alt),
}
end
function Status:position()
local cursor = self._current.cursor
local length = #self._current.files
local cursor = self._current.cursor
local length = #self._current.files
local style = self:style()
return ui.Line {
ui.Span(th.status.sep_right.open):fg(style.main:bg()):bg(style.alt:bg()),
ui.Span(string.format(" %2d/%-2d ", math.min(cursor + 1, length), length)):style(style.main),
ui.Span(th.status.sep_right.close):fg(style.main:bg()):bg(App.bg()),
}
local style = self:style()
return ui.Line {
ui.Span(th.status.sep_right.open):fg(style.main:bg()):bg(style.alt:bg()),
ui.Span(string.format(" %2d/%-2d ", math.min(cursor + 1, length), length)):style(style.main),
ui.Span(th.status.sep_right.close):fg(style.main:bg()):bg(App.bg()),
}
end
function Status:reflow() return { self } end
function Status:redraw()
local left = self:children_redraw(self.LEFT)
local left = self:children_redraw(self.LEFT)
local right = self:children_redraw(self.RIGHT)
local right_width = right:width()
local right = self:children_redraw(self.RIGHT)
local right_width = right:width()
return {
ui.Text(""):area(self._area):style(th.status.overall),
ui.Line(left):area(self._area),
ui.Line(right):area(self._area):align(ui.Align.RIGHT),
table.unpack(ui.redraw(Progress:new(self._area, right_width))),
}
return {
ui.Text(""):area(self._area):style(th.status.overall),
ui.Line(left):area(self._area),
ui.Line(right):area(self._area):align(ui.Align.RIGHT),
table.unpack(ui.redraw(Progress:new(self._area, right_width))),
}
end
-- Mouse events
@ -156,29 +156,29 @@ function Status:touch(event, step) end
-- Children
function Status:children_add(fn, order, side)
self._inc = self._inc + 1
local children = side == self.RIGHT and self._right or self._left
self._inc = self._inc + 1
local children = side == self.RIGHT and self._right or self._left
children[#children + 1] = { fn, id = self._inc, order = order }
table.sort(children, function(a, b) return a.order < b.order end)
children[#children + 1] = { fn, id = self._inc, order = order }
table.sort(children, function(a, b) return a.order < b.order end)
return self._inc
return self._inc
end
function Status:children_remove(id, side)
local children = side == self.RIGHT and self._right or self._left
for i, child in ipairs(children) do
if child.id == id then
table.remove(children, i)
break
end
end
local children = side == self.RIGHT and self._right or self._left
for i, child in ipairs(children) do
if child.id == id then
table.remove(children, i)
break
end
end
end
function Status:children_redraw(side)
local lines = {}
for _, c in ipairs(side == self.RIGHT and self._right or self._left) do
lines[#lines + 1] = (type(c[1]) == "string" and self[c[1]] or c[1])(self)
end
return ui.Line(lines)
local lines = {}
for _, c in ipairs(side == self.RIGHT and self._right or self._left) do
lines[#lines + 1] = (type(c[1]) == "string" and self[c[1]] or c[1])(self)
end
return ui.Line(lines)
end

View file

@ -28,12 +28,16 @@ pub fn compose() -> Composer<ComposerGet, ComposerSet> {
.into_lua(lua)
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
pub fn reset() -> mlua::Result<()> { LUA.globals().raw_set("th", compose()) }
pub fn reset() -> mlua::Result<()> {
LUA.globals().raw_set("th", compose())
}
fn app() -> Composer<ComposerGet, ComposerSet> {
fn get(lua: &Lua, key: &[u8]) -> mlua::Result<Value> {
@ -45,7 +49,9 @@ fn app() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -59,6 +65,8 @@ fn mgr() -> Composer<ComposerGet, ComposerSet> {
b"find_keyword" => Style::from(&m.find_keyword).into_lua(lua),
b"find_position" => Style::from(&m.find_position).into_lua(lua),
b"filter_keyword" => Style::from(&m.filter_keyword).into_lua(lua),
b"symlink_target" => Style::from(&m.symlink_target).into_lua(lua),
b"marker_copied" => Style::from(&m.marker_copied).into_lua(lua),
@ -79,7 +87,9 @@ fn mgr() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -108,7 +118,9 @@ fn tabs() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -130,7 +142,9 @@ fn mode() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -153,7 +167,9 @@ fn indicator() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -190,7 +206,9 @@ fn status() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -212,7 +230,9 @@ fn which() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -239,7 +259,9 @@ fn confirm() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -258,7 +280,9 @@ fn spot() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -279,7 +303,9 @@ fn notify() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -296,7 +322,9 @@ fn pick() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -314,7 +342,9 @@ fn input() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -335,7 +365,9 @@ fn cmp() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -352,7 +384,9 @@ fn tasks() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}
@ -370,7 +404,9 @@ fn help() -> Composer<ComposerGet, ComposerSet> {
}
}
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> { Ok(value) }
fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result<Value> {
Ok(value)
}
Composer::new(get, set)
}