use crate::os_input_output::SpawnTerminalError;
use crate::terminal_bytes::TerminalBytes;
use crate::{
panes::PaneId,
screen::ScreenInstruction,
thread_bus::{Bus, ThreadSenders},
wasm_vm::PluginInstruction,
ClientId, ServerInstruction,
};
use async_std::task::{self, JoinHandle};
use std::{collections::HashMap, env, os::unix::io::RawFd, path::PathBuf};
use zellij_utils::nix::unistd::Pid;
use zellij_utils::{
async_std,
errors::prelude::*,
errors::{ContextType, PtyContext},
input::{
command::{RunCommand, TerminalAction},
layout::{Layout, PaneLayout, Run},
},
};
pub type VteBytes = Vec<u8>;
pub type TabIndex = u32;
#[derive(Clone, Copy, Debug)]
pub enum ClientOrTabIndex {
ClientId(ClientId),
TabIndex(usize),
}
/// Instructions related to PTYs (pseudoterminals).
#[derive(Clone, Debug)]
pub(crate) enum PtyInstruction {
SpawnTerminal(
Option<TerminalAction>,
Option<bool>,
Option<String>,
ClientOrTabIndex,
), // bool (if Some) is
// should_float, String is an optional pane name
OpenInPlaceEditor(PathBuf, Option<usize>, ClientId), // Option<usize> is the optional line number
SpawnTerminalVertically(Option<TerminalAction>, Option<String>, ClientId), // String is an
// optional pane
// name
SpawnTerminalHorizontally(Option<TerminalAction>, Option<String>, ClientId), // String is an
// optional pane
// name
UpdateActivePane(Option<PaneId>, ClientId),
GoToTab(TabIndex, ClientId),
NewTab(
Option<TerminalAction>,
Option<PaneLayout>,
Option<String>,
ClientId,
), // the String is the tab name
ClosePane(PaneId),
CloseTab(Vec<PaneId>),
ReRunCommandInPane(PaneId, RunCommand),
Exit,
}
impl From<&PtyInstruction> for PtyContext {
fn from(pty_instruction: &PtyInstruction) -> Self {
match *pty_instruction {
PtyInstruction::SpawnTerminal(..) => PtyContext::SpawnTerminal,
PtyInstruction::OpenInPlaceEditor