标题粗体显示:h1-h6 标题在正文中标粗区分
This commit is contained in:
@@ -239,13 +239,38 @@ egui::ComboBox::from_id_salt("bg_type_selector")
|
||||
ui.with_layout(
|
||||
egui::Layout::top_down(align).with_main_justify(false),
|
||||
|ui| {
|
||||
ui.add(
|
||||
egui::Label::new(
|
||||
egui::RichText::new(&indented)
|
||||
let mut is_heading = false;
|
||||
let mut remaining = indented.as_str();
|
||||
while !remaining.is_empty() {
|
||||
if let Some(pos) = remaining.find(['\x01', '\x02']) {
|
||||
if pos > 0 {
|
||||
let text = &remaining[..pos];
|
||||
let mut rt = egui::RichText::new(text)
|
||||
.size(style.font_size)
|
||||
.color(colors.text);
|
||||
if is_heading {
|
||||
rt = rt.strong();
|
||||
}
|
||||
ui.add(egui::Label::new(rt).wrap());
|
||||
}
|
||||
let marker = remaining.chars().nth(pos).unwrap();
|
||||
if marker == '\x01' {
|
||||
is_heading = true;
|
||||
} else {
|
||||
is_heading = false;
|
||||
}
|
||||
remaining = &remaining[pos + 1..];
|
||||
} else {
|
||||
let mut rt = egui::RichText::new(remaining)
|
||||
.size(style.font_size)
|
||||
.color(colors.text)
|
||||
).wrap()
|
||||
);
|
||||
.color(colors.text);
|
||||
if is_heading {
|
||||
rt = rt.strong();
|
||||
}
|
||||
ui.add(egui::Label::new(rt).wrap());
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user