@@ -30,9 +30,9 @@ pub fn get_text_width(text string, text_style TextStyle, mut window Window) f32
3030 }
3131}
3232
33+ // text_width measures the visual width of the shape's lines, mirroring render rules:
34+ // - when in password mode (and not placeholder), measure '*' repeated for visible rune count
3335fn text_width (shape & Shape, mut window Window) f32 {
34- // Measure the visual width of the shape's lines, mirroring render rules:
35- // - when in password mode (and not placeholder), measure '*' repeated for visible rune count
3636 mut max_width := f32 (0 )
3737 mut text_cfg_set := false
3838 htx := fnv1 a.sum32_struct (shape.text_style).str ()
@@ -72,6 +72,7 @@ fn line_height(shape &Shape) f32 {
7272 return shape.text_style.size + shape.text_style.line_spacing
7373}
7474
75+ // text_wrap applies text wrapping logic to a given shape based on its text mode.
7576fn text_wrap (mut shape Shape, mut window Window) {
7677 if shape.text_mode in [.wrap, .wrap_keep_spaces] && shape.shape_type == .text {
7778 style := shape.text_style
@@ -197,7 +198,7 @@ fn wrap_text_keep_spaces(text string, text_style TextStyle, max_width f32, tab_s
197198 field_index++
198199 }
199200
200- // We must flush the decided output line even if it's empty (e.g., max_width == 0)
201+ // Flush the decided output line even if it's empty (e.g., max_width == 0)
201202 lines << output_line
202203 current_line = ''
203204 continue
@@ -233,7 +234,7 @@ fn wrap_text_keep_spaces(text string, text_style TextStyle, max_width f32, tab_s
233234 }
234235 }
235236
236- // 2) If we still can't add a space and line is non-empty & not ending with space,
237+ // 2) If space can't be added and line is non-empty & not ending with space,
237238 // try to wrap earlier at a space.
238239 if ! can_add_space && is_line_non_empty && ! line_ends_with_space {
239240 mut should_wrap_early := false
@@ -256,7 +257,7 @@ fn wrap_text_keep_spaces(text string, text_style TextStyle, max_width f32, tab_s
256257 current_line = field
257258 }
258259 } else if is_line_non_empty {
259- // We either added spaces or the line already ended with a space
260+ // Either added spaces or the line already ended with a space
260261 current_line = field
261262 } else {
262263 // Line is empty but field is too wide – place it anyway to avoid infinite loop
0 commit comments