From 627e6b3672f6a02e2dac1e6a597088e97a9f631f Mon Sep 17 00:00:00 2001 From: denis Date: Mon, 1 Mar 2021 15:19:40 +0200 Subject: [PATCH] wip: working on osapi message variants --- src/common/mod.rs | 3 ++- src/common/os_input_output.rs | 18 +++++++++++++++++- src/server/mod.rs | 11 ++++++++++- 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), + ReadFromTtyStdout(RawFd, Vec), + WriteToTtyStdin(RawFd, Vec), + TcDrain(RawFd), + Kill(RawFd), + ReadFromStdin, + GetStdoutWriter, + BoxClone +} + impl Clone for Box { fn clone(&self) -> Box { 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, opts: CliArgs) -> thread::JoinHand let server_buffer = SharedRingBuffer::create(ZELLIJ_IPC_PIPE, 8192).unwrap(); + let (send_os_instructions, receive_os_instructions): ChannelWithContext = 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, 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)