mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Add which color into theme system
This commit is contained in:
parent
cdd20f8510
commit
6b59f81f20
2 changed files with 17 additions and 15 deletions
|
|
@ -1,8 +1,8 @@
|
|||
use core::Ctx;
|
||||
|
||||
use ratatui::{layout, prelude::{Buffer, Constraint, Direction, Rect}, style::{Color, Style}, widgets::{Block, Clear, Widget}};
|
||||
use config::THEME;
|
||||
use ratatui::{layout, prelude::{Buffer, Constraint, Direction, Rect}, style::Style, widgets::{Block, Clear, Widget}};
|
||||
|
||||
use super::Side;
|
||||
use crate::Ctx;
|
||||
|
||||
pub(crate) struct Which<'a> {
|
||||
cx: &'a Ctx,
|
||||
|
|
@ -35,11 +35,13 @@ 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)])
|
||||
.constraints(
|
||||
[Constraint::Ratio(1, 3), Constraint::Ratio(1, 3), Constraint::Ratio(1, 3)].as_ref(),
|
||||
)
|
||||
.split(area);
|
||||
|
||||
Clear.render(area, buf);
|
||||
Block::new().style(Style::new().bg(Color::Rgb(47, 51, 73))).render(area, buf);
|
||||
Block::new().style(Style::new().bg(*THEME.which.block)).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);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use config::keymap::Control;
|
||||
use ratatui::{prelude::{Buffer, Rect}, style::{Color, Style}, text::{Line, Span}, widgets::{Block, List, ListItem, Padding, Widget}};
|
||||
use config::{keymap::Control, THEME};
|
||||
use ratatui::{prelude::{Buffer, Rect}, style::Style, text::{Line, Span}, widgets::{Block, List, ListItem, Padding, Widget}};
|
||||
|
||||
pub(super) struct Side<'a> {
|
||||
times: usize,
|
||||
|
|
@ -21,19 +21,19 @@ impl Widget for Side<'_> {
|
|||
// Keys
|
||||
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::styled(keys[0].clone(), Style::new().fg(Color::LightCyan)));
|
||||
spans.push(Span::styled(keys[0].clone(), THEME.which.key.get()));
|
||||
spans.extend(
|
||||
keys
|
||||
.iter()
|
||||
.skip(1)
|
||||
.map(|k| Span::styled(k.to_string(), Style::new().fg(Color::DarkGray))),
|
||||
keys.iter().skip(1).map(|k| Span::styled(k.to_string(), THEME.which.extend.get())),
|
||||
);
|
||||
|
||||
// Separator
|
||||
spans.push(Span::styled(" ".to_string(), Style::new().fg(Color::DarkGray)));
|
||||
spans.push(Span::styled(
|
||||
THEME.which.separator.separator.to_string(),
|
||||
Style::new().fg(*THEME.which.separator.color),
|
||||
));
|
||||
|
||||
// Exec
|
||||
spans.push(Span::styled(c.desc_or_exec(), Style::new().fg(Color::Magenta)));
|
||||
// Exec,
|
||||
spans.push(Span::styled(c.desc_or_exec(), THEME.which.desc.get()));
|
||||
|
||||
ListItem::new(Line::from(spans))
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue