Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-tui/src/text.rs')
-rw-r--r--helix-tui/src/text.rs32
1 files changed, 4 insertions, 28 deletions
diff --git a/helix-tui/src/text.rs b/helix-tui/src/text.rs
index a9c36503..c4313e15 100644
--- a/helix-tui/src/text.rs
+++ b/helix-tui/src/text.rs
@@ -10,7 +10,7 @@
//! These types form a hierarchy: [`Spans`] is a collection of [`Span`] and each line of [`Text`]
//! is a [`Spans`].
//!
-//! Keep in mind that a lot of widgets will use those types to advertise what kind of string is
+//! Keep it mind that a lot of widgets will use those types to advertise what kind of string is
//! supported for their properties. Moreover, `tui` provides convenient `From` implementations so
//! that you can start by using simple `String` or `&str` and then promote them to the previous
//! primitives when you need additional styling capabilities.
@@ -374,30 +374,6 @@ impl<'a> Text<'a> {
self.lines.len()
}
- /// Patch text with a new style. Only updates fields that are in the new style.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use helix_tui::text::Text;
- /// # use helix_view::graphics::{Color, Style};
- /// let style1 = Style::default().fg(Color::Yellow);
- /// let style2 = Style::default().fg(Color::Yellow).bg(Color::Black);
- /// let mut half_styled_text = Text::styled(String::from("The first line\nThe second line"), style1);
- /// let full_styled_text = Text::styled(String::from("The first line\nThe second line"), style2);
- /// assert_ne!(half_styled_text, full_styled_text);
- ///
- /// half_styled_text.patch_style(Style::default().bg(Color::Black));
- /// assert_eq!(half_styled_text, full_styled_text);
- /// ```
- pub fn patch_style(&mut self, style: Style) {
- for line in &mut self.lines {
- for span in &mut line.0 {
- span.style = span.style.patch(style);
- }
- }
- }
-
/// Apply a new style to existing text.
///
/// # Examples
@@ -410,13 +386,13 @@ impl<'a> Text<'a> {
/// let styled_text = Text::styled(String::from("The first line\nThe second line"), style);
/// assert_ne!(raw_text, styled_text);
///
- /// raw_text.set_style(style);
+ /// raw_text.patch_style(style);
/// assert_eq!(raw_text, styled_text);
/// ```
- pub fn set_style(&mut self, style: Style) {
+ pub fn patch_style(&mut self, style: Style) {
for line in &mut self.lines {
for span in &mut line.0 {
- span.style = style;
+ span.style = span.style.patch(style);
}
}
}