diff options
| author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-04-04 01:24:46 +0530 |
|---|---|---|
| committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-04 20:48:15 +0530 |
| commit | 2a648187fc8d4afc9b34d322b4f8394dcd39b6dd (patch) | |
| tree | e85afef2b8e03d6e86a85f57c9b9a3da75d823e3 /src/common | |
| parent | Move screen and plugins to client side. (diff) | |
| download | sl0ppij-2a648187fc8d4afc9b34d322b4f8394dcd39b6dd.tar.gz sl0ppij-2a648187fc8d4afc9b34d322b4f8394dcd39b6dd.tar.xz sl0ppij-2a648187fc8d4afc9b34d322b4f8394dcd39b6dd.zip | |
Fix after rebase
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/errors.rs | 2 | ||||
| -rw-r--r-- | src/common/input/handler.rs | 2 | ||||
| -rw-r--r-- | src/common/os_input_output.rs | 16 | ||||
| -rw-r--r-- | src/common/screen.rs | 7 |
4 files changed, 21 insertions, 6 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs index 720341a4..10b2165a 100644 --- a/src/common/errors.rs +++ b/src/common/errors.rs @@ -259,7 +259,7 @@ impl From<&ScreenInstruction> for ScreenContext { ScreenInstruction::CloseTab => ScreenContext::CloseTab, ScreenInstruction::GoToTab(_) => ScreenContext::GoToTab, ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName, - ScreenInstruction::TerminalResize => ScreenContext::TerminalResize, + ScreenInstruction::TerminalResize(_) => ScreenContext::TerminalResize, ScreenInstruction::ChangeMode(_) => ScreenContext::ChangeMode, ScreenInstruction::ToggleActiveSyncPanes => ScreenContext::ToggleActiveSyncPanes, } diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 4015938a..947a8d02 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -127,7 +127,7 @@ impl InputHandler { Event::ModeUpdate(get_mode_info(mode)), )); self.os_input - .send_to_server(ServerInstruction::change_input_mode(mode)); + .send_to_server(ServerInstruction::change_mode(get_mode_info(mode))); self.os_input.send_to_server(ServerInstruction::render()); } Action::Resize(direction) => { diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs index 53300424..66957a4a 100644 --- a/src/common/os_input_output.rs +++ b/src/common/os_input_output.rs @@ -7,6 +7,7 @@ use nix::sys::wait::waitpid; use nix::unistd; use nix::unistd::{ForkResult, Pid}; use serde::Serialize; +use signal_hook::{consts::signal::*, iterator::Signals}; use std::env; use std::io; use std::io::prelude::*; @@ -334,6 +335,7 @@ pub trait ClientOsApi: Send + Sync { fn client_recv(&self) -> (ClientInstruction, ErrorContext); /// Setup the client IpcChannel and notify server of new client fn connect_to_server(&mut self, full_screen_ws: PositionAndSize); + fn receive_sigwinch(&self, cb: Box<dyn Fn()>); } impl ClientOsApi for ClientOsInputOutput { @@ -389,6 +391,20 @@ impl ClientOsApi for ClientOsInputOutput { .recv() .unwrap() } + fn receive_sigwinch(&self, cb: Box<dyn Fn()>) { + let mut signals = Signals::new(&[SIGWINCH, SIGTERM, SIGINT, SIGQUIT]).unwrap(); + for signal in signals.forever() { + match signal { + SIGWINCH => { + cb(); + } + SIGTERM | SIGINT | SIGQUIT => { + break; + } + _ => unreachable!(), + } + } + } } impl Clone for Box<dyn ClientOsApi> { diff --git a/src/common/screen.rs b/src/common/screen.rs index 8868febb..92e1075c 100644 --- a/src/common/screen.rs +++ b/src/common/screen.rs @@ -58,7 +58,7 @@ pub enum ScreenInstruction { CloseTab, GoToTab(u32), UpdateTabName(Vec<u8>), - TerminalResize, + TerminalResize(PositionAndSize), ChangeMode(ModeInfo), } @@ -83,7 +83,7 @@ pub struct Screen { active_tab_index: Option<usize>, /// The [`ClientOsApi`] this [`Screen`] uses. os_api: Box<dyn ServerOsApi>, - input_mode: InputMode, + mode_info: ModeInfo, } impl Screen { @@ -233,8 +233,7 @@ impl Screen { } } - pub fn resize_to_screen(&mut self) { - let new_screen_size = self.os_api.get_terminal_size_using_fd(0); + pub fn resize_to_screen(&mut self, new_screen_size: PositionAndSize) { self.full_screen_ws = new_screen_size; for (_, tab) in self.tabs.iter_mut() { tab.resize_whole_tab(new_screen_size); |
