mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
3e0466f552
commit
80dd0347c5
8 changed files with 30 additions and 46 deletions
|
|
@ -18,10 +18,10 @@ impl Widget for Bindings<'_> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key
|
// On
|
||||||
let col1 = bindings
|
let col1 = bindings
|
||||||
.iter()
|
.iter()
|
||||||
.map(|c| ListItem::new(c.on()).style(THEME.help.key.into()))
|
.map(|c| ListItem::new(c.on()).style(THEME.help.on.into()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
// Execution
|
// Execution
|
||||||
|
|
@ -33,10 +33,7 @@ impl Widget for Bindings<'_> {
|
||||||
// Description
|
// Description
|
||||||
let col3 = bindings
|
let col3 = bindings
|
||||||
.iter()
|
.iter()
|
||||||
.map(|c| {
|
.map(|c| ListItem::new(c.desc.as_deref().unwrap_or("-")).style(THEME.help.desc.into()))
|
||||||
ListItem::new(if let Some(ref desc) = c.desc { desc } else { "-" })
|
|
||||||
.style(THEME.help.desc.into())
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let chunks = layout::Layout::new()
|
let chunks = layout::Layout::new()
|
||||||
|
|
@ -47,7 +44,7 @@ impl Widget for Bindings<'_> {
|
||||||
let cursor = self.cx.help.rel_cursor() as u16;
|
let cursor = self.cx.help.rel_cursor() as u16;
|
||||||
buf.set_style(
|
buf.set_style(
|
||||||
Rect { x: area.x, y: area.y + cursor, width: area.width, height: 1 },
|
Rect { x: area.x, y: area.y + cursor, width: area.width, height: 1 },
|
||||||
THEME.help.curr.into(),
|
THEME.help.hovered.into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
List::new(col1).render(chunks[0], buf);
|
List::new(col1).render(chunks[0], buf);
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,14 @@ impl<'a> Widget for Layout<'a> {
|
||||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||||
let chunks = layout::Layout::new()
|
let chunks = layout::Layout::new()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints([Constraint::Min(0), Constraint::Length(1)].as_ref())
|
.constraints([Constraint::Min(0), Constraint::Length(1)])
|
||||||
.split(area);
|
.split(area);
|
||||||
|
|
||||||
Clear.render(area, buf);
|
Clear.render(area, buf);
|
||||||
|
|
||||||
let help = &self.cx.help;
|
let help = &self.cx.help;
|
||||||
Paragraph::new(help.keyword().unwrap_or_else(|| format!("{}.help", help.layer())))
|
Paragraph::new(help.keyword().unwrap_or_else(|| format!("{}.help", help.layer())))
|
||||||
.style(THEME.help.btm.into())
|
.style(THEME.help.footer.into())
|
||||||
.render(chunks[1], buf);
|
.render(chunks[1], buf);
|
||||||
|
|
||||||
Bindings::new(self.cx).render(chunks[0], buf);
|
Bindings::new(self.cx).render(chunks[0], buf);
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,12 @@ impl<'a> Widget for Layout<'a> {
|
||||||
Clear.render(area, buf);
|
Clear.render(area, buf);
|
||||||
let block = Block::new()
|
let block = Block::new()
|
||||||
.title({
|
.title({
|
||||||
let mut line = Line::from("Tasks".to_string());
|
let mut line = Line::from("Tasks");
|
||||||
line.patch_style(THEME.tasks.title.into());
|
line.patch_style(THEME.tasks.title.into());
|
||||||
line
|
line
|
||||||
})
|
})
|
||||||
.title_alignment(Alignment::Center)
|
.title_alignment(Alignment::Center)
|
||||||
.padding(Padding::new(0, 0, 1, 1))
|
.padding(Padding::new(0, 0, 1, 1))
|
||||||
// Maybe also add these border type in to the later theme system
|
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_type(BorderType::Rounded)
|
.border_type(BorderType::Rounded)
|
||||||
.border_style(THEME.tasks.border.into());
|
.border_style(THEME.tasks.border.into());
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,11 @@ impl Widget for Which<'_> {
|
||||||
|
|
||||||
let chunks = layout::Layout::new()
|
let chunks = layout::Layout::new()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.constraints(
|
.constraints([Constraint::Ratio(1, 3), Constraint::Ratio(1, 3), Constraint::Ratio(1, 3)])
|
||||||
[Constraint::Ratio(1, 3), Constraint::Ratio(1, 3), Constraint::Ratio(1, 3)].as_ref(),
|
|
||||||
)
|
|
||||||
.split(area);
|
.split(area);
|
||||||
|
|
||||||
Clear.render(area, buf);
|
Clear.render(area, buf);
|
||||||
Block::new().style(THEME.which.block.into()).render(area, buf);
|
Block::new().style(THEME.which.mask.into()).render(area, buf);
|
||||||
Side::new(which.times, cands.0).render(chunks[0], buf);
|
Side::new(which.times, cands.0).render(chunks[0], buf);
|
||||||
Side::new(which.times, cands.1).render(chunks[1], buf);
|
Side::new(which.times, cands.1).render(chunks[1], buf);
|
||||||
Side::new(which.times, cands.2).render(chunks[2], buf);
|
Side::new(which.times, cands.2).render(chunks[2], buf);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use config::{keymap::Control, THEME};
|
use config::{keymap::Control, THEME};
|
||||||
use ratatui::{prelude::{Buffer, Rect}, style::Style, text::{Line, Span}, widgets::{Block, List, ListItem, Padding, Widget}};
|
use ratatui::{prelude::{Buffer, Rect}, text::{Line, Span}, widgets::{Block, List, ListItem, Padding, Widget}};
|
||||||
|
|
||||||
pub(super) struct Side<'a> {
|
pub(super) struct Side<'a> {
|
||||||
times: usize,
|
times: usize,
|
||||||
|
|
@ -21,18 +21,18 @@ impl Widget for Side<'_> {
|
||||||
// Keys
|
// Keys
|
||||||
let keys = c.on[self.times..].iter().map(ToString::to_string).collect::<Vec<_>>();
|
let keys = c.on[self.times..].iter().map(ToString::to_string).collect::<Vec<_>>();
|
||||||
spans.push(Span::raw(" ".repeat(10usize.saturating_sub(keys.join("").len()))));
|
spans.push(Span::raw(" ".repeat(10usize.saturating_sub(keys.join("").len()))));
|
||||||
spans.push(Span::styled(keys[0].clone(), THEME.which.key.into()));
|
spans.push(Span::styled(keys[0].clone(), THEME.which.cand.into()));
|
||||||
spans.extend(
|
spans.extend(
|
||||||
keys.iter().skip(1).map(|k| Span::styled(k.to_string(), THEME.which.extend.into())),
|
keys.iter().skip(1).map(|k| Span::styled(k.to_string(), THEME.which.rest.into())),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Separator
|
// Separator
|
||||||
spans.push(Span::styled(
|
spans.push(Span::styled(
|
||||||
THEME.which.separator.separator.to_string(),
|
THEME.which.separator.to_string(),
|
||||||
Style::new().fg(THEME.which.separator.color.into()),
|
THEME.which.separator_style.into(),
|
||||||
));
|
));
|
||||||
|
|
||||||
// Exec,
|
// Exec
|
||||||
spans.push(Span::styled(c.desc_or_exec(), THEME.which.desc.into()));
|
spans.push(Span::styled(c.desc_or_exec(), THEME.which.desc.into()));
|
||||||
|
|
||||||
ListItem::new(Line::from(spans))
|
ListItem::new(Line::from(spans))
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,10 @@ use super::Style;
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct Help {
|
pub struct Help {
|
||||||
pub key: Style,
|
pub on: Style,
|
||||||
pub exec: Style,
|
pub exec: Style,
|
||||||
pub desc: Style,
|
pub desc: Style,
|
||||||
pub curr: Style,
|
|
||||||
pub btm: Style,
|
pub hovered: Style,
|
||||||
|
pub footer: Style,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,14 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::{Color, Style};
|
use super::Style;
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct Which {
|
pub struct Which {
|
||||||
pub block: Style,
|
pub mask: Style,
|
||||||
pub key: Style,
|
pub cand: Style,
|
||||||
pub separator: WhichSeparator,
|
pub rest: Style,
|
||||||
pub extend: Style,
|
pub desc: Style,
|
||||||
pub desc: Style,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
pub separator: String,
|
||||||
pub struct WhichItem {
|
pub separator_style: Style,
|
||||||
pub key: Color,
|
|
||||||
pub extend: Color,
|
|
||||||
pub description: Color,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
|
||||||
pub struct WhichSeparator {
|
|
||||||
pub separator: String,
|
|
||||||
pub color: Color,
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ"],"version":"0.2"}
|
{"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand"],"language":"en","version":"0.2","flagWords":[]}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue