aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authordenis <denismaximov98@gmail.com>2021-03-17 10:05:43 +0200
committerdenis <denismaximov98@gmail.com>2021-03-17 10:05:43 +0200
commit448c426c2b8ca925f2a8016171988a5c824f66d3 (patch)
tree610d3f367fc78bdf73e37343118892f78c3f05ad /src/client
parentwip: need to debug somehow (diff)
parentPerformance: only render panes that should be updated (#234) (diff)
downloadsl0ppij-448c426c2b8ca925f2a8016171988a5c824f66d3.tar.gz
sl0ppij-448c426c2b8ca925f2a8016171988a5c824f66d3.tar.xz
sl0ppij-448c426c2b8ca925f2a8016171988a5c824f66d3.zip
Merge branch 'main' into focused-pane
Diffstat (limited to 'src/client')
-rw-r--r--src/client/layout.rs3
-rw-r--r--src/client/panes/terminal_pane.rs31
-rw-r--r--src/client/tab.rs30
3 files changed, 33 insertions, 31 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/panes/terminal_pane.rs b/src/client/panes/terminal_pane.rs
index fd83d571..9fa70d11 100644
--- a/src/client/panes/terminal_pane.rs
+++ b/src/client/panes/terminal_pane.rs
@@ -70,13 +70,11 @@ impl Pane for TerminalPane {
fn reset_size_and_position_override(&mut self) {
self.position_and_size_override = None;
self.reflow_lines();
- self.mark_for_rerender();
}
fn change_pos_and_size(&mut self, position_and_size: &PositionAndSize) {
self.position_and_size.columns = position_and_size.columns;
self.position_and_size.rows = position_and_size.rows;
self.reflow_lines();
- self.mark_for_rerender();
}
fn override_size_and_position(&mut self, x: usize, y: usize, size: &PositionAndSize) {
let position_and_size_override = PositionAndSize {
@@ -87,7 +85,6 @@ impl Pane for TerminalPane {
};
self.position_and_size_override = Some(position_and_size_override);
self.reflow_lines();
- self.mark_for_rerender();
}
fn handle_event(&mut self, event: VteEvent) {
match event {
@@ -191,12 +188,7 @@ impl Pane for TerminalPane {
self.max_height
}
fn render(&mut self) -> Option<String> {
- // if self.should_render {
- if true {
- // while checking should_render rather than rendering each pane every time
- // is more performant, it causes some problems when the pane to the left should be
- // rendered and has wide characters (eg. Chinese characters or emoji)
- // as a (hopefully) temporary hack, we render all panes until we find a better solution
+ if self.should_render || cfg!(test) {
let mut vte_output = String::new();
let buffer_lines = &self.read_buffer_as_lines();
let display_cols = self.get_columns();
@@ -205,12 +197,11 @@ impl Pane for TerminalPane {
for line_index in 0..self.grid.height {
let x = self.get_x();
let y = self.get_y();
- vte_output = format!(
- "{}\u{1b}[{};{}H\u{1b}[m",
- vte_output,
+ vte_output.push_str(&format!(
+ "\u{1b}[{};{}H\u{1b}[m",
y + line_index + 1,
x + 1
- ); // goto row/col and reset styles
+ )); // goto row/col and reset styles
for _col_index in 0..self.grid.width {
vte_output.push(EMPTY_TERMINAL_CHARACTER.character);
}
@@ -220,7 +211,7 @@ impl Pane for TerminalPane {
for (row, line) in buffer_lines.iter().enumerate() {
let x = self.get_x();
let y = self.get_y();
- vte_output = format!("{}\u{1b}[{};{}H\u{1b}[m", vte_output, y + row + 1, x + 1); // goto row/col and reset styles
+ vte_output.push_str(&format!("\u{1b}[{};{}H\u{1b}[m", y + row + 1, x + 1)); // goto row/col and reset styles
for (col, t_character) in line.iter().enumerate() {
if col < display_cols {
// in some cases (eg. while resizing) some characters will spill over
@@ -232,14 +223,14 @@ impl Pane for TerminalPane {
// the terminal keeps the previous styles as long as we're in the same
// line, so we only want to update the new styles here (this also
// includes resetting previous styles as needed)
- vte_output = format!("{}{}", vte_output, new_styles);
+ vte_output.push_str(&new_styles.to_string());
}
vte_output.push(t_character.character);
}
}
character_styles.clear();
}
- self.mark_for_rerender();
+ self.should_render = false;
Some(vte_output)
} else {
None
@@ -252,45 +243,37 @@ impl Pane for TerminalPane {
self.position_and_size.y += count;
self.position_and_size.rows -= count;
self.reflow_lines();
- self.mark_for_rerender();
}
fn increase_height_down(&mut self, count: usize) {
self.position_and_size.rows += count;
self.reflow_lines();
- self.mark_for_rerender();
}
fn increase_height_up(&mut self, count: usize) {
self.position_and_size.y -= count;
self.position_and_size.rows += count;
self.reflow_lines();
- self.mark_for_rerender();
}
fn reduce_height_up(&mut self, count: usize) {
self.position_and_size.rows -= count;
self.reflow_lines();
- self.mark_for_rerender();
}
fn reduce_width_right(&mut self, count: usize) {
self.position_and_size.x += count;
self.position_and_size.columns -= count;
self.reflow_lines();
- self.mark_for_rerender();
}
fn reduce_width_left(&mut self, count: usize) {
self.position_and_size.columns -= count;
self.reflow_lines();
- self.mark_for_rerender();
}
fn increase_width_left(&mut self, count: usize) {
self.position_and_size.x -= count;
self.position_and_size.columns += count;
self.reflow_lines();
- self.mark_for_rerender();
}
fn increase_width_right(&mut self, count: usize) {
self.position_and_size.columns += count;
self.reflow_lines();
- self.mark_for_rerender();
}
fn scroll_up(&mut self, count: usize) {
self.grid.move_viewport_up(count);
diff --git a/src/client/tab.rs b/src/client/tab.rs
index d5c7f896..b7c43cf4 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();
}
_ => {}
@@ -1662,7 +1682,6 @@ impl Tab {
} else if self.can_reduce_pane_and_surroundings_right(&active_pane_id, count) {
self.reduce_pane_and_surroundings_right(&active_pane_id, count);
}
- self.render();
}
}
pub fn resize_left(&mut self) {
@@ -1674,7 +1693,6 @@ impl Tab {
} else if self.can_reduce_pane_and_surroundings_left(&active_pane_id, count) {
self.reduce_pane_and_surroundings_left(&active_pane_id, count);
}
- self.render();
}
}
pub fn resize_down(&mut self) {
@@ -1686,7 +1704,6 @@ impl Tab {
} else if self.can_reduce_pane_and_surroundings_down(&active_pane_id, count) {
self.reduce_pane_and_surroundings_down(&active_pane_id, count);
}
- self.render();
}
}
pub fn resize_up(&mut self) {
@@ -1698,7 +1715,6 @@ impl Tab {
} else if self.can_reduce_pane_and_surroundings_up(&active_pane_id, count) {
self.reduce_pane_and_surroundings_up(&active_pane_id, count);
}
- self.render();
}
}
pub fn move_focus(&mut self) {