1 def load_text (text_box : MultilineTextBox) (s : String) = 2 let text = text_box.display_text 3 if text.is_not_empty then 4 text.clear 5 6 text.insert TextPos.new s 7 text_box.update_colors 0 text.lines.size 8 update_mesh 9 10 type Editor 11 val tree = Tree 12 =data 13 min_width = 360 14 15 val output_text_box = MultilineTextBox 16 min_width = 400 17 is_readonly = true 18 19 local output = output_text_box.display_text 20 21 val tab_control = TabControl 22 background = Vector3.color "AAAAAA" 23 selected_background = Vector3.gray 0.84 24 set_foreground = false 25 on_closing = { args -> 26 let text_box = tab_item_text_boxes[args.tab_item] 27 if text_box.is_changed && not app.os_window.is_control_pressed then 28 args.is_cancelled = true } 29 30 on_closed = { tab_item -> 31 let file_item = tab_item_file_items[tab_item] 32 tab_item_text_boxes.remove tab_item 33 tab_item_file_items.remove tab_item 34 file_item_tab_items.remove file_item } 35 36 val apply_button = Button.new 37 let buttons_stack = Stack 38 distance = 5 39 Grid 40 count = 3 41 distance = 5 42 apply_button 43 text = "apply" 44 command = Command/Apply 45 Button 46 text = "revert" 47 command = Command/Revert 48 Button 49 text = "save" 50 command = Command/SaveAll 51 Grid 52 count = 2 53 distance = 5 54 Button 55 text = "remove" 56 command = Command/Remove 57 Button 58 text = "rename" 59 command = Command/Rename 60 Grid 61 count = 3 62 distance = 5 63 Button 64 text = "crate" 65 command = Command/Crate 66 Button 67 text = "file" 68 command = Command/File 69 Button 70 text = "dir" 71 command = Command/Directory 72 Grid 73 count = 4 74 distance = 5 75 Button 76 text = "left" 77 command = Command/Left 78 Button 79 text = "right" 80 command = Command/Right 81 Button 82 text = "up" 83 command = Command/Up 84 Button 85 text = "down" 86 command = Command/Down 87 88 let left_splitter = Splitter 89 ratio = 0 90 is_vertical = true 91 Margin 92 down = 5 93 buttons_stack 94 Rectangle 95 color = Vector3.gray 0.8 96 Scroller 97 tree 98 99 let rectangle = Rectangle 100 color = Vector3.gray 0.4 101 Margin 102 run@ set_thickness 10 103 Resizer 104 Resizer 105 is_first_primary = false 106 left_splitter 107 tab_control 108 109 output_text_box 110 111 app.set_content rectangle 112 113 tab_control.selected_tab_item@atom.subscribe 114 { maybe_prev_tab_item maybe_tab_item -> 115 if maybe_prev_tab_item.is_some && maybe_tab_item.is_some then 116 let prev_tab_item = maybe_prev_tab_item.unwrap 117 let tab_item = maybe_tab_item.unwrap 118 let prev_text_box = tab_item_text_boxes[prev_tab_item] 119 if app.display.focus == Some prev_text_box then 120 let text_box = tab_item_text_boxes[tab_item] 121 app.display.focus = text_box } 122 |> tokens.add 123 124 let default_foreground = apply_button.foreground 125 changed.bind 126 { index _ -> if index == 0 && changed.size == 1 then 127 apply_button.foreground = Colors.blue } 128 129 { index _ -> if index == 0 && changed.size == 0 then 130 apply_button.foreground = default_foreground } 131 |> tokens.add 132