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                    show up_left
26           let line = text_box.display_text.lines[position.line - 1]
27           line.highlight Colors.error_line_background
28           text_box.highlighted_line = Some line
29           app.display.focus = text_box
30   
31       let tick (dt : f32) =
32           check_process
33           let mut has_changed = false
34           if listener.try_next ? Some stream then
35               assert state == EditorState/BuildKedr
36               let string = stream.read_text
37               if string == "success" then
38                   write_message "success"
39                   separate
40                   let command = maybe_command.unwrap
41                   if command.build_cpp then
42                       let path = "$develop_path/cpptest"
43                       let text = "cmake -S $path -B $path/build"
44                       state = EditorState/CMake
45                       write_message "compiling"
46                       separate
47                       maybe_process = sys/process/run text
48                   else
49                       maybe_command = None
50                       state = EditorState/Idle
51               else
52                   maybe_command = None
53                   state = EditorState/Idle
54   
55                   let lines = string.lines
56                   if lines.size == 1 then
57                       write lines[0]
58                   else
59                       let path_line = lines[lines.size - 2]
60                       let position_line = lines[lines.size - 1]
61                       let position_parts = position_line.split ' '
62                       let line_index = u32.parse position_parts[0]
63                       let char_index = u32.parse position_parts[1]
64                       assert line_index >= 0 && char_index >= 0
65                       let position = TextPos line_index char_index
66                       navigate_to path_line position
67                       for i = 0 until lines.size - 3 do
68                           write lines[i]
69                                 endl = true
70   
71               stream.discard
72               has_changed = true
73   
74           if should_draw then
75               has_changed = true
76               if tab_control.selected_tab_item ? Some tab_item then
77                   let text_box = tab_item_text_boxes[tab_item]
78                   text_box.update
79   
80               if was_resized then
81                   was_resized = false
82               else
83                   should_draw = false
84   
85           if has_changed then
86               output_text_box.update
87               app.display.update
88               drawer.update dt app.display.controls.as_readonly
89   
90       app.tick.subscribe { tick _ } |> tokens.add
91