summaryrefslogtreecommitdiffstats
path: root/zellij-server/src/unit
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2022-04-12 18:07:32 +0200
committerGitHub <noreply@github.com>2022-04-12 18:07:32 +0200
commit19adb29be516a871620071b289594bacf3d3056c (patch)
tree3ff60c31f6b7fc460089bb5d2da4ad81acc2ec8d /zellij-server/src/unit
parent028885c82273c2f6c7ce080edeba097ca5f5dfa4 (diff)
feat(signals): support XTWINOPS 14 and 16 (and query the terminal for them on startup and SIGWINCH) (#1316)
* feat(signals): get pixel info from terminal emulator * feat(signals): query for pixel info on sigwinch * feat(signals): reply to csi 14t and csi 16t * style(fmt): rustfmt * style(comments): remove outdated
Diffstat (limited to 'zellij-server/src/unit')
-rw-r--r--zellij-server/src/unit/screen_tests.rs82
1 files changed, 80 insertions, 2 deletions
diff --git a/zellij-server/src/unit/screen_tests.rs b/zellij-server/src/unit/screen_tests.rs
index cf9b89b59..333d85b0a 100644
--- a/zellij-server/src/unit/screen_tests.rs
+++ b/zellij-server/src/unit/screen_tests.rs
@@ -12,11 +12,11 @@ use zellij_utils::input::command::TerminalAction;
use zellij_utils::input::layout::LayoutTemplate;
use zellij_utils::input::options::Clipboard;
use zellij_utils::ipc::IpcReceiverWithContext;
-use zellij_utils::pane_size::Size;
+use zellij_utils::pane_size::{Size, SizeInPixels};
use std::os::unix::io::RawFd;
-use zellij_utils::ipc::ClientAttributes;
+use zellij_utils::ipc::{ClientAttributes, PixelDimensions};
use zellij_utils::nix;
use zellij_utils::{
@@ -464,3 +464,81 @@ fn switch_to_tab_with_fullscreen() {
"Active pane is still the fullscreen pane"
);
}
+
+#[test]
+fn update_screen_pixel_dimensions() {
+ let size = Size {
+ cols: 121,
+ rows: 20,
+ };
+ let mut screen = create_new_screen(size);
+ let initial_pixel_dimensions = screen.pixel_dimensions;
+ screen.update_pixel_dimensions(PixelDimensions {
+ character_cell_size: Some(SizeInPixels {
+ height: 10,
+ width: 5,
+ }),
+ text_area_size: None,
+ });
+ let pixel_dimensions_after_first_update = screen.pixel_dimensions;
+ screen.update_pixel_dimensions(PixelDimensions {
+ character_cell_size: None,
+ text_area_size: Some(SizeInPixels {
+ height: 100,
+ width: 50,
+ }),
+ });
+ let pixel_dimensions_after_second_update = screen.pixel_dimensions;
+ screen.update_pixel_dimensions(PixelDimensions {
+ character_cell_size: None,
+ text_area_size: None,
+ });
+ let pixel_dimensions_after_third_update = screen.pixel_dimensions;
+ assert_eq!(
+ initial_pixel_dimensions,
+ PixelDimensions {
+ character_cell_size: None,
+ text_area_size: None
+ },
+ "Initial pixel dimensions empty"
+ );
+ assert_eq!(
+ pixel_dimensions_after_first_update,
+ PixelDimensions {
+ character_cell_size: Some(SizeInPixels {
+ height: 10,
+ width: 5
+ }),
+ text_area_size: None
+ },
+ "character_cell_size updated properly",
+ );
+ assert_eq!(
+ pixel_dimensions_after_second_update,
+ PixelDimensions {
+ character_cell_size: Some(SizeInPixels {
+ height: 10,
+ width: 5
+ }),
+ text_area_size: Some(SizeInPixels {
+ height: 100,
+ width: 50,
+ }),
+ },
+ "text_area_size updated properly without overriding character_cell_size",
+ );
+ assert_eq!(
+ pixel_dimensions_after_third_update,
+ PixelDimensions {
+ character_cell_size: Some(SizeInPixels {
+ height: 10,
+ width: 5
+ }),
+ text_area_size: Some(SizeInPixels {
+ height: 100,
+ width: 50,
+ }),
+ },
+ "empty update does not delete existing data",
+ );
+}