mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-18 23:01:47 +03:00
Introduce ServerContext
This commit is contained in:
parent
2ab18244f7
commit
be060e9a13
@ -1,7 +1,9 @@
|
||||
//! Error context system based on a thread-local representation of the call stack, itself based on
|
||||
//! the instructions that are sent between threads.
|
||||
|
||||
use super::{os_input_output::ServerOsApiInstruction, AppInstruction, OPENCALLS};
|
||||
use super::{
|
||||
os_input_output::ServerOsApiInstruction, AppInstruction, ServerInstruction, OPENCALLS,
|
||||
};
|
||||
use crate::pty_bus::PtyInstruction;
|
||||
use crate::screen::ScreenInstruction;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -144,7 +146,7 @@ pub enum ContextType {
|
||||
Plugin(PluginContext),
|
||||
/// An app-related call.
|
||||
App(AppContext),
|
||||
IPCServer, // Fix: Create a separate ServerContext when sessions are introduced
|
||||
IPCServer(ServerContext),
|
||||
StdinHandler,
|
||||
AsyncTask,
|
||||
/// An empty, placeholder call. This should be thought of as representing no call at all.
|
||||
@ -163,7 +165,7 @@ impl Display for ContextType {
|
||||
ContextType::Os(c) => write!(f, "{}os_thread: {}{:?}", purple, green, c),
|
||||
ContextType::Plugin(c) => write!(f, "{}plugin_thread: {}{:?}", purple, green, c),
|
||||
ContextType::App(c) => write!(f, "{}main_thread: {}{:?}", purple, green, c),
|
||||
ContextType::IpcServer => write!(f, "{}ipc_server: {}AcceptInput", purple, green),
|
||||
ContextType::IPCServer(c) => write!(f, "{}ipc_server: {}{:?}", purple, green, c),
|
||||
ContextType::StdinHandler => {
|
||||
write!(f, "{}stdin_handler_thread: {}AcceptInput", purple, green)
|
||||
}
|
||||
@ -367,3 +369,37 @@ impl From<&AppInstruction> for AppContext {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Stack call representations corresponding to the different types of [`AppInstruction`]s.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||
pub enum ServerContext {
|
||||
OpenFile,
|
||||
SplitHorizontally,
|
||||
SplitVertically,
|
||||
MoveFocus,
|
||||
NewClient,
|
||||
ToPty,
|
||||
ToScreen,
|
||||
OsApi,
|
||||
DoneClosingPane,
|
||||
ClosePluginPane,
|
||||
Exit,
|
||||
}
|
||||
|
||||
impl From<&ServerInstruction> for ServerContext {
|
||||
fn from(server_instruction: &ServerInstruction) -> Self {
|
||||
match *server_instruction {
|
||||
ServerInstruction::OpenFile(_) => ServerContext::OpenFile,
|
||||
ServerInstruction::SplitHorizontally => ServerContext::SplitHorizontally,
|
||||
ServerInstruction::SplitVertically => ServerContext::SplitVertically,
|
||||
ServerInstruction::MoveFocus => ServerContext::MoveFocus,
|
||||
ServerInstruction::NewClient(_) => ServerContext::NewClient,
|
||||
ServerInstruction::ToPty(_) => ServerContext::ToPty,
|
||||
ServerInstruction::ToScreen(_) => ServerContext::ToScreen,
|
||||
ServerInstruction::OsApi(_) => ServerContext::OsApi,
|
||||
ServerInstruction::DoneClosingPane => ServerContext::DoneClosingPane,
|
||||
ServerInstruction::ClosePluginPane(_) => ServerContext::ClosePluginPane,
|
||||
ServerInstruction::Exit => ServerContext::Exit,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ use crate::common::{
|
||||
ChannelWithContext, ClientInstruction, IpcSenderWithContext, SenderType, SenderWithContext,
|
||||
ServerInstruction,
|
||||
};
|
||||
use crate::errors::{ContextType, ErrorContext, OsContext, PtyContext};
|
||||
use crate::os_input_output::{get_server_os_input, ServerOsApi, ServerOsApiInstruction};
|
||||
use crate::errors::{ContextType, ErrorContext, OsContext, PtyContext, ServerContext};
|
||||
use crate::os_input_output::{ServerOsApi, ServerOsApiInstruction};
|
||||
use crate::panes::PaneId;
|
||||
use crate::pty_bus::{PtyBus, PtyInstruction};
|
||||
use crate::screen::ScreenInstruction;
|
||||
@ -161,7 +161,7 @@ pub fn start_server(
|
||||
move || loop {
|
||||
let (mut err_ctx, instruction): (ErrorContext, ServerInstruction) =
|
||||
recv_server_instructions.recv().unwrap();
|
||||
err_ctx.add_call(ContextType::IPCServer);
|
||||
err_ctx.add_call(ContextType::IPCServer(ServerContext::from(&instruction)));
|
||||
send_pty_instructions.update(err_ctx);
|
||||
send_os_instructions.update(err_ctx);
|
||||
if send_client_instructions.len() == 1 {
|
||||
|
Loading…
Reference in New Issue
Block a user