feat: Configuring the display results of notify using theme.toml

This commit is contained in:
evpeople 2024-02-28 19:27:01 +08:00 committed by sxyazi
parent 4d8e276a6f
commit 61907b5324
No known key found for this signature in database
2 changed files with 21 additions and 4 deletions

View file

@ -335,4 +335,20 @@ rules = [
{ name = "*/", text = "" }, { name = "*/", text = "" },
] ]
# : }}}
# : Notify {{{
[notify]
title_info = { fg = "green" }
title_warn = { bg = "yellow" }
title_error = { fg = "red" }
# Icons
icon_info = ""
icon_warn = ""
icon_error = ""
# : }}} # : }}}

View file

@ -1,6 +1,7 @@
use std::rc::Rc; use std::rc::Rc;
use ratatui::{buffer::Buffer, layout::{self, Constraint, Offset, Rect}, style::{Style, Stylize}, widgets::{Block, BorderType, Paragraph, Widget, Wrap}}; use ratatui::{buffer::Buffer, layout::{self, Constraint, Offset, Rect}, widgets::{Block, BorderType, Paragraph, Widget, Wrap}};
use yazi_config::THEME;
use yazi_core::notify::{Level, Message}; use yazi_core::notify::{Level, Message};
use crate::{widgets::Clear, Ctx}; use crate::{widgets::Clear, Ctx};
@ -42,9 +43,9 @@ impl<'a> Widget for Layout<'a> {
for (i, m) in notify.messages.iter().enumerate().take(limit) { for (i, m) in notify.messages.iter().enumerate().take(limit) {
let (icon, style) = match m.level { let (icon, style) = match m.level {
Level::Info => ("", Style::default().green()), Level::Info => (&THEME.notify.icon_info, THEME.notify.title_info),
Level::Warn => ("", Style::default().yellow()), Level::Warn => (&THEME.notify.icon_warn, THEME.notify.title_warn),
Level::Error => ("", Style::default().red()), Level::Error => (&THEME.notify.icon_error, THEME.notify.title_error),
}; };
let mut rect = let mut rect =