1 type Command 2 | Left 3 | Right 4 | Up 5 | Down 6 | Apply 7 | Revert 8 | SaveAll 9 | Rename 10 | Remove 11 | File 12 | Directory 13 | Crate 14 15 type EditorCommand = 16 val build_kedr : bool 17 val emit_cpp : bool 18 val build_cpp : bool 19 val run : bool 20 21 type EditorState = 22 | Idle 23 | BuildKedr 24 | CMake 25 | BuildCpp 26 | Run 27 28 object Colors = 29 val blue = Vector3 0.1 0.5 0.9 30 val tree_foreground = Vector3.gray 0.2 31 32 begin@ editor 33 34 type Editor @[mut internal] = 35 val app : App 36 val crate_name : String 37 val crates_path : String 38 val target_path : String 39 val develop_path : String 40 var maybe_process : Option<Process> = None 41 var maybe_command : Option<EditorCommand> = None 42 var state = EditorState/Idle 43 var should_draw = true 44 var was_resized = false 45 local mut should_separate = false 46 val crates = List<FileItem>.new 47 val changed = obs/List<FileItem>.new 48 val content_changed = List<FileItem>.new 49 val tokens = List<Token>.new 50 51 val data = FileItem 52 is_root = true 53 is_directory = true 54 path = crates_path 55 actual_path = crates_path 56 57 val tab_item_text_boxes = Map<TabItem, MultilineTextBox>.new 58 val tab_item_file_items = Map<TabItem, FileItem>.new 59 val file_item_tab_items = Map<FileItem, TabItem>.new 60 61 val listener = TcpListener.bind 8000 62 63 def redraw = 64 should_draw = true 65 66 app.os_window.sizes.subscribe { redraw 67 was_resized = true } 68 |> tokens.add 69 70 local add_all_to_changed (item : FileItem) : Unit = 71 changed.add item 72 for x in item.items do 73 add_all_to_changed x 74 75 fun destruct = 76 listener.discard 77 for i = tokens.size - 1 downto 0 do 78 tokens[i].discard 79 80 tokens.clear 81 82 def compile (crate_name : String) (emit_c : bool) = 83 let s = if emit_c then "compile" else "build" 84 let text = "$s $crate_name" 85 case TcpStream.connect "127.0.0.1:8001" of 86 Some input_stream -> 87 input_stream.write text 88 discard 89 true 90 91 None -> false 92