A simple CPU rendered GUI IDE experience.
bendn 8 days ago
parent cfd11e3 · commit 47d3fad
-rw-r--r--src/lsp.rs49
-rw-r--r--src/rnd.rs9
-rw-r--r--src/trm.rs40
3 files changed, 60 insertions, 38 deletions
diff --git a/src/lsp.rs b/src/lsp.rs
index ddf2751..ec57c44 100644
--- a/src/lsp.rs
+++ b/src/lsp.rs
@@ -10,8 +10,7 @@ use std::sync::atomic::Ordering::Relaxed;
use std::task::Poll;
use std::thread::spawn;
use std::time::Instant;
-use tokio::task;
-use crate::text::{SortTedits, TextArea, cursor::ceach};
+
use Default::default;
use anyhow::bail;
use crossbeam::channel::{
@@ -28,8 +27,12 @@ use lsp_types::*;
use serde::{Deserialize, Serialize};
use serde_json::json;
use tokio::sync::oneshot;
+use tokio::task;
use tokio_util::task::AbortOnDropHandle;
use winit::window::Window;
+
+use crate::text::cursor::ceach;
+use crate::text::{SortTedits, TextArea};
#[derive(Debug)]
pub struct Client {
pub runtime: tokio::runtime::Runtime,
@@ -489,7 +492,9 @@ impl Client {
self.request::<lsp_request!("experimental/matchingBrace")>(
&MatchingBraceParams {
text_document: f.tid(),
- positions: vec![t.to_l_position(*t.cursor.first()).unwrap()],
+ positions: vec![
+ t.to_l_position(*t.cursor.first()).unwrap(),
+ ],
},
)
.unwrap()
@@ -605,28 +610,28 @@ impl Client {
pub fn enter<'a>(&self, f: &Path, t: &'a mut TextArea) {
ceach!(t.cursor, |c| {
- let r = self
- .runtime
- .block_on(
- self.request::<lsp_request!("experimental/onEnter")>(
- &TextDocumentPositionParams {
- text_document: f.tid(),
- position: t.to_l_position(*c).unwrap(),
- },
+ let r = self
+ .runtime
+ .block_on(
+ self.request::<lsp_request!("experimental/onEnter")>(
+ &TextDocumentPositionParams {
+ text_document: f.tid(),
+ position: t.to_l_position(*c).unwrap(),
+ },
+ )
+ .unwrap()
+ .0,
)
- .unwrap()
- .0,
- )
- .unwrap();
- match r {
- None => t.enter(),
- Some(mut r) => {
- r.sort_tedits();
- for f in r {
- t.apply_snippet_tedit(&f).unwrap();
+ .unwrap();
+ match r {
+ None => t.enter(),
+ Some(mut r) => {
+ r.sort_tedits();
+ for f in r {
+ t.apply_snippet_tedit(&f).unwrap();
+ }
}
}
- }
});
}
}
diff --git a/src/rnd.rs b/src/rnd.rs
index 7faa1db..7babc67 100644
--- a/src/rnd.rs
+++ b/src/rnd.rs
@@ -272,14 +272,17 @@ pub fn render(
if let Some(d) = &ed.requests.git_diff.result {
for h in d.hunks() {
// let b = text.rope.byte_to_line(h.after.start as _);
- if h.after.start == h.after.end && (text.vo..text.vo + r).contains(&(h.after.start as usize)) {
+ if h.after.start == h.after.end
+ && (text.vo..text.vo + r)
+ .contains(&(h.after.start as usize))
+ {
let l = h.after.start - text.vo as u32;
let f = fh + ls * fac;
i.tri::<f32>(
(0.0f32, (l as f32 - 0.15) * f - (ls * fac)),
- (6.0f32, (l as f32) * f - (ls * fac)),
+ (6.0f32, (l as f32) * f - (ls * fac)),
(0.0f32, (l as f32 + 0.15) * f - (ls * fac)),
- col!("#F27983")
+ col!("#F27983"),
);
}
for l in h.after.clone() {
diff --git a/src/trm.rs b/src/trm.rs
index 9eee9a5..f55b4c0 100644
--- a/src/trm.rs
+++ b/src/trm.rs
@@ -11,25 +11,35 @@ pub fn toggle(at: &Path) {
_ = try bikeshed anyhow::Result<()> {
let l = LAST.load(Relaxed);
let mut niri = niri::socket::Socket::connect()?;
- let Ok(Ok(Response::FocusedWindow(Some(focused)))) = niri.send(Request::FocusedWindow) else { unreachable!() };
+ let Ok(Ok(Response::FocusedWindow(Some(focused)))) =
+ niri.send(Request::FocusedWindow)
+ else {
+ unreachable!()
+ };
if l != !0 {
- let Ok(Ok(Response::Windows(x))) = niri.send(Request::Windows) else { unreachable!() };
+ let Ok(Ok(Response::Windows(x))) = niri.send(Request::Windows)
+ else {
+ unreachable!()
+ };
_ = niri.send(Request::Action(Action::SetColumnDisplay {
- display: Normal
+ display: Normal,
}))?;
if x.iter().any(|x| x.id == l) {
- _ = niri.send(Request::Action(Action::FocusWindow { id: l }))?;
+ _ = niri.send(Request::Action(Action::FocusWindow {
+ id: l,
+ }))?;
// std::thread::sleep(Duration::from_millis(500));
// let Ok(Ok(Response::FocusedWindow(Some(x)))) = niri.send(Request::FocusedWindow) else { unreachable!() };
// dbg!(&x);
// if x.layout.window_size.1 < 200 {
- _ = niri.send(Request::Action(Action::SetWindowHeight {
- id: Some(l),
- change: niri::SizeChange::SetFixed(400),
- }))?;
+ _ =
+ niri.send(Request::Action(Action::SetWindowHeight {
+ id: Some(l),
+ change: niri::SizeChange::SetFixed(400),
+ }))?;
// }
- return
+ return;
}
// it died :(
}
@@ -39,14 +49,18 @@ pub fn toggle(at: &Path) {
.to_vec(),
}))?;
std::thread::sleep(Duration::from_millis(500));
- _ = niri.send(Request::Action(Action::ConsumeOrExpelWindowLeft {
- id: None,
- }))?;
+ _ = niri.send(Request::Action(
+ Action::ConsumeOrExpelWindowLeft { id: None },
+ ))?;
_ = niri.send(Request::Action(Action::SetWindowHeight {
id: None,
change: niri::SizeChange::SetFixed(400),
}))?;
- let Ok(Ok(Response::FocusedWindow(Some(ot)))) = niri.send(Request::FocusedWindow) else { unreachable!() };
+ let Ok(Ok(Response::FocusedWindow(Some(ot)))) =
+ niri.send(Request::FocusedWindow)
+ else {
+ unreachable!()
+ };
LAST.store(ot.id, Relaxed);
};
}