aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authordenis <denismaximov98@gmail.com>2021-03-24 07:50:47 +0200
committerdenis <denismaximov98@gmail.com>2021-03-24 07:50:47 +0200
commit91608dfe4ea3e75853d4966d7f464d85c022beef (patch)
tree1902f249409182d378c61a93858ed1d346025111 /src/client
parentwip: remove colored_borders (diff)
downloadsl0ppij-91608dfe4ea3e75853d4966d7f464d85c022beef.tar.gz
sl0ppij-91608dfe4ea3e75853d4966d7f464d85c022beef.tar.xz
sl0ppij-91608dfe4ea3e75853d4966d7f464d85c022beef.zip
wip: cleanup the TabData, get rid of input_mode in tab, pass through render instead
Diffstat (limited to 'src/client')
-rw-r--r--src/client/boundaries.rs15
-rw-r--r--src/client/tab.rs36
2 files changed, 25 insertions, 26 deletions
diff --git a/src/client/boundaries.rs b/src/client/boundaries.rs
index 85dfaa23..36fe17c5 100644
--- a/src/client/boundaries.rs
+++ b/src/client/boundaries.rs
@@ -57,7 +57,7 @@ impl Display for BoundarySymbol {
match self.invisible {
true => write!(f, " "),
false => match self.color {
- Some(_) => write!(f, "{}", self.color.unwrap().paint(self.boundary_type)),
+ Some(color) => write!(f, "{}", color.paint(self.boundary_type)),
None => write!(f, "{}", self.boundary_type),
},
}
@@ -67,7 +67,7 @@ impl Display for BoundarySymbol {
fn combine_symbols(
current_symbol: BoundarySymbol,
next_symbol: BoundarySymbol,
- input_mode: InputMode,
+ input_mode: Option<InputMode>,
) -> Option<BoundarySymbol> {
let invisible = current_symbol.invisible || next_symbol.invisible;
let should_be_colored = current_symbol.color.is_some() || next_symbol.color.is_some();
@@ -75,7 +75,7 @@ fn combine_symbols(
let next_symbol = next_symbol.boundary_type;
let color = match should_be_colored {
true => match input_mode {
- InputMode::Normal | InputMode::Locked => Some(colors::GREEN),
+ Some(InputMode::Normal) | Some(InputMode::Locked) => Some(colors::GREEN),
_ => Some(colors::WHITE),
},
false => None,
@@ -682,7 +682,7 @@ fn combine_symbols(
fn find_next_symbol(
first_symbol: BoundarySymbol,
second_symbol: BoundarySymbol,
- input_mode: InputMode,
+ input_mode: Option<InputMode>,
) -> Option<BoundarySymbol> {
if let Some(symbol) = combine_symbols(first_symbol, second_symbol, input_mode) {
Some(symbol)
@@ -769,7 +769,12 @@ impl Boundaries {
boundary_characters: HashMap::new(),
}
}
- pub fn add_rect(&mut self, rect: &dyn Pane, input_mode: InputMode, color: Option<Colour>) {
+ pub fn add_rect(
+ &mut self,
+ rect: &dyn Pane,
+ input_mode: Option<InputMode>,
+ color: Option<Colour>,
+ ) {
if rect.x() > 0 {
let boundary_x_coords = rect.x() - 1;
let first_row_coordinates = self.rect_right_boundary_row_start(rect);
diff --git a/src/client/tab.rs b/src/client/tab.rs
index 5cb0fdce..b58cc591 100644
--- a/src/client/tab.rs
+++ b/src/client/tab.rs
@@ -68,7 +68,6 @@ pub struct Tab {
pub send_plugin_instructions: SenderWithContext<PluginInstruction>,
pub send_app_instructions: SenderWithContext<AppInstruction>,
expansion_boundary: Option<PositionAndSize>,
- pub input_mode: InputMode,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
@@ -77,7 +76,6 @@ pub struct TabData {
pub position: usize,
pub name: String,
pub active: bool,
- pub input_mode: InputMode,
}
// FIXME: Use a struct that has a pane_type enum, to reduce all of the duplication
@@ -194,7 +192,6 @@ impl Tab {
send_app_instructions: SenderWithContext<AppInstruction>,
max_panes: Option<usize>,
pane_id: Option<PaneId>,
- input_mode: InputMode,
) -> Self {
let panes = if let Some(PaneId::Terminal(pid)) = pane_id {
let new_terminal = TerminalPane::new(pid, *full_screen_ws);
@@ -224,7 +221,6 @@ impl Tab {
send_pty_instructions,
send_plugin_instructions,
expansion_boundary: None,
- input_mode,
}
}
@@ -304,7 +300,7 @@ impl Tab {
.unwrap();
}
self.active_terminal = self.panes.iter().map(|(id, _)| id.to_owned()).next();
- self.render();
+ self.render(None);
}
pub fn new_pane(&mut self, pid: PaneId) {
self.close_down_to_max_terminals();
@@ -405,7 +401,7 @@ impl Tab {
}
}
self.active_terminal = Some(pid);
- self.render();
+ self.render(None);
}
}
pub fn horizontal_split(&mut self, pid: PaneId) {
@@ -464,7 +460,7 @@ impl Tab {
}
self.active_terminal = Some(pid);
- self.render();
+ self.render(None);
}
}
}
@@ -524,7 +520,7 @@ impl Tab {
}
self.active_terminal = Some(pid);
- self.render();
+ self.render(None);
}
}
}
@@ -628,14 +624,14 @@ impl Tab {
active_terminal.rows() as u16,
);
}
- self.render();
+ self.render(None);
self.toggle_fullscreen_is_active();
}
}
pub fn toggle_fullscreen_is_active(&mut self) {
self.fullscreen_is_active = !self.fullscreen_is_active;
}
- pub fn render(&mut self) {
+ pub fn render(&mut self, input_mode: Option<InputMode>) {
if self.active_terminal.is_none() {
// 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
@@ -653,10 +649,8 @@ impl Tab {
for (kind, terminal) in self.panes.iter_mut() {
if !self.panes_to_hide.contains(&terminal.pid()) {
match self.active_terminal.unwrap() == terminal.pid() {
- true => {
- boundaries.add_rect(terminal.as_ref(), self.input_mode, Some(colors::GREEN))
- }
- false => boundaries.add_rect(terminal.as_ref(), self.input_mode, None),
+ true => boundaries.add_rect(terminal.as_ref(), input_mode, Some(colors::GREEN)),
+ false => boundaries.add_rect(terminal.as_ref(), input_mode, None),
}
if let Some(vte_output) = terminal.render() {
let vte_output = if let PaneId::Terminal(_) = kind {
@@ -1745,7 +1739,7 @@ impl Tab {
} else {
self.active_terminal = Some(*first_terminal);
}
- self.render();
+ self.render(None);
}
pub fn move_focus_left(&mut self) {
if !self.has_selectable_panes() {
@@ -1775,7 +1769,7 @@ impl Tab {
} else {
self.active_terminal = Some(active_terminal.unwrap().pid());
}
- self.render();
+ self.render(None);
}
pub fn move_focus_down(&mut self) {
if !self.has_selectable_panes() {
@@ -1805,7 +1799,7 @@ impl Tab {
} else {
self.active_terminal = Some(active_terminal.unwrap().pid());
}
- self.render();
+ self.render(None);
}
pub fn move_focus_up(&mut self) {
if !self.has_selectable_panes() {
@@ -1835,7 +1829,7 @@ impl Tab {
} else {
self.active_terminal = Some(active_terminal.unwrap().pid());
}
- self.render();
+ self.render(None);
}
pub fn move_focus_right(&mut self) {
if !self.has_selectable_panes() {
@@ -1865,7 +1859,7 @@ impl Tab {
} else {
self.active_terminal = Some(active_terminal.unwrap().pid());
}
- self.render();
+ self.render(None);
}
fn horizontal_borders(&self, terminals: &[PaneId]) -> HashSet<usize> {
terminals.iter().fold(HashSet::new(), |mut borders, t| {
@@ -2072,7 +2066,7 @@ impl Tab {
.get_mut(&PaneId::Terminal(active_terminal_id))
.unwrap();
active_terminal.scroll_up(1);
- self.render();
+ self.render(None);
}
}
pub fn scroll_active_terminal_down(&mut self) {
@@ -2082,7 +2076,7 @@ impl Tab {
.get_mut(&PaneId::Terminal(active_terminal_id))
.unwrap();
active_terminal.scroll_down(1);
- self.render();
+ self.render(None);
}
}
pub fn clear_active_terminal_scroll(&mut self) {