This PR will allow word-break in wrapped paragraphs.
Testing guidelines
Create a Paragraph in a Block, with the break_word value in its Wrap set to true.
Such as :
const SAMPLE_STRING: &str = "The library is based on the principle of immediate rendering with \
intermediate buffers. This means that at each new frame you should build all widgets that are \
supposed to be part of the UI. While providing a great flexibility for rich and \
interactive UI, this may introduce overhead for highly dynamic content.";
fn ui<B: Backend>(frame: &mut Frame<B>) {
let size = Rect::new(0, 0, 20, 10);
let text = vec![Spans::from(SAMPLE_STRING)];
let paragraph = Paragraph::new(text)
.block(Block::default().borders(Borders::ALL))
.alignment(Alignment::Left)
.wrap(Wrap {
trim: true,
break_words: true,
});
frame.render_widget(paragraph, size);
}
If set break_words as true, the result will be like:
┌──────────────────┐
│The library is bas│
│ed on the principl│
│e of immediate ren│
│dering with interm│
│ediate buffers. Th│
│is means that at e│
│ach new frame you │
│should build all w│
└──────────────────┘
If set break_words as false, the result will be like:
┌──────────────────┐
│The library is │
│based on the │
│principle of │
│immediate │
│rendering with │
│intermediate │
│buffers. This │
│means that at each│
└──────────────────┘
Description
This PR will allow word-break in wrapped paragraphs.
Testing guidelines
Create a
Paragraph
in aBlock
, with thebreak_word
value in itsWrap
set totrue
.Such as :
If set
break_words
astrue
, the result will be like:If set
break_words
asfalse
, the result will be like:Checklist