@@ -19,9 +19,12 @@ use crossterm::{
1919 execute, terminal,
2020};
2121#[cfg(not(windows))]
22−use signal_hook::{consts::signal, low_level};
23−#[cfg(not(windows))]
24−use signal_hook_tokio::Signals;
22+use {
23+ signal_hook::{consts::signal, low_level},
24+ signal_hook_tokio::Signals,
25+};
26+#[cfg(windows)]
27+type Signals = futures_util::stream::Empty<()>;
2528
2629pub struct Application {
2730 compositor: Compositor,
@@ -40,7 +43,6 @@ pub struct Application {
4043 #[allow(dead_code)]
4144 syn_loader: Arc<syntax::Loader>,
4245
43− #[cfg(not(windows))]
4446 signals: Signals,
4547 jobs: Jobs,
4648 lsp_progress: LspProgressMap,
@@ -108,6 +110,8 @@ impl Application {
108110
109111 editor.set_theme(theme);
110112
113+ #[cfg(windows)]
114+ let signals = futures_util::stream::empty();
111115 #[cfg(not(windows))]
112116 let signals = Signals::new(&[signal::SIGTSTP, signal::SIGCONT])?;
113117
@@ -120,7 +124,6 @@ impl Application {
120124 theme_loader,
121125 syn_loader,
122126
123− #[cfg(not(windows))]
124127 signals,
125128 jobs: Jobs::new(),
126129 lsp_progress: LspProgressMap::new(),
@@ -158,7 +161,6 @@ impl Application {
158161
159162 use futures_util::StreamExt;
160163
161− #[cfg(not(windows))]
162164 tokio::select! {
163165 biased;
164166
@@ -166,23 +168,7 @@ impl Application {
166168 self.handle_terminal_events(event)
167169 }
168170 Some(signal) = self.signals.next() => {
169− use helix_view::graphics::Rect;
170− match signal {
171− signal::SIGTSTP => {
172− self.compositor.save_cursor();
173− self.restore_term().unwrap();
174− low_level::emulate_default_handler(signal::SIGTSTP).unwrap();
175− }
176− signal::SIGCONT => {
177− self.claim_term().await.unwrap();
178− // redraw the terminal
179− let Rect { width, height, .. } = self.compositor.size();
180− self.compositor.resize(width, height);
181− self.compositor.load_cursor();
182− self.render();
183− }
184− _ => unreachable!(),
185− }
171+ self.handle_signals(signal).await;
186172 }
187173 Some((id, call)) = self.editor.language_servers.incoming.next() => {
188174 self.handle_language_server_message(call, id).await;
@@ -202,31 +188,31 @@ impl Application {
202188 self.render();
203189 }
204190 }
205− #[cfg(windows)]
206− tokio::select! {
207− biased;
191+ }
192+ }
208193
209− event = reader.next() => {
210− self.handle_terminal_events(event)
211− }
212− Some((id, call)) = self.editor.language_servers.incoming.next() => {
213− self.handle_language_server_message(call, id).await;
214− // limit render calls for fast language server messages
215− let last = self.editor.language_servers.incoming.is_empty();
216− if last || last_render.elapsed() > deadline {
217− self.render();
218− last_render = Instant::now();
219− }
220− }
221− Some(callback) = self.jobs.futures.next() => {
222− self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
223− self.render();
224− }
225− Some(callback) = self.jobs.wait_futures.next() => {
226− self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
227− self.render();
228− }
194+ #[cfg(windows)]
195+ // no signal handling available on windows
196+ pub async fn handle_signals(&mut self, _signal: ()) {}
197+
198+ #[cfg(not(windows))]
199+ pub async fn handle_signals(&mut self, signal: i32) {
200+ use helix_view::graphics::Rect;
201+ match signal {
202+ signal::SIGTSTP => {
203+ self.compositor.save_cursor();
204+ self.restore_term().unwrap();
205+ low_level::emulate_default_handler(signal::SIGTSTP).unwrap();
206+ }
207+ signal::SIGCONT => {
208+ self.claim_term().await.unwrap();
209+ // redraw the terminal
210+ let Rect { width, height, .. } = self.compositor.size();
211+ self.compositor.resize(width, height);
212+ self.compositor.load_cursor();
213+ self.render();
229214 }
215+ _ => unreachable!(),
230216 }
231217 }
232218