mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-24 17:53:36 +03:00
Moving the sync command to the Tab mode (#412)
* Moving the sync command to the Tab mode * Fixing bug related to plugin panes and sync mode When sync mode was enabled the input from a plugin pane was being incorrectly ignored.
This commit is contained in:
parent
ba7368667c
commit
543b70a2bd
@ -97,8 +97,6 @@ keybinds:
|
|||||||
key: [Char: 'r',]
|
key: [Char: 'r',]
|
||||||
- action: [CloseFocus,]
|
- action: [CloseFocus,]
|
||||||
key: [Char: 'x',]
|
key: [Char: 'x',]
|
||||||
- action: [ToggleActiveSyncPanes]
|
|
||||||
key: [Char: 's']
|
|
||||||
- action: [ToggleFocusFullscreen,]
|
- action: [ToggleFocusFullscreen,]
|
||||||
key: [Char: 'f',]
|
key: [Char: 'f',]
|
||||||
- action: [FocusPreviousPane,]
|
- action: [FocusPreviousPane,]
|
||||||
@ -130,6 +128,8 @@ keybinds:
|
|||||||
key: [ Char: 'n',]
|
key: [ Char: 'n',]
|
||||||
- action: [CloseTab,]
|
- action: [CloseTab,]
|
||||||
key: [ Char: 'x',]
|
key: [ Char: 'x',]
|
||||||
|
- action: [ToggleActiveSyncTab]
|
||||||
|
key: [Char: 's']
|
||||||
- action: [MoveFocus: Left,]
|
- action: [MoveFocus: Left,]
|
||||||
key: [ Alt: 'h',]
|
key: [ Alt: 'h',]
|
||||||
- action: [MoveFocus: Right,]
|
- action: [MoveFocus: Right,]
|
||||||
|
@ -607,23 +607,17 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
pub fn write_to_terminals_on_current_tab(&mut self, input_bytes: Vec<u8>) {
|
pub fn write_to_terminals_on_current_tab(&mut self, input_bytes: Vec<u8>) {
|
||||||
let pane_ids = self.get_pane_ids();
|
let pane_ids = self.get_pane_ids();
|
||||||
pane_ids.iter().for_each(|pane_id| match pane_id {
|
pane_ids.iter().for_each(|&pane_id| {
|
||||||
PaneId::Terminal(pid) => {
|
self.write_to_pane_id(input_bytes.clone(), pane_id);
|
||||||
self.write_to_pane_id(input_bytes.clone(), *pid);
|
|
||||||
}
|
|
||||||
PaneId::Plugin(_) => {}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
pub fn write_to_pane_id(&mut self, mut input_bytes: Vec<u8>, pid: RawFd) {
|
|
||||||
self.os_api
|
|
||||||
.write_to_tty_stdin(pid, &mut input_bytes)
|
|
||||||
.expect("failed to write to terminal");
|
|
||||||
self.os_api.tcdrain(pid).expect("failed to drain terminal");
|
|
||||||
}
|
|
||||||
pub fn write_to_active_terminal(&mut self, input_bytes: Vec<u8>) {
|
pub fn write_to_active_terminal(&mut self, input_bytes: Vec<u8>) {
|
||||||
match self.get_active_pane_id() {
|
self.write_to_pane_id(input_bytes, self.get_active_pane_id().unwrap());
|
||||||
Some(PaneId::Terminal(active_terminal_id)) => {
|
}
|
||||||
let active_terminal = self.get_active_pane().unwrap();
|
pub fn write_to_pane_id(&mut self, input_bytes: Vec<u8>, pane_id: PaneId) {
|
||||||
|
match pane_id {
|
||||||
|
PaneId::Terminal(active_terminal_id) => {
|
||||||
|
let active_terminal = self.panes.get(&pane_id).unwrap();
|
||||||
let mut adjusted_input = active_terminal.adjust_input_to_terminal(input_bytes);
|
let mut adjusted_input = active_terminal.adjust_input_to_terminal(input_bytes);
|
||||||
self.os_api
|
self.os_api
|
||||||
.write_to_tty_stdin(active_terminal_id, &mut adjusted_input)
|
.write_to_tty_stdin(active_terminal_id, &mut adjusted_input)
|
||||||
@ -632,14 +626,13 @@ impl Tab {
|
|||||||
.tcdrain(active_terminal_id)
|
.tcdrain(active_terminal_id)
|
||||||
.expect("failed to drain terminal");
|
.expect("failed to drain terminal");
|
||||||
}
|
}
|
||||||
Some(PaneId::Plugin(pid)) => {
|
PaneId::Plugin(pid) => {
|
||||||
for key in parse_keys(&input_bytes) {
|
for key in parse_keys(&input_bytes) {
|
||||||
self.send_plugin_instructions
|
self.send_plugin_instructions
|
||||||
.send(PluginInstruction::Update(Some(pid), Event::KeyPress(key)))
|
.send(PluginInstruction::Update(Some(pid), Event::KeyPress(key)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn get_active_terminal_cursor_position(&self) -> Option<(usize, usize)> {
|
pub fn get_active_terminal_cursor_position(&self) -> Option<(usize, usize)> {
|
||||||
@ -713,7 +706,7 @@ impl Tab {
|
|||||||
pub fn is_sync_panes_active(&self) -> bool {
|
pub fn is_sync_panes_active(&self) -> bool {
|
||||||
self.synchronize_is_active
|
self.synchronize_is_active
|
||||||
}
|
}
|
||||||
pub fn toggle_sync_panes_is_active(&mut self) {
|
pub fn toggle_sync_tab_is_active(&mut self) {
|
||||||
self.synchronize_is_active = !self.synchronize_is_active;
|
self.synchronize_is_active = !self.synchronize_is_active;
|
||||||
}
|
}
|
||||||
pub fn panes_contain_widechar(&self) -> bool {
|
pub fn panes_contain_widechar(&self) -> bool {
|
||||||
|
@ -200,7 +200,7 @@ pub enum ScreenContext {
|
|||||||
PageScrollDown,
|
PageScrollDown,
|
||||||
ClearScroll,
|
ClearScroll,
|
||||||
CloseFocusedPane,
|
CloseFocusedPane,
|
||||||
ToggleActiveSyncPanes,
|
ToggleActiveSyncTab,
|
||||||
ToggleActiveTerminalFullscreen,
|
ToggleActiveTerminalFullscreen,
|
||||||
SetSelectable,
|
SetSelectable,
|
||||||
SetInvisibleBorders,
|
SetInvisibleBorders,
|
||||||
@ -261,7 +261,7 @@ impl From<&ScreenInstruction> for ScreenContext {
|
|||||||
ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName,
|
ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName,
|
||||||
ScreenInstruction::TerminalResize(_) => ScreenContext::TerminalResize,
|
ScreenInstruction::TerminalResize(_) => ScreenContext::TerminalResize,
|
||||||
ScreenInstruction::ChangeMode(_) => ScreenContext::ChangeMode,
|
ScreenInstruction::ChangeMode(_) => ScreenContext::ChangeMode,
|
||||||
ScreenInstruction::ToggleActiveSyncPanes => ScreenContext::ToggleActiveSyncPanes,
|
ScreenInstruction::ToggleActiveSyncTab => ScreenContext::ToggleActiveSyncTab,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ pub enum Action {
|
|||||||
PageScrollDown,
|
PageScrollDown,
|
||||||
/// Toggle between fullscreen focus pane and normal layout.
|
/// Toggle between fullscreen focus pane and normal layout.
|
||||||
ToggleFocusFullscreen,
|
ToggleFocusFullscreen,
|
||||||
/// Toggle between sending text commands to all panes and normal mode.
|
/// Toggle between sending text commands to all panes on the current tab and normal mode.
|
||||||
ToggleActiveSyncPanes,
|
ToggleActiveSyncTab,
|
||||||
/// Open a new pane in the specified direction (relative to focus).
|
/// Open a new pane in the specified direction (relative to focus).
|
||||||
/// If no direction is specified, will try to use the biggest available space.
|
/// If no direction is specified, will try to use the biggest available space.
|
||||||
NewPane(Option<Direction>),
|
NewPane(Option<Direction>),
|
||||||
|
@ -160,7 +160,6 @@ pub fn get_mode_info(mode: InputMode, palette: Palette) -> ModeInfo {
|
|||||||
keybinds.push(("d".to_string(), "Down split".to_string()));
|
keybinds.push(("d".to_string(), "Down split".to_string()));
|
||||||
keybinds.push(("r".to_string(), "Right split".to_string()));
|
keybinds.push(("r".to_string(), "Right split".to_string()));
|
||||||
keybinds.push(("x".to_string(), "Close".to_string()));
|
keybinds.push(("x".to_string(), "Close".to_string()));
|
||||||
keybinds.push(("s".to_string(), "Sync".to_string()));
|
|
||||||
keybinds.push(("f".to_string(), "Fullscreen".to_string()));
|
keybinds.push(("f".to_string(), "Fullscreen".to_string()));
|
||||||
}
|
}
|
||||||
InputMode::Tab => {
|
InputMode::Tab => {
|
||||||
@ -168,6 +167,7 @@ pub fn get_mode_info(mode: InputMode, palette: Palette) -> ModeInfo {
|
|||||||
keybinds.push(("n".to_string(), "New".to_string()));
|
keybinds.push(("n".to_string(), "New".to_string()));
|
||||||
keybinds.push(("x".to_string(), "Close".to_string()));
|
keybinds.push(("x".to_string(), "Close".to_string()));
|
||||||
keybinds.push(("r".to_string(), "Rename".to_string()));
|
keybinds.push(("r".to_string(), "Rename".to_string()));
|
||||||
|
keybinds.push(("s".to_string(), "Sync".to_string()));
|
||||||
}
|
}
|
||||||
InputMode::Scroll => {
|
InputMode::Scroll => {
|
||||||
keybinds.push(("↓↑".to_string(), "Scroll".to_string()));
|
keybinds.push(("↓↑".to_string(), "Scroll".to_string()));
|
||||||
|
@ -52,7 +52,7 @@ pub enum ScreenInstruction {
|
|||||||
NewTab(RawFd),
|
NewTab(RawFd),
|
||||||
SwitchTabNext,
|
SwitchTabNext,
|
||||||
SwitchTabPrev,
|
SwitchTabPrev,
|
||||||
ToggleActiveSyncPanes,
|
ToggleActiveSyncTab,
|
||||||
CloseTab,
|
CloseTab,
|
||||||
GoToTab(u32),
|
GoToTab(u32),
|
||||||
UpdateTabName(Vec<u8>),
|
UpdateTabName(Vec<u8>),
|
||||||
|
@ -528,11 +528,11 @@ fn init_session(
|
|||||||
ScreenInstruction::ChangeMode(mode_info) => {
|
ScreenInstruction::ChangeMode(mode_info) => {
|
||||||
screen.change_mode(mode_info);
|
screen.change_mode(mode_info);
|
||||||
}
|
}
|
||||||
ScreenInstruction::ToggleActiveSyncPanes => {
|
ScreenInstruction::ToggleActiveSyncTab => {
|
||||||
screen
|
screen
|
||||||
.get_active_tab_mut()
|
.get_active_tab_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.toggle_sync_panes_is_active();
|
.toggle_sync_tab_is_active();
|
||||||
screen.update_tabs();
|
screen.update_tabs();
|
||||||
}
|
}
|
||||||
ScreenInstruction::Exit => {
|
ScreenInstruction::Exit => {
|
||||||
@ -781,10 +781,10 @@ fn route_action(action: Action, session: &SessionMetaData, os_input: &dyn Server
|
|||||||
.send(ScreenInstruction::SwitchTabPrev)
|
.send(ScreenInstruction::SwitchTabPrev)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
Action::ToggleActiveSyncPanes => {
|
Action::ToggleActiveSyncTab => {
|
||||||
session
|
session
|
||||||
.send_screen_instructions
|
.send_screen_instructions
|
||||||
.send(ScreenInstruction::ToggleActiveSyncPanes)
|
.send(ScreenInstruction::ToggleActiveSyncTab)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
Action::CloseTab => {
|
Action::CloseTab => {
|
||||||
|
Loading…
Reference in New Issue
Block a user