mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
fa2a9cea2c
commit
d703e00714
3 changed files with 21 additions and 25 deletions
|
|
@ -13,20 +13,15 @@ function Status.mode()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Status.size()
|
function Status.size()
|
||||||
-- cx.manager.current.files
|
local h = cx.manager.current.hovered
|
||||||
|
if h == nil then
|
||||||
-- yazi.print(#cx.manager.current.files)
|
return ui.Span("")
|
||||||
|
|
||||||
for key, value in pairs(cx.manager.current.files) do
|
|
||||||
yazi.print(key, value)
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return ui.Span("fff")
|
return ui.Line(
|
||||||
-- return ui.Line(
|
ui.Span(" " .. utils.readable_size(h.length) .. " "):fg(THEME.status.mode_normal.bg):bg(THEME.status.fancy.bg),
|
||||||
-- ui.Span(" " .. utils.readable_size(h.length) .. " "):fg(THEME.status.mode_normal.bg):bg(THEME.status.fancy.bg),
|
ui.Span(THEME.status.separator.closing):fg(THEME.status.fancy.bg)
|
||||||
-- ui.Span(THEME.status.separator.closing):fg(THEME.status.fancy.bg)
|
)
|
||||||
-- )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Status.name()
|
function Status.name()
|
||||||
|
|
@ -35,7 +30,7 @@ function Status.name()
|
||||||
return ui.Span("")
|
return ui.Span("")
|
||||||
end
|
end
|
||||||
|
|
||||||
return ui.Span(" " .. utils.basename(h.url))
|
return ui.Span(" " .. utils.basename(tostring(h.url)))
|
||||||
end
|
end
|
||||||
|
|
||||||
function Status.permissions()
|
function Status.permissions()
|
||||||
|
|
@ -67,7 +62,7 @@ end
|
||||||
function Status.percentage()
|
function Status.percentage()
|
||||||
local percent = 0
|
local percent = 0
|
||||||
local cursor = cx.manager.current.cursor
|
local cursor = cx.manager.current.cursor
|
||||||
local length = cx.manager.current.len()
|
local length = #cx.manager.current.files
|
||||||
if cursor ~= 0 and length ~= 0 then
|
if cursor ~= 0 and length ~= 0 then
|
||||||
percent = math.floor((cursor + 1) * 100 / length)
|
percent = math.floor((cursor + 1) * 100 / length)
|
||||||
end
|
end
|
||||||
|
|
@ -86,7 +81,7 @@ end
|
||||||
|
|
||||||
function Status.position()
|
function Status.position()
|
||||||
local cursor = cx.manager.current.cursor
|
local cursor = cx.manager.current.cursor
|
||||||
local length = cx.manager.current.length
|
local length = #cx.manager.current.files
|
||||||
|
|
||||||
return ui.Line(
|
return ui.Line(
|
||||||
ui.Span(string.format(" %2d/%-2d ", cursor + 1, length)):style(THEME.status.mode_normal),
|
ui.Span(string.format(" %2d/%-2d ", cursor + 1, length)):style(THEME.status.mode_normal),
|
||||||
|
|
@ -100,12 +95,11 @@ function Status:render(area)
|
||||||
:constraints({ ui.Constraint.Percentage(50), ui.Constraint.Percentage(50) })
|
:constraints({ ui.Constraint.Percentage(50), ui.Constraint.Percentage(50) })
|
||||||
:split(area)
|
:split(area)
|
||||||
|
|
||||||
-- local left = ui.Line(self.mode(), self.size(), self.name())
|
local left = ui.Line(self.mode(), self.size(), self.name())
|
||||||
-- local right = ui.Line(self.permissions(), self.percentage(), self.position())
|
local right = ui.Line(self.permissions(), self.percentage(), self.position())
|
||||||
|
|
||||||
local left = ui.Line(self.mode(), self.size())
|
|
||||||
return ui.Paragraph.render(
|
return ui.Paragraph.render(
|
||||||
ui.Paragraph(left):area(chunks[1])
|
ui.Paragraph(left):area(chunks[1]),
|
||||||
-- ui.Paragraph(right):align(ui.Alignment.RIGHT):area(chunks[2])
|
ui.Paragraph(right):align(ui.Alignment.RIGHT):area(chunks[2])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use mlua::{AnyUserData, IntoLua, MetaMethod, UserData, UserDataFields, UserDataMethods, UserDataRef, Value};
|
use mlua::{AnyUserData, IntoLua, MetaMethod, UserDataFields, UserDataMethods};
|
||||||
use tracing::info;
|
|
||||||
|
|
||||||
use crate::{Url, LUA};
|
use crate::{Url, LUA};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use mlua::UserData;
|
use mlua::{MetaMethod, UserData};
|
||||||
|
|
||||||
// Url
|
// Url
|
||||||
pub struct Url(shared::Url);
|
pub struct Url(shared::Url);
|
||||||
|
|
@ -7,5 +7,8 @@ impl From<&shared::Url> for Url {
|
||||||
fn from(value: &shared::Url) -> Self { Self(value.clone()) }
|
fn from(value: &shared::Url) -> Self { Self(value.clone()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
impl UserData for Url {
|
||||||
impl UserData for Url {}
|
fn add_methods<'lua, M: mlua::UserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||||
|
methods.add_meta_method(MetaMethod::ToString, |_, me, ()| Ok(me.0.display().to_string()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue