From c60abe6ad634d9889a95c0043bfb0e05105a1e29 Mon Sep 17 00:00:00 2001 From: Kunal Mohan Date: Tue, 25 May 2021 13:11:37 +0530 Subject: [PATCH] CHange keybind for Session mode and add comments for clarity --- assets/config/default.yaml | 12 ++++++------ default-plugins/status-bar/src/first_line.rs | 16 ++++++++-------- zellij-server/src/lib.rs | 3 +++ zellij-server/src/os_input_output.rs | 5 +++++ zellij-server/src/tab.rs | 1 + 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/assets/config/default.yaml b/assets/config/default.yaml index e649f2ae..42bc1688 100644 --- a/assets/config/default.yaml +++ b/assets/config/default.yaml @@ -13,7 +13,7 @@ keybinds: - action: [SwitchToMode: Scroll,] key: [Ctrl: 's',] - action: [SwitchToMode: Session,] - key: [Ctrl: 'b',] + key: [Ctrl: 'o',] - action: [Quit,] key: [Ctrl: 'q',] - action: [NewPane: ] @@ -45,7 +45,7 @@ keybinds: - action: [SwitchToMode: Scroll,] key: [Ctrl: 's'] - action: [SwitchToMode: Session,] - key: [Ctrl: 'b',] + key: [Ctrl: 'o',] - action: [Quit] key: [Ctrl: 'q'] - action: [Resize: Left,] @@ -82,7 +82,7 @@ keybinds: - action: [SwitchToMode: Scroll,] key: [Ctrl: 's'] - action: [SwitchToMode: Session,] - key: [Ctrl: 'b',] + key: [Ctrl: 'o',] - action: [Quit,] key: [Ctrl: 'q',] - action: [MoveFocus: Left,] @@ -121,7 +121,7 @@ keybinds: - action: [SwitchToMode: Scroll,] key: [Ctrl: 's'] - action: [SwitchToMode: Session,] - key: [Ctrl: 'b',] + key: [Ctrl: 'o',] - action: [SwitchToMode: RenameTab, TabNameInput: [0],] key: [Char: 'r'] - action: [Quit,] @@ -177,7 +177,7 @@ keybinds: - action: [SwitchToMode: Pane,] key: [Ctrl: 'p',] - action: [SwitchToMode: Session,] - key: [Ctrl: 'b',] + key: [Ctrl: 'o',] - action: [Quit,] key: [Ctrl: 'q',] - action: [ScrollDown,] @@ -233,7 +233,7 @@ keybinds: - action: [SwitchToMode: Tab,] key: [Ctrl: 't',] - action: [SwitchToMode: Normal,] - key: [Ctrl: 'b', Char: "\n", Char: ' ',] + key: [Ctrl: 'o', Char: "\n", Char: ' ',] - action: [SwitchToMode: Scroll,] key: [Ctrl: 's'] - action: [Quit,] diff --git a/default-plugins/status-bar/src/first_line.rs b/default-plugins/status-bar/src/first_line.rs index b6a01fd9..a8bc19cd 100644 --- a/default-plugins/status-bar/src/first_line.rs +++ b/default-plugins/status-bar/src/first_line.rs @@ -62,7 +62,7 @@ impl CtrlKeyShortcut { CtrlKeyAction::Resize => 'r', CtrlKeyAction::Scroll => 's', CtrlKeyAction::Quit => 'q', - CtrlKeyAction::Session => 'b', + CtrlKeyAction::Session => 'o', } } } @@ -300,8 +300,8 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart { CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Tab), CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Resize), CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Scroll), - CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Quit), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session), + CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Quit), ], colored_elements, separator, @@ -314,8 +314,8 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart { CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab), CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Resize), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll), - CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session), + CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), ], colored_elements, separator, @@ -328,8 +328,8 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart { CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll), - CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session), + CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), ], colored_elements, separator, @@ -342,8 +342,8 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart { CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Tab), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll), - CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session), + CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), ], colored_elements, separator, @@ -356,8 +356,8 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart { CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize), CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Scroll), - CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session), + CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), ], colored_elements, separator, @@ -370,8 +370,8 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart { CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll), - CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session), + CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), ], colored_elements, separator, @@ -384,8 +384,8 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart { CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize), CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll), - CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Session), + CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit), ], colored_elements, separator, diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs index 7a5aed1e..aeb13cb5 100644 --- a/zellij-server/src/lib.rs +++ b/zellij-server/src/lib.rs @@ -265,6 +265,9 @@ pub fn start_server(os_input: Box, socket_path: PathBuf) { } ServerInstruction::Render(output) => { if *session_state.read().unwrap() == SessionState::Attached { + // Here output is of type Option sent by screen thread. + // If `Some(_)`- unwrap it and forward it to the client to render. + // If `None`- Send an exit instruction. This is the case when the user closes last Tab/Pane. if let Some(op) = output { os_input.send_to_client(ServerToClientMsg::Render(op)); } else { diff --git a/zellij-server/src/os_input_output.rs b/zellij-server/src/os_input_output.rs index 51903c9a..bef3445f 100644 --- a/zellij-server/src/os_input_output.rs +++ b/zellij-server/src/os_input_output.rs @@ -159,6 +159,11 @@ pub trait ServerOsApi: Send + Sync { fn send_to_client(&self, msg: ServerToClientMsg); /// Adds a sender to client fn add_client_sender(&self); + /// Send to the temporary client + // A temporary client is the one that hasn't been registered as a client yet. + // Only the corresponding router thread has access to send messages to it. + // This can be the case when the client cannot attach to the session, + // so it tries to connect and then exits, hence temporary. fn send_to_temp_client(&self, msg: ServerToClientMsg); /// Removes the sender to client fn remove_client_sender(&self); diff --git a/zellij-server/src/tab.rs b/zellij-server/src/tab.rs index 68d01ec0..4a0db153 100644 --- a/zellij-server/src/tab.rs +++ b/zellij-server/src/tab.rs @@ -730,6 +730,7 @@ impl Tab { { // we might not have an active terminal if we closed the last pane // in that case, we should not render as the app is exiting + // or if this session is not attached to a client, we do not have to render return; } // if any pane contain widechar, all pane in the same row will messup. We should render them every time