aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authordenis <denismaximov98@gmail.com>2021-03-27 14:43:16 +0200
committerdenis <denismaximov98@gmail.com>2021-03-27 14:43:16 +0200
commitb71315b03638c630b2e70dac1b464dd79d84d781 (patch)
tree00b2661efc4306c653ba61e3f7b16ddb3d615076 /src/client
parentwip: scary how messy it is, but it's a start (diff)
parentfeat(plugin): refactored to a new and more general plugin API (diff)
downloadsl0ppij-b71315b03638c630b2e70dac1b464dd79d84d781.tar.gz
sl0ppij-b71315b03638c630b2e70dac1b464dd79d84d781.tar.xz
sl0ppij-b71315b03638c630b2e70dac1b464dd79d84d781.zip
wip: latest plugin system merge in
Diffstat (limited to 'src/client')
-rw-r--r--src/client/boundaries.rs142
-rw-r--r--src/client/layout.rs8
-rw-r--r--src/client/panes/plugin_pane.rs2
-rw-r--r--src/client/panes/terminal_character.rs10
-rw-r--r--src/client/tab.rs189
5 files changed, 163 insertions, 188 deletions
diff --git a/src/client/boundaries.rs b/src/client/boundaries.rs
index e7c2cb03..eb1a5a21 100644
--- a/src/client/boundaries.rs
+++ b/src/client/boundaries.rs
@@ -1,9 +1,9 @@
-use crate::{common::{input::handler::Palette, colors, input::handler::InputMode}, tab::Pane};
+use crate::tab::Pane;
use ansi_term::Colour::RGB;
use std::collections::HashMap;
+use zellij_tile::data::{colors, InputMode, Palette};
use std::fmt::{Display, Error, Formatter};
-
pub mod boundary_type {
pub const TOP_RIGHT: &str = "┐";
pub const VERTICAL: &str = "│";
@@ -50,7 +50,11 @@ impl Display for BoundarySymbol {
match self.invisible {
true => write!(f, " "),
false => match self.color {
- Some(color) => write!(f, "{}", RGB(color.0, color.1, color.2).paint(self.boundary_type)),
+ Some(color) => write!(
+ f,
+ "{}",
+ RGB(color.0, color.1, color.2).paint(self.boundary_type)
+ ),
None => write!(f, "{}", self.boundary_type),
},
}
@@ -75,7 +79,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_RIGHT, boundary_type::VERTICAL) => {
@@ -84,7 +88,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_RIGHT, boundary_type::HORIZONTAL) => {
@@ -93,7 +97,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_RIGHT, boundary_type::TOP_LEFT) => {
@@ -102,7 +106,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_RIGHT, boundary_type::BOTTOM_RIGHT) => {
@@ -111,7 +115,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_RIGHT, boundary_type::BOTTOM_LEFT) => {
@@ -120,7 +124,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_RIGHT, boundary_type::VERTICAL_LEFT) => {
@@ -129,7 +133,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_RIGHT, boundary_type::VERTICAL_RIGHT) => {
@@ -138,7 +142,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_RIGHT, boundary_type::HORIZONTAL_DOWN) => {
@@ -147,7 +151,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_RIGHT, boundary_type::HORIZONTAL_UP) => {
@@ -156,7 +160,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_RIGHT, boundary_type::CROSS) => {
@@ -165,7 +169,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL, boundary_type::HORIZONTAL) => {
@@ -174,7 +178,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL, boundary_type::VERTICAL) => {
@@ -183,7 +187,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL, boundary_type::TOP_LEFT) => {
@@ -192,7 +196,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL, boundary_type::BOTTOM_RIGHT) => {
@@ -201,7 +205,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL, boundary_type::BOTTOM_LEFT) => {
@@ -210,7 +214,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL, boundary_type::VERTICAL_LEFT) => {
@@ -219,7 +223,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL, boundary_type::VERTICAL_RIGHT) => {
@@ -228,7 +232,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL, boundary_type::HORIZONTAL_DOWN) => {
@@ -237,7 +241,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL, boundary_type::HORIZONTAL_UP) => {
@@ -246,7 +250,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL, boundary_type::CROSS) => {
@@ -255,7 +259,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL, boundary_type::VERTICAL) => {
@@ -264,7 +268,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL, boundary_type::TOP_LEFT) => {
@@ -273,7 +277,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL, boundary_type::BOTTOM_RIGHT) => {
@@ -282,7 +286,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL, boundary_type::BOTTOM_LEFT) => {
@@ -291,7 +295,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL, boundary_type::VERTICAL_LEFT) => {
@@ -300,7 +304,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL, boundary_type::VERTICAL_RIGHT) => {
@@ -309,7 +313,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL, boundary_type::HORIZONTAL_DOWN) => {
@@ -318,7 +322,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL, boundary_type::HORIZONTAL_UP) => {
@@ -327,7 +331,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL, boundary_type::CROSS) => {
@@ -336,7 +340,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_LEFT, boundary_type::TOP_LEFT) => {
@@ -345,7 +349,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_LEFT, boundary_type::BOTTOM_RIGHT) => {
@@ -354,7 +358,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_LEFT, boundary_type::BOTTOM_LEFT) => {
@@ -363,7 +367,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_LEFT, boundary_type::VERTICAL_LEFT) => {
@@ -372,7 +376,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_LEFT, boundary_type::VERTICAL_RIGHT) => {
@@ -381,7 +385,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_LEFT, boundary_type::HORIZONTAL_DOWN) => {
@@ -390,7 +394,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_LEFT, boundary_type::HORIZONTAL_UP) => {
@@ -399,7 +403,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::TOP_LEFT, boundary_type::CROSS) => {
@@ -408,7 +412,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_RIGHT, boundary_type::BOTTOM_RIGHT) => {
@@ -417,7 +421,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_RIGHT, boundary_type::BOTTOM_LEFT) => {
@@ -426,7 +430,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_RIGHT, boundary_type::VERTICAL_LEFT) => {
@@ -435,7 +439,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_RIGHT, boundary_type::VERTICAL_RIGHT) => {
@@ -444,7 +448,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_RIGHT, boundary_type::HORIZONTAL_DOWN) => {
@@ -453,7 +457,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_RIGHT, boundary_type::HORIZONTAL_UP) => {
@@ -462,7 +466,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_RIGHT, boundary_type::CROSS) => {
@@ -471,7 +475,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_LEFT, boundary_type::BOTTOM_LEFT) => {
@@ -480,7 +484,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_LEFT, boundary_type::VERTICAL_LEFT) => {
@@ -489,7 +493,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_LEFT, boundary_type::VERTICAL_RIGHT) => {
@@ -498,7 +502,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_LEFT, boundary_type::HORIZONTAL_DOWN) => {
@@ -507,7 +511,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_LEFT, boundary_type::HORIZONTAL_UP) => {
@@ -516,7 +520,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::BOTTOM_LEFT, boundary_type::CROSS) => {
@@ -525,7 +529,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL_LEFT, boundary_type::VERTICAL_LEFT) => {
@@ -534,7 +538,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL_LEFT, boundary_type::VERTICAL_RIGHT) => {
@@ -543,7 +547,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL_LEFT, boundary_type::HORIZONTAL_DOWN) => {
@@ -552,7 +556,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL_LEFT, boundary_type::HORIZONTAL_UP) => {
@@ -561,7 +565,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL_LEFT, boundary_type::CROSS) => {
@@ -570,7 +574,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL_RIGHT, boundary_type::VERTICAL_RIGHT) => {
@@ -579,7 +583,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL_RIGHT, boundary_type::HORIZONTAL_DOWN) => {
@@ -588,7 +592,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL_RIGHT, boundary_type::HORIZONTAL_UP) => {
@@ -597,7 +601,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::VERTICAL_RIGHT, boundary_type::CROSS) => {
@@ -606,7 +610,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL_DOWN, boundary_type::HORIZONTAL_DOWN) => {
@@ -615,7 +619,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL_DOWN, boundary_type::HORIZONTAL_UP) => {
@@ -624,7 +628,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL_DOWN, boundary_type::CROSS) => {
@@ -633,7 +637,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL_UP, boundary_type::HORIZONTAL_UP) => {
@@ -642,7 +646,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::HORIZONTAL_UP, boundary_type::CROSS) => {
@@ -651,7 +655,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(boundary_type::CROSS, boundary_type::CROSS) => {
@@ -660,7 +664,7 @@ fn combine_symbols(
Some(BoundarySymbol {
boundary_type,
invisible,
- color: color,
+ color,
})
}
(_, _) => None,
diff --git a/src/client/layout.rs b/src/client/layout.rs
index 1b383540..2d1daaf4 100644
--- a/src/client/layout.rs
+++ b/src/client/layout.rs
@@ -1,10 +1,8 @@
-use crate::utils::consts::ZELLIJ_ROOT_LAYOUT_DIR;
use directories_next::ProjectDirs;
use serde::{Deserialize, Serialize};
-use std::path::{Path, PathBuf};
+use std::path::PathBuf;
use std::{fs::File, io::prelude::*};
-use crate::common::wasm_vm::EventType;
use crate::panes::PositionAndSize;
fn split_space_to_parts_vertically(
@@ -181,19 +179,15 @@ pub struct Layout {
pub plugin: Option<PathBuf>,
#[serde(default)]
pub expansion_boundary: bool,
- #[serde(default, skip_serializing_if = "Vec::is_empty")]
- pub events: Vec<EventType>,
}
impl Layout {
pub fn new(layout_path: PathBuf) -> Self {
let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
let layout_dir = project_dirs.data_dir().join("layouts/");
- let root_layout_dir = Path::new(ZELLIJ_ROOT_LAYOUT_DIR);
let mut layout_file = File::open(&layout_path)
.or_else(|_| File::open(&layout_path.with_extension("yaml")))
.or_else(|_| File::open(&layout_dir.join(&layout_path).with_extension("yaml")))
- .or_else(|_| File::open(root_layout_dir.join(&layout_path).with_extension("yaml")))
.unwrap_or_else(|_| panic!("cannot find layout {}", &layout_path.display()));
let mut layout = String::new();
diff --git a/src/client/panes/plugin_pane.rs b/src/client/panes/plugin_pane.rs
index 588cffd6..4cffff5f 100644
--- a/src/client/panes/plugin_pane.rs
+++ b/src/client/panes/plugin_pane.rs
@@ -120,7 +120,7 @@ impl Pane for PluginPane {
let (buf_tx, buf_rx) = channel();
self.send_plugin_instructions
- .send(PluginInstruction::Draw(
+ .send(PluginInstruction::Render(
buf_tx,
self.pid,
self.rows(),
diff --git a/src/client/panes/terminal_character.rs b/src/client/panes/terminal_character.rs
index 80c3162b..053ebd3f 100644
--- a/src/client/panes/terminal_character.rs
+++ b/src/client/panes/terminal_character.rs
@@ -23,7 +23,7 @@ pub enum AnsiCode {
On,
Reset,
NamedColor(NamedColor),
- RGBCode((u8, u8, u8)),
+ RgbCode((u8, u8, u8)),
ColorIndex(u8),
}
@@ -336,7 +336,7 @@ impl CharacterStyles {
[36, ..] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::Cyan))),
[37, ..] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::White))),
[38, 2, ..] => {
- let ansi_code = AnsiCode::RGBCode((
+ let ansi_code = AnsiCode::RgbCode((
*ansi_params.get(2).unwrap() as u8,
*ansi_params.get(3).unwrap() as u8,
*ansi_params.get(4).unwrap() as u8,
@@ -364,7 +364,7 @@ impl CharacterStyles {
[46, ..] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::Cyan))),
[47, ..] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::White))),
[48, 2, ..] => {
- let ansi_code = AnsiCode::RGBCode((
+ let ansi_code = AnsiCode::RgbCode((
*ansi_params.get(2).unwrap() as u8,
*ansi_params.get(3).unwrap() as u8,
*ansi_params.get(4).unwrap() as u8,
@@ -416,7 +416,7 @@ impl Display for CharacterStyles {
}
if let Some(ansi_code) = self.foreground {
match ansi_code {
- AnsiCode::RGBCode((r, g, b)) => {
+ AnsiCode::RgbCode((r, g, b)) => {
write!(f, "\u{1b}[38;2;{};{};{}m", r, g, b)?;
}
AnsiCode::ColorIndex(color_index) => {
@@ -433,7 +433,7 @@ impl Display for CharacterStyles {
};
if let Some(ansi_code) = self.background {
match ansi_code {
- AnsiCode::RGBCode((r, g, b)) => {
+ AnsiCode::RgbCode((r, g, b)) => {
write!(f, "\u{1b}[48;2;{};{};{}m", r, g, b)?;
}
AnsiCode::ColorIndex(color_index) => {
diff --git a/src/client/tab.rs b/src/client/tab.rs
index 56970851..d5a190f4 100644
--- a/src/client/tab.rs
+++ b/src/client/tab.rs
@@ -1,23 +1,20 @@
//! `Tab`s holds multiple panes. It tracks their coordinates (x/y) and size,
//! as well as how they should be resized
-use crate::common::{AppInstruction, SenderWithContext, input::handler::{Palette, InputMode}};
+use crate::common::{input::handler::parse_keys, AppInstruction, SenderWithContext};
use crate::layout::Layout;
use crate::panes::{PaneId, PositionAndSize, TerminalPane};
use crate::pty_bus::{PtyInstruction, VteEvent};
-use crate::wasm_vm::{PluginInputType, PluginInstruction};
-use crate::{
- boundaries::Boundaries,
- panes::PluginPane,
-};
+use crate::wasm_vm::PluginInstruction;
+use crate::{boundaries::Boundaries, panes::PluginPane};
use crate::{os_input_output::OsApi, utils::shared::pad_to_size};
-use serde::{Deserialize, Serialize};
use std::os::unix::io::RawFd;
use std::{
cmp::Reverse,
collections::{BTreeMap, HashSet},
};
use std::{io::Write, sync::mpsc::channel};
+use zellij_tile::data::{colors, Event, InputMode, Palette};
const CURSOR_HEIGHT_WIDTH_RATIO: usize = 4; // this is not accurate and kind of a magic number, TODO: look into this
const MIN_TERMINAL_HEIGHT: usize = 2;
@@ -69,15 +66,7 @@ pub struct Tab {
pub send_app_instructions: SenderWithContext<AppInstruction>,
expansion_boundary: Option<PositionAndSize>,
pub input_mode: InputMode,
- pub colors: Palette
-}
-
-#[derive(Clone, Debug, Default, Serialize, Deserialize)]
-pub struct TabData {
- /* subset of fields to publish to plugins */
- pub position: usize,
- pub name: String,
- pub active: bool,
+ pub colors: Palette,
}
// FIXME: Use a struct that has a pane_type enum, to reduce all of the duplication
@@ -195,7 +184,7 @@ impl Tab {
max_panes: Option<usize>,
pane_id: Option<PaneId>,
input_mode: InputMode,
- colors: Palette
+ colors: Palette,
) -> Self {
let panes = if let Some(PaneId::Terminal(pid)) = pane_id {
let new_terminal = TerminalPane::new(pid, *full_screen_ws);
@@ -226,7 +215,7 @@ impl Tab {
send_plugin_instructions,
expansion_boundary: None,
input_mode,
- colors
+ colors,
}
}
@@ -271,11 +260,7 @@ impl Tab {
if let Some(plugin) = &layout.plugin {
let (pid_tx, pid_rx) = channel();
self.send_plugin_instructions
- .send(PluginInstruction::Load(
- pid_tx,
- plugin.clone(),
- layout.events.clone(),
- ))
+ .send(PluginInstruction::Load(pid_tx, plugin.clone()))
.unwrap();
let pid = pid_rx.recv().unwrap();
let new_plugin = PluginPane::new(
@@ -314,7 +299,6 @@ impl Tab {
self.toggle_active_pane_fullscreen();
}
if !self.has_panes() {
- // FIXME: This could use a second look
if let PaneId::Terminal(term_pid) = pid {
let new_terminal = TerminalPane::new(term_pid, self.full_screen_ws);
self.os_api.set_terminal_size_using_fd(
@@ -365,7 +349,6 @@ impl Tab {
if terminal_to_split.rows() * CURSOR_HEIGHT_WIDTH_RATIO > terminal_to_split.columns()
&& terminal_to_split.rows() > terminal_to_split.min_height() * 2
{
- // FIXME: This could use a second look
if let PaneId::Terminal(term_pid) = pid {
let (top_winsize, bottom_winsize) = split_horizontally_with_gap(&terminal_ws);
let new_terminal = TerminalPane::new(term_pid, bottom_winsize);
@@ -386,7 +369,6 @@ impl Tab {
self.active_terminal = Some(pid);
}
} else if terminal_to_split.columns() > terminal_to_split.min_width() * 2 {
- // FIXME: This could use a second look
if let PaneId::Terminal(term_pid) = pid {
let (left_winsize, right_winsize) = split_vertically_with_gap(&terminal_ws);
let new_terminal = TerminalPane::new(term_pid, right_winsize);
@@ -416,7 +398,6 @@ impl Tab {
self.toggle_active_pane_fullscreen();
}
if !self.has_panes() {
- // FIXME: This could use a second look
if let PaneId::Terminal(term_pid) = pid {
let new_terminal = TerminalPane::new(term_pid, self.full_screen_ws);
self.os_api.set_terminal_size_using_fd(
@@ -427,47 +408,44 @@ impl Tab {
self.panes.insert(pid, Box::new(new_terminal));
self.active_terminal = Some(pid);
}
- } else {
- // FIXME: This could use a second look
- if let PaneId::Terminal(term_pid) = pid {
- // TODO: check minimum size of active terminal
- let active_pane_id = &self.get_active_pane_id().unwrap();
- let active_pane = self.panes.get_mut(active_pane_id).unwrap();
- if active_pane.rows() < MIN_TERMINAL_HEIGHT * 2 + 1 {
- self.send_pty_instructions
- .send(PtyInstruction::ClosePane(pid)) // we can't open this pane, close the pty
- .unwrap();
- return;
- }
- let terminal_ws = PositionAndSize {
- x: active_pane.x(),
- y: active_pane.y(),
- rows: active_pane.rows(),
- columns: active_pane.columns(),
- };
- let (top_winsize, bottom_winsize) = split_horizontally_with_gap(&terminal_ws);
+ } else if let PaneId::Terminal(term_pid) = pid {
+ // TODO: check minimum size of active terminal
+ let active_pane_id = &self.get_active_pane_id().unwrap();
+ let active_pane = self.panes.get_mut(active_pane_id).unwrap();
+ if active_pane.rows() < MIN_TERMINAL_HEIGHT * 2 + 1 {
+ self.send_pty_instructions
+ .send(PtyInstruction::ClosePane(pid)) // we can't open this pane, close the pty
+ .unwrap();
+ return;
+ }
+ let terminal_ws = PositionAndSize {
+ x: active_pane.x(),
+ y: active_pane.y(),
+ rows: active_pane.rows(),
+ columns: active_pane.columns(),
+ };
+ let (top_winsize, bottom_winsize) = split_horizontally_with_gap(&terminal_ws);
+
+ active_pane.change_pos_and_size(&top_winsize);
- active_pane.change_pos_and_size(&top_winsize);
+ let new_terminal = TerminalPane::new(term_pid, bottom_winsize);
+ self.os_api.set_terminal_size_using_fd(
+ new_terminal.pid,
+ bottom_winsize.columns as u16,
+ bottom_winsize.rows as u16,
+ );
+ self.panes.insert(pid, Box::new(new_terminal));
- let new_terminal = TerminalPane::new(term_pid, bottom_winsize);
+ if let PaneId::Terminal(active_terminal_pid) = active_pane_id {
self.os_api.set_terminal_size_using_fd(
- new_terminal.pid,
- bottom_winsize.columns as u16,
- bottom_winsize.rows as u16,
+ *active_terminal_pid,
+ top_winsize.columns as u16,
+ top_winsize.rows as u16,
);
- self.panes.insert(pid, Box::new(new_terminal));
-
- if let PaneId::Terminal(active_terminal_pid) = active_pane_id {
- self.os_api.set_terminal_size_using_fd(
- *active_terminal_pid,
- top_winsize.columns as u16,
- top_winsize.rows as u16,
- );
- }
-
- self.active_terminal = Some(pid);
- self.render();
}
+
+ self.active_terminal = Some(pid);
+ self.render();
}
}
pub fn vertical_split(&mut self, pid: PaneId) {
@@ -476,7 +454,6 @@ impl Tab {
self.toggle_active_pane_fullscreen();
}
if !self.has_panes() {
- // FIXME: This could use a second look
if let PaneId::Terminal(term_pid) = pid {
let new_terminal = TerminalPane::new(term_pid, self.full_screen_ws);
self.os_api.set_terminal_size_using_fd(
@@ -487,47 +464,44 @@ impl Tab {
self.panes.insert(pid, Box::new(new_terminal));
self.active_terminal = Some(pid);
}
- } else {
- // FIXME: This could use a second look
- if let PaneId::Terminal(term_pid) = pid {
- // TODO: check minimum size of active terminal
- let active_pane_id = &self.get_active_pane_id().unwrap();
- let active_pane = self.panes.get_mut(active_pane_id).unwrap();
- if active_pane.columns() < MIN_TERMINAL_WIDTH * 2 + 1 {
- self.send_pty_instructions
- .send(PtyInstruction::ClosePane(pid)) // we can't open this pane, close the pty
- .unwrap();
- return;
- }
- let terminal_ws = PositionAndSize {
- x: active_pane.x(),
- y: active_pane.y(),
- rows: active_pane.rows(),
- columns: active_pane.columns(),
- };
- let (left_winsize, right_winsize) = split_vertically_with_gap(&terminal_ws);
+ } else if let PaneId::Terminal(term_pid) = pid {
+ // TODO: check minimum size of active terminal
+ let active_pane_id = &self.get_active_pane_id().unwrap();
+ let active_pane = self.panes.get_mut(active_pane_id).unwrap();
+ if active_pane.columns() < MIN_TERMINAL_WIDTH * 2 + 1 {
+ self.send_pty_instructions
+ .send(PtyInstruction::ClosePane(pid)) // we can't open this pane, close the pty
+ .unwrap();
+ return;
+ }
+ let terminal_ws = PositionAndSize {
+ x: active_pane.x(),
+ y: active_pane.y(),
+ rows: active_pane.rows(),
+ columns: active_pane.columns(),
+ };
+ let (left_winsize, right_winsize) = split_vertically_with_gap(&terminal_ws);
- active_pane.change_pos_and_size(&left_winsize);
+ active_pane.change_pos_and_size(&left_winsize);
- let new_terminal = TerminalPane::new(term_pid, right_winsize);
+ let new_terminal = TerminalPane::new(term_pid, right_winsize);
+ self.os_api.set_terminal_size_using_fd(
+ new_terminal.pid,
+ right_winsize.columns as u16,
+ right_winsize.rows as u16,
+ );
+ self.panes.insert(pid, Box::new(new_terminal));
+
+ if let PaneId::Terminal(active_terminal_pid) = active_pane_id {
self.os_api.set_terminal_size_using_fd(
- new_terminal.pid,
- right_winsize.columns as u16,
- right_winsize.rows as u16,
+ *active_terminal_pid,
+ left_winsize.columns as u16,
+ left_winsize.rows as u16,
);
- self.panes.insert(pid, Box::new(new_terminal));
-
- if let PaneId::Terminal(active_terminal_pid) = active_pane_id {
- self.os_api.set_terminal_size_using_fd(
- *active_terminal_pid,
- left_winsize.columns as u16,
- left_winsize.rows as u16,
- );
- }
-
- self.active_terminal = Some(pid);
- self.render();
}
+
+ self.active_terminal = Some(pid);
+ self.render();
}
}
pub fn get_active_pane(&self) -> Option<&dyn Pane> {
@@ -571,12 +545,11 @@ impl Tab {
.expect("failed to drain terminal");
}
Some(PaneId::Plugin(pid)) => {
- self.send_plugin_instructions
- .send(PluginInstruction::Input(
- PluginInputType::Normal(pid),
- input_bytes,
- ))
- .unwrap();
+ for key in parse_keys(&input_bytes) {
+ self.send_plugin_instructions
+ .send(PluginInstruction::Update(Some(pid), Event::KeyPress(key)))
+ .unwrap()
+ }
}
_ => {}
}
@@ -1694,6 +1667,7 @@ impl Tab {
self.reduce_pane_and_surroundings_right(&active_pane_id, count);
}
}
+ self.render();
}
pub fn resize_left(&mut self) {
// TODO: find out by how much we actually reduced and only reduce by that much
@@ -1705,6 +1679,7 @@ impl Tab {
self.reduce_pane_and_surroundings_left(&active_pane_id, count);
}
}
+ self.render();
}
pub fn resize_down(&mut self) {
// TODO: find out by how much we actually reduced and only reduce by that much
@@ -1716,6 +1691,7 @@ impl Tab {
self.reduce_pane_and_surroundings_down(&active_pane_id, count);
}
}
+ self.render();
}
pub fn resize_up(&mut self) {
// TODO: find out by how much we actually reduced and only reduce by that much
@@ -1727,6 +1703,7 @@ impl Tab {
self.reduce_pane_and_surroundings_up(&active_pane_id, count);
}
}
+ self.render();
}
pub fn move_focus(&mut self) {
if !self.has_selectable_panes() {