mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-04 23:44:13 +00:00
create new tag for new link
This commit is contained in:
parent
d87e56661b
commit
15decfa19a
@ -12,6 +12,7 @@ use parser::{
|
||||
use tag::Tag;
|
||||
use widget::Widget;
|
||||
|
||||
use adw::StyleManager;
|
||||
use gtk::{
|
||||
gdk::{BUTTON_MIDDLE, BUTTON_PRIMARY},
|
||||
gio::{AppInfo, AppLaunchContext, SimpleAction},
|
||||
@ -39,7 +40,7 @@ impl Reader {
|
||||
let mut title = None;
|
||||
|
||||
// Init HashMap storage for event controllers
|
||||
let mut links: HashMap<&TextTag, Uri> = HashMap::new();
|
||||
let mut links: HashMap<TextTag, Uri> = HashMap::new();
|
||||
|
||||
// Init multiline code builder features
|
||||
let mut multiline = None;
|
||||
@ -133,9 +134,6 @@ impl Reader {
|
||||
|
||||
// Is link
|
||||
if let Some(link) = Link::from(line, Some(base), Some(&TimeZone::local())) {
|
||||
// Append tag to HashMap storage
|
||||
// links.insert(tag.link(), link.uri.clone()); @TODO
|
||||
|
||||
// Create vector for alt values
|
||||
let mut alt = Vec::new();
|
||||
|
||||
@ -160,10 +158,24 @@ impl Reader {
|
||||
None => link.uri.to_string(),
|
||||
});
|
||||
|
||||
// Create new tag for new link
|
||||
let a = TextTag::builder()
|
||||
.foreground_rgba(&StyleManager::default().accent_color_rgba()) // @TODO
|
||||
.sentence(true)
|
||||
.wrap_mode(WrapMode::Word)
|
||||
.build();
|
||||
|
||||
if !tag.add(&a) {
|
||||
panic!() // @TODO handle
|
||||
}
|
||||
|
||||
// Append alt vector values to buffer
|
||||
buffer.insert_with_tags(&mut buffer.end_iter(), &alt.join(" "), &[&tag.link()]);
|
||||
buffer.insert_with_tags(&mut buffer.end_iter(), &alt.join(" "), &[&a]);
|
||||
buffer.insert(&mut buffer.end_iter(), "\n");
|
||||
|
||||
// Append tag to HashMap storage
|
||||
links.insert(a, link.uri.clone());
|
||||
|
||||
// Skip other actions for this line
|
||||
continue;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ mod code;
|
||||
mod h1;
|
||||
mod h2;
|
||||
mod h3;
|
||||
mod link;
|
||||
mod list;
|
||||
mod quote;
|
||||
mod title;
|
||||
@ -11,7 +10,6 @@ use code::Code;
|
||||
use h1::H1;
|
||||
use h2::H2;
|
||||
use h3::H3;
|
||||
use link::Link;
|
||||
use list::List;
|
||||
use quote::Quote;
|
||||
use title::Title;
|
||||
@ -25,7 +23,6 @@ pub struct Tag {
|
||||
h1: H1,
|
||||
h2: H2,
|
||||
h3: H3,
|
||||
link: Link,
|
||||
list: List,
|
||||
quote: Quote,
|
||||
title: Title,
|
||||
@ -39,7 +36,6 @@ impl Tag {
|
||||
let h1 = H1::new();
|
||||
let h2 = H2::new();
|
||||
let h3 = H3::new();
|
||||
let link = Link::new();
|
||||
let list = List::new();
|
||||
let quote = Quote::new();
|
||||
let title = Title::new();
|
||||
@ -52,7 +48,6 @@ impl Tag {
|
||||
gobject.add(h2.gobject());
|
||||
gobject.add(h3.gobject());
|
||||
gobject.add(title.gobject());
|
||||
gobject.add(link.gobject());
|
||||
gobject.add(list.gobject());
|
||||
gobject.add(quote.gobject());
|
||||
|
||||
@ -63,13 +58,17 @@ impl Tag {
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
link,
|
||||
list,
|
||||
quote,
|
||||
title,
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn add(&self, tag: &TextTag) -> bool {
|
||||
self.gobject.add(tag)
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &TextTagTable {
|
||||
&self.gobject
|
||||
@ -91,10 +90,6 @@ impl Tag {
|
||||
&self.h3.gobject()
|
||||
}
|
||||
|
||||
pub fn link(&self) -> &TextTag {
|
||||
&self.link.gobject()
|
||||
}
|
||||
|
||||
pub fn list(&self) -> &TextTag {
|
||||
&self.list.gobject()
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
use adw::StyleManager;
|
||||
use gtk::{TextTag, WrapMode};
|
||||
|
||||
pub struct Link {
|
||||
tag: TextTag,
|
||||
}
|
||||
|
||||
impl Link {
|
||||
// Construct
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
tag: TextTag::builder()
|
||||
.foreground_rgba(&StyleManager::default().accent_color_rgba()) // @TODO
|
||||
.sentence(true)
|
||||
.wrap_mode(WrapMode::Word)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &TextTag {
|
||||
&self.tag
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user