mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
implement indicator icons, update quotes decoration
This commit is contained in:
parent
7b624f72bb
commit
ab6375a746
3 changed files with 53 additions and 2 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
mod ansi;
|
mod ansi;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
mod icon;
|
||||||
mod syntax;
|
mod syntax;
|
||||||
mod tag;
|
mod tag;
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
|
use icon::Icon;
|
||||||
use syntax::Syntax;
|
use syntax::Syntax;
|
||||||
use tag::Tag;
|
use tag::Tag;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
@ -58,6 +60,9 @@ impl Reader {
|
||||||
// Init multiline code builder features
|
// Init multiline code builder features
|
||||||
let mut multiline = None;
|
let mut multiline = None;
|
||||||
|
|
||||||
|
// Init quote icon feature
|
||||||
|
let mut is_line_after_quote = false;
|
||||||
|
|
||||||
// Init colors
|
// Init colors
|
||||||
// @TODO use accent colors in adw 1.6 / ubuntu 24.10+
|
// @TODO use accent colors in adw 1.6 / ubuntu 24.10+
|
||||||
let link_color = (RGBA::new(0.2, 0.5, 0.9, 1.0), RGBA::new(0.2, 0.5, 0.9, 0.9));
|
let link_color = (RGBA::new(0.2, 0.5, 0.9, 1.0), RGBA::new(0.2, 0.5, 0.9, 0.9));
|
||||||
|
|
@ -65,6 +70,9 @@ impl Reader {
|
||||||
// Init syntect highlight features
|
// Init syntect highlight features
|
||||||
let syntax = Syntax::new();
|
let syntax = Syntax::new();
|
||||||
|
|
||||||
|
// Init icons
|
||||||
|
let icon = Icon::new();
|
||||||
|
|
||||||
// Init tags
|
// Init tags
|
||||||
let tag = Tag::new();
|
let tag = Tag::new();
|
||||||
|
|
||||||
|
|
@ -282,12 +290,24 @@ impl Reader {
|
||||||
|
|
||||||
// Is quote
|
// Is quote
|
||||||
if let Some(quote) = Quote::from(line) {
|
if let Some(quote) = Quote::from(line) {
|
||||||
|
// Show quote indicator if last line is not quote (to prevent duplicates)
|
||||||
|
if !is_line_after_quote {
|
||||||
|
// Show only if the icons resolved for default `Display`
|
||||||
|
if let Some(ref icon) = icon {
|
||||||
|
buffer.insert_paintable(&mut buffer.end_iter(), &icon.quote);
|
||||||
|
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is_line_after_quote = true;
|
||||||
|
|
||||||
// Append value to buffer
|
// Append value to buffer
|
||||||
buffer.insert_with_tags(&mut buffer.end_iter(), "e.value, &[&tag.quote]);
|
buffer.insert_with_tags(&mut buffer.end_iter(), "e.value, &[&tag.quote]);
|
||||||
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
||||||
|
|
||||||
// Skip other actions for this line
|
// Skip other actions for this line
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
is_line_after_quote = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing match custom tags above,
|
// Nothing match custom tags above,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
use gtk::{gdk::Display, IconLookupFlags, IconPaintable, IconTheme, TextDirection};
|
||||||
|
|
||||||
|
const SIZE: i32 = 16;
|
||||||
|
|
||||||
|
/// Indication icons asset (for tag blocks decoration)
|
||||||
|
pub struct Icon {
|
||||||
|
pub quote: IconPaintable,
|
||||||
|
// @TODO other tags..
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Icon {
|
||||||
|
pub fn new() -> Option<Self> {
|
||||||
|
Display::default().map(|display| {
|
||||||
|
let theme = IconTheme::for_display(&display);
|
||||||
|
Self {
|
||||||
|
quote: icon(&theme, "mail-forward-symbolic"),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn icon(theme: &IconTheme, name: &str) -> IconPaintable {
|
||||||
|
theme.lookup_icon(
|
||||||
|
name,
|
||||||
|
&[], // @TODO
|
||||||
|
SIZE,
|
||||||
|
SIZE,
|
||||||
|
TextDirection::None,
|
||||||
|
IconLookupFlags::FORCE_SYMBOLIC,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use gtk::{pango::Style, TextTag, WrapMode};
|
use gtk::{TextTag, WrapMode};
|
||||||
|
|
||||||
pub fn new() -> TextTag {
|
pub fn new() -> TextTag {
|
||||||
TextTag::builder()
|
TextTag::builder()
|
||||||
.style(Style::Italic)
|
.left_margin(28)
|
||||||
.wrap_mode(WrapMode::Word)
|
.wrap_mode(WrapMode::Word)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue