aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorDenis Maximov <denismaximov98@gmail.com>2021-03-24 11:37:35 +0200
committerGitHub <noreply@github.com>2021-03-24 11:37:35 +0200
commitd64e814e54c52085647a053ec0bd6393e8986b19 (patch)
treecf9ceb0c4288f2d811497482c80809d90961ce7f /src/common
parentPerformance: only render panes that should be updated (#234) (diff)
parentwip: input_mode back in tab, not passing stuff around anymore (diff)
downloadsl0ppij-d64e814e54c52085647a053ec0bd6393e8986b19.tar.gz
sl0ppij-d64e814e54c52085647a053ec0bd6393e8986b19.tar.xz
sl0ppij-d64e814e54c52085647a053ec0bd6393e8986b19.zip
Merge pull request #235 from zellij-org/focused-pane
feature: Focused pane border coloring
Diffstat (limited to 'src/common')
-rw-r--r--src/common/errors.rs2
-rw-r--r--src/common/input/handler.rs3
-rw-r--r--src/common/mod.rs4
-rw-r--r--src/common/screen.rs14
4 files changed, 22 insertions, 1 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs
index df741629..eeebf93f 100644
--- a/src/common/errors.rs
+++ b/src/common/errors.rs
@@ -199,6 +199,7 @@ pub enum ScreenContext {
CloseTab,
GoToTab,
UpdateTabName,
+ ChangeInputMode,
}
impl From<&ScreenInstruction> for ScreenContext {
@@ -238,6 +239,7 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenInstruction::CloseTab => ScreenContext::CloseTab,
ScreenInstruction::GoToTab(_) => ScreenContext::GoToTab,
ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName,
+ ScreenInstruction::ChangeInputMode(_) => ScreenContext::ChangeInputMode,
}
}
}
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs
index 57bb46fb..2d5e965f 100644
--- a/src/common/input/handler.rs
+++ b/src/common/input/handler.rs
@@ -134,6 +134,9 @@ impl InputHandler {
input_mode: self.mode,
});
self.send_screen_instructions
+ .send(ScreenInstruction::ChangeInputMode(self.mode))
+ .unwrap();
+ self.send_screen_instructions
.send(ScreenInstruction::Render)
.unwrap();
}
diff --git a/src/common/mod.rs b/src/common/mod.rs
index 7b19bcef..7e52dde7 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -290,6 +290,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
&full_screen_ws,
os_input,
max_panes,
+ InputMode::Normal,
);
loop {
let (event, mut err_ctx) = screen
@@ -424,6 +425,9 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
ScreenInstruction::UpdateTabName(c) => {
screen.update_active_tab_name(c);
}
+ ScreenInstruction::ChangeInputMode(input_mode) => {
+ screen.change_input_mode(input_mode);
+ }
ScreenInstruction::Quit => {
break;
}
diff --git a/src/common/screen.rs b/src/common/screen.rs
index 57bb0e0f..bb77ab85 100644
--- a/src/common/screen.rs
+++ b/src/common/screen.rs
@@ -5,7 +5,7 @@ use std::os::unix::io::RawFd;
use std::str;
use std::sync::mpsc::Receiver;
-use super::{AppInstruction, SenderWithContext};
+use super::{input::handler::InputMode, AppInstruction, SenderWithContext};
use crate::os_input_output::OsApi;
use crate::panes::PositionAndSize;
use crate::pty_bus::{PtyInstruction, VteEvent};
@@ -48,6 +48,7 @@ pub enum ScreenInstruction {
CloseTab,
GoToTab(u32),
UpdateTabName(Vec<u8>),
+ ChangeInputMode(InputMode),
}
/// A [`Screen`] holds multiple [`Tab`]s, each one holding multiple [`panes`](crate::client::panes).
@@ -72,6 +73,7 @@ pub struct Screen {
/// The [`OsApi`] this [`Screen`] uses.
os_api: Box<dyn OsApi>,
tabname_buf: String,
+ input_mode: InputMode,
}
impl Screen {
@@ -84,6 +86,7 @@ impl Screen {
full_screen_ws: &PositionAndSize,
os_api: Box<dyn OsApi>,
max_panes: Option<usize>,
+ input_mode: InputMode,
) -> Self {
Screen {
receiver: receive_screen_instructions,
@@ -96,6 +99,7 @@ impl Screen {
tabs: BTreeMap::new(),
os_api,
tabname_buf: String::new(),
+ input_mode,
}
}
@@ -115,6 +119,7 @@ impl Screen {
self.send_app_instructions.clone(),
self.max_panes,
Some(PaneId::Terminal(pane_id)),
+ self.input_mode,
);
self.active_tab_index = Some(tab_index);
self.tabs.insert(tab_index, tab);
@@ -259,6 +264,7 @@ impl Screen {
self.send_app_instructions.clone(),
self.max_panes,
None,
+ self.input_mode,
);
tab.apply_layout(layout, new_pids);
self.active_tab_index = Some(tab_index);
@@ -303,4 +309,10 @@ impl Screen {
}
}
}
+ pub fn change_input_mode(&mut self, input_mode: InputMode) {
+ self.input_mode = input_mode;
+ for tab in self.tabs.values_mut() {
+ tab.input_mode = self.input_mode;
+ }
+ }
}