Add Status:owner to the tips page of documentation

This commit is contained in:
sxyazi 2024-01-03 01:27:06 +08:00
parent b13a2a19ff
commit b013d12706
No known key found for this signature in database
2 changed files with 1 additions and 27 deletions

View file

@ -140,35 +140,11 @@ function Status:progress(area, offset)
} }
end end
function Status:owner(area)
local h = cx.active.current.hovered
if ya.target_family() ~= "unix" or h == nil then
return ui.Span("")
end
local spans = {}
local uid = h.cha.uid
if uid then
spans[#spans + 1] = ui.Span(ya.get_user_name_by_uid(uid) or tostring(uid))
spans[#spans + 1] = ui.Span(" ")
end
local gid = h.cha.gid
if gid then
spans[#spans + 1] = ui.Span(ya.get_group_name_by_gid(gid) or tostring(gid))
spans[#spans + 1] = ui.Span(" ")
end
return ui.Line(spans)
end
function Status:render(area) function Status:render(area)
self.area = area self.area = 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 right = ui.Line({ self:owner(), self:permissions(), self:percentage(), self:position() })
local progress = self:progress(area, right:width()) local progress = self:progress(area, right:width())
return { return {
ui.Paragraph(area, { left }), ui.Paragraph(area, { left }),

View file

@ -6,11 +6,9 @@ use super::Utils;
impl Utils { impl Utils {
#[cfg(unix)] #[cfg(unix)]
pub(super) fn user(lua: &Lua, ya: &Table) -> mlua::Result<()> { pub(super) fn user(lua: &Lua, ya: &Table) -> mlua::Result<()> {
#[cfg(unix)]
use uzers::{Groups, Users, UsersCache}; use uzers::{Groups, Users, UsersCache};
#[cfg(unix)]
static CACHE: RoCell<UsersCache> = RoCell::new();
static CACHE: RoCell<UsersCache> = RoCell::new();
CACHE.with(Default::default); CACHE.with(Default::default);
ya.set("uid", lua.create_function(|_, ()| Ok(CACHE.get_current_uid()))?)?; ya.set("uid", lua.create_function(|_, ()| Ok(CACHE.get_current_uid()))?)?;