mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-18 06:32:09 +03:00
wip: working on osapi message variants
This commit is contained in:
parent
ef1c902be6
commit
627e6b3672
@ -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,
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user