1 type HistoryItem = 2 | Add position : TextPos 3 | AddStr from : TextPos 4 to : TextPos 5 6 | Remove position : TextPos 7 cursor_pos : TextPos 8 c : Char 9 10 | RemoveStr position : TextPos 11 cursor_pos : TextPos 12 s : String 13 14 module multiline_text_box 15 16 type MultilineTextBox @mut = 17 inherit TextEditControl 18 19 let get_font : GetFont @auto 20 21 local mut offset : i32 = 0 22 local offset_controls = List<Control>.new 23 24 val font = get_font "JetBrainsMono" 18 25 var obs is_changed = false 26 var obs text = "" 27 var obs background = Colors.multiline_text_box_background 28 var obs show_line_numbers = false 29 var is_readonly = false 30 val display_text = Text.new 31 val os_window : OsWindow @auto 32 val history = List<HistoryItem>.new 33 val selection_offset_y = font.line_height.as<f32> * font.offset_multiplier 34 |> round |> as<u32> 35 var text_margin = 36 let margin_x = font.advance * 0.7 |> round |> as<u32> 37 let margin_y = selection_offset_y 38 Thickness left = margin_x 39 right = margin_x 40 up = margin_y 41 down = margin_y 42 43 var obs cursor_pos = TextPos.new 44 var obs selection : Option<(TextPos, TextPos)> = None 45 var update_colors : Option<Text * u32 * u32 -> Unit> = None 46 47 is_focusable = true 48