mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 01:00:02 +00:00
remove extra struct wrapper for tags
This commit is contained in:
parent
bdab2d2ded
commit
cc9b86caf3
@ -141,7 +141,7 @@ impl Reader {
|
|||||||
buffer.insert_with_tags(
|
buffer.insert_with_tags(
|
||||||
&mut buffer.end_iter(),
|
&mut buffer.end_iter(),
|
||||||
alt.as_str(),
|
alt.as_str(),
|
||||||
&[&tag.title.text_tag],
|
&[&tag.title],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Append new line after alt text
|
// Append new line after alt text
|
||||||
@ -206,9 +206,9 @@ impl Reader {
|
|||||||
&mut buffer.end_iter(),
|
&mut buffer.end_iter(),
|
||||||
header.value.as_str(),
|
header.value.as_str(),
|
||||||
&[match header.level {
|
&[match header.level {
|
||||||
Level::H1 => &tag.h1.text_tag,
|
Level::H1 => &tag.h1,
|
||||||
Level::H2 => &tag.h2.text_tag,
|
Level::H2 => &tag.h2,
|
||||||
Level::H3 => &tag.h3.text_tag,
|
Level::H3 => &tag.h3,
|
||||||
}],
|
}],
|
||||||
);
|
);
|
||||||
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
||||||
@ -278,7 +278,7 @@ impl Reader {
|
|||||||
buffer.insert_with_tags(
|
buffer.insert_with_tags(
|
||||||
&mut buffer.end_iter(),
|
&mut buffer.end_iter(),
|
||||||
format!("{LIST_ITEM} {}", list.value).as_str(),
|
format!("{LIST_ITEM} {}", list.value).as_str(),
|
||||||
&[&tag.list.text_tag],
|
&[&tag.list],
|
||||||
);
|
);
|
||||||
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ impl Reader {
|
|||||||
buffer.insert_with_tags(
|
buffer.insert_with_tags(
|
||||||
&mut buffer.end_iter(),
|
&mut buffer.end_iter(),
|
||||||
quote.value.as_str(),
|
quote.value.as_str(),
|
||||||
&[&tag.quote.text_tag],
|
&[&tag.quote],
|
||||||
);
|
);
|
||||||
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ impl Reader {
|
|||||||
|
|
||||||
// Nothing match custom tags above,
|
// Nothing match custom tags above,
|
||||||
// just append plain text covered in empty tag (to handle controller events properly)
|
// just append plain text covered in empty tag (to handle controller events properly)
|
||||||
buffer.insert_with_tags(&mut buffer.end_iter(), line, &[&tag.plain.text_tag]);
|
buffer.insert_with_tags(&mut buffer.end_iter(), line, &[&tag.plain]);
|
||||||
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,50 +6,42 @@ mod plain;
|
|||||||
mod quote;
|
mod quote;
|
||||||
mod title;
|
mod title;
|
||||||
|
|
||||||
use h1::H1;
|
use gtk::{TextTag, TextTagTable};
|
||||||
use h2::H2;
|
|
||||||
use h3::H3;
|
|
||||||
use list::List;
|
|
||||||
use plain::Plain;
|
|
||||||
use quote::Quote;
|
|
||||||
use title::Title;
|
|
||||||
|
|
||||||
use gtk::TextTagTable;
|
|
||||||
|
|
||||||
pub struct Tag {
|
pub struct Tag {
|
||||||
pub text_tag_table: TextTagTable,
|
pub text_tag_table: TextTagTable,
|
||||||
// Tags
|
// Tags
|
||||||
pub h1: H1,
|
pub h1: TextTag,
|
||||||
pub h2: H2,
|
pub h2: TextTag,
|
||||||
pub h3: H3,
|
pub h3: TextTag,
|
||||||
pub list: List,
|
pub list: TextTag,
|
||||||
pub quote: Quote,
|
pub quote: TextTag,
|
||||||
pub title: Title,
|
pub title: TextTag,
|
||||||
pub plain: Plain,
|
pub plain: TextTag,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tag {
|
impl Tag {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let h1 = H1::new();
|
let h1 = h1::new();
|
||||||
let h2 = H2::new();
|
let h2 = h2::new();
|
||||||
let h3 = H3::new();
|
let h3 = h3::new();
|
||||||
let list = List::new();
|
let list = list::new();
|
||||||
let quote = Quote::new();
|
let quote = quote::new();
|
||||||
let title = Title::new();
|
let title = title::new();
|
||||||
let plain = Plain::new();
|
let plain = plain::new();
|
||||||
|
|
||||||
// Init tag table
|
// Init tag table
|
||||||
let text_tag_table = TextTagTable::new();
|
let text_tag_table = TextTagTable::new();
|
||||||
|
|
||||||
text_tag_table.add(&h1.text_tag);
|
text_tag_table.add(&h1);
|
||||||
text_tag_table.add(&h2.text_tag);
|
text_tag_table.add(&h2);
|
||||||
text_tag_table.add(&h3.text_tag);
|
text_tag_table.add(&h3);
|
||||||
text_tag_table.add(&title.text_tag);
|
text_tag_table.add(&title);
|
||||||
text_tag_table.add(&list.text_tag);
|
text_tag_table.add(&list);
|
||||||
text_tag_table.add("e.text_tag);
|
text_tag_table.add("e);
|
||||||
text_tag_table.add(&plain.text_tag);
|
text_tag_table.add(&plain);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
text_tag_table,
|
text_tag_table,
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
use gtk::{TextTag, WrapMode};
|
use gtk::{TextTag, WrapMode};
|
||||||
|
|
||||||
pub struct H1 {
|
pub fn new() -> TextTag {
|
||||||
pub text_tag: TextTag,
|
TextTag::builder()
|
||||||
}
|
.scale(1.6)
|
||||||
|
.sentence(true)
|
||||||
impl H1 {
|
.weight(500)
|
||||||
// Construct
|
.wrap_mode(WrapMode::Word)
|
||||||
pub fn new() -> Self {
|
.build()
|
||||||
Self {
|
|
||||||
text_tag: TextTag::builder()
|
|
||||||
.scale(1.6)
|
|
||||||
.sentence(true)
|
|
||||||
.weight(500)
|
|
||||||
.wrap_mode(WrapMode::Word)
|
|
||||||
.build(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
use gtk::{TextTag, WrapMode};
|
use gtk::{TextTag, WrapMode};
|
||||||
|
|
||||||
pub struct H2 {
|
pub fn new() -> TextTag {
|
||||||
pub text_tag: TextTag,
|
TextTag::builder()
|
||||||
}
|
.scale(1.4)
|
||||||
|
.sentence(true)
|
||||||
impl H2 {
|
.weight(400)
|
||||||
// Construct
|
.wrap_mode(WrapMode::Word)
|
||||||
pub fn new() -> Self {
|
.build()
|
||||||
Self {
|
|
||||||
text_tag: TextTag::builder()
|
|
||||||
.scale(1.4)
|
|
||||||
.sentence(true)
|
|
||||||
.weight(400)
|
|
||||||
.wrap_mode(WrapMode::Word)
|
|
||||||
.build(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
use gtk::{TextTag, WrapMode};
|
use gtk::{TextTag, WrapMode};
|
||||||
|
|
||||||
pub struct H3 {
|
pub fn new() -> TextTag {
|
||||||
pub text_tag: TextTag,
|
TextTag::builder()
|
||||||
}
|
.scale(1.2)
|
||||||
|
.sentence(true)
|
||||||
impl H3 {
|
.weight(400)
|
||||||
// Construct
|
.wrap_mode(WrapMode::Word)
|
||||||
pub fn new() -> Self {
|
.build()
|
||||||
Self {
|
|
||||||
text_tag: TextTag::builder()
|
|
||||||
.scale(1.2)
|
|
||||||
.sentence(true)
|
|
||||||
.weight(400)
|
|
||||||
.wrap_mode(WrapMode::Word)
|
|
||||||
.build(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
use gtk::{TextTag, WrapMode};
|
use gtk::{TextTag, WrapMode};
|
||||||
|
|
||||||
pub struct List {
|
pub fn new() -> TextTag {
|
||||||
pub text_tag: TextTag,
|
TextTag::builder()
|
||||||
}
|
.left_margin(28)
|
||||||
|
.pixels_above_lines(4)
|
||||||
impl List {
|
.pixels_below_lines(4)
|
||||||
// Construct
|
.wrap_mode(WrapMode::Word)
|
||||||
pub fn new() -> Self {
|
.build()
|
||||||
Self {
|
|
||||||
text_tag: TextTag::builder()
|
|
||||||
.left_margin(28)
|
|
||||||
.pixels_above_lines(4)
|
|
||||||
.pixels_below_lines(4)
|
|
||||||
.wrap_mode(WrapMode::Word)
|
|
||||||
.build(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
use gtk::{TextTag, WrapMode};
|
use gtk::{TextTag, WrapMode};
|
||||||
|
|
||||||
pub struct Plain {
|
pub fn new() -> TextTag {
|
||||||
pub text_tag: TextTag,
|
TextTag::builder().wrap_mode(WrapMode::Word).build()
|
||||||
}
|
|
||||||
|
|
||||||
impl Plain {
|
|
||||||
// Construct
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
text_tag: TextTag::builder().wrap_mode(WrapMode::Word).build(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,8 @@
|
|||||||
use gtk::{pango::Style, TextTag, WrapMode};
|
use gtk::{pango::Style, TextTag, WrapMode};
|
||||||
|
|
||||||
pub struct Quote {
|
pub fn new() -> TextTag {
|
||||||
pub text_tag: TextTag,
|
TextTag::builder()
|
||||||
}
|
.style(Style::Italic)
|
||||||
|
.wrap_mode(WrapMode::Word)
|
||||||
impl Quote {
|
.build()
|
||||||
// Construct
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
text_tag: TextTag::builder()
|
|
||||||
.style(Style::Italic)
|
|
||||||
.wrap_mode(WrapMode::Word)
|
|
||||||
.build(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
use gtk::{TextTag, WrapMode};
|
use gtk::{TextTag, WrapMode};
|
||||||
|
|
||||||
pub struct Title {
|
pub fn new() -> TextTag {
|
||||||
pub text_tag: TextTag,
|
TextTag::builder()
|
||||||
}
|
.pixels_above_lines(4)
|
||||||
|
.pixels_below_lines(8)
|
||||||
impl Title {
|
.weight(500)
|
||||||
// Construct
|
.wrap_mode(WrapMode::None)
|
||||||
pub fn new() -> Self {
|
.build()
|
||||||
Self {
|
|
||||||
text_tag: TextTag::builder()
|
|
||||||
.pixels_above_lines(4)
|
|
||||||
.pixels_below_lines(8)
|
|
||||||
.weight(500)
|
|
||||||
.wrap_mode(WrapMode::None)
|
|
||||||
.build(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user