Different header sizes
This commit is contained in:
24
src/app.rs
24
src/app.rs
@ -14,8 +14,8 @@ use crate::{
|
|||||||
util::{GuiSender, file_mtime, log_error},
|
util::{GuiSender, file_mtime, log_error},
|
||||||
};
|
};
|
||||||
use egui::{
|
use egui::{
|
||||||
Align, Button, Context, FontData, FontDefinitions, Image, Key, Modifiers, PointerButton,
|
Align, Button, Context, FontData, FontDefinitions, FontId, Image, Key, Modifiers,
|
||||||
RichText, ScrollArea, Widget, include_image,
|
PointerButton, RichText, ScrollArea, Widget, include_image,
|
||||||
};
|
};
|
||||||
use eyre::eyre;
|
use eyre::eyre;
|
||||||
|
|
||||||
@ -201,6 +201,26 @@ impl App {
|
|||||||
|
|
||||||
cc.egui_ctx.set_fonts(fonts);
|
cc.egui_ctx.set_fonts(fonts);
|
||||||
|
|
||||||
|
// markdown font styles
|
||||||
|
cc.egui_ctx.style_mut(|style| {
|
||||||
|
for (name, size) in [
|
||||||
|
("H1", 28.0),
|
||||||
|
("H2", 26.0),
|
||||||
|
("H3", 24.0),
|
||||||
|
("H4", 22.0),
|
||||||
|
("H5", 20.0),
|
||||||
|
("H6", 18.0),
|
||||||
|
] {
|
||||||
|
style.text_styles.insert(
|
||||||
|
egui::TextStyle::Name(name.into()),
|
||||||
|
FontId {
|
||||||
|
size,
|
||||||
|
family: egui::FontFamily::Proportional,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// enable features on egui_extras to add more image types
|
// enable features on egui_extras to add more image types
|
||||||
egui_extras::install_image_loaders(&cc.egui_ctx);
|
egui_extras::install_image_loaders(&cc.egui_ctx);
|
||||||
|
|
||||||
|
|||||||
@ -145,7 +145,7 @@ impl FileEditor {
|
|||||||
|
|
||||||
if let Some(inner) = &mut self.inner {
|
if let Some(inner) = &mut self.inner {
|
||||||
while let Ok(event) = inner.file_events.try_recv() {
|
while let Ok(event) = inner.file_events.try_recv() {
|
||||||
match dbg!(event) {
|
match event {
|
||||||
FileEvent::NewFileMTime(mtime) => {
|
FileEvent::NewFileMTime(mtime) => {
|
||||||
self.file_mtime = Some(mtime);
|
self.file_mtime = Some(mtime);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
use egui::text::{CCursorRange, LayoutJob};
|
use egui::text::{CCursorRange, LayoutJob};
|
||||||
|
|
||||||
|
use crate::markdown::Heading;
|
||||||
|
|
||||||
use super::{Item, Style, parse};
|
use super::{Item, Style, parse};
|
||||||
|
|
||||||
/// Highlight markdown, caching previous output to save CPU.
|
/// Highlight markdown, caching previous output to save CPU.
|
||||||
@ -71,8 +73,15 @@ fn format_from_style(egui_style: &egui::Style, style: &Style) -> egui::text::Tex
|
|||||||
egui_style.visuals.text_color()
|
egui_style.visuals.text_color()
|
||||||
};
|
};
|
||||||
|
|
||||||
let text_style = if style.heading.is_some() {
|
let text_style = if let Some(heading) = style.heading {
|
||||||
TextStyle::Heading
|
match heading {
|
||||||
|
Heading::H1 => TextStyle::Name("H1".into()),
|
||||||
|
Heading::H2 => TextStyle::Name("H2".into()),
|
||||||
|
Heading::H3 => TextStyle::Name("H3".into()),
|
||||||
|
Heading::H4 => TextStyle::Name("H4".into()),
|
||||||
|
Heading::H5 => TextStyle::Name("H5".into()),
|
||||||
|
Heading::H6 => TextStyle::Name("H6".into()),
|
||||||
|
}
|
||||||
} else if style.code {
|
} else if style.code {
|
||||||
TextStyle::Monospace
|
TextStyle::Monospace
|
||||||
} else if style.small | style.raised {
|
} else if style.small | style.raised {
|
||||||
|
|||||||
Reference in New Issue
Block a user