From 8e956876fa9386c7cf010cbc148251d02582982b Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sun, 6 Apr 2025 11:35:25 +0200 Subject: [PATCH] tui/zellij/{module.nix, zellij-good-scrolling.patch}: init --- modules/programs/tui/zellij/module.nix | 12 ++++++++++ .../tui/zellij/zellij-good-scrolling.patch | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 modules/programs/tui/zellij/module.nix create mode 100644 modules/programs/tui/zellij/zellij-good-scrolling.patch diff --git a/modules/programs/tui/zellij/module.nix b/modules/programs/tui/zellij/module.nix new file mode 100644 index 0000000..9ee55df --- /dev/null +++ b/modules/programs/tui/zellij/module.nix @@ -0,0 +1,12 @@ +{pkgs, ...}: let + # I am patching zellij because of this issue: + # https://github.com/zellij-org/zellij/pull/2548 + patched-zellij = pkgs.zellij.overrideAttrs (old: { + patches = [./zellij-good-scrolling.patch]; + doCheck = false; + }); +in { + environment.systemPackages = builtins.attrValues { + inherit patched-zellij; + }; +} diff --git a/modules/programs/tui/zellij/zellij-good-scrolling.patch b/modules/programs/tui/zellij/zellij-good-scrolling.patch new file mode 100644 index 0000000..c7ba14d --- /dev/null +++ b/modules/programs/tui/zellij/zellij-good-scrolling.patch @@ -0,0 +1,22 @@ +--- a/zellij-server/src/panes/grid.rs ++++ b/zellij-server/src/panes/grid.rs +@@ -271,7 +271,7 @@ fn subtract_isize_from_usize(u: usize, i: isize) -> usize { + macro_rules! dump_screen { + ($lines:expr) => {{ + let mut is_first = true; +- let mut buf = "".to_owned(); ++ let mut buf = String::with_capacity($lines.iter().map(|l| l.len()).sum()); + + for line in &$lines { + if line.is_canonical && !is_first { +@@ -280,8 +280,7 @@ macro_rules! dump_screen { + let s: String = (&line.columns).into_iter().map(|x| x.character).collect(); + // Replace the spaces at the end of the line. Sometimes, the lines are + // collected with spaces until the end of the panel. +- let re = Regex::new("([^ ])[ ]*$").unwrap(); +- buf.push_str(&(re.replace(&s, "${1}"))); ++ buf.push_str(&s.trim_end_matches(' ')); + is_first = false; + } + buf +