summaryrefslogtreecommitdiffstats
path: root/zellij-server/src/ui
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2022-11-21 20:07:24 +0100
committerGitHub <noreply@github.com>2022-11-21 20:07:24 +0100
commit63e7531c48f1c8fbe916e3ac5475cf36201f52b8 (patch)
tree534e56cf9cf2924cec94a32bef1b6bcf92760209 /zellij-server/src/ui
parent5ad0429adc3bbb33b2578d3e699f2e61d6d0b940 (diff)
performance(rendering): improve rendering performance (#1960)
* refactor(plugins): plugins now need to explicitly ask to be rendered * performance(render): remove various needless renders * performance(render): cache boundaries * performance(render): adjust tests and cache cursor location/shape * style(comment): remove outdated * style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/ui')
-rw-r--r--zellij-server/src/ui/boundaries.rs22
-rw-r--r--zellij-server/src/ui/pane_contents_and_ui.rs33
2 files changed, 39 insertions, 16 deletions
diff --git a/zellij-server/src/ui/boundaries.rs b/zellij-server/src/ui/boundaries.rs
index c0827c24e..2ba3e67e5 100644
--- a/zellij-server/src/ui/boundaries.rs
+++ b/zellij-server/src/ui/boundaries.rs
@@ -27,10 +27,10 @@ pub mod boundary_type {
pub const CROSS: &str = "┼";
}
-pub(crate) type BoundaryType = &'static str; // easy way to refer to boundary_type above
+pub type BoundaryType = &'static str; // easy way to refer to boundary_type above
-#[derive(Clone, Copy, Debug)]
-pub(crate) struct BoundarySymbol {
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub struct BoundarySymbol {
boundary_type: BoundaryType,
invisible: bool,
color: Option<PaletteColor>,
@@ -420,7 +420,7 @@ fn combine_symbols(
}
#[derive(PartialEq, Eq, Hash, Debug)]
-pub(crate) struct Coordinates {
+pub struct Coordinates {
x: usize,
y: usize,
}
@@ -433,7 +433,7 @@ impl Coordinates {
pub struct Boundaries {
viewport: Viewport,
- boundary_characters: HashMap<Coordinates, BoundarySymbol>,
+ pub boundary_characters: HashMap<Coordinates, BoundarySymbol>,
}
impl Boundaries {
@@ -540,9 +540,19 @@ impl Boundaries {
}
}
}
- pub fn render(&self) -> Result<Vec<CharacterChunk>> {
+ pub fn render(
+ &self,
+ existing_boundaries_on_screen: Option<&Boundaries>,
+ ) -> Result<Vec<CharacterChunk>> {
let mut character_chunks = vec![];
for (coordinates, boundary_character) in &self.boundary_characters {
+ let already_on_screen = existing_boundaries_on_screen
+ .and_then(|e| e.boundary_characters.get(coordinates))
+ .map(|e| e == boundary_character)
+ .unwrap_or(false);
+ if already_on_screen {
+ continue;
+ }
character_chunks.push(CharacterChunk::new(
vec![boundary_character
.as_terminal_character()
diff --git a/zellij-server/src/ui/pane_contents_and_ui.rs b/zellij-server/src/ui/pane_contents_and_ui.rs
index 946d9f681..1cc715d83 100644
--- a/zellij-server/src/ui/pane_contents_and_ui.rs
+++ b/zellij-server/src/ui/pane_contents_and_ui.rs
@@ -65,15 +65,17 @@ impl<'a> PaneContentsAndUi<'a> {
self.z_index,
);
if let Some(raw_vte_output) = raw_vte_output {
- self.output.add_post_vte_instruction_to_multiple_clients(
- clients.iter().copied(),
- &format!(
- "\u{1b}[{};{}H\u{1b}[m{}",
- self.pane.y() + 1,
- self.pane.x() + 1,
- raw_vte_output
- ),
- );
+ if !raw_vte_output.is_empty() {
+ self.output.add_post_vte_instruction_to_multiple_clients(
+ clients.iter().copied(),
+ &format!(
+ "\u{1b}[{};{}H\u{1b}[m{}",
+ self.pane.y() + 1,
+ self.pane.x() + 1,
+ raw_vte_output
+ ),
+ );
+ }
}
}
Ok(())
@@ -140,11 +142,22 @@ impl<'a> PaneContentsAndUi<'a> {
}
Ok(())
}
- pub fn render_terminal_title_if_needed(&mut self, client_id: ClientId, client_mode: InputMode) {
+ pub fn render_terminal_title_if_needed(
+ &mut self,
+ client_id: ClientId,
+ client_mode: InputMode,
+ previous_title: &mut Option<String>,
+ ) {
if !self.focused_clients.contains(&client_id) {
return;
}
let vte_output = self.pane.render_terminal_title(client_mode);
+ if let Some(previous_title) = previous_title {
+ if *previous_title == vte_output {
+ return;
+ }
+ }
+ *previous_title = Some(vte_output.clone());
self.output
.add_post_vte_instruction_to_client(client_id, &vte_output);
}