mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-23 19:10:09 +03:00
wip: input_mode back in tab, not passing stuff around anymore
This commit is contained in:
parent
91608dfe4e
commit
57e1f476f2
@ -67,19 +67,14 @@ impl Display for BoundarySymbol {
|
|||||||
fn combine_symbols(
|
fn combine_symbols(
|
||||||
current_symbol: BoundarySymbol,
|
current_symbol: BoundarySymbol,
|
||||||
next_symbol: BoundarySymbol,
|
next_symbol: BoundarySymbol,
|
||||||
input_mode: Option<InputMode>,
|
|
||||||
) -> Option<BoundarySymbol> {
|
) -> Option<BoundarySymbol> {
|
||||||
let invisible = current_symbol.invisible || next_symbol.invisible;
|
let invisible = current_symbol.invisible || next_symbol.invisible;
|
||||||
let should_be_colored = current_symbol.color.is_some() || next_symbol.color.is_some();
|
let color = match (current_symbol.color.is_some(), next_symbol.color.is_some()) {
|
||||||
|
(true, _) => current_symbol.color,
|
||||||
|
_ => next_symbol.color,
|
||||||
|
};
|
||||||
let current_symbol = current_symbol.boundary_type;
|
let current_symbol = current_symbol.boundary_type;
|
||||||
let next_symbol = next_symbol.boundary_type;
|
let next_symbol = next_symbol.boundary_type;
|
||||||
let color = match should_be_colored {
|
|
||||||
true => match input_mode {
|
|
||||||
Some(InputMode::Normal) | Some(InputMode::Locked) => Some(colors::GREEN),
|
|
||||||
_ => Some(colors::WHITE),
|
|
||||||
},
|
|
||||||
false => None,
|
|
||||||
};
|
|
||||||
match (current_symbol, next_symbol) {
|
match (current_symbol, next_symbol) {
|
||||||
(boundary_type::TOP_RIGHT, boundary_type::TOP_RIGHT) => {
|
(boundary_type::TOP_RIGHT, boundary_type::TOP_RIGHT) => {
|
||||||
// (┐, ┐) => Some(┐)
|
// (┐, ┐) => Some(┐)
|
||||||
@ -682,12 +677,11 @@ fn combine_symbols(
|
|||||||
fn find_next_symbol(
|
fn find_next_symbol(
|
||||||
first_symbol: BoundarySymbol,
|
first_symbol: BoundarySymbol,
|
||||||
second_symbol: BoundarySymbol,
|
second_symbol: BoundarySymbol,
|
||||||
input_mode: Option<InputMode>,
|
|
||||||
) -> Option<BoundarySymbol> {
|
) -> Option<BoundarySymbol> {
|
||||||
if let Some(symbol) = combine_symbols(first_symbol, second_symbol, input_mode) {
|
if let Some(symbol) = combine_symbols(first_symbol, second_symbol) {
|
||||||
Some(symbol)
|
Some(symbol)
|
||||||
} else {
|
} else {
|
||||||
combine_symbols(second_symbol, first_symbol, input_mode)
|
combine_symbols(second_symbol, first_symbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,12 +763,14 @@ impl Boundaries {
|
|||||||
boundary_characters: HashMap::new(),
|
boundary_characters: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn add_rect(
|
pub fn add_rect(&mut self, rect: &dyn Pane, input_mode: InputMode, color: Option<Colour>) {
|
||||||
&mut self,
|
let color = match color.is_some() {
|
||||||
rect: &dyn Pane,
|
true => match input_mode {
|
||||||
input_mode: Option<InputMode>,
|
InputMode::Normal | InputMode::Locked => Some(colors::GREEN),
|
||||||
color: Option<Colour>,
|
_ => Some(colors::WHITE),
|
||||||
) {
|
},
|
||||||
|
false => None,
|
||||||
|
};
|
||||||
if rect.x() > 0 {
|
if rect.x() > 0 {
|
||||||
let boundary_x_coords = rect.x() - 1;
|
let boundary_x_coords = rect.x() - 1;
|
||||||
let first_row_coordinates = self.rect_right_boundary_row_start(rect);
|
let first_row_coordinates = self.rect_right_boundary_row_start(rect);
|
||||||
@ -794,9 +790,7 @@ impl Boundaries {
|
|||||||
let next_symbol = self
|
let next_symbol = self
|
||||||
.boundary_characters
|
.boundary_characters
|
||||||
.remove(&coordinates)
|
.remove(&coordinates)
|
||||||
.and_then(|current_symbol| {
|
.and_then(|current_symbol| find_next_symbol(current_symbol, symbol_to_add))
|
||||||
find_next_symbol(current_symbol, symbol_to_add, input_mode)
|
|
||||||
})
|
|
||||||
.unwrap_or(symbol_to_add);
|
.unwrap_or(symbol_to_add);
|
||||||
self.boundary_characters.insert(coordinates, next_symbol);
|
self.boundary_characters.insert(coordinates, next_symbol);
|
||||||
}
|
}
|
||||||
@ -820,9 +814,7 @@ impl Boundaries {
|
|||||||
let next_symbol = self
|
let next_symbol = self
|
||||||
.boundary_characters
|
.boundary_characters
|
||||||
.remove(&coordinates)
|
.remove(&coordinates)
|
||||||
.and_then(|current_symbol| {
|
.and_then(|current_symbol| find_next_symbol(current_symbol, symbol_to_add))
|
||||||
find_next_symbol(current_symbol, symbol_to_add, input_mode)
|
|
||||||
})
|
|
||||||
.unwrap_or(symbol_to_add);
|
.unwrap_or(symbol_to_add);
|
||||||
self.boundary_characters.insert(coordinates, next_symbol);
|
self.boundary_characters.insert(coordinates, next_symbol);
|
||||||
}
|
}
|
||||||
@ -847,9 +839,7 @@ impl Boundaries {
|
|||||||
let next_symbol = self
|
let next_symbol = self
|
||||||
.boundary_characters
|
.boundary_characters
|
||||||
.remove(&coordinates)
|
.remove(&coordinates)
|
||||||
.and_then(|current_symbol| {
|
.and_then(|current_symbol| find_next_symbol(current_symbol, symbol_to_add))
|
||||||
find_next_symbol(current_symbol, symbol_to_add, input_mode)
|
|
||||||
})
|
|
||||||
.unwrap_or(symbol_to_add);
|
.unwrap_or(symbol_to_add);
|
||||||
self.boundary_characters.insert(coordinates, next_symbol);
|
self.boundary_characters.insert(coordinates, next_symbol);
|
||||||
}
|
}
|
||||||
@ -873,9 +863,7 @@ impl Boundaries {
|
|||||||
let next_symbol = self
|
let next_symbol = self
|
||||||
.boundary_characters
|
.boundary_characters
|
||||||
.remove(&coordinates)
|
.remove(&coordinates)
|
||||||
.and_then(|current_symbol| {
|
.and_then(|current_symbol| find_next_symbol(current_symbol, symbol_to_add))
|
||||||
find_next_symbol(current_symbol, symbol_to_add, input_mode)
|
|
||||||
})
|
|
||||||
.unwrap_or(symbol_to_add);
|
.unwrap_or(symbol_to_add);
|
||||||
self.boundary_characters.insert(coordinates, next_symbol);
|
self.boundary_characters.insert(coordinates, next_symbol);
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ pub struct Tab {
|
|||||||
pub send_plugin_instructions: SenderWithContext<PluginInstruction>,
|
pub send_plugin_instructions: SenderWithContext<PluginInstruction>,
|
||||||
pub send_app_instructions: SenderWithContext<AppInstruction>,
|
pub send_app_instructions: SenderWithContext<AppInstruction>,
|
||||||
expansion_boundary: Option<PositionAndSize>,
|
expansion_boundary: Option<PositionAndSize>,
|
||||||
|
pub input_mode: InputMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||||
@ -192,6 +193,7 @@ impl Tab {
|
|||||||
send_app_instructions: SenderWithContext<AppInstruction>,
|
send_app_instructions: SenderWithContext<AppInstruction>,
|
||||||
max_panes: Option<usize>,
|
max_panes: Option<usize>,
|
||||||
pane_id: Option<PaneId>,
|
pane_id: Option<PaneId>,
|
||||||
|
input_mode: InputMode,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let panes = if let Some(PaneId::Terminal(pid)) = pane_id {
|
let panes = if let Some(PaneId::Terminal(pid)) = pane_id {
|
||||||
let new_terminal = TerminalPane::new(pid, *full_screen_ws);
|
let new_terminal = TerminalPane::new(pid, *full_screen_ws);
|
||||||
@ -221,6 +223,7 @@ impl Tab {
|
|||||||
send_pty_instructions,
|
send_pty_instructions,
|
||||||
send_plugin_instructions,
|
send_plugin_instructions,
|
||||||
expansion_boundary: None,
|
expansion_boundary: None,
|
||||||
|
input_mode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +303,7 @@ impl Tab {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
self.active_terminal = self.panes.iter().map(|(id, _)| id.to_owned()).next();
|
self.active_terminal = self.panes.iter().map(|(id, _)| id.to_owned()).next();
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
pub fn new_pane(&mut self, pid: PaneId) {
|
pub fn new_pane(&mut self, pid: PaneId) {
|
||||||
self.close_down_to_max_terminals();
|
self.close_down_to_max_terminals();
|
||||||
@ -401,7 +404,7 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.active_terminal = Some(pid);
|
self.active_terminal = Some(pid);
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn horizontal_split(&mut self, pid: PaneId) {
|
pub fn horizontal_split(&mut self, pid: PaneId) {
|
||||||
@ -460,7 +463,7 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.active_terminal = Some(pid);
|
self.active_terminal = Some(pid);
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -520,7 +523,7 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.active_terminal = Some(pid);
|
self.active_terminal = Some(pid);
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -624,14 +627,14 @@ impl Tab {
|
|||||||
active_terminal.rows() as u16,
|
active_terminal.rows() as u16,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
self.render(None);
|
self.render();
|
||||||
self.toggle_fullscreen_is_active();
|
self.toggle_fullscreen_is_active();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn toggle_fullscreen_is_active(&mut self) {
|
pub fn toggle_fullscreen_is_active(&mut self) {
|
||||||
self.fullscreen_is_active = !self.fullscreen_is_active;
|
self.fullscreen_is_active = !self.fullscreen_is_active;
|
||||||
}
|
}
|
||||||
pub fn render(&mut self, input_mode: Option<InputMode>) {
|
pub fn render(&mut self) {
|
||||||
if self.active_terminal.is_none() {
|
if self.active_terminal.is_none() {
|
||||||
// we might not have an active terminal if we closed the last pane
|
// 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
|
// in that case, we should not render as the app is exiting
|
||||||
@ -649,8 +652,10 @@ impl Tab {
|
|||||||
for (kind, terminal) in self.panes.iter_mut() {
|
for (kind, terminal) in self.panes.iter_mut() {
|
||||||
if !self.panes_to_hide.contains(&terminal.pid()) {
|
if !self.panes_to_hide.contains(&terminal.pid()) {
|
||||||
match self.active_terminal.unwrap() == terminal.pid() {
|
match self.active_terminal.unwrap() == terminal.pid() {
|
||||||
true => boundaries.add_rect(terminal.as_ref(), input_mode, Some(colors::GREEN)),
|
true => {
|
||||||
false => boundaries.add_rect(terminal.as_ref(), input_mode, None),
|
boundaries.add_rect(terminal.as_ref(), self.input_mode, Some(colors::GREEN))
|
||||||
|
}
|
||||||
|
false => boundaries.add_rect(terminal.as_ref(), self.input_mode, None),
|
||||||
}
|
}
|
||||||
if let Some(vte_output) = terminal.render() {
|
if let Some(vte_output) = terminal.render() {
|
||||||
let vte_output = if let PaneId::Terminal(_) = kind {
|
let vte_output = if let PaneId::Terminal(_) = kind {
|
||||||
@ -1739,7 +1744,7 @@ impl Tab {
|
|||||||
} else {
|
} else {
|
||||||
self.active_terminal = Some(*first_terminal);
|
self.active_terminal = Some(*first_terminal);
|
||||||
}
|
}
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
pub fn move_focus_left(&mut self) {
|
pub fn move_focus_left(&mut self) {
|
||||||
if !self.has_selectable_panes() {
|
if !self.has_selectable_panes() {
|
||||||
@ -1769,7 +1774,7 @@ impl Tab {
|
|||||||
} else {
|
} else {
|
||||||
self.active_terminal = Some(active_terminal.unwrap().pid());
|
self.active_terminal = Some(active_terminal.unwrap().pid());
|
||||||
}
|
}
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
pub fn move_focus_down(&mut self) {
|
pub fn move_focus_down(&mut self) {
|
||||||
if !self.has_selectable_panes() {
|
if !self.has_selectable_panes() {
|
||||||
@ -1799,7 +1804,7 @@ impl Tab {
|
|||||||
} else {
|
} else {
|
||||||
self.active_terminal = Some(active_terminal.unwrap().pid());
|
self.active_terminal = Some(active_terminal.unwrap().pid());
|
||||||
}
|
}
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
pub fn move_focus_up(&mut self) {
|
pub fn move_focus_up(&mut self) {
|
||||||
if !self.has_selectable_panes() {
|
if !self.has_selectable_panes() {
|
||||||
@ -1829,7 +1834,7 @@ impl Tab {
|
|||||||
} else {
|
} else {
|
||||||
self.active_terminal = Some(active_terminal.unwrap().pid());
|
self.active_terminal = Some(active_terminal.unwrap().pid());
|
||||||
}
|
}
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
pub fn move_focus_right(&mut self) {
|
pub fn move_focus_right(&mut self) {
|
||||||
if !self.has_selectable_panes() {
|
if !self.has_selectable_panes() {
|
||||||
@ -1859,7 +1864,7 @@ impl Tab {
|
|||||||
} else {
|
} else {
|
||||||
self.active_terminal = Some(active_terminal.unwrap().pid());
|
self.active_terminal = Some(active_terminal.unwrap().pid());
|
||||||
}
|
}
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
fn horizontal_borders(&self, terminals: &[PaneId]) -> HashSet<usize> {
|
fn horizontal_borders(&self, terminals: &[PaneId]) -> HashSet<usize> {
|
||||||
terminals.iter().fold(HashSet::new(), |mut borders, t| {
|
terminals.iter().fold(HashSet::new(), |mut borders, t| {
|
||||||
@ -2066,7 +2071,7 @@ impl Tab {
|
|||||||
.get_mut(&PaneId::Terminal(active_terminal_id))
|
.get_mut(&PaneId::Terminal(active_terminal_id))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
active_terminal.scroll_up(1);
|
active_terminal.scroll_up(1);
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn scroll_active_terminal_down(&mut self) {
|
pub fn scroll_active_terminal_down(&mut self) {
|
||||||
@ -2076,7 +2081,7 @@ impl Tab {
|
|||||||
.get_mut(&PaneId::Terminal(active_terminal_id))
|
.get_mut(&PaneId::Terminal(active_terminal_id))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
active_terminal.scroll_down(1);
|
active_terminal.scroll_down(1);
|
||||||
self.render(None);
|
self.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn clear_active_terminal_scroll(&mut self) {
|
pub fn clear_active_terminal_scroll(&mut self) {
|
||||||
|
@ -119,6 +119,7 @@ impl Screen {
|
|||||||
self.send_app_instructions.clone(),
|
self.send_app_instructions.clone(),
|
||||||
self.max_panes,
|
self.max_panes,
|
||||||
Some(PaneId::Terminal(pane_id)),
|
Some(PaneId::Terminal(pane_id)),
|
||||||
|
self.input_mode,
|
||||||
);
|
);
|
||||||
self.active_tab_index = Some(tab_index);
|
self.active_tab_index = Some(tab_index);
|
||||||
self.tabs.insert(tab_index, tab);
|
self.tabs.insert(tab_index, tab);
|
||||||
@ -217,10 +218,9 @@ impl Screen {
|
|||||||
|
|
||||||
/// Renders this [`Screen`], which amounts to rendering its active [`Tab`].
|
/// Renders this [`Screen`], which amounts to rendering its active [`Tab`].
|
||||||
pub fn render(&mut self) {
|
pub fn render(&mut self) {
|
||||||
let input_mode = self.input_mode;
|
|
||||||
if let Some(active_tab) = self.get_active_tab_mut() {
|
if let Some(active_tab) = self.get_active_tab_mut() {
|
||||||
if active_tab.get_active_pane().is_some() {
|
if active_tab.get_active_pane().is_some() {
|
||||||
active_tab.render(Some(input_mode));
|
active_tab.render();
|
||||||
} else {
|
} else {
|
||||||
self.close_tab();
|
self.close_tab();
|
||||||
}
|
}
|
||||||
@ -264,6 +264,7 @@ impl Screen {
|
|||||||
self.send_app_instructions.clone(),
|
self.send_app_instructions.clone(),
|
||||||
self.max_panes,
|
self.max_panes,
|
||||||
None,
|
None,
|
||||||
|
self.input_mode,
|
||||||
);
|
);
|
||||||
tab.apply_layout(layout, new_pids);
|
tab.apply_layout(layout, new_pids);
|
||||||
self.active_tab_index = Some(tab_index);
|
self.active_tab_index = Some(tab_index);
|
||||||
@ -310,5 +311,8 @@ impl Screen {
|
|||||||
}
|
}
|
||||||
pub fn change_input_mode(&mut self, input_mode: InputMode) {
|
pub fn change_input_mode(&mut self, input_mode: InputMode) {
|
||||||
self.input_mode = input_mode;
|
self.input_mode = input_mode;
|
||||||
|
for tab in self.tabs.values_mut() {
|
||||||
|
tab.input_mode = self.input_mode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user