diff options
| author | Brooks J Rady <b.j.rady@gmail.com> | 2021-01-06 19:34:18 +0000 |
|---|---|---|
| committer | Brooks J Rady <b.j.rady@gmail.com> | 2021-01-06 19:34:18 +0000 |
| commit | 1fa23e6fa4635a61a64ab0f53da1455c72b405d8 (patch) | |
| tree | 789be804ce4bdae3f9da02bdabea7322c6179bdb /src/main.rs | |
| parent | A module rename to please clippy (diff) | |
| download | sl0ppij-1fa23e6fa4635a61a64ab0f53da1455c72b405d8.tar.gz sl0ppij-1fa23e6fa4635a61a64ab0f53da1455c72b405d8.tar.xz sl0ppij-1fa23e6fa4635a61a64ab0f53da1455c72b405d8.zip | |
Get clipped, fool
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs index 395859df..01d0f232 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,6 +24,7 @@ use std::thread; use panes::PaneId; use serde::{Deserialize, Serialize}; use structopt::StructOpt; +use wasm_vm::PluginInstruction; use crate::command_is_executing::CommandIsExecuting; use crate::errors::{AppContext, ContextType, ErrorContext, PtyContext, ScreenContext}; @@ -38,7 +39,7 @@ use crate::utils::{ }; use std::cell::RefCell; -thread_local!(static OPENCALLS: RefCell<ErrorContext> = RefCell::new(ErrorContext::new())); +thread_local!(static OPENCALLS: RefCell<ErrorContext> = RefCell::default()); #[derive(Serialize, Deserialize, Debug)] enum ApiCommand { @@ -48,6 +49,9 @@ enum ApiCommand { MoveFocus, } +pub type ChannelWithContext<T> = (Sender<(T, ErrorContext)>, Receiver<(T, ErrorContext)>); +pub type SyncChannelWithContext<T> = (SyncSender<(T, ErrorContext)>, Receiver<(T, ErrorContext)>); + #[derive(Clone)] enum SenderType<T: Clone> { Sender(Sender<(T, ErrorContext)>), @@ -146,35 +150,27 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: Opt) { let command_is_executing = CommandIsExecuting::new(); let full_screen_ws = os_input.get_terminal_size_using_fd(0); - os_input.into_raw_mode(0); - let (send_screen_instructions, receive_screen_instructions): ( - Sender<(ScreenInstruction, ErrorContext)>, - Receiver<(ScreenInstruction, ErrorContext)>, - ) = channel(); + os_input.set_raw_mode(0); + let (send_screen_instructions, receive_screen_instructions): ChannelWithContext< + ScreenInstruction, + > = channel(); let err_ctx = OPENCALLS.with(|ctx| *ctx.borrow()); let mut send_screen_instructions = SenderWithContext::new(err_ctx, SenderType::Sender(send_screen_instructions)); - let (send_pty_instructions, receive_pty_instructions): ( - Sender<(PtyInstruction, ErrorContext)>, - Receiver<(PtyInstruction, ErrorContext)>, - ) = channel(); + + let (send_pty_instructions, receive_pty_instructions): ChannelWithContext<PtyInstruction> = + channel(); let mut send_pty_instructions = SenderWithContext::new(err_ctx, SenderType::Sender(send_pty_instructions)); - use crate::wasm_vm::PluginInstruction; - - let (send_plugin_instructions, receive_plugin_instructions): ( - Sender<(PluginInstruction, ErrorContext)>, - Receiver<(PluginInstruction, ErrorContext)>, - ) = channel(); - + let (send_plugin_instructions, receive_plugin_instructions): ChannelWithContext< + PluginInstruction, + > = channel(); let send_plugin_instructions = SenderWithContext::new(err_ctx, SenderType::Sender(send_plugin_instructions)); - let (send_app_instructions, receive_app_instructions): ( - SyncSender<(AppInstruction, ErrorContext)>, - Receiver<(AppInstruction, ErrorContext)>, - ) = sync_channel(0); + let (send_app_instructions, receive_app_instructions): SyncChannelWithContext<AppInstruction> = + sync_channel(0); let send_app_instructions = SenderWithContext::new(err_ctx, SenderType::SyncSender(send_app_instructions)); |
