mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-19 07:11:55 +03:00
remove command_is_executing from pty_thread
This commit is contained in:
parent
5ece7f44cc
commit
2111f95f33
@ -225,7 +225,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs, config: Config) {
|
|||||||
let mut send_app_instructions =
|
let mut send_app_instructions =
|
||||||
SenderWithContext::new(err_ctx, SenderType::SyncSender(send_app_instructions));
|
SenderWithContext::new(err_ctx, SenderType::SyncSender(send_app_instructions));
|
||||||
|
|
||||||
let ipc_thread = start_server(os_input.clone(), opts.clone(), command_is_executing.clone());
|
let ipc_thread = start_server(os_input.clone(), opts.clone());
|
||||||
|
|
||||||
let (client_buffer_path, client_buffer) = SharedRingBuffer::create_temp(8192).unwrap();
|
let (client_buffer_path, client_buffer) = SharedRingBuffer::create_temp(8192).unwrap();
|
||||||
let mut send_server_instructions = IpcSenderWithContext::to_server();
|
let mut send_server_instructions = IpcSenderWithContext::to_server();
|
||||||
@ -379,6 +379,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs, config: Config) {
|
|||||||
}
|
}
|
||||||
ScreenInstruction::CloseFocusedPane => {
|
ScreenInstruction::CloseFocusedPane => {
|
||||||
screen.get_active_tab_mut().unwrap().close_focused_pane();
|
screen.get_active_tab_mut().unwrap().close_focused_pane();
|
||||||
|
command_is_executing.done_closing_pane();
|
||||||
screen.render();
|
screen.render();
|
||||||
}
|
}
|
||||||
ScreenInstruction::SetSelectable(id, selectable) => {
|
ScreenInstruction::SetSelectable(id, selectable) => {
|
||||||
@ -402,6 +403,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs, config: Config) {
|
|||||||
}
|
}
|
||||||
ScreenInstruction::ClosePane(id) => {
|
ScreenInstruction::ClosePane(id) => {
|
||||||
screen.get_active_tab_mut().unwrap().close_pane(id);
|
screen.get_active_tab_mut().unwrap().close_pane(id);
|
||||||
|
command_is_executing.done_closing_pane();
|
||||||
screen.render();
|
screen.render();
|
||||||
}
|
}
|
||||||
ScreenInstruction::ToggleActiveTerminalFullscreen => {
|
ScreenInstruction::ToggleActiveTerminalFullscreen => {
|
||||||
@ -416,7 +418,10 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs, config: Config) {
|
|||||||
}
|
}
|
||||||
ScreenInstruction::SwitchTabNext => screen.switch_tab_next(),
|
ScreenInstruction::SwitchTabNext => screen.switch_tab_next(),
|
||||||
ScreenInstruction::SwitchTabPrev => screen.switch_tab_prev(),
|
ScreenInstruction::SwitchTabPrev => screen.switch_tab_prev(),
|
||||||
ScreenInstruction::CloseTab => screen.close_tab(),
|
ScreenInstruction::CloseTab => {
|
||||||
|
screen.close_tab();
|
||||||
|
command_is_executing.done_closing_pane();
|
||||||
|
}
|
||||||
ScreenInstruction::ApplyLayout((layout, new_pane_pids)) => {
|
ScreenInstruction::ApplyLayout((layout, new_pane_pids)) => {
|
||||||
screen.apply_layout(Layout::new(layout), new_pane_pids);
|
screen.apply_layout(Layout::new(layout), new_pane_pids);
|
||||||
command_is_executing.done_opening_new_pane();
|
command_is_executing.done_opening_new_pane();
|
||||||
|
@ -15,11 +15,7 @@ use std::path::PathBuf;
|
|||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
pub fn start_server(
|
pub fn start_server(os_input: Box<dyn OsApi>, opts: CliArgs) -> thread::JoinHandle<()> {
|
||||||
os_input: Box<dyn OsApi>,
|
|
||||||
opts: CliArgs,
|
|
||||||
command_is_executing: CommandIsExecuting,
|
|
||||||
) -> thread::JoinHandle<()> {
|
|
||||||
let (send_pty_instructions, receive_pty_instructions): ChannelWithContext<PtyInstruction> =
|
let (send_pty_instructions, receive_pty_instructions): ChannelWithContext<PtyInstruction> =
|
||||||
channel();
|
channel();
|
||||||
let mut send_pty_instructions = SenderWithContext::new(
|
let mut send_pty_instructions = SenderWithContext::new(
|
||||||
@ -47,64 +43,55 @@ pub fn start_server(
|
|||||||
|
|
||||||
let pty_thread = thread::Builder::new()
|
let pty_thread = thread::Builder::new()
|
||||||
.name("pty".to_string())
|
.name("pty".to_string())
|
||||||
.spawn({
|
.spawn(move || loop {
|
||||||
let mut command_is_executing = command_is_executing.clone();
|
let (event, mut err_ctx) = pty_bus
|
||||||
move || loop {
|
.receive_pty_instructions
|
||||||
let (event, mut err_ctx) = pty_bus
|
.recv()
|
||||||
.receive_pty_instructions
|
.expect("failed to receive event on channel");
|
||||||
.recv()
|
err_ctx.add_call(ContextType::Pty(PtyContext::from(&event)));
|
||||||
.expect("failed to receive event on channel");
|
match event {
|
||||||
err_ctx.add_call(ContextType::Pty(PtyContext::from(&event)));
|
PtyInstruction::SpawnTerminal(file_to_open) => {
|
||||||
match event {
|
let pid = pty_bus.spawn_terminal(file_to_open);
|
||||||
PtyInstruction::SpawnTerminal(file_to_open) => {
|
pty_bus
|
||||||
let pid = pty_bus.spawn_terminal(file_to_open);
|
.send_server_instructions
|
||||||
|
.send(ServerInstruction::ToScreen(ScreenInstruction::NewPane(
|
||||||
|
PaneId::Terminal(pid),
|
||||||
|
)))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
PtyInstruction::SpawnTerminalVertically(file_to_open) => {
|
||||||
|
let pid = pty_bus.spawn_terminal(file_to_open);
|
||||||
|
pty_bus
|
||||||
|
.send_server_instructions
|
||||||
|
.send(ServerInstruction::ToScreen(
|
||||||
|
ScreenInstruction::VerticalSplit(PaneId::Terminal(pid)),
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
PtyInstruction::SpawnTerminalHorizontally(file_to_open) => {
|
||||||
|
let pid = pty_bus.spawn_terminal(file_to_open);
|
||||||
|
pty_bus
|
||||||
|
.send_server_instructions
|
||||||
|
.send(ServerInstruction::ToScreen(
|
||||||
|
ScreenInstruction::HorizontalSplit(PaneId::Terminal(pid)),
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
PtyInstruction::NewTab => {
|
||||||
|
if let Some(layout) = maybe_layout.clone() {
|
||||||
|
pty_bus.spawn_terminals_for_layout(layout);
|
||||||
|
} else {
|
||||||
|
let pid = pty_bus.spawn_terminal(None);
|
||||||
pty_bus
|
pty_bus
|
||||||
.send_server_instructions
|
.send_server_instructions
|
||||||
.send(ServerInstruction::ToScreen(ScreenInstruction::NewPane(
|
.send(ServerInstruction::ToScreen(ScreenInstruction::NewTab(pid)))
|
||||||
PaneId::Terminal(pid),
|
|
||||||
)))
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
PtyInstruction::SpawnTerminalVertically(file_to_open) => {
|
}
|
||||||
let pid = pty_bus.spawn_terminal(file_to_open);
|
PtyInstruction::ClosePane(id) => pty_bus.close_pane(id),
|
||||||
pty_bus
|
PtyInstruction::CloseTab(ids) => pty_bus.close_tab(ids),
|
||||||
.send_server_instructions
|
PtyInstruction::Exit => {
|
||||||
.send(ServerInstruction::ToScreen(
|
break;
|
||||||
ScreenInstruction::VerticalSplit(PaneId::Terminal(pid)),
|
|
||||||
))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
PtyInstruction::SpawnTerminalHorizontally(file_to_open) => {
|
|
||||||
let pid = pty_bus.spawn_terminal(file_to_open);
|
|
||||||
pty_bus
|
|
||||||
.send_server_instructions
|
|
||||||
.send(ServerInstruction::ToScreen(
|
|
||||||
ScreenInstruction::HorizontalSplit(PaneId::Terminal(pid)),
|
|
||||||
))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
PtyInstruction::NewTab => {
|
|
||||||
if let Some(layout) = maybe_layout.clone() {
|
|
||||||
pty_bus.spawn_terminals_for_layout(layout);
|
|
||||||
} else {
|
|
||||||
let pid = pty_bus.spawn_terminal(None);
|
|
||||||
pty_bus
|
|
||||||
.send_server_instructions
|
|
||||||
.send(ServerInstruction::ToScreen(ScreenInstruction::NewTab(pid)))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PtyInstruction::ClosePane(id) => {
|
|
||||||
pty_bus.close_pane(id);
|
|
||||||
command_is_executing.done_closing_pane();
|
|
||||||
}
|
|
||||||
PtyInstruction::CloseTab(ids) => {
|
|
||||||
pty_bus.close_tab(ids);
|
|
||||||
command_is_executing.done_closing_pane();
|
|
||||||
}
|
|
||||||
PtyInstruction::Exit => {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -115,7 +102,7 @@ pub fn start_server(
|
|||||||
.spawn({
|
.spawn({
|
||||||
let recv_server_instructions = IpcReceiver::new(server_buffer);
|
let recv_server_instructions = IpcReceiver::new(server_buffer);
|
||||||
// Fixme: We cannot use uninitialised sender, therefore this Vec.
|
// Fixme: We cannot use uninitialised sender, therefore this Vec.
|
||||||
// We make sure that the first message is `NewClient` so there are no out of bouns panics.
|
// For now, We make sure that the first message is `NewClient` so there are no out of bound panics.
|
||||||
let mut send_client_instructions: Vec<IpcSenderWithContext> = Vec::with_capacity(1);
|
let mut send_client_instructions: Vec<IpcSenderWithContext> = Vec::with_capacity(1);
|
||||||
move || loop {
|
move || loop {
|
||||||
let (mut err_ctx, instruction): (ErrorContext, ServerInstruction) =
|
let (mut err_ctx, instruction): (ErrorContext, ServerInstruction) =
|
||||||
|
Loading…
Reference in New Issue
Block a user