1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
use zellij_tile::prelude::actions::Action;
use zellij_tile::prelude::*;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ActionType {
MoveFocus,
MovePaneWithDirection,
MovePaneWithoutDirection,
ResizeIncrease,
ResizeDecrease,
ResizeAny,
Search,
NewPaneWithDirection,
NewPaneWithoutDirection,
BreakPaneLeftOrRight,
GoToAdjacentTab,
Scroll,
PageScroll,
HalfPageScroll,
SessionManager,
Configuration,
PluginManager,
About,
SwitchToMode(InputMode),
TogglePaneEmbedOrFloating,
ToggleFocusFullscreen,
ToggleFloatingPanes,
CloseFocus,
CloseTab,
ToggleActiveSyncTab,
ToggleTab,
BreakPane,
EditScrollback,
NewTab,
Detach,
Quit,
NewStackedPane,
Other(String), // Fallback for unhandled actions
}
impl ActionType {
pub fn description(&self) -> String {
match self {
ActionType::MoveFocus => "Move focus".to_string(),
ActionType::MovePaneWithDirection => "Move pane".to_string(),
ActionType::MovePaneWithoutDirection => "Move pane".to_string(),
ActionType::ResizeIncrease => "Increase size in direction".to_string(),
ActionType::ResizeDecrease => "Decrease size in direction".to_string(),
ActionType::ResizeAny => "Increase or decrease size".to_string(),
ActionType::Search => "Search".to_string(),
ActionType::NewPaneWithDirection => "Split right/down".to_string(),
ActionType::NewPaneWithoutDirection => "New pane".to_string(),
ActionType::BreakPaneLeftOrRight => "Break pane to adjacent tab".to_string(),
ActionType::GoToAdjacentTab => "Move tab focus".to_string(),
ActionType::Scroll => "Scroll".to_string(),
ActionType::PageScroll => "Scroll page".to_string(),
ActionType::HalfPageScroll => "Scroll half Page".to_string(),
ActionType::SessionManager => "Session manager".to_string(),
ActionType::PluginManager => "Plugin manager".to_string(),
ActionType::Configuration => "Configuration".to_string(),
ActionType::About => "About Zellij".to_string(),
ActionType::SwitchToMode(input_mode) if input_mode == &InputMode::RenamePane => {
"Rename pane".to_string()
},
ActionType::SwitchToMode(input_mode) if input_mode == &InputMode::RenameTab => {
"Rename tab".to_string()
},
ActionType::SwitchToMode(input_mode) if input_mode == &InputMode::EnterSearch => {
"Search".to_string()
},
ActionType::SwitchToMode(input_mode) if input_mode == &InputMode::Locked => {
"Lock".to_string()
},
ActionType::SwitchToMode(input_mode) if input_mode == &InputMode::Normal => {
"Unlock".to_string()
},
ActionType::SwitchToMode(input_mode) => format!("{:?}", input_mode),
ActionType::TogglePaneEmbedOrFloating => "Float or embed".to_string(),
ActionType::NewStackedPane => "New stacked pane".to_string(),
ActionType::ToggleFocusFullscreen => "Toggle fullscreen".to_string(),
ActionType::ToggleFloatingPanes => "Show/hide floating panes".to_string(),
ActionType::CloseFocus => "Close pane".to_string(),
ActionType::CloseTab => "Close tab".to_string(),
ActionType::ToggleActiveSyncTab => "Sync panes in tab".to_string(),
ActionType::ToggleTab => "Circle tab focus".to_string(),
ActionType::BreakPane => "Break pane to new tab".to_string(),
ActionType::EditScrollback => "Open pane scrollback in editor".to_string(),
ActionType::NewTab => "New tab".to_string(),
ActionType::Detach => "Detach".to_string(),
ActionType::Quit => "Quit".to_string(),
ActionType::Other(_) => "Other action".to_string(),
}
}
pub fn from_action(action: &Action) -> Self {
match action {
Action::MoveFocus { .. } => ActionType::MoveFocus,
Action::MovePane { direction: Some(_) } => ActionType::MovePaneWithDirection,
Action::MovePane { direction: None } => ActionType::MovePaneWithoutDirection,
Action::Resize {
resize: Resize::Increase,
direction: Some(_),
} => ActionType::ResizeIncrease,
Action::Resize {
resize: Resize::Decrease,
direction: Some(_),
} => ActionType::ResizeDecrease,
Action::Resize {
resize: _,
direction: None,
} => ActionType::ResizeAny,
Action::Search { .. } => ActionType::Search,
Action::NewPane {
direction: Some(_), ..
} => ActionType::NewPaneWithDirection,
Action::NewPane {
direction: None, ..
} => ActionType::NewPaneWithoutDirection,
Action::NewStackedPane { .. } => ActionType::NewStackedPane,
Action::BreakPaneLeft | Action::BreakPaneRight => ActionType::BreakPaneLeftOrRight,
Action::GoToPreviousTab | Action::GoToNextTab => ActionType::GoToAdjacentTab,
Action::ScrollUp | Action::ScrollDown => ActionType::Scroll,
Action::PageScrollUp | Action::PageScrollDown => ActionType::PageScroll,
Action::HalfPageScrollUp | Action::HalfPageScrollDown => ActionType::HalfPageScroll,
Action::SwitchToMode { input_mode } => ActionType::SwitchToMode(*input_mode),
Action::TogglePaneEmbedOrFloating => ActionType::TogglePaneEmbedOrFloating,
Action::ToggleFocusFullscreen => ActionType::ToggleFocusFullscreen,
Action::ToggleFloatingPanes => ActionType::ToggleFloatingPanes,
Action::CloseFocus => ActionType::CloseFocus,
Action::CloseTab => ActionType::CloseTab,
Action::ToggleActiveSyncTab => ActionType::ToggleActiveSyncTab,
Action::ToggleTab => ActionType::ToggleTab,
Action::BreakPane => ActionType::BreakPane,
Action::EditScrollback { .. } => ActionType::EditScrollback,
Action::Detach => ActionType::Detach,
Action::Quit => ActionType::Quit,
action if action.launches_plugin("session-manager") => ActionType::SessionManager,
action if action.launches_plugin("configuration") => ActionType::Configuration,
action if action.launches_plugin("plugin-manager") => ActionType::PluginManager,
action if action.launches_plugin("zellij:about") => ActionType::About,
action if matches!(action, Action::NewTab { .. }) => ActionType::NewTab,
_ => ActionType::Other(format!("{:?}", action)),
}
}
}
|