diff --git a/src/widgets/paragraph.rs b/src/widgets/paragraph.rs index fce2bdc..69a0c3f 100644 --- a/src/widgets/paragraph.rs +++ b/src/widgets/paragraph.rs @@ -40,7 +40,7 @@ fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Alignment) /// .block(Block::default().title("Paragraph").borders(Borders::ALL)) /// .style(Style::default().fg(Color::White).bg(Color::Black)) /// .alignment(Alignment::Center) -/// .wrap(Wrap { trim: true }); +/// .wrap(Wrap { trim: true, break_words: false }); /// ``` #[derive(Debug, Clone)] pub struct Paragraph<'a> { @@ -70,7 +70,7 @@ pub struct Paragraph<'a> { /// - Here is another point that is long enough to wrap"#); /// /// // With leading spaces trimmed (window width of 30 chars): -/// Paragraph::new(bullet_points.clone()).wrap(Wrap { trim: true }); +/// Paragraph::new(bullet_points.clone()).wrap(Wrap { trim: true, break_words: false }); /// // Some indented points: /// // - First thing goes here and is /// // long so that it wraps @@ -78,7 +78,7 @@ pub struct Paragraph<'a> { /// // is long enough to wrap /// /// // But without trimming, indentation is preserved: -/// Paragraph::new(bullet_points).wrap(Wrap { trim: false }); +/// Paragraph::new(bullet_points).wrap(Wrap { trim: false, break_words: false }); /// // Some indented points: /// // - First thing goes here /// // and is long so that it wraps @@ -89,6 +89,7 @@ pub struct Paragraph<'a> { pub struct Wrap { /// Should leading whitespace be trimmed pub trim: bool, + /// Should words at the end of lines be broken pub break_words: bool, } diff --git a/tests/widgets_paragraph.rs b/tests/widgets_paragraph.rs index d3061fc..6881352 100644 --- a/tests/widgets_paragraph.rs +++ b/tests/widgets_paragraph.rs @@ -83,7 +83,7 @@ fn widgets_paragraph_can_wrap_its_content() { } #[test] -fn widgets_paragraph_can_wrap_its_content_with_word_break() { +fn widgets_paragraph_can_wrap_its_content_with_word_break_enabled() { let test_case = |alignment, expected| { let backend = TestBackend::new(20, 10); let mut terminal = Terminal::new(backend).unwrap();