mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-31 22:16:59 -06:00
Merge the startup, clipboard, animation-preview and UI PRs integrated on land-r5 (#644 #652 #655 #702 #571 #539 #674 #648 #697 #479 #369 #368)
# Conflicts: # crates/ui-egui/src/canvas.rs # crates/ui-egui/src/ribbon.rs
This commit is contained in:
@@ -504,6 +504,21 @@ impl Paragraph {
|
||||
pub fn new(text: &str) -> Self {
|
||||
Paragraph { runs: if text.is_empty() { vec![] } else { vec![Run::new(text)] }, ..Default::default() }
|
||||
}
|
||||
/// Leading tabs are the outline level (at most 8), the same rule as a typed indent.
|
||||
/// Returns whether any tab was consumed.
|
||||
pub fn promote_leading_tabs(&mut self) -> bool {
|
||||
let Some(r) = self.runs.first_mut() else { return false };
|
||||
if r.kind != RunKind::Text {
|
||||
return false;
|
||||
}
|
||||
let tabs = r.text.chars().take_while(|c| *c == '\t').count();
|
||||
if tabs == 0 {
|
||||
return false;
|
||||
}
|
||||
r.text = r.text.trim_start_matches('\t').to_string();
|
||||
self.level = tabs.min(8) as u8;
|
||||
true
|
||||
}
|
||||
pub fn text(&self) -> String {
|
||||
self.runs.iter().map(|r| r.content()).collect()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user