mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Move help colors into THEME system
This commit is contained in:
parent
a690dfc69b
commit
8fbbb547ca
3 changed files with 25 additions and 11 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use core::Ctx;
|
||||
use config::THEME;
|
||||
use ratatui::{layout::{self, Constraint}, prelude::{Buffer, Direction, Rect}, widgets::{List, ListItem, Widget}};
|
||||
|
||||
use ratatui::{layout::{self, Constraint}, prelude::{Buffer, Direction, Rect}, style::{Color, Style, Stylize}, widgets::{List, ListItem, Widget}};
|
||||
use crate::context::Ctx;
|
||||
|
||||
pub(super) struct Bindings<'a> {
|
||||
cx: &'a Ctx,
|
||||
|
|
@ -17,19 +18,25 @@ impl Widget for Bindings<'_> {
|
|||
return;
|
||||
}
|
||||
|
||||
// Key
|
||||
let col1 = bindings
|
||||
.iter()
|
||||
.map(|c| ListItem::new(c.on()).style(Style::new().fg(Color::Yellow)))
|
||||
.map(|c| ListItem::new(c.on()).style(THEME.help.key.get()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Execution
|
||||
let col2 = bindings
|
||||
.iter()
|
||||
.map(|c| ListItem::new(c.exec()).style(Style::new().fg(Color::Cyan)))
|
||||
.map(|c| ListItem::new(c.exec()).style(THEME.help.exec.get()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Description
|
||||
let col3 = bindings
|
||||
.iter()
|
||||
.map(|c| ListItem::new(if let Some(ref desc) = c.desc { desc } else { "-" }))
|
||||
.map(|c| {
|
||||
ListItem::new(if let Some(ref desc) = c.desc { desc } else { "-" })
|
||||
.style(THEME.help.desc.get())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let chunks = layout::Layout::new()
|
||||
|
|
@ -40,7 +47,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 },
|
||||
Style::new().bg(Color::Black).bold(),
|
||||
THEME.help.curr.get(),
|
||||
);
|
||||
|
||||
List::new(col1).render(chunks[0], buf);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use core::Ctx;
|
||||
|
||||
use ratatui::{buffer::Buffer, layout::{self, Rect}, prelude::{Constraint, Direction}, style::{Color, Style}, widgets::{Clear, Paragraph, Widget}};
|
||||
use config::THEME;
|
||||
use ratatui::{buffer::Buffer, layout::{self, Rect}, prelude::{Constraint, Direction}, widgets::{Clear, Paragraph, Widget}};
|
||||
|
||||
use super::Bindings;
|
||||
use crate::Ctx;
|
||||
|
||||
pub(crate) struct Layout<'a> {
|
||||
cx: &'a Ctx,
|
||||
|
|
@ -16,14 +16,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)])
|
||||
.constraints([Constraint::Min(0), Constraint::Length(1)].as_ref())
|
||||
.split(area);
|
||||
|
||||
Clear.render(area, buf);
|
||||
|
||||
let help = &self.cx.help;
|
||||
Paragraph::new(help.keyword().unwrap_or_else(|| format!("{}.help", help.layer())))
|
||||
.style(Style::new().fg(Color::Black).bg(Color::White))
|
||||
.style(THEME.help.btm.get())
|
||||
.render(chunks[1], buf);
|
||||
|
||||
Bindings::new(self.cx).render(chunks[0], buf);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@ cut = { fg = "#FF84A9", bg = "#FF84A9" }
|
|||
hovered = { underline = true }
|
||||
syntect_theme = "~/.config/bat/themes/Catppuccin-macchiato.tmTheme"
|
||||
|
||||
[help]
|
||||
key = { fg = "#E5E510" }
|
||||
exec = { fg = "#11A8CD" }
|
||||
desc = { fg = "#E5E5E5" }
|
||||
curr = { bg = "#666666", bold = true }
|
||||
btm = { fg = "#666666", bg = "#E5E5E5" }
|
||||
|
||||
[filetype]
|
||||
|
||||
rules = [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue