A simple CPU rendered GUI IDE experience.
set titles
| -rw-r--r-- | src/commands.rs | 4 | ||||
| -rw-r--r-- | src/edi.rs | 15 | ||||
| -rw-r--r-- | src/lsp.rs | 21 | ||||
| -rw-r--r-- | src/main.rs | 6 |
4 files changed, 42 insertions, 4 deletions
diff --git a/src/commands.rs b/src/commands.rs index c85911b..78dea1a 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -63,7 +63,9 @@ commands!( /// Cancels current running rust-analyzer check process @ RACancelFlycheck: "cancel-flycheck", /// Opens Cargo.toml file for this workspace - @ RAOpenCargoToml: "open-cargo-toml" + @ RAOpenCargoToml: "open-cargo-toml", + /// Runs the test at the cursor + @ RARunTest: "run-test", ); #[derive(Debug, Default)] @@ -1859,8 +1859,23 @@ impl Editor { .unwrap(); }); } + self.set_title(w); Ok(()) } + pub fn set_title(&self, w: Option<Arc<Window>>) { + if let Some(x) = w + && let Some(t) = self.title() + { + x.set_title(&t); + } + } + pub fn title(&self) -> Option<String> { + [self.workspace.as_deref(), self.origin.as_deref()] + .try_map(|x| { + x.and_then(Path::file_name).and_then(|x| x.to_str()) + }) + .map(|[wo, or]| format!("gracilaria - {wo} - {or}")) + } pub fn store(&mut self) -> anyhow::Result<()> { let ws = self.workspace.clone(); @@ -622,6 +622,25 @@ impl Client { } }); } + pub fn runnables( + &self, + t: &Path, + c: Option<Position>, + ) -> Result< + impl Future< + Output = Result< + Vec<Runnable>, + RequestError<Runnables>, + >, + >, + SendError<Message>, + > { + self.request::<Runnables>(&RunnablesParams { + text_document: t.tid(), + position: c, + }) + .map(|(x, _)| x) + } } pub fn run( (tx, rx): (Sender<Message>, Receiver<Message>), @@ -873,7 +892,7 @@ pub fn run( "rangeExclusiveHints": { "enable": true }, "closureCaptureHints": { "enable": true }, }, - "typing": { "triggerChars": ".=<>{(|+" }, + "typing": { "triggerChars": ".=<>{(+" }, "assist": { "preferSelf": true }, "checkOnSave": true, "diagnostics": { "enable": true }, diff --git a/src/main.rs b/src/main.rs index 07fd6ca..8f9786b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ #![feature( btree_set_entry, + array_try_map, tuple_trait, unboxed_closures, fn_traits, @@ -137,7 +138,7 @@ pub(crate) fn entry(event_loop: EventLoop<()>) { None => None, }; let (fw, fh) = dsb::dims(&fonts.bold, ls); - + let title = ed.title(); let app = winit_app::WinitAppBuilder::with_init( move |elwt| { let window = winit_app::make_window(elwt, |x| { @@ -157,7 +158,8 @@ pub(crate) fn entry(event_loop: EventLoop<()>) { if let Some(x) = w.take() { x.send(window.clone()).unwrap(); } - + let w_ = window.clone(); + title.as_deref().map(move |x| w_.set_title(x)); window.set_ime_allowed(true); window.set_ime_purpose(winit::window::ImePurpose::Terminal); let context = |