Skip to main content

rustapi/docks/
log.rs

1// use crate::editor::RUSTERIX;
2use crate::prelude::*;
3use theframework::prelude::*;
4
5pub struct LogDock;
6
7impl Dock for LogDock {
8    fn new() -> Self
9    where
10        Self: Sized,
11    {
12        Self
13    }
14
15    fn setup(&mut self, _ctx: &mut TheContext) -> TheCanvas {
16        let mut center = TheCanvas::new();
17
18        let mut textedit = TheTextAreaEdit::new(TheId::named("LogEdit"));
19
20        if let Some(bytes) = crate::Embedded::get("parser/gruvbox-dark.tmTheme") {
21            if let Ok(source) = std::str::from_utf8(bytes.data.as_ref()) {
22                textedit.add_theme_from_string(source);
23                textedit.set_code_theme("Gruvbox Dark");
24            }
25        }
26
27        if let Some(bytes) = crate::Embedded::get("parser/log.sublime-syntax") {
28            if let Ok(source) = std::str::from_utf8(bytes.data.as_ref()) {
29                textedit.add_syntax_from_string(source);
30                textedit.set_code_type("Eldiron Log");
31            }
32        }
33
34        textedit.set_continuous(true);
35        textedit.display_line_number(true);
36        textedit.use_global_statusbar(true);
37        textedit.set_font_size(14.0);
38        textedit.readonly(true);
39        // Handled manually, but this dock is read-only
40        textedit.set_supports_undo(false);
41        textedit.readonly(true);
42
43        center.set_widget(textedit);
44
45        center
46    }
47
48    fn activate(
49        &mut self,
50        _ui: &mut TheUI,
51        _ctx: &mut TheContext,
52        _project: &Project,
53        _server_ctx: &mut ServerContext,
54    ) {
55    }
56
57    fn supports_actions(&self) -> bool {
58        false
59    }
60}