aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorJonah Caplan <jonahcaplan@gmail.com>2021-03-08 04:06:23 -0500
committerGitHub <noreply@github.com>2021-03-08 10:06:23 +0100
commit44b0246e91ae65b09f3e2d9b111772a6b093135b (patch)
treec1a422e0f9ffb02cb978ae4d5bb68018deb2a998 /src/client
parentNew tab styling (#216) (diff)
downloadsl0ppij-44b0246e91ae65b09f3e2d9b111772a6b093135b.tar.gz
sl0ppij-44b0246e91ae65b09f3e2d9b111772a6b093135b.tar.xz
sl0ppij-44b0246e91ae65b09f3e2d9b111772a6b093135b.zip
feat(tabs): add ability to set tab name (#212)
* send all tabs in vec * works but no input filtering * add event types * add event handler for tab events * fmt fixups * update tab name in place, and escape rename works * rename handle_tab_event handle_tab_rename_keypress * handle empty new_name when renaming * fix(tabs): pad active tab name too * fix(tabs): report proper length * fix(tabs): always render active tab * style(fmt): rustfmt Co-authored-by: Aram Drevekenin <aram@poor.dev>
Diffstat (limited to 'src/client')
-rw-r--r--src/client/layout.rs3
-rw-r--r--src/client/tab.rs26
2 files changed, 26 insertions, 3 deletions
diff --git a/src/client/layout.rs b/src/client/layout.rs
index c032be38..1b383540 100644
--- a/src/client/layout.rs
+++ b/src/client/layout.rs
@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use std::{fs::File, io::prelude::*};
+use crate::common::wasm_vm::EventType;
use crate::panes::PositionAndSize;
fn split_space_to_parts_vertically(
@@ -180,6 +181,8 @@ 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 {
diff --git a/src/client/tab.rs b/src/client/tab.rs
index bf096367..1ef0b720 100644
--- a/src/client/tab.rs
+++ b/src/client/tab.rs
@@ -2,11 +2,13 @@
//! as well as how they should be resized
use crate::common::{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::{layout::Layout, wasm_vm::PluginInstruction};
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,
@@ -51,6 +53,7 @@ fn split_horizontally_with_gap(rect: &PositionAndSize) -> (PositionAndSize, Posi
pub struct Tab {
pub index: usize,
pub position: usize,
+ pub name: String,
panes: BTreeMap<PaneId, Box<dyn Pane>>,
panes_to_hide: HashSet<PaneId>,
active_terminal: Option<PaneId>,
@@ -64,6 +67,14 @@ pub struct Tab {
expansion_boundary: Option<PositionAndSize>,
}
+#[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,
+}
+
// FIXME: Use a struct that has a pane_type enum, to reduce all of the duplication
pub trait Pane {
fn x(&self) -> usize;
@@ -170,6 +181,7 @@ impl Tab {
pub fn new(
index: usize,
position: usize,
+ name: String,
full_screen_ws: &PositionAndSize,
mut os_api: Box<dyn OsApi>,
send_pty_instructions: SenderWithContext<PtyInstruction>,
@@ -195,6 +207,7 @@ impl Tab {
index,
position,
panes,
+ name,
max_panes,
panes_to_hide: HashSet::new(),
active_terminal: pane_id,
@@ -249,7 +262,11 @@ 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()))
+ .send(PluginInstruction::Load(
+ pid_tx,
+ plugin.clone(),
+ layout.events.clone(),
+ ))
.unwrap();
let pid = pid_rx.recv().unwrap();
let new_plugin = PluginPane::new(
@@ -546,7 +563,10 @@ impl Tab {
}
Some(PaneId::Plugin(pid)) => {
self.send_plugin_instructions
- .send(PluginInstruction::Input(pid, input_bytes))
+ .send(PluginInstruction::Input(
+ PluginInputType::Normal(pid),
+ input_bytes,
+ ))
.unwrap();
}
_ => {}