diff --git a/src/text.rs b/src/text.rs index 0ff5816..54cb8cc 100644 --- a/src/text.rs +++ b/src/text.rs @@ -111,7 +111,7 @@ impl<'a> Span<'a> { } pub fn masked(content: T, style: Style, mask: char) -> Span<'a> - where + where T: Into>, { Span { diff --git a/src/widgets/paragraph.rs b/src/widgets/paragraph.rs index d4ded86..3a15cee 100644 --- a/src/widgets/paragraph.rs +++ b/src/widgets/paragraph.rs @@ -177,7 +177,12 @@ impl<'a> Widget for Paragraph<'a> { if y >= self.scroll.0 { let mut x = get_line_offset(current_line_width, text_area.width, self.alignment); - for StyledGrapheme { symbol, style, mask } in current_line { + for StyledGrapheme { + symbol, + style, + mask, + } in current_line + { let to_render_symbol = if symbol.is_empty() { // If the symbol is empty, the last char which rendered last time will // leave on the line. It's a quick fix. @@ -185,20 +190,23 @@ impl<'a> Widget for Paragraph<'a> { } else { match mask { None => symbol.to_string(), - Some(masker) => if false { - // FIXME: - // TODO: Only one of if/else branch is to be left - // should we do: - // - masker.repeat(symbol.len()) or, - // - makser - std::iter::repeat(masker) - .take(symbol.len()) - .collect() - } else { String::from(*masker) }, + Some(masker) => { + if false { + // FIXME: + // TODO: Only one of if/else branch is to be left + // should we do: + // - masker.repeat(symbol.len()) or, + // - makser + std::iter::repeat(masker).take(symbol.len()).collect() + } else { + String::from(*masker) + } + } } }; buf.get_mut(text_area.left() + x, text_area.top() + y - self.scroll.0) - .set_symbol(to_render_symbol.as_str()).set_style(*style); + .set_symbol(to_render_symbol.as_str()) + .set_style(*style); x += symbol.width() as u16; } } diff --git a/src/widgets/reflow.rs b/src/widgets/reflow.rs index c79d80b..b847b1d 100644 --- a/src/widgets/reflow.rs +++ b/src/widgets/reflow.rs @@ -55,7 +55,12 @@ impl<'a, 'b> LineComposer<'a> for WordWrapper<'a, 'b> { let mut width_to_last_word_end: u16 = 0; let mut prev_whitespace = false; let mut symbols_exhausted = true; - for StyledGrapheme { symbol, style, mask } in &mut self.symbols { + for StyledGrapheme { + symbol, + style, + mask, + } in &mut self.symbols + { symbols_exhausted = false; let symbol_whitespace = symbol.chars().all(&char::is_whitespace) && symbol != NBSP; @@ -82,7 +87,11 @@ impl<'a, 'b> LineComposer<'a> for WordWrapper<'a, 'b> { width_to_last_word_end = current_line_width; } - self.current_line.push(StyledGrapheme { symbol, style, mask }); + self.current_line.push(StyledGrapheme { + symbol, + style, + mask, + }); current_line_width += symbol.width() as u16; if current_line_width > self.max_line_width { @@ -161,7 +170,12 @@ impl<'a, 'b> LineComposer<'a> for LineTruncator<'a, 'b> { let mut skip_rest = false; let mut symbols_exhausted = true; let mut horizontal_offset = self.horizontal_offset as usize; - for StyledGrapheme { symbol, style, mask } in &mut self.symbols { + for StyledGrapheme { + symbol, + style, + mask, + } in &mut self.symbols + { symbols_exhausted = false; // Ignore characters wider that the total max width. @@ -194,7 +208,11 @@ impl<'a, 'b> LineComposer<'a> for LineTruncator<'a, 'b> { } }; current_line_width += symbol.width() as u16; - self.current_line.push(StyledGrapheme { symbol, style, mask }); + self.current_line.push(StyledGrapheme { + symbol, + style, + mask, + }); } if skip_rest { @@ -242,8 +260,11 @@ mod test { fn run_composer(which: Composer, text: &str, text_area_width: u16) -> (Vec, Vec) { let style = Default::default(); let mask = None; - let mut styled = - UnicodeSegmentation::graphemes(text, true).map(|g| StyledGrapheme { symbol: g, style, mask }); + let mut styled = UnicodeSegmentation::graphemes(text, true).map(|g| StyledGrapheme { + symbol: g, + style, + mask, + }); let mut composer: Box = match which { Composer::WordWrapper { trim } => { Box::new(WordWrapper::new(&mut styled, text_area_width, trim))