diff options
author | Aram Drevekenin <aram@poor.dev> | 2023-06-09 22:49:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-09 22:49:12 +0200 |
commit | 8485b1c2969e7f88feaf2f809b6b405fbe442ba4 (patch) | |
tree | 989148565b8883d9a04e35f795a3f50008c0e1b1 | |
parent | 7f0b87852079f260cc9a834c2dc54eeb002d5879 (diff) |
feat(plugins): extensive plugin api (#2516)
* feat(plugins): add our entire API
* style(fmt): rustfmt
* fix(detach): make it work again
67 files changed, 5430 insertions, 568 deletions
diff --git a/default-plugins/fixture-plugin-for-tests/src/main.rs b/default-plugins/fixture-plugin-for-tests/src/main.rs index 7e4139f55..2107137d1 100644 --- a/default-plugins/fixture-plugin-for-tests/src/main.rs +++ b/default-plugins/fixture-plugin-for-tests/src/main.rs @@ -38,10 +38,10 @@ impl ZellijPlugin for State { fn load(&mut self) { subscribe(&[ EventType::InputReceived, + EventType::Key, EventType::SystemClipboardFailure, EventType::CustomMessage, EventType::FileSystemCreate, - EventType::FileSystemRead, EventType::FileSystemUpdate, EventType::FileSystemDelete, ]); @@ -49,6 +49,142 @@ impl ZellijPlugin for State { fn update(&mut self, event: Event) -> bool { match &event { + Event::Key(key) => match key { + Key::Char('a') => { + switch_to_input_mode(&InputMode::Tab); + }, + Key::Char('b') => { + new_tabs_with_layout( + "layout { + tab { + pane + pane + } + tab split_direction=\"vertical\" { + pane + pane + } + }", + ); + }, + Key::Char('c') => new_tab(), + Key::Char('d') => go_to_next_tab(), + Key::Char('e') => go_to_previous_tab(), + Key::Char('f') => { + let resize = Resize::Increase; + resize_focused_pane(resize) + }, + Key::Char('g') => { + let resize = Resize::Increase; + let direction = Direction::Left; + resize_focused_pane_with_direction(resize, direction); + }, + Key::Char('h') => focus_next_pane(), + Key::Char('i') => focus_previous_pane(), + Key::Char('j') => { + let direction = Direction::Left; + move_focus(direction) + }, + Key::Char('k') => { + let direction = Direction::Left; + move_focus_or_tab(direction) + }, + Key::Char('l') => detach(), + Key::Char('m') => edit_scrollback(), + Key::Char('n') => { + let bytes = vec![102, 111, 111]; + write(bytes) + }, + Key::Char('o') => { + let chars = "foo"; + write_chars(chars); + }, + Key::Char('p') => toggle_tab(), + Key::Char('q') => move_pane(), + Key::Char('r') => { + let direction = Direction::Left; + move_pane_with_direction(direction) + }, + Key::Char('s') => clear_screen(), + Key::Char('t') => scroll_up(), + Key::Char('u') => scroll_down(), + Key::Char('v') => scroll_to_top(), + Key::Char('w') => scroll_to_bottom(), |