@@ -15,15 +15,15 @@ pub struct Text {
15
15
/// Should not affect its position within a container.
16
16
pub alignment : TextAlignment ,
17
17
/// How the text should linebreak when running out of the bounds determined by max_size
18
- pub linebreak_behaviour : TextLineBreakBehaviour ,
18
+ pub linebreak_behaviour : BreakLineOn ,
19
19
}
20
20
21
21
impl Default for Text {
22
22
fn default ( ) -> Self {
23
23
Self {
24
24
sections : Default :: default ( ) ,
25
25
alignment : TextAlignment :: Left ,
26
- linebreak_behaviour : TextLineBreakBehaviour :: Unicode ,
26
+ linebreak_behaviour : BreakLineOn :: WordBoundary ,
27
27
}
28
28
}
29
29
}
@@ -177,24 +177,22 @@ impl Default for TextStyle {
177
177
/// Determines how lines will be broken when preventing text from running out of bounds.
178
178
#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , Reflect , Serialize , Deserialize ) ]
179
179
#[ reflect( Serialize , Deserialize ) ]
180
- pub enum TextLineBreakBehaviour {
181
- /// Lines will be broken up at the nearest word boundary, usually at a space.<br/>
182
- /// This behaviour suits most cases, as it keeps words intact. Aims to implement the Unicode line breaking algorithm.
183
- Unicode ,
184
- /// Lines will be broken without discrimination at the first character that runs out of bounds.<br/>
185
- /// This is closer to the behaviour one might expect from a terminal.
180
+ pub enum BreakLineOn {
181
+ /// Uses the [Unicode Line Breaking Algorithm](https://www.unicode.org/reports/tr14/).<br/>
182
+ /// Lines will be broken up at the nearest suitable word boundary, usually a space.<br/>
183
+ /// This behaviour suits most cases, as it keeps words intact across linebreaks.<br/>
184
+ WordBoundary ,
185
+ /// Lines will be broken without discrimination on any character that would leave bounds.<br/>
186
+ /// This is closer to the behaviour one might expect from text in a terminal. <br/>
187
+ /// However it may lead to words being broken up across linebreaks<br />
186
188
AnyCharacter ,
187
189
}
188
190
189
- impl From < TextLineBreakBehaviour > for glyph_brush_layout:: BuiltInLineBreaker {
190
- fn from ( val : TextLineBreakBehaviour ) -> Self {
191
+ impl From < BreakLineOn > for glyph_brush_layout:: BuiltInLineBreaker {
192
+ fn from ( val : BreakLineOn ) -> Self {
191
193
match val {
192
- TextLineBreakBehaviour :: Unicode => {
193
- glyph_brush_layout:: BuiltInLineBreaker :: UnicodeLineBreaker
194
- }
195
- TextLineBreakBehaviour :: AnyCharacter => {
196
- glyph_brush_layout:: BuiltInLineBreaker :: AnyCharLineBreaker
197
- }
194
+ BreakLineOn :: WordBoundary => glyph_brush_layout:: BuiltInLineBreaker :: UnicodeLineBreaker ,
195
+ BreakLineOn :: AnyCharacter => glyph_brush_layout:: BuiltInLineBreaker :: AnyCharLineBreaker ,
198
196
}
199
197
}
200
198
}
0 commit comments