mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-25 01:31:36 +03:00
feat: add idx
field to the file API
This commit is contained in:
parent
b4d91df767
commit
42cbedbe42
@ -31,6 +31,7 @@ impl File {
|
||||
|
||||
pub(super) fn register(lua: &Lua) -> mlua::Result<()> {
|
||||
lua.register_userdata_type::<Self>(|reg| {
|
||||
reg.add_field_method_get("idx", |_, me| Ok(me.idx + 1));
|
||||
reg.add_field_method_get("url", |lua, me| Url::cast(lua, me.url.clone()));
|
||||
reg.add_field_method_get("cha", |lua, me| Cha::cast(lua, me.cha));
|
||||
reg.add_field_method_get("link_to", |lua, me| {
|
||||
|
@ -22,7 +22,7 @@ impl Tabs {
|
||||
|
||||
pub(super) fn register(lua: &Lua) -> mlua::Result<()> {
|
||||
lua.register_userdata_type::<Self>(|reg| {
|
||||
reg.add_field_method_get("idx", |_, me| Ok(me.idx));
|
||||
reg.add_field_method_get("idx", |_, me| Ok(me.idx + 1));
|
||||
|
||||
reg.add_meta_method(MetaMethod::Len, |_, me, ()| Ok(me.len()));
|
||||
|
||||
|
@ -51,7 +51,7 @@ function Header:tabs()
|
||||
if THEME.manager.tab_width > 2 then
|
||||
text = ya.truncate(text .. " " .. cx.tabs[i]:name(), THEME.manager.tab_width)
|
||||
end
|
||||
if i == cx.tabs.idx + 1 then
|
||||
if i == cx.tabs.idx then
|
||||
spans[#spans + 1] = ui.Span(" " .. text .. " "):style(THEME.manager.tab_active)
|
||||
else
|
||||
spans[#spans + 1] = ui.Span(" " .. text .. " "):style(THEME.manager.tab_inactive)
|
||||
|
Loading…
Reference in New Issue
Block a user