diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-12-16 16:03:20 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-16 16:03:20 +0100 |
| commit | dd291e2a1f9b4ee3eb1a947e1501a54b10663ea7 (patch) | |
| tree | 0ae41e8175d2a3fd260b3c510a30502f6386ac7f /zellij-server/src/output/mod.rs | |
| parent | docs(changelog): multiplayer cursor fix (diff) | |
| download | sl0ppij-dd291e2a1f9b4ee3eb1a947e1501a54b10663ea7.tar.gz sl0ppij-dd291e2a1f9b4ee3eb1a947e1501a54b10663ea7.tar.xz sl0ppij-dd291e2a1f9b4ee3eb1a947e1501a54b10663ea7.zip | |
feat(ux): pin floating panes (#3876)
* working
* ui indication
* add keybinding
* add to plugin panes
* fix with multiple cursors
* toggle with the mouse
* fix e2e tests and add new one
* some cleanups
* add to layouts
* make mouse click more lenient
* allow setting a new floating pane as pinned
* make toggle work throughthe command line
* add to plugin api
* get tests to pass
* style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/output/mod.rs')
| -rw-r--r-- | zellij-server/src/output/mod.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/zellij-server/src/output/mod.rs b/zellij-server/src/output/mod.rs index ccb5f665..32192a20 100644 --- a/zellij-server/src/output/mod.rs +++ b/zellij-server/src/output/mod.rs @@ -449,6 +449,12 @@ impl Output { self.client_character_chunks.values().any(|c| !c.is_empty()) || self.sixel_chunks.values().any(|c| !c.is_empty()) } + pub fn cursor_is_visible(&self, cursor_x: usize, cursor_y: usize) -> bool { + self.floating_panes_stack + .as_ref() + .map(|s| s.cursor_is_visible(cursor_x, cursor_y)) + .unwrap_or(true) + } } // this struct represents the geometry of a group of floating panes @@ -740,6 +746,24 @@ impl FloatingPanesStack { } uncovered_chunks } + pub fn cursor_is_visible(&self, cursor_x: usize, cursor_y: usize) -> bool { + let z_index = 0; // TODO: receive z_index + let panes_to_check = self.layers.iter().skip(z_index); + for pane_geom in panes_to_check { + let pane_top_edge = pane_geom.y; + let pane_left_edge = pane_geom.x; + let pane_bottom_edge = pane_geom.y + pane_geom.rows.as_usize().saturating_sub(1); + let pane_right_edge = pane_geom.x + pane_geom.cols.as_usize().saturating_sub(1); + if pane_top_edge <= cursor_y + && pane_bottom_edge >= cursor_y + && pane_left_edge <= cursor_x + && pane_right_edge >= cursor_x + { + return false; + } + } + true + } } #[derive(Debug, Clone, Default)] |
