diff --git a/cursive-core/src/views/text_view.rs b/cursive-core/src/views/text_view.rs index f9a4559c..4f91376c 100644 --- a/cursive-core/src/views/text_view.rs +++ b/cursive-core/src/views/text_view.rs @@ -217,6 +217,22 @@ impl TextView { Self::new_with_content(TextContent::new(content)) } + /// Convenient function to create a TextView by parsing the given content as cursup. + /// + /// Shortcut for `TextView::new(cursup::parse(content))`. + /// + /// # Examples + /// + /// ``` + /// # use cursive_core::views::TextView; + /// let view = TextView::cursup("/red+bold{warning}"); + /// ``` + pub fn cursup(content: S) -> Self + where S: Into, + { + Self::new(crate::utils::markup::cursup::parse(content)) + } + /// Creates a new TextView using the given `TextContent`. /// /// If you kept a clone of the given content, you'll be able to update it