diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index add355401b..83f3363d2b 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -791,6 +791,36 @@ impl Screen { self.update_tabs(); self.render(); } + + fn unblock_input(&self) -> () { + self.bus + .senders + .send_to_server(ServerInstruction::UnblockInputThread) + .unwrap(); + } +} + +/// Get the active tab and call a closure on it +/// +/// If no active tab can be found, an error is logged instead. +/// +/// # Parameters +/// +/// - screen: An instance of `Screen` to operate on +/// - client_id: The client_id, usually taken from the `ScreenInstruction` that's being processed +/// - closure: A closure satisfying `|tab: &mut Tab| -> ()` +macro_rules! active_tab { + ($screen:ident, $client_id:ident, $closure:expr) => { + if let Some(active_tab) = $screen.get_active_tab_mut($client_id) { + // This could be made more ergonomic by declaring the type of 'active_tab' in the + // closure, known as "Type Ascription". Then we could hint the type here and forego the + // "&mut Tab" in all the closures below... + // See: https://github.com/rust-lang/rust/issues/23416 + $closure(active_tab); + } else { + log::error!("Active tab not found for client id: {:?}", $client_id); + } + }; } // The box is here in order to make the @@ -827,12 +857,14 @@ pub(crate) fn screen_thread_main( session_is_mirrored, copy_options, ); + loop { let (event, mut err_ctx) = screen .bus .recv() .expect("failed to receive event on channel"); err_ctx.add_call(ContextType::Screen((&event).into())); + match event { ScreenInstruction::PtyBytes(pid, vte_bytes) => { let all_tabs = screen.get_tabs_mut(); @@ -849,11 +881,8 @@ pub(crate) fn screen_thread_main( ScreenInstruction::NewPane(pid, client_or_tab_index) => { match client_or_tab_index { ClientOrTabIndex::ClientId(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.new_pane(pid, Some(client_id)); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } + active_tab!(screen, client_id, |tab: &mut Tab| tab + .new_pane(pid, Some(client_id))); }, ClientOrTabIndex::TabIndex(tab_index) => { if let Some(active_tab) = screen.tabs.get_mut(&tab_index) { @@ -863,393 +892,217 @@ pub(crate) fn screen_thread_main( } }, }; - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); + screen.unblock_input(); screen.update_tabs(); screen.render(); }, ScreenInstruction::OpenInPlaceEditor(pid, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.suppress_active_pane(pid, client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - return; - } - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); + active_tab!(screen, client_id, |tab: &mut Tab| tab + .suppress_active_pane(pid, client_id)); + screen.unblock_input(); screen.update_tabs(); screen.render(); }, ScreenInstruction::TogglePaneEmbedOrFloating(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.toggle_pane_embed_or_floating(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); + active_tab!(screen, client_id, |tab: &mut Tab| tab + .toggle_pane_embed_or_floating(client_id)); + screen.unblock_input(); screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins screen.render(); }, ScreenInstruction::ToggleFloatingPanes(client_id, default_shell) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.toggle_floating_panes(client_id, default_shell); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); + active_tab!(screen, client_id, |tab: &mut Tab| tab + .toggle_floating_panes(client_id, default_shell)); + screen.unblock_input(); screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins screen.render(); }, ScreenInstruction::HorizontalSplit(pid, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.horizontal_split(pid, client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); + active_tab!(screen, client_id, |tab: &mut Tab| tab + .horizontal_split(pid, client_id)); + screen.unblock_input(); screen.update_tabs(); - screen.render(); }, ScreenInstruction::VerticalSplit(pid, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.vertical_split(pid, client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); + active_tab!(screen, client_id, |tab: &mut Tab| tab + .vertical_split(pid, client_id)); + screen.unblock_input(); screen.update_tabs(); - screen.render(); }, ScreenInstruction::WriteCharacter(bytes, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - match active_tab.is_sync_panes_active() { - true => active_tab.write_to_terminals_on_current_tab(bytes), - false => active_tab.write_to_active_terminal(bytes, client_id), + active_tab!(screen, client_id, |tab: &mut Tab| { + match tab.is_sync_panes_active() { + true => tab.write_to_terminals_on_current_tab(bytes), + false => tab.write_to_active_terminal(bytes, client_id), } - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } + }); }, ScreenInstruction::ResizeLeft(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.resize_left(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .resize_left(client_id)); screen.render(); }, ScreenInstruction::ResizeRight(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.resize_right(client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .resize_right(client_id)); screen.render(); }, ScreenInstruction::ResizeDown(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.resize_down(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .resize_down(client_id)); screen.render(); }, ScreenInstruction::ResizeUp(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.resize_up(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab.resize_up(client_id)); screen.render(); }, ScreenInstruction::ResizeIncrease(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.resize_increase(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .resize_increase(client_id)); screen.render(); }, ScreenInstruction::ResizeDecrease(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.resize_decrease(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .resize_decrease(client_id)); screen.render(); }, ScreenInstruction::SwitchFocus(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.focus_next_pane(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .focus_next_pane(client_id)); screen.render(); }, ScreenInstruction::FocusNextPane(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.focus_next_pane(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .focus_next_pane(client_id)); screen.render(); }, ScreenInstruction::FocusPreviousPane(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.focus_previous_pane(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .focus_previous_pane(client_id)); screen.render(); }, ScreenInstruction::MoveFocusLeft(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.move_focus_left(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .move_focus_left(client_id)); screen.render(); }, ScreenInstruction::MoveFocusLeftOrPreviousTab(client_id) => { screen.move_focus_left_or_previous_tab(client_id); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); - + screen.unblock_input(); screen.render(); }, ScreenInstruction::MoveFocusDown(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.move_focus_down(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .move_focus_down(client_id)); screen.render(); }, ScreenInstruction::MoveFocusRight(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.move_focus_right(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .move_focus_right(client_id)); screen.render(); }, ScreenInstruction::MoveFocusRightOrNextTab(client_id) => { screen.move_focus_right_or_next_tab(client_id); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); - + screen.unblock_input(); screen.render(); }, ScreenInstruction::MoveFocusUp(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.move_focus_up(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .move_focus_up(client_id)); screen.render(); }, ScreenInstruction::DumpScreen(file, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.dump_active_terminal_screen(Some(file.to_string()), client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .dump_active_terminal_screen(Some(file.to_string()), client_id)); screen.render(); }, ScreenInstruction::EditScrollback(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.edit_scrollback(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .edit_scrollback(client_id)); screen.render(); }, ScreenInstruction::ScrollUp(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.scroll_active_terminal_up(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .scroll_active_terminal_up(client_id)); screen.render(); }, ScreenInstruction::MovePane(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.move_active_pane(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .move_active_pane(client_id)); screen.render(); }, ScreenInstruction::MovePaneDown(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.move_active_pane_down(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .move_active_pane_down(client_id)); screen.render(); }, ScreenInstruction::MovePaneUp(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.move_active_pane_up(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .move_active_pane_up(client_id)); screen.render(); }, ScreenInstruction::MovePaneRight(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.move_active_pane_right(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .move_active_pane_right(client_id)); screen.render(); }, ScreenInstruction::MovePaneLeft(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.move_active_pane_left(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .move_active_pane_left(client_id)); screen.render(); }, ScreenInstruction::ScrollUpAt(point, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.scroll_terminal_up(&point, 3, client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .scroll_terminal_up(&point, 3, client_id)); screen.render(); }, ScreenInstruction::ScrollDown(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.scroll_active_terminal_down(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .scroll_active_terminal_down(client_id)); screen.render(); }, ScreenInstruction::ScrollDownAt(point, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.scroll_terminal_down(&point, 3, client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .scroll_terminal_down(&point, 3, client_id)); screen.render(); }, ScreenInstruction::ScrollToBottom(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.scroll_active_terminal_to_bottom(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .scroll_active_terminal_to_bottom(client_id)); screen.render(); }, ScreenInstruction::PageScrollUp(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.scroll_active_terminal_up_page(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .scroll_active_terminal_up_page(client_id)); screen.render(); }, ScreenInstruction::PageScrollDown(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.scroll_active_terminal_down_page(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .scroll_active_terminal_down_page(client_id)); screen.render(); }, ScreenInstruction::HalfPageScrollUp(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.scroll_active_terminal_up_half_page(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .scroll_active_terminal_up_half_page(client_id)); screen.render(); }, ScreenInstruction::HalfPageScrollDown(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.scroll_active_terminal_down_half_page(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .scroll_active_terminal_down_half_page(client_id)); screen.render(); }, ScreenInstruction::ClearScroll(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.clear_active_terminal_scroll(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .clear_active_terminal_scroll(client_id)); screen.render(); }, ScreenInstruction::CloseFocusedPane(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.close_focused_pane(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } + active_tab!(screen, client_id, |tab: &mut Tab| tab + .close_focused_pane(client_id)); screen.update_tabs(); // update_tabs eventually calls render through the plugin thread }, ScreenInstruction::SetSelectable(id, selectable, tab_index) => { @@ -1269,13 +1122,7 @@ pub(crate) fn screen_thread_main( ScreenInstruction::ClosePane(id, client_id) => { match client_id { Some(client_id) => { - screen - .get_active_tab_mut(client_id) - .and_then(|active_tab| active_tab.close_pane(id, false)) - .or_else(|| { - log::error!("Active tab not found for client id: {:?}", client_id); - None - }); + active_tab!(screen, client_id, |tab: &mut Tab| tab.close_pane(id, false)); }, None => { for tab in screen.tabs.values_mut() { @@ -1289,22 +1136,14 @@ pub(crate) fn screen_thread_main( screen.update_tabs(); }, ScreenInstruction::UpdatePaneName(c, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.update_active_pane_name(c, client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .update_active_pane_name(c, client_id)); screen.render(); }, ScreenInstruction::ToggleActiveTerminalFullscreen(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.toggle_active_pane_fullscreen(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } + active_tab!(screen, client_id, |tab: &mut Tab| tab + .toggle_active_pane_fullscreen(client_id)); screen.update_tabs(); - screen.render(); }, ScreenInstruction::TogglePaneFrames => { @@ -1316,42 +1155,22 @@ pub(crate) fn screen_thread_main( }, ScreenInstruction::SwitchTabNext(client_id) => { screen.switch_tab_next(client_id); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); - + screen.unblock_input(); screen.render(); }, ScreenInstruction::SwitchTabPrev(client_id) => { screen.switch_tab_prev(client_id); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); - + screen.unblock_input(); screen.render(); }, ScreenInstruction::CloseTab(client_id) => { screen.close_tab(client_id); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); - + screen.unblock_input(); screen.render(); }, ScreenInstruction::NewTab(layout, new_pane_pids, client_id) => { screen.new_tab(layout, new_pane_pids, client_id); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); - + screen.unblock_input(); screen.render(); }, ScreenInstruction::GoToTab(tab_index, client_id) => { @@ -1359,23 +1178,16 @@ pub(crate) fn screen_thread_main( client_id.or_else(|| screen.active_tab_indices.keys().next().copied()) { screen.go_to_tab(tab_index as usize, client_id); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); - + screen.unblock_input(); screen.render(); } }, ScreenInstruction::UpdateTabName(c, client_id) => { screen.update_active_tab_name(c, client_id); - screen.render(); }, ScreenInstruction::TerminalResize(new_size) => { screen.resize_to_screen(new_size); - screen.render(); }, ScreenInstruction::TerminalPixelDimensions(pixel_dimensions) => { @@ -1389,64 +1201,39 @@ pub(crate) fn screen_thread_main( }, ScreenInstruction::ChangeMode(mode_info, client_id) => { screen.change_mode(mode_info, client_id); - screen.render(); }, ScreenInstruction::ToggleActiveSyncTab(client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.toggle_sync_panes_is_active(); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } + active_tab!(screen, client_id, |tab: &mut Tab| tab + .toggle_sync_panes_is_active()); screen.update_tabs(); - screen.render(); }, ScreenInstruction::LeftClick(point, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.handle_left_click(&point, client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .handle_left_click(&point, client_id)); screen.update_tabs(); screen.render(); }, ScreenInstruction::RightClick(point, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.handle_right_click(&point, client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .handle_right_click(&point, client_id)); screen.update_tabs(); screen.render(); }, ScreenInstruction::MouseRelease(point, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.handle_mouse_release(&point, client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .handle_mouse_release(&point, client_id)); screen.render(); }, ScreenInstruction::MouseHold(point, client_id) => { - if let Some(active_tab) = screen.get_active_tab_mut(client_id) { - active_tab.handle_mouse_hold(&point, client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .handle_mouse_hold(&point, client_id)); screen.render(); }, ScreenInstruction::Copy(client_id) => { - if let Some(active_tab) = screen.get_active_tab(client_id) { - active_tab.copy_selection(client_id); - } else { - log::error!("Active tab not found for client id: {:?}", client_id); - } - + active_tab!(screen, client_id, |tab: &mut Tab| tab + .copy_selection(client_id)); screen.render(); }, ScreenInstruction::Exit => { @@ -1454,42 +1241,27 @@ pub(crate) fn screen_thread_main( }, ScreenInstruction::ToggleTab(client_id) => { screen.toggle_tab(client_id); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); - + screen.unblock_input(); screen.render(); }, ScreenInstruction::AddClient(client_id) => { screen.add_client(client_id); screen.update_tabs(); - screen.render(); }, ScreenInstruction::RemoveClient(client_id) => { screen.remove_client(client_id); - screen.render(); }, ScreenInstruction::AddOverlay(overlay, _client_id) => { screen.get_active_overlays_mut().pop(); screen.get_active_overlays_mut().push(overlay); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); + screen.unblock_input(); }, ScreenInstruction::RemoveOverlay(_client_id) => { screen.get_active_overlays_mut().pop(); screen.render(); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); + screen.unblock_input(); }, ScreenInstruction::ConfirmPrompt(_client_id) => { let overlay = screen.get_active_overlays_mut().pop(); @@ -1497,20 +1269,12 @@ pub(crate) fn screen_thread_main( if let Some(instruction) = instruction { screen.bus.senders.send_to_server(*instruction).unwrap(); } - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); + screen.unblock_input(); }, ScreenInstruction::DenyPrompt(_client_id) => { screen.get_active_overlays_mut().pop(); screen.render(); - screen - .bus - .senders - .send_to_server(ServerInstruction::UnblockInputThread) - .unwrap(); + screen.unblock_input(); }, } }