1    let find_file (path : String) (item : FileItem) : Option<FileItem> =
2        if item.path == path then
3            Some item
4        else
5            for x in item.items do
6                let maybe_file = find_file path x
7                if maybe_file.is_some then
8                    return maybe_file
9    
10           None
11   
12   type Editor
13       let navigate_to (path : String) (position : TextPos) =
14           let file_item = find_file path data |> unwrap
15           let result = open file_item
16           let tab_item = file_item_tab_items[file_item]
17           let text_box = tab_item_text_boxes[tab_item]
18           let up_left = position.up.left
19           if result then
20               control/measure_clamped tab_control tab_control.width
21                                       tab_control.height
22               tab_control.arrange
23   
24           text_box.cursor_pos = up_left
25           text_box.show up_left
26           app.display.focus = text_box
27   
28       let tick (dt : f32) =
29           check_process
30           let mut has_changed = false
31           if listener.try_next ? Some stream then
32               assert state == EditorState/BuildKedr
33               let string = stream.read_text
34               if string == "success" then
35                   write_message "success"
36                   separate
37                   let command = maybe_command.unwrap
38                   if command.build_cpp then
39                       let path = "$develop_path/cpptest"
40                       let text = "cmake -S $path -B $path/build"
41                       state = EditorState/CMake
42                       write_message "compiling"
43                       separate
44                       maybe_process = sys/process/run text
45                   else
46                       maybe_command = None
47                       state = EditorState/Idle
48               else
49                   maybe_command = None
50                   state = EditorState/Idle
51   
52                   let lines = string.lines
53                   if lines.size == 1 then
54                       write lines[0]
55                   else
56                       let path_line = lines[lines.size - 2]
57                       let position_line = lines[lines.size - 1]
58                       let position_parts = position_line.split ' '
59                       let line_index = u32.parse position_parts[0]
60                       let char_index = u32.parse position_parts[1]
61                       assert line_index >= 0 && char_index >= 0
62                       let position = TextPos line_index char_index
63                       navigate_to path_line position
64                       for i = 0 until lines.size - 3 do
65                           write lines[i]
66                                 endl = true
67   
68               stream.discard
69               has_changed = true
70   
71           if should_draw then
72               has_changed = true
73               if tab_control.selected_tab_item ? Some tab_item then
74                   let text_box = tab_item_text_boxes[tab_item]
75                   text_box.update
76   
77               if was_resized then
78                   was_resized = false
79               else
80                   should_draw = false
81   
82           if has_changed then
83               output_text_box.update
84               app.display.update
85               app.drawer.update dt app.display.controls.as_readonly
86   
87       app.tick.subscribe { tick _ } |> tokens.add
88