aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordenis <denismaximov98@gmail.com>2021-03-01 15:19:40 +0200
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-04 20:47:50 +0530
commit627e6b3672f6a02e2dac1e6a597088e97a9f631f (patch)
tree4269d50fb4fbc2985d51729db5e2045dada38c27 /src
parentIntroduce DoneCLosingPane message to ensure atomicity in state change (diff)
downloadsl0ppij-627e6b3672f6a02e2dac1e6a597088e97a9f631f.tar.gz
sl0ppij-627e6b3672f6a02e2dac1e6a597088e97a9f631f.tar.xz
sl0ppij-627e6b3672f6a02e2dac1e6a597088e97a9f631f.zip
wip: working on osapi message variants
Diffstat (limited to 'src')
-rw-r--r--src/common/mod.rs3
-rw-r--r--src/common/os_input_output.rs18
-rw-r--r--src/server/mod.rs11
3 files changed, 29 insertions, 3 deletions
diff --git a/src/common/mod.rs b/src/common/mod.rs
index c0c35565..a5c004f9 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -31,7 +31,7 @@ use crate::server::start_server;
use command_is_executing::CommandIsExecuting;
use errors::{AppContext, ContextType, ErrorContext, PluginContext, ScreenContext};
use input::handler::input_loop;
-use os_input_output::OsApi;
+use os_input_output::{OsApi, OsApiInstruction};
use pty_bus::PtyInstruction;
use screen::{Screen, ScreenInstruction};
use serde::{Deserialize, Serialize};
@@ -51,6 +51,7 @@ pub enum ServerInstruction {
NewClient(String),
ToPty(PtyInstruction),
ToScreen(ScreenInstruction),
+ OsApi(OsApiInstruction),
DoneClosingPane,
ClosePluginPane(u32),
Exit,
diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs
index 74d14036..8a8cea14 100644
--- a/src/common/os_input_output.rs
+++ b/src/common/os_input_output.rs
@@ -13,7 +13,7 @@ use std::os::unix::io::RawFd;
use std::path::PathBuf;
use std::process::{Child, Command};
use std::sync::{Arc, Mutex};
-use zellij_tile::data::Palette;
+use serde::{Deserialize, Serialize};
use signal_hook::{consts::signal::*, iterator::Signals};
@@ -269,6 +269,22 @@ impl OsApi for OsInputOutput {
}
}
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub enum OsApiInstruction {
+ GetTerminalSizeUsingFd(RawFd),
+ SetTerminalSizeUsingFd(RawFd, u16, u16),
+ SetRawMode(RawFd),
+ UnsetRawMode(RawFd),
+ SpawnTerminal(Option<PathBuf>),
+ ReadFromTtyStdout(RawFd, Vec<u8>),
+ WriteToTtyStdin(RawFd, Vec<u8>),
+ TcDrain(RawFd),
+ Kill(RawFd),
+ ReadFromStdin,
+ GetStdoutWriter,
+ BoxClone
+}
+
impl Clone for Box<dyn OsApi> {
fn clone(&self) -> Box<dyn OsApi> {
self.box_clone()
diff --git a/src/server/mod.rs b/src/server/mod.rs
index e71e91da..fef66366 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -4,7 +4,7 @@ use crate::common::{
ServerInstruction,
};
use crate::errors::{ContextType, ErrorContext, PtyContext};
-use crate::os_input_output::OsApi;
+use crate::os_input_output::{OsApi, OsApiInstruction};
use crate::panes::PaneId;
use crate::pty_bus::{PtyBus, PtyInstruction};
use crate::screen::ScreenInstruction;
@@ -24,6 +24,12 @@ pub fn start_server(os_input: Box<dyn OsApi>, opts: CliArgs) -> thread::JoinHand
let server_buffer = SharedRingBuffer::create(ZELLIJ_IPC_PIPE, 8192).unwrap();
+ let (send_os_instructions, receive_os_instructions): ChannelWithContext<OsApiInstruction> = channel();
+ let mut send_os_instructions = SenderWithContext::new(
+ ErrorContext::new(),
+ SenderType::Sender(send_os_instructions),
+ );
+
// Don't use default layouts in tests, but do everywhere else
#[cfg(not(test))]
let default_layout = Some(PathBuf::from("default"));
@@ -160,6 +166,9 @@ pub fn start_server(os_input: Box<dyn OsApi>, opts: CliArgs) -> thread::JoinHand
.send(ClientInstruction::ToScreen(instr))
.unwrap();
}
+ ServerInstruction::OsApi(instr) => {
+ send_os_instructions.send(instr).unwrap();
+ }
ServerInstruction::DoneClosingPane => {
send_client_instructions[0]
.send(ClientInstruction::DoneClosingPane)