summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-02-08 17:35:55 +0100
committerGitHub <noreply@github.com>2024-02-08 17:35:55 +0100
commit326c8cd3c6566e8fa4acd3a9369c718ce96f6625 (patch)
tree805ded9e78a35e9cd1ae91594358c8888a53abe2
parent662c37b5083e2c31d6227645ff5a27ad5d5ceb41 (diff)
feat(panes): allow specifying coordinates for a new floating pane through the CLI or plugins (#3122)
* working * add tests * add coordinates to all the places * refactor: move things around: * style(fmt): rustfmt * style(code): cleanups
-rw-r--r--default-plugins/fixture-plugin-for-tests/src/main.rs38
-rw-r--r--default-plugins/strider/src/search/search_state.rs26
-rw-r--r--src/main.rs24
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_floating_plugin_command.snap3
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_plugin_command.snap3
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_floating_plugin_command.snap1
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_plugin_command.snap3
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_with_line_floating_plugin_command.snap3
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_with_line_plugin_command.snap3
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_terminal_floating_plugin_command.snap3
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_terminal_plugin_command.snap3
-rw-r--r--zellij-server/src/plugins/zellij_exports.rs44
-rw-r--r--zellij-server/src/pty.rs9
-rw-r--r--zellij-server/src/route.rs23
-rw-r--r--zellij-server/src/screen.rs38
-rw-r--r--zellij-server/src/tab/mod.rs23
-rw-r--r--zellij-server/src/tab/unit/tab_integration_tests.rs412
-rw-r--r--zellij-server/src/tab/unit/tab_tests.rs24
-rw-r--r--zellij-server/src/unit/screen_tests.rs142
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_default_parameters.snap4
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_line_number.snap4
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_launch_or_focus_plugin_action.snap3
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_default_parameters.snap4
-rw-r--r--zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_floating_pane_and_coordinates.snap6
-rw-r--r--zellij-tile/src/shim.rs20
-rwxr-xr-xzellij-utils/assets/plugins/compact-bar.wasmbin873526 -> 887621 bytes
-rwxr-xr-xzellij-utils/assets/plugins/fixture-plugin-for-tests.wasmbin857362 -> 873465 bytes
-rwxr-xr-xzellij-utils/assets/plugins/session-manager.wasmbin868274 -> 926195 bytes
-rwxr-xr-xzellij-utils/assets/plugins/status-bar.wasmbin1025354 -> 1029901 bytes
-rwxr-xr-xzellij-utils/assets/plugins/strider.wasmbin2100620 -> 2109959 bytes
-rwxr-xr-xzellij-utils/assets/plugins/tab-bar.wasmbin843400 -> 868307 bytes
-rw-r--r--zellij-utils/assets/prost/api.plugin_command.rs50
-rw-r--r--zellij-utils/src/cli.rs63
-rw-r--r--zellij-utils/src/data.rs89
-rw-r--r--zellij-utils/src/input/actions.rs34
-rw-r--r--zellij-utils/src/input/layout.rs11
-rw-r--r--zellij-utils/src/kdl/mod.rs22
-rw-r--r--zellij-utils/src/pane_size.rs51
-rw-r--r--zellij-utils/src/plugin_api/action.rs23
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.proto19
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.rs187
41 files changed, 1078 insertions, 337 deletions
diff --git a/default-plugins/fixture-plugin-for-tests/src/main.rs b/default-plugins/fixture-plugin-for-tests/src/main.rs
index 17f299435..fe740f740 100644
--- a/default-plugins/fixture-plugin-for-tests/src/main.rs
+++ b/default-plugins/fixture-plugin-for-tests/src/main.rs
@@ -167,10 +167,13 @@ impl ZellijPlugin for State {
});
},
Key::Ctrl('h') => {
- open_file_floating(FileToOpen {
- path: std::path::PathBuf::from("/path/to/my/file.rs"),
- ..Default::default()
- });
+ open_file_floating(
+ FileToOpen {
+ path: std::path::PathBuf::from("/path/to/my/file.rs"),
+ ..Default::default()
+ },
+ None,
+ );
},
Key::Ctrl('i') => {
open_file(FileToOpen {
@@ -180,11 +183,14 @@ impl ZellijPlugin for State {
});
},
Key::Ctrl('j') => {
- open_file_floating(FileToOpen {
- path: std::path::PathBuf::from("/path/to/my/file.rs"),
- line_number: Some(42),
- ..Default::default()
- });
+ open_file_floating(
+ FileToOpen {
+ path: std::path::PathBuf::from("/path/to/my/file.rs"),
+ line_number: Some(42),
+ ..Default::default()
+ },
+ None,
+ );
},
Key::Ctrl('k') => {
open_terminal(std::path::PathBuf::from("/path/to/my/file.rs").as_path());
@@ -192,6 +198,7 @@ impl ZellijPlugin for State {
Key::Ctrl('l') => {
open_terminal_floating(
std::path::PathBuf::from("/path/to/my/file.rs").as_path(),
+ None,
);
},
Key::Ctrl('m') => {
@@ -202,11 +209,14 @@ impl ZellijPlugin for State {
});
},
Key::Ctrl('n') => {
- open_command_pane_floating(CommandToRun {
- path: std::path::PathBuf::from("/path/to/my/file.rs"),
- args: vec!["arg1".to_owned(), "arg2".to_owned()],
- ..Default::default()
- });
+ open_command_pane_floating(
+ CommandToRun {
+ path: std::path::PathBuf::from("/path/to/my/file.rs"),
+ args: vec!["arg1".to_owned(), "arg2".to_owned()],
+ ..Default::default()
+ },
+ None,
+ );
},
Key::Ctrl('o') => {
switch_tab_to(1);
diff --git a/default-plugins/strider/src/search/search_state.rs b/default-plugins/strider/src/search/search_state.rs
index 834a74fe6..60d03941d 100644
--- a/default-plugins/strider/src/search/search_state.rs
+++ b/default-plugins/strider/src/search/search_state.rs
@@ -88,10 +88,13 @@ impl SearchState {
match self.selected_search_result_entry() {
Some(SearchResult::File { path, .. }) => {
if self.should_open_floating {
- open_file_floating(FileToOpen {
- path: PathBuf::from(path),
- ..Default::default()
- });
+ open_file_floating(
+ FileToOpen {
+ path: PathBuf::from(path),
+ ..Default::default()
+ },
+ None,
+ );
} else {
open_file(FileToOpen {
path: PathBuf::from(path),
@@ -103,11 +106,14 @@ impl SearchState {
path, line_number, ..
}) => {
if self.should_open_floating {
- open_file_floating(FileToOpen {
- path: PathBuf::from(path),
- line_number: Some(line_number),
- ..Default::default()
- });
+ open_file_floating(
+ FileToOpen {
+ path: PathBuf::from(path),
+ line_number: Some(line_number),
+ ..Default::default()
+ },
+ None,
+ );
} else {
open_file(FileToOpen {
path: PathBuf::from(path),
@@ -132,7 +138,7 @@ impl SearchState {
{
let dir_path = dir_path_of_result(&path);
if self.should_open_floating {
- open_terminal_floating(&dir_path);
+ open_terminal_floating(&dir_path, None);
} else {
open_terminal(&dir_path);
}
diff --git a/src/main.rs b/src/main.rs
index 30770405e..871d468fe 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,6 +29,10 @@ fn main() {
name,
close_on_exit,
start_suspended,
+ x,
+ y,
+ width,
+ height,
})) = opts.command
{
let cwd = cwd.or_else(|| std::env::current_dir().ok());
@@ -45,6 +49,10 @@ fn main() {
start_suspended,
configuration: None,
skip_plugin_cache,
+ x,
+ y,
+ width,
+ height,
};
commands::send_action_to_session(command_cli_action, opts.session, config);
std::process::exit(0);
@@ -55,6 +63,10 @@ fn main() {
in_place,
configuration,
skip_plugin_cache,
+ x,
+ y,
+ width,
+ height,
})) = opts.command
{
let cwd = std::env::current_dir().ok();
@@ -70,6 +82,10 @@ fn main() {
start_suspended: false,
configuration,
skip_plugin_cache,
+ x,
+ y,
+ width,
+ height,
};
commands::send_action_to_session(command_cli_action, opts.session, config);
std::process::exit(0);
@@ -81,6 +97,10 @@ fn main() {
floating,
in_place,
cwd,
+ x,
+ y,
+ width,
+ height,
})) = opts.command
{
let mut file = file;
@@ -97,6 +117,10 @@ fn main() {
floating,
in_place,
cwd,
+ x,
+ y,
+ width,
+ height,
};
commands::send_action_to_session(command_cli_action, opts.session, config);
std::process::exit(0);
diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_floating_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_floating_plugin_command.snap
index a222f4faf..a1ab04754 100644
--- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_floating_plugin_command.snap
+++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_floating_plugin_command.snap
@@ -1,6 +1,6 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
-assertion_line: 3198
+assertion_line: 4400
expression: "format!(\"{:#?}\", new_tab_event)"
---
Some(
@@ -23,6 +23,7 @@ Some(
true,
),
None,
+ None,
ClientId(
1,
),
diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_plugin_command.snap
index 2807e4952..935f72bbe 100644
--- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_plugin_command.snap
+++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_plugin_command.snap
@@ -1,6 +1,6 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
-assertion_line: 3144
+assertion_line: 4323
expression: "format!(\"{:#?}\", new_tab_event)"
---
Some(
@@ -23,6 +23,7 @@ Some(
false,
),
None,
+ None,
ClientId(
1,
),
diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_floating_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_floating_plugin_command.snap
index daff15fa6..9a1ffe587 100644
--- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_floating_plugin_command.snap
+++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_floating_plugin_command.snap
@@ -20,6 +20,7 @@ Some(
Some(
"Editing: /path/to/my/file.rs",
),
+ None,
ClientId(
1,
),
diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_plugin_command.snap
index f895c55ce..b24094af5 100644
--- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_plugin_command.snap
+++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_plugin_command.snap
@@ -1,6 +1,6 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
-assertion_line: 3925
+assertion_line: 3927
expression: "format!(\"{:#?}\",\n new_tab_event).replace(&format!(\"{:?}\", temp_folder.path()),\n \"\\\"CWD\\\"\")"
---
Some(
@@ -20,6 +20,7 @@ Some(
Some(
"Editing: /path/to/my/file.rs",
),
+ None,
ClientId(
1,
),
diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_with_line_floating_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_with_line_floating_plugin_command.snap
index da0a726e5..dca771df8 100644
--- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_with_line_floating_plugin_command.snap
+++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_with_line_floating_plugin_command.snap
@@ -1,6 +1,6 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
-assertion_line: 4076
+assertion_line: 4090
expression: "format!(\"{:#?}\",\n new_tab_event).replace(&format!(\"{:?}\", temp_folder.path()),\n \"\\\"CWD\\\"\")"
---
Some(
@@ -22,6 +22,7 @@ Some(
Some(
"Editing: /path/to/my/file.rs",
),
+ None,
ClientId(
1,
),
diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_with_line_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_with_line_plugin_command.snap
index ee8feb31a..fd9d8e82e 100644
--- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_with_line_plugin_command.snap
+++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_file_with_line_plugin_command.snap
@@ -1,6 +1,6 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
-assertion_line: 3999
+assertion_line: 4009
expression: "format!(\"{:#?}\",\n new_tab_event).replace(&format!(\"{:?}\", temp_folder.path()),\n \"\\\"CWD\\\"\")"
---
Some(
@@ -22,6 +22,7 @@ Some(
Some(
"Editing: /path/to/my/file.rs",
),
+ None,
ClientId(
1,
),
diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_terminal_floating_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_terminal_floating_plugin_command.snap
index c43958a73..4c752eff9 100644
--- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_terminal_floating_plugin_command.snap
+++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_terminal_floating_plugin_command.snap
@@ -1,6 +1,6 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
-assertion_line: 3090
+assertion_line: 4246
expression: "format!(\"{:#?}\", new_tab_event)"
---
Some(
@@ -22,6 +22,7 @@ Some(
true,
),
None,
+ None,
ClientId(
1,
),
diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_terminal_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_terminal_plugin_command.snap
index 88fdd2edf..7c0fb608b 100644
--- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_terminal_plugin_command.snap
+++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_terminal_plugin_command.snap
@@ -1,6 +1,6 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
-assertion_line: 3036
+assertion_line: 4169
expression: "format!(\"{:#?}\", new_tab_event)"
---
Some(
@@ -22,6 +22,7 @@ Some(
false,
),
None,
+ None,
ClientId(
1,
),
diff --git a/zellij-server/src/plugins/zellij_exports.rs b/zellij-server/src/plugins/zellij_exports.rs
index 4d203afd3..19bac2822 100644
--- a/zellij-server/src/plugins/zellij_exports.rs
+++ b/zellij-server/src/plugins/zellij_exports.rs
@@ -18,8 +18,8 @@ use std::{
use wasmer::{imports, AsStoreMut, Function, FunctionEnv, FunctionEnvMut, Imports};
use wasmer_wasi::WasiEnv;
use zellij_utils::data::{
- CommandType, ConnectToSession, HttpVerb, LayoutInfo, MessageToPlugin, PermissionStatus,
- PermissionType, PluginPermission,
+ CommandType, ConnectToSession, FloatingPaneCoordinates, HttpVerb, LayoutInfo, MessageToPlugin,
+ PermissionStatus, PermissionType, PluginPermission,
};
use zellij_utils::input::permission::PermissionCache;
use zellij_utils::{
@@ -117,19 +117,20 @@ fn host_run_pl