mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Add Status:owner to the tips page of documentation
This commit is contained in:
parent
b13a2a19ff
commit
b013d12706
2 changed files with 1 additions and 27 deletions
|
|
@ -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 }),
|
||||||
|
|
|
||||||
|
|
@ -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()))?)?;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue