Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(panes): allow specifying coordinates for a new floating pane through the CLI or plugins #3122

Merged
merged 6 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions default-plugins/fixture-plugin-for-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -180,18 +183,22 @@ 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());
},
Key::Ctrl('l') => {
open_terminal_floating(
std::path::PathBuf::from("/path/to/my/file.rs").as_path(),
None,
);
},
Key::Ctrl('m') => {
Expand All @@ -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);
Expand Down
26 changes: 16 additions & 10 deletions default-plugins/strider/src/search/search_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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);
}
Expand Down
24 changes: 24 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -81,6 +97,10 @@ fn main() {
floating,
in_place,
cwd,
x,
y,
width,
height,
})) = opts.command
{
let mut file = file;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -23,6 +23,7 @@ Some(
true,
),
None,
None,
ClientId(
1,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -23,6 +23,7 @@ Some(
false,
),
None,
None,
ClientId(
1,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Some(
Some(
"Editing: /path/to/my/file.rs",
),
None,
ClientId(
1,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -20,6 +20,7 @@ Some(
Some(
"Editing: /path/to/my/file.rs",
),
None,
ClientId(
1,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -22,6 +22,7 @@ Some(
Some(
"Editing: /path/to/my/file.rs",
),
None,
ClientId(
1,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -22,6 +22,7 @@ Some(
Some(
"Editing: /path/to/my/file.rs",
),
None,
ClientId(
1,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -22,6 +22,7 @@ Some(
true,
),
None,
None,
ClientId(
1,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -22,6 +22,7 @@ Some(
false,
),
None,
None,
ClientId(
1,
),
Expand Down
Loading
Loading