* WIP: add exaple of permission ui * feat: add request permission ui * feat: add caching permission in memory * feat: add permission check * feat: add file caching * fix: changes request * feat(ui): new status bar mode (#2619) * supermode prototype * fix integration tests * fix tests * style(fmt): rustfmt * docs(changelog): status-bar supermode * fix(rendering): occasional glitches while resizing (#2621) * docs(changelog): resize glitches fix * chore(version): bump development version * Fix colored pane frames in mirrored sessions (#2625) * server/panes/tiled: Fix colored frames in mirrored sessions. Colored frames were previously ignored because they were treated like floating panes when rendering tiled panes. * CHANGELOG: Add PR #2625 * server/tab/unit: Fix unit tests for server. * fix(sessions): use custom lists of adjectives and nouns for generating session names (#2122) * Create custom lists of adjectives and nouns for generating session names * move word lists to const slices * add logic to retry name generation * refactor - reuse the name generator - iterator instead of for loop --------- Co-authored-by: Thomas Linford <linford.t@gmail.com> * docs(changelog): generate session names with custom words list * feat(plugins): make plugins configurable (#2646) * work * make every plugin entry point configurable * make integration tests pass * make e2e tests pass * add test for plugin configuration * add test snapshot * add plugin config parsing test * cleanups * style(fmt): rustfmt * style(comment): remove commented code * docs(changelog): configurable plugins * style(fmt): rustfmt * touch up ui * fix: don't save permission data in memory * feat: load cached permission * test: add example test (WIP) * fix: issue event are always denied * test: update snapshot * apply formatting * refactor: update default cache function * test: add more new test * apply formatting * Revert "apply formatting" This reverts commit a4e93703fbfdb6865131daa1c8b90fc5c36ab25e. * apply format * fix: update cache path * apply format * fix: cache path * fix: update log level * test for github workflow * Revert "test for github workflow" This reverts commit 01eff3bc5d1627a4e60bc6dac8ebe5500bc5b56e. * refactor: permission cache * fix(test): permission grant/deny race condition * style(fmt): rustfmt * style(fmt): rustfmt * configure permissions * permission denied test * snapshot * add ui for small plugins * style(fmt): rustfmt * some cleanups --------- Co-authored-by: Aram Drevekenin <aram@poor.dev> Co-authored-by: har7an <99636919+har7an@users.noreply.github.com> Co-authored-by: Kyle Sutherland-Cash <kyle.sutherlandcash@gmail.com> Co-authored-by: Thomas Linford <linford.t@gmail.com> Co-authored-by: Thomas Linford <tlinford@users.noreply.github.com>
122 lines
4.3 KiB
Rust
122 lines
4.3 KiB
Rust
pub mod actions;
|
|
pub mod command;
|
|
pub mod config;
|
|
pub mod keybinds;
|
|
pub mod layout;
|
|
pub mod options;
|
|
pub mod permission;
|
|
pub mod plugins;
|
|
pub mod theme;
|
|
|
|
// Can't use this in wasm due to dependency on the `termwiz` crate.
|
|
#[cfg(not(target_family = "wasm"))]
|
|
pub mod mouse;
|
|
|
|
#[cfg(not(target_family = "wasm"))]
|
|
pub use not_wasm::*;
|
|
|
|
#[cfg(not(target_family = "wasm"))]
|
|
mod not_wasm {
|
|
use crate::{
|
|
data::{CharOrArrow, Direction, InputMode, Key, ModeInfo, PluginCapabilities},
|
|
envs,
|
|
ipc::ClientAttributes,
|
|
};
|
|
use termwiz::input::{InputEvent, InputParser, KeyCode, KeyEvent, Modifiers};
|
|
|
|
/// Creates a [`ModeInfo`] struct indicating the current [`InputMode`] and its keybinds
|
|
/// (as pairs of [`String`]s).
|
|
pub fn get_mode_info(
|
|
mode: InputMode,
|
|
attributes: &ClientAttributes,
|
|
capabilities: PluginCapabilities,
|
|
) -> ModeInfo {
|
|
let keybinds = attributes.keybinds.to_keybinds_vec();
|
|
let session_name = envs::get_session_name().ok();
|
|
|
|
ModeInfo {
|
|
mode,
|
|
keybinds,
|
|
style: attributes.style,
|
|
capabilities,
|
|
session_name,
|
|
}
|
|
}
|
|
|
|
pub fn parse_keys(input_bytes: &[u8]) -> Vec<Key> {
|
|
let mut ret = vec![];
|
|
let mut input_parser = InputParser::new(); // this is the termwiz InputParser
|
|
let maybe_more = false;
|
|
let parse_input_event = |input_event: InputEvent| {
|
|
if let InputEvent::Key(key_event) = input_event {
|
|
ret.push(cast_termwiz_key(key_event, input_bytes));
|
|
}
|
|
};
|
|
input_parser.parse(input_bytes, parse_input_event, maybe_more);
|
|
ret
|
|
}
|
|
|
|
// FIXME: This is an absolutely cursed function that should be destroyed as soon
|
|
// as an alternative that doesn't touch zellij-tile can be developed...
|
|
pub fn cast_termwiz_key(event: KeyEvent, raw_bytes: &[u8]) -> Key {
|
|
let modifiers = event.modifiers;
|
|
|
|
// *** THIS IS WHERE WE SHOULD WORK AROUND ISSUES WITH TERMWIZ ***
|
|
if raw_bytes == [8] {
|
|
return Key::Ctrl('h');
|
|
};
|
|
|
|
match event.key {
|
|
KeyCode::Char(c) => {
|
|
if modifiers.contains(Modifiers::CTRL) {
|
|
Key::Ctrl(c.to_lowercase().next().unwrap_or_default())
|
|
} else if modifiers.contains(Modifiers::ALT) {
|
|
Key::Alt(CharOrArrow::Char(c))
|
|
} else {
|
|
Key::Char(c)
|
|
}
|
|
},
|
|
KeyCode::Backspace => Key::Backspace,
|
|
KeyCode::LeftArrow | KeyCode::ApplicationLeftArrow => {
|
|
if modifiers.contains(Modifiers::ALT) {
|
|
Key::Alt(CharOrArrow::Direction(Direction::Left))
|
|
} else {
|
|
Key::Left
|
|
}
|
|
},
|
|
KeyCode::RightArrow | KeyCode::ApplicationRightArrow => {
|
|
if modifiers.contains(Modifiers::ALT) {
|
|
Key::Alt(CharOrArrow::Direction(Direction::Right))
|
|
} else {
|
|
Key::Right
|
|
}
|
|
},
|
|
KeyCode::UpArrow | KeyCode::ApplicationUpArrow => {
|
|
if modifiers.contains(Modifiers::ALT) {
|
|
//Key::AltPlusUpArrow
|
|
Key::Alt(CharOrArrow::Direction(Direction::Up))
|
|
} else {
|
|
Key::Up
|
|
}
|
|
},
|
|
KeyCode::DownArrow | KeyCode::ApplicationDownArrow => {
|
|
if modifiers.contains(Modifiers::ALT) {
|
|
Key::Alt(CharOrArrow::Direction(Direction::Down))
|
|
} else {
|
|
Key::Down
|
|
}
|
|
},
|
|
KeyCode::Home => Key::Home,
|
|
KeyCode::End => Key::End,
|
|
KeyCode::PageUp => Key::PageUp,
|
|
KeyCode::PageDown => Key::PageDown,
|
|
KeyCode::Tab => Key::BackTab, // TODO: ???
|
|
KeyCode::Delete => Key::Delete,
|
|
KeyCode::Insert => Key::Insert,
|
|
KeyCode::Function(n) => Key::F(n),
|
|
KeyCode::Escape => Key::Esc,
|
|
KeyCode::Enter => Key::Char('\n'),
|
|
_ => Key::Esc, // there are other keys we can implement here, but we might need additional terminal support to implement them, not just exhausting this enum
|
|
}
|
|
}
|
|
}
|