A simple CPU rendered GUI IDE experience.
store hl cfg
| -rw-r--r-- | src/main.rs | 4 | ||||
| -rw-r--r-- | src/text.rs | 26 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs index 3dbda22..f6eef1d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,6 +26,7 @@ pub(crate) fn entry(event_loop: EventLoop<()>) { let mut text = TextArea::default(); let fname = std::env::args().nth(1).unwrap_or("new buffer".into()); + let mut fonts = dsb::Fonts::new(*FONT, F::instance(*FONT,* BFONT), *IFONT, F::instance(*IFONT, *BIFONT)); std::env::args().nth(1).map(|x| { text.insert(&std::fs::read_to_string(x).unwrap()); text.cursor = 0; @@ -97,7 +98,7 @@ pub(crate) fn entry(event_loop: EventLoop<()>) { dbg!(now.elapsed()); let now = Instant::now(); let mut res = unsafe { - dsb::render(&cells, (c, r), ppem, [31, 36, 48],dsb::Fonts::new(*FONT, F::instance(*FONT,* BFONT), *IFONT, F::instance(*IFONT, *BIFONT)), + dsb::render(&cells, (c, r), ppem, [31, 36, 48], &mut fonts, ls, true)}; eprint!("rend="); dbg!(now.elapsed()); @@ -127,6 +128,7 @@ pub(crate) fn entry(event_loop: EventLoop<()>) { // } let mut buffer = surface.buffer_mut().unwrap(); + for y in 0..height.get() { for x in 0..width.get() { let index = y as usize * width.get() as usize + x as usize; diff --git a/src/text.rs b/src/text.rs index 46bf764..ee74cc8 100644 --- a/src/text.rs +++ b/src/text.rs @@ -1,3 +1,5 @@ +use std::sync::LazyLock; + use atools::Chunked; use dsb::Cell; use dsb::cell::Style; @@ -173,16 +175,20 @@ impl TextArea { color: [u8; 3], bg: [u8; 3], ) -> Vec<Cell> { - let mut x = HighlightConfiguration::new( - tree_sitter_rust::LANGUAGE.into(), - "rust", - include_str!("queries.scm"), - tree_sitter_rust::INJECTIONS_QUERY, - "", - ) - .unwrap(); + static HL: LazyLock<HighlightConfiguration> = + LazyLock::new(|| { + let mut x = HighlightConfiguration::new( + tree_sitter_rust::LANGUAGE.into(), + "rust", + include_str!("queries.scm"), + tree_sitter_rust::INJECTIONS_QUERY, + "", + ) + .unwrap(); - x.configure(&NAMES); + x.configure(&NAMES); + x + }); let mut cells = vec![ Cell { @@ -205,7 +211,7 @@ impl TextArea { for hl in self .highlighter .highlight( - &x, + &HL, &self.rope.bytes().collect::<Vec<_>>(), None, |_| None, |