A simple CPU rendered GUI IDE experience.
better path fixing/ non variable fixed font
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | CascadiaCodeNF.ttf | bin | 2548236 -> 2893648 bytes | |||
| -rw-r--r-- | CascadiaCodeNFBold.ttf | bin | 0 -> 2894232 bytes | |||
| -rw-r--r-- | CascadiaCodeNFBoldItalic.ttf | bin | 0 -> 2756024 bytes | |||
| -rw-r--r-- | CascadiaCodeNFItalic.ttf | bin | 2352780 -> 2755568 bytes | |||
| -rw-r--r-- | src/bar.rs | 4 | ||||
| -rw-r--r-- | src/edi.rs | 25 | ||||
| -rw-r--r-- | src/edi/st.rs | 3 | ||||
| -rw-r--r-- | src/main.rs | 26 | ||||
| -rw-r--r-- | src/rnd.rs | 21 |
10 files changed, 55 insertions, 26 deletions
@@ -23,7 +23,7 @@ array_chunks = "1.0.0" rust-fsm = { git = "https://git.bendn.org/rust-fsm", features = ["diagram"] } clipp = "0.1.0" diff-match-patch-rs = { git = "https://git.bendn.org/dmp" } -regex = "1.11.3" +regex = { version = "1.11.3", features = ["unstable", "use_std"] } tree-house = { version = "0.3.0", features = ["fixtures"] } # for tree house grammar loading diff --git a/CascadiaCodeNF.ttf b/CascadiaCodeNF.ttf Binary files differindex 8c64f5d..b589dd0 100644 --- a/CascadiaCodeNF.ttf +++ b/CascadiaCodeNF.ttf diff --git a/CascadiaCodeNFBold.ttf b/CascadiaCodeNFBold.ttf Binary files differnew file mode 100644 index 0000000..d7ec691 --- /dev/null +++ b/CascadiaCodeNFBold.ttf diff --git a/CascadiaCodeNFBoldItalic.ttf b/CascadiaCodeNFBoldItalic.ttf Binary files differnew file mode 100644 index 0000000..a6a9927 --- /dev/null +++ b/CascadiaCodeNFBoldItalic.ttf diff --git a/CascadiaCodeNFItalic.ttf b/CascadiaCodeNFItalic.ttf Binary files differindex 66894ea..ee552e0 100644 --- a/CascadiaCodeNFItalic.ttf +++ b/CascadiaCodeNFItalic.ttf @@ -5,6 +5,7 @@ use dsb::cell::Style; use lsp_types::WorkDoneProgress; use crate::lsp::{Client, Rq}; +use crate::rnd::simplify_path; use crate::sym::Symbols; use crate::text::TextArea; #[derive(Default, Debug)] @@ -24,6 +25,7 @@ impl Bar { t: &TextArea, lsp: Option<&Client>, ) { + let fname = simplify_path(fname); let row = &mut into[oy * w..oy * w + w]; row.fill(Cell { style: Style::new(color, bg) | Style::ITALIC, @@ -70,7 +72,7 @@ impl Bar { _ => None, }) { - dbg!(&m); + // dbg!(&m); row.iter_mut() .rev() .zip(m.chars().rev()) @@ -780,13 +780,16 @@ impl Editor { target_range, .. }) = self.requests.def.result - && let Some(p) = self.origin.as_deref() { - if target_uri == &p.tid().uri { - text.cursor = - text.l_position(target_range.start).unwrap(); - text.scroll_to_cursor(); - } + self.open( + &target_uri.to_file_path().unwrap(), + w.clone(), + ) + .unwrap(); + + self.text.cursor = + self.text.l_position(target_range.start).unwrap(); + self.text.scroll_to_cursor(); } } None => {} @@ -948,7 +951,7 @@ impl Editor { self.state = State::Default; self.requests.complete = CompletionState::None; if Some(&f) != self.origin.as_ref() { - self.open(&f, window)?; + self.open(&f, window.clone())?; } let p = self.text .l_position(x.location.range.start).ok_or(anyhow::anyhow!("rah"))?; @@ -1341,7 +1344,7 @@ impl Editor { change!(self); } Some(Do::OpenFile(x)) => { - _ = self.open(Path::new(&x), window); + _ = self.open(Path::new(&x), window.clone()); } Some( Do::MoveCursor | Do::ExtendSelectionToMouse | Do::Hover, @@ -1400,7 +1403,7 @@ impl Editor { pub fn open( &mut self, x: &Path, - w: &mut Arc<Window>, + w: Arc<Window>, ) -> anyhow::Result<()> { let x = x.canonicalize()?.to_path_buf(); if Some(&*x) == self.origin.as_deref() { @@ -1435,7 +1438,7 @@ impl Editor { std::thread::JoinHandle<()>, Option<Sender<Arc<Window>>>, )>, - w: Option<&mut Arc<Window>>, + w: Option<Arc<Window>>, ws: Option<PathBuf>, ) -> anyhow::Result<()> { if let Some(x) = self.files.remove(x) { @@ -1483,7 +1486,7 @@ impl Editor { x.rq_semantic_tokens( &mut self.requests.semantic_tokens, origin, - w.cloned(), + w.clone(), ) .unwrap(); }); diff --git a/src/edi/st.rs b/src/edi/st.rs index 3d38806..6c11b87 100644 --- a/src/edi/st.rs +++ b/src/edi/st.rs @@ -60,11 +60,10 @@ Symbols(Rq { result: Some(_x), request: None }) => { }, Symbols(Rq::<Symbols, Vec<SymbolInformation>, (), AQErr> => _rq) => { K(Key::Character(x) if x == "d" && ctrl()) => _ [SwitchType], // crahs cond methinks - K(_) => _ [SymbolsHandleKey], K(Key::Named(Escape)) => Default, + K(_) => _ [SymbolsHandleKey], C(_) => _, M(_) => _, - K(_) => _, }, CodeAction(Rq { result : Some(_x), request }) => { K(Key::Named(Tab) if shift()) => _ [CASelectPrev], diff --git a/src/main.rs b/src/main.rs index 3961eb3..da30c41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -243,11 +243,12 @@ pub(crate) fn entry(event_loop: EventLoop<()>) { // let ed = Box::leak(Box::new(ed)); let mut fonts = dsb::Fonts::new( - F::FontRef(*FONT, &[(2003265652, 550.0)]), - F::instance(*FONT, *BFONT), - F::FontRef(*IFONT, &[(2003265652, 550.0)]), - F::instance(*IFONT, *BIFONT), + F::FontRef(*FONT, &[]), + F::FontRef(*BFONT, &[]), + F::FontRef(*IFONT, &[]), + F::FontRef(*BIFONT, &[]), ); + let mut cursor_position = (0, 0); let mut i = Image::build(1, 1).fill(BG); let mut cells = vec![]; @@ -479,12 +480,21 @@ pub static IFONT: LazyLock<FontRef<'static>> = LazyLock::new(|| { .unwrap() }); -pub static BIFONT: LazyLock<Instance<'static>> = LazyLock::new(|| { - IFONT.instances().find_by_name("Bold Italic").unwrap() +pub static BIFONT: LazyLock<FontRef<'static>> = LazyLock::new(|| { + FontRef::from_index( + &include_bytes!("../CascadiaCodeNFBoldItalic.ttf")[..], + 0, + ) + .unwrap() }); -pub static BFONT: LazyLock<Instance<'static>> = - LazyLock::new(|| FONT.instances().find_by_name("Bold").unwrap()); +pub static BFONT: LazyLock<FontRef<'static>> = LazyLock::new(|| { + FontRef::from_index( + &include_bytes!("../CascadiaCodeNFBold.ttf")[..], + 0, + ) + .unwrap() +}); fn shift() -> bool { unsafe { MODIFIERS }.shift_key() } @@ -1,3 +1,4 @@ +use std::borrow::Cow; use std::iter::once; use std::os::fd::AsFd; use std::sync::{Arc, LazyLock}; @@ -10,6 +11,7 @@ use dsb::{Cell, Fonts}; use fimg::pixels::Blend; use fimg::{Image, OverlayAt}; use lsp_types::*; +use regex::Regex; use rust_fsm::StateMachine; use softbuffer::Surface; use swash::{FontRef, Instance}; @@ -376,10 +378,9 @@ pub fn render( (95, (r.saturating_sub(5)) as _), false, ); - for b in x + for b in simplify_path(&x .replace('\n', "\r\n") - .replace("⸬", ":") - .replace("/home/os", "") + .replace("⸬", ":")) .bytes() { t.rx( @@ -762,3 +763,17 @@ pub fn render( buffer.present().unwrap(); } } + +pub fn simplify_path(x: &str) -> String { + static DEP: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"\.cargo\/git\/checkouts\/(?<name>[^/]+)\-[a-f0-9]+\/[a-f0-9]+").unwrap()); + static DEP2: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"\.cargo\/registry\/src/index.crates.io-[0-9a-f]+/(?<name>[^/]+)\-(?<version>[0-9]+\.[0-9]+\.[0-9]+)").unwrap()); + static RUST_SRC: LazyLock<Regex> = LazyLock::new(|| Regex::new(r".rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library").unwrap()); + let x = x.replace(env!("HOME"), " "); + [ + (&*RUST_SRC, " "), + (&*DEP, " /$name"), + (&*DEP2, " /$name"), + ].into_iter().fold(x, |acc, (r, repl)| { + r.replace(&acc, repl).into_owned() + }) +}
\ No newline at end of file |