From 80dd0347c58a495caddf1b74801a09955ba23b32 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Thu, 12 Oct 2023 23:11:41 +0800 Subject: [PATCH] .. --- app/src/help/bindings.rs | 11 ++++------- app/src/help/layout.rs | 4 ++-- app/src/tasks/layout.rs | 9 ++++----- app/src/which/layout.rs | 6 ++---- app/src/which/side.rs | 12 ++++++------ config/src/theme/help.rs | 7 ++++--- config/src/theme/which.rs | 25 +++++++------------------ cspell.json | 2 +- 8 files changed, 30 insertions(+), 46 deletions(-) diff --git a/app/src/help/bindings.rs b/app/src/help/bindings.rs index b69958e4..efcf2124 100644 --- a/app/src/help/bindings.rs +++ b/app/src/help/bindings.rs @@ -18,10 +18,10 @@ impl Widget for Bindings<'_> { return; } - // Key + // On let col1 = bindings .iter() - .map(|c| ListItem::new(c.on()).style(THEME.help.key.into())) + .map(|c| ListItem::new(c.on()).style(THEME.help.on.into())) .collect::>(); // Execution @@ -33,10 +33,7 @@ impl Widget for Bindings<'_> { // Description let col3 = bindings .iter() - .map(|c| { - ListItem::new(if let Some(ref desc) = c.desc { desc } else { "-" }) - .style(THEME.help.desc.into()) - }) + .map(|c| ListItem::new(c.desc.as_deref().unwrap_or("-")).style(THEME.help.desc.into())) .collect::>(); let chunks = layout::Layout::new() @@ -47,7 +44,7 @@ impl Widget for Bindings<'_> { let cursor = self.cx.help.rel_cursor() as u16; buf.set_style( 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); diff --git a/app/src/help/layout.rs b/app/src/help/layout.rs index dc1d34bd..33644a17 100644 --- a/app/src/help/layout.rs +++ b/app/src/help/layout.rs @@ -17,14 +17,14 @@ impl<'a> Widget for Layout<'a> { fn render(self, area: Rect, buf: &mut Buffer) { let chunks = layout::Layout::new() .direction(Direction::Vertical) - .constraints([Constraint::Min(0), Constraint::Length(1)].as_ref()) + .constraints([Constraint::Min(0), Constraint::Length(1)]) .split(area); Clear.render(area, buf); let help = &self.cx.help; 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); Bindings::new(self.cx).render(chunks[0], buf); diff --git a/app/src/tasks/layout.rs b/app/src/tasks/layout.rs index 994855c2..82bfd53d 100644 --- a/app/src/tasks/layout.rs +++ b/app/src/tasks/layout.rs @@ -40,13 +40,12 @@ impl<'a> Widget for Layout<'a> { Clear.render(area, buf); let block = Block::new() .title({ - let mut line = Line::from("Tasks".to_string()); - line.patch_style(THEME.tasks.title.into()); - line -}) + let mut line = Line::from("Tasks"); + line.patch_style(THEME.tasks.title.into()); + line + }) .title_alignment(Alignment::Center) .padding(Padding::new(0, 0, 1, 1)) - // Maybe also add these border type in to the later theme system .borders(Borders::ALL) .border_type(BorderType::Rounded) .border_style(THEME.tasks.border.into()); diff --git a/app/src/which/layout.rs b/app/src/which/layout.rs index 9f4f66f4..89a7f9c8 100644 --- a/app/src/which/layout.rs +++ b/app/src/which/layout.rs @@ -36,13 +36,11 @@ impl Widget for Which<'_> { let chunks = layout::Layout::new() .direction(Direction::Horizontal) - .constraints( - [Constraint::Ratio(1, 3), Constraint::Ratio(1, 3), Constraint::Ratio(1, 3)].as_ref(), - ) + .constraints([Constraint::Ratio(1, 3), Constraint::Ratio(1, 3), Constraint::Ratio(1, 3)]) .split(area); 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.1).render(chunks[1], buf); Side::new(which.times, cands.2).render(chunks[2], buf); diff --git a/app/src/which/side.rs b/app/src/which/side.rs index 4b11eed5..08dac2cf 100644 --- a/app/src/which/side.rs +++ b/app/src/which/side.rs @@ -1,5 +1,5 @@ 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> { times: usize, @@ -21,18 +21,18 @@ impl Widget for Side<'_> { // Keys let keys = c.on[self.times..].iter().map(ToString::to_string).collect::>(); 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( - 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 spans.push(Span::styled( - THEME.which.separator.separator.to_string(), - Style::new().fg(THEME.which.separator.color.into()), + THEME.which.separator.to_string(), + THEME.which.separator_style.into(), )); - // Exec, + // Exec spans.push(Span::styled(c.desc_or_exec(), THEME.which.desc.into())); ListItem::new(Line::from(spans)) diff --git a/config/src/theme/help.rs b/config/src/theme/help.rs index 199297ce..2e6697aa 100644 --- a/config/src/theme/help.rs +++ b/config/src/theme/help.rs @@ -4,9 +4,10 @@ use super::Style; #[derive(Deserialize, Serialize)] pub struct Help { - pub key: Style, + pub on: Style, pub exec: Style, pub desc: Style, - pub curr: Style, - pub btm: Style, + + pub hovered: Style, + pub footer: Style, } diff --git a/config/src/theme/which.rs b/config/src/theme/which.rs index fc274fb3..1713f9dd 100644 --- a/config/src/theme/which.rs +++ b/config/src/theme/which.rs @@ -1,25 +1,14 @@ use serde::{Deserialize, Serialize}; -use super::{Color, Style}; +use super::Style; #[derive(Deserialize, Serialize)] pub struct Which { - pub block: Style, - pub key: Style, - pub separator: WhichSeparator, - pub extend: Style, - pub desc: Style, -} + pub mask: Style, + pub cand: Style, + pub rest: Style, + pub desc: Style, -#[derive(Deserialize, Serialize)] -pub struct WhichItem { - pub key: Color, - pub extend: Color, - pub description: Color, -} - -#[derive(Deserialize, Serialize)] -pub struct WhichSeparator { - pub separator: String, - pub color: Color, + pub separator: String, + pub separator_style: Style, } diff --git a/cspell.json b/cspell.json index b1209d6d..33135cb1 100644 --- a/cspell.json +++ b/cspell.json @@ -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":[]}