aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src
diff options
context:
space:
mode:
authorqepasa <pawelpalenica11@gmail.com>2021-07-20 22:19:03 -0700
committerGitHub <noreply@github.com>2021-07-20 22:19:03 -0700
commitf0bc2977434d54079e0ca50bd1c18cd8bb7e1830 (patch)
tree501314d4f6fcb6116acac0314cf21fa1c3e75223 /zellij-server/src
parentRead from LoggingPipe returns error (diff)
parentdocs(changelog): noop for mouse actions on plugins (diff)
downloadsl0ppij-f0bc2977434d54079e0ca50bd1c18cd8bb7e1830.tar.gz
sl0ppij-f0bc2977434d54079e0ca50bd1c18cd8bb7e1830.tar.xz
sl0ppij-f0bc2977434d54079e0ca50bd1c18cd8bb7e1830.zip
Merge branch 'main' into unified-logging
Diffstat (limited to 'zellij-server/src')
-rw-r--r--zellij-server/src/panes/plugin_pane.rs6
-rw-r--r--zellij-server/src/pty.rs62
-rw-r--r--zellij-server/src/screen.rs10
-rw-r--r--zellij-server/src/tab.rs13
-rw-r--r--zellij-server/src/unit/screen_tests.rs12
-rw-r--r--zellij-server/src/unit/tab_tests.rs4
6 files changed, 55 insertions, 52 deletions
diff --git a/zellij-server/src/panes/plugin_pane.rs b/zellij-server/src/panes/plugin_pane.rs
index c01c7b87..256ceaea 100644
--- a/zellij-server/src/panes/plugin_pane.rs
+++ b/zellij-server/src/panes/plugin_pane.rs
@@ -196,13 +196,13 @@ impl Pane for PluginPane {
self.position_and_size.y -= count;
}
fn scroll_up(&mut self, _count: usize) {
- unimplemented!()
+ //unimplemented!()
}
fn scroll_down(&mut self, _count: usize) {
- unimplemented!()
+ //unimplemented!()
}
fn clear_scroll(&mut self) {
- unimplemented!()
+ //unimplemented!()
}
// FIXME: This need to be reevaluated and deleted if possible.
// `max` doesn't make sense when things are fixed...
diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs
index e7884f35..5ef3b321 100644
--- a/zellij-server/src/pty.rs
+++ b/zellij-server/src/pty.rs
@@ -1,11 +1,3 @@
-use zellij_utils::async_std;
-
-use async_std::future::timeout as async_timeout;
-use async_std::task::{self, JoinHandle};
-use std::collections::HashMap;
-use std::os::unix::io::RawFd;
-use std::time::{Duration, Instant};
-
use crate::{
os_input_output::{AsyncReader, Pid, ServerOsApi},
panes::PaneId,
@@ -14,9 +6,22 @@ use crate::{
wasm_vm::PluginInstruction,
ServerInstruction,
};
+use async_std::{
+ future::timeout as async_timeout,
+ task::{self, JoinHandle},
+};
+use std::{
+ collections::HashMap,
+ os::unix::io::RawFd,
+ time::{Duration, Instant},
+};
use zellij_utils::{
+ async_std,
errors::{get_current_ctx, ContextType, PtyContext},
- input::{command::TerminalAction, layout::Layout},
+ input::{
+ command::TerminalAction,
+ layout::{Layout, Run},
+ },
logging::debug_to_file,
};
@@ -236,19 +241,36 @@ impl Pty {
pub fn spawn_terminals_for_layout(
&mut self,
layout: Layout,
- terminal_action: Option<TerminalAction>,
+ default_shell: Option<TerminalAction>,
) {
- let total_panes = layout.total_terminal_panes();
+ let extracted_run_instructions = layout.extract_run_instructions();
let mut new_pane_pids = vec![];
- for _ in 0..total_panes {
- let (pid_primary, pid_secondary): (RawFd, Pid) = self
- .bus
- .os_input
- .as_mut()
- .unwrap()
- .spawn_terminal(terminal_action.clone());
- self.id_to_child_pid.insert(pid_primary, pid_secondary);
- new_pane_pids.push(pid_primary);
+ for run_instruction in extracted_run_instructions {
+ match run_instruction {
+ Some(Run::Command(command)) => {
+ let cmd = TerminalAction::RunCommand(command);
+ let (pid_primary, pid_secondary): (RawFd, Pid) = self
+ .bus
+ .os_input
+ .as_mut()
+ .unwrap()
+ .spawn_terminal(Some(cmd));
+ self.id_to_child_pid.insert(pid_primary, pid_secondary);
+ new_pane_pids.push(pid_primary);
+ }
+ None => {
+ let (pid_primary, pid_secondary): (RawFd, Pid) = self
+ .bus
+ .os_input
+ .as_mut()
+ .unwrap()
+ .spawn_terminal(default_shell.clone());
+ self.id_to_child_pid.insert(pid_primary, pid_secondary);
+ new_pane_pids.push(pid_primary);
+ }
+ // Investigate moving plugin loading to here.
+ Some(Run::Plugin(_)) => {}
+ }
}
self.bus
.senders
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index 9005d795..c96c1345 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -15,7 +15,7 @@ use crate::{
wasm_vm::PluginInstruction,
ServerInstruction, SessionState,
};
-use zellij_tile::data::{Event, InputMode, ModeInfo, Palette, PluginCapabilities, TabInfo};
+use zellij_tile::data::{Event, ModeInfo, Palette, PluginCapabilities, TabInfo};
use zellij_utils::{
errors::{ContextType, ScreenContext},
input::options::Options,
@@ -149,7 +149,6 @@ pub(crate) struct Screen {
/// The index of this [`Screen`]'s active [`Tab`].
active_tab_index: Option<usize>,
mode_info: ModeInfo,
- input_mode: InputMode,
colors: Palette,
session_state: Arc<RwLock<SessionState>>,
}
@@ -161,7 +160,6 @@ impl Screen {
client_attributes: &ClientAttributes,
max_panes: Option<usize>,
mode_info: ModeInfo,
- input_mode: InputMode,
session_state: Arc<RwLock<SessionState>>,
) -> Self {
Screen {
@@ -172,7 +170,6 @@ impl Screen {
active_tab_index: None,
tabs: BTreeMap::new(),
mode_info,
- input_mode,
session_state,
}
}
@@ -192,7 +189,6 @@ impl Screen {
self.max_panes,
Some(PaneId::Terminal(pane_id)),
self.mode_info.clone(),
- self.input_mode,
self.colors,
self.session_state.clone(),
);
@@ -354,7 +350,6 @@ impl Screen {
self.max_panes,
None,
self.mode_info.clone(),
- self.input_mode,
self.colors,
self.session_state.clone(),
);
@@ -428,7 +423,6 @@ pub(crate) fn screen_thread_main(
session_state: Arc<RwLock<SessionState>>,
) {
let capabilities = config_options.simplified_ui;
- let default_mode = config_options.default_mode.unwrap_or_default();
let mut screen = Screen::new(
bus,
@@ -439,10 +433,8 @@ pub(crate) fn screen_thread_main(
capabilities: PluginCapabilities {
arrow_fonts: capabilities,
},
- mode: default_mode,
..ModeInfo::default()
},
- default_mode,
session_state,
);
loop {
diff --git a/zellij-server/src/tab.rs b/zellij-server/src/tab.rs
index 68e7b7a6..f3b30fe3 100644
--- a/zellij-server/src/tab.rs
+++ b/zellij-server/src/tab.rs
@@ -24,9 +24,12 @@ use std::{
cmp::Reverse,
collections::{BTreeMap, HashSet},
};
-use zellij_tile::data::{Event, InputMode, ModeInfo, Palette};
+use zellij_tile::data::{Event, ModeInfo, Palette};
use zellij_utils::{
- input::{layout::Layout, parse_keys},
+ input::{
+ layout::{Layout, Run},
+ parse_keys,
+ },
pane_size::PositionAndSize,
shared::adjust_to_size,
};
@@ -84,7 +87,6 @@ pub(crate) struct Tab {
should_clear_display_before_rendering: bool,
session_state: Arc<RwLock<SessionState>>,
pub mode_info: ModeInfo,
- pub input_mode: InputMode,
pub colors: Palette,
}
@@ -96,7 +98,6 @@ pub(crate) struct TabData {
pub name: String,
pub active: bool,
pub mode_info: ModeInfo,
- pub input_mode: InputMode,
pub colors: Palette,
}
@@ -257,7 +258,6 @@ impl Tab {
max_panes: Option<usize>,
pane_id: Option<PaneId>,
mode_info: ModeInfo,
- input_mode: InputMode,
colors: Palette,
session_state: Arc<RwLock<SessionState>>,
) -> Self {
@@ -296,7 +296,6 @@ impl Tab {
senders,
should_clear_display_before_rendering: false,
mode_info,
- input_mode,
colors,
session_state,
}
@@ -338,7 +337,7 @@ impl Tab {
let mut new_pids = new_pids.iter();
for (layout, position_and_size) in positions_and_size {
// A plugin pane
- if let Some(plugin) = &layout.plugin {
+ if let Some(Run::Plugin(Some(plugin))) = &layout.run {
let (pid_tx, pid_rx) = channel();
self.senders
.send_to_plugin(PluginInstruction::Load(pid_tx, plugin.clone()))
diff --git a/zellij-server/src/unit/screen_tests.rs b/zellij-server/src/unit/screen_tests.rs
index 173e2ccc..df159dde 100644
--- a/zellij-server/src/unit/screen_tests.rs
+++ b/zellij-server/src/unit/screen_tests.rs
@@ -1,5 +1,5 @@
use super::{Screen, ScreenInstruction};
-use crate::zellij_tile::data::{InputMode, ModeInfo, Palette};
+use crate::zellij_tile::data::{ModeInfo, Palette};
use crate::{
os_input_output::{AsyncReader, Pid, ServerOsApi},
thread_bus::Bus,
@@ -81,16 +81,8 @@ fn create_new_screen(position_and_size: PositionAndSize) -> Screen {
client_attributes.position_and_size = position_and_size;
let max_panes = None;
let mode_info = ModeInfo::default();
- let input_mode = InputMode::Normal;
let session_state = Arc::new(RwLock::new(SessionState::Attached));
- Screen::new(
- bus,
- &client_attributes,
- max_panes,
- mode_info,
- input_mode,
- session_state,
- )
+ Screen::new(bus, &client_attributes, max_panes, mode_info, session_state)
}
#[test]
diff --git a/zellij-server/src/unit/tab_tests.rs b/zellij-server/src/unit/tab_tests.rs
index c19c41ce..cc08a5b1 100644
--- a/zellij-server/src/unit/tab_tests.rs
+++ b/zellij-server/src/unit/tab_tests.rs
@@ -1,5 +1,5 @@
use super::Tab;
-use crate::zellij_tile::data::{InputMode, ModeInfo, Palette};
+use crate::zellij_tile::data::{ModeInfo, Palette};
use crate::{
os_input_output::{AsyncReader, Pid, ServerOsApi},
panes::PaneId,
@@ -82,7 +82,6 @@ fn create_new_tab(position_and_size: PositionAndSize) -> Tab {
let max_panes = None;
let first_pane_id = Some(PaneId::Terminal(1));
let mode_info = ModeInfo::default();
- let input_mode = InputMode::Normal;
let colors = Palette::default();
let session_state = Arc::new(RwLock::new(SessionState::Attached));
Tab::new(
@@ -95,7 +94,6 @@ fn create_new_tab(position_and_size: PositionAndSize) -> Tab {
max_panes,
first_pane_id,
mode_info,
- input_mode,
colors,
session_state,
)