Deduplicate the WASM interface structs
This commit is contained in:
parent
3e10e34575
commit
06bce9a1fd
17 changed files with 111 additions and 130 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -2258,7 +2258,6 @@ dependencies = [
|
||||||
"strip-ansi-escapes",
|
"strip-ansi-escapes",
|
||||||
"structopt",
|
"structopt",
|
||||||
"strum",
|
"strum",
|
||||||
"strum_macros",
|
|
||||||
"termion_temporary_zellij_fork",
|
"termion_temporary_zellij_fork",
|
||||||
"termios",
|
"termios",
|
||||||
"toml",
|
"toml",
|
||||||
|
|
@ -2268,6 +2267,7 @@ dependencies = [
|
||||||
"walkdir",
|
"walkdir",
|
||||||
"wasmer",
|
"wasmer",
|
||||||
"wasmer-wasi",
|
"wasmer-wasi",
|
||||||
|
"zellij-tile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -2276,4 +2276,6 @@ version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"strum",
|
||||||
|
"strum_macros",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -27,17 +27,17 @@ signal-hook = "0.1.10"
|
||||||
strip-ansi-escapes = "0.1.0"
|
strip-ansi-escapes = "0.1.0"
|
||||||
structopt = "0.3"
|
structopt = "0.3"
|
||||||
# termion = { git = "https://gitlab.com/TheLostLambda/termion.git", version = "1.6.0", features = ["serde"] }
|
# termion = { git = "https://gitlab.com/TheLostLambda/termion.git", version = "1.6.0", features = ["serde"] }
|
||||||
termion = { package = "termion_temporary_zellij_fork" , version = "1.6.0", features = ["serde"]}
|
termion = { package = "termion_temporary_zellij_fork", version = "1.6.0", features = ["serde"]}
|
||||||
termios = "0.3"
|
termios = "0.3"
|
||||||
unicode-truncate = "0.2.0"
|
unicode-truncate = "0.2.0"
|
||||||
unicode-width = "0.1.8"
|
unicode-width = "0.1.8"
|
||||||
vte = "0.8.0"
|
vte = "0.8.0"
|
||||||
strum = "0.20.0"
|
strum = "0.20.0"
|
||||||
strum_macros = "0.20.0"
|
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
wasmer = "1.0.0"
|
wasmer = "1.0.0"
|
||||||
wasmer-wasi = "1.0.0"
|
wasmer-wasi = "1.0.0"
|
||||||
interprocess = "1.0.1"
|
interprocess = "1.0.1"
|
||||||
|
zellij-tile = { path = "zellij-tile/", version = "0.5.0" }
|
||||||
|
|
||||||
[dependencies.async-std]
|
[dependencies.async-std]
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use colored::*;
|
use colored::*;
|
||||||
use std::fmt::{Display, Error, Formatter};
|
use std::fmt::{Display, Error, Formatter};
|
||||||
use zellij_tile::*;
|
use zellij_tile::prelude::*;
|
||||||
|
|
||||||
// for more of these, copy paste from: https://en.wikipedia.org/wiki/Box-drawing_character
|
// for more of these, copy paste from: https://en.wikipedia.org/wiki/Box-drawing_character
|
||||||
static ARROW_SEPARATOR: &str = " ";
|
static ARROW_SEPARATOR: &str = " ";
|
||||||
|
|
@ -152,7 +152,7 @@ fn key_path(help: &Help) -> LinePart {
|
||||||
len,
|
len,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
InputMode::Normal | _ => {
|
InputMode::Normal => {
|
||||||
let key_path = superkey_text.on_green();
|
let key_path = superkey_text.on_green();
|
||||||
let separator = ARROW_SEPARATOR.green().on_black();
|
let separator = ARROW_SEPARATOR.green().on_black();
|
||||||
(
|
(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ mod state;
|
||||||
use colored::*;
|
use colored::*;
|
||||||
use state::{FsEntry, State};
|
use state::{FsEntry, State};
|
||||||
use std::{cmp::min, fs::read_dir};
|
use std::{cmp::min, fs::read_dir};
|
||||||
use zellij_tile::*;
|
use zellij_tile::prelude::*;
|
||||||
|
|
||||||
register_tile!(State);
|
register_tile!(State);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
mod line;
|
mod line;
|
||||||
mod tab;
|
mod tab;
|
||||||
|
|
||||||
use zellij_tile::*;
|
use zellij_tile::prelude::*;
|
||||||
|
|
||||||
use crate::line::tab_line;
|
use crate::line::tab_line;
|
||||||
use crate::tab::tab_style;
|
use crate::tab::tab_style;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ use crate::pty_bus::{PtyInstruction, VteEvent};
|
||||||
use crate::wasm_vm::{PluginInputType, PluginInstruction};
|
use crate::wasm_vm::{PluginInputType, PluginInstruction};
|
||||||
use crate::{boundaries::Boundaries, panes::PluginPane};
|
use crate::{boundaries::Boundaries, panes::PluginPane};
|
||||||
use crate::{os_input_output::OsApi, utils::shared::pad_to_size};
|
use crate::{os_input_output::OsApi, utils::shared::pad_to_size};
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::os::unix::io::RawFd;
|
use std::os::unix::io::RawFd;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::Reverse,
|
cmp::Reverse,
|
||||||
|
|
@ -67,14 +66,6 @@ pub struct Tab {
|
||||||
expansion_boundary: Option<PositionAndSize>,
|
expansion_boundary: Option<PositionAndSize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
|
||||||
pub struct TabData {
|
|
||||||
/* subset of fields to publish to plugins */
|
|
||||||
pub position: usize,
|
|
||||||
pub name: String,
|
|
||||||
pub active: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Use a struct that has a pane_type enum, to reduce all of the duplication
|
// FIXME: Use a struct that has a pane_type enum, to reduce all of the duplication
|
||||||
pub trait Pane {
|
pub trait Pane {
|
||||||
fn x(&self) -> usize;
|
fn x(&self) -> usize;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//! Definition of the actions that can be bound to keys.
|
//! Definition of the actions that can be bound to keys.
|
||||||
|
|
||||||
use super::handler;
|
use zellij_tile::data::InputMode;
|
||||||
|
|
||||||
/// The four directions (left, right, up, down).
|
/// The four directions (left, right, up, down).
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
@ -19,7 +19,7 @@ pub enum Action {
|
||||||
/// Write to the terminal.
|
/// Write to the terminal.
|
||||||
Write(Vec<u8>),
|
Write(Vec<u8>),
|
||||||
/// Switch to the specified input mode.
|
/// Switch to the specified input mode.
|
||||||
SwitchToMode(handler::InputMode),
|
SwitchToMode(InputMode),
|
||||||
/// Resize focus pane in specified direction.
|
/// Resize focus pane in specified direction.
|
||||||
Resize(Direction),
|
Resize(Direction),
|
||||||
/// Switch focus to next pane in specified direction.
|
/// Switch focus to next pane in specified direction.
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,8 @@ use crate::screen::ScreenInstruction;
|
||||||
use crate::wasm_vm::{EventType, PluginInputType, PluginInstruction};
|
use crate::wasm_vm::{EventType, PluginInputType, PluginInstruction};
|
||||||
use crate::CommandIsExecuting;
|
use crate::CommandIsExecuting;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use strum_macros::EnumIter;
|
|
||||||
use termion::input::TermReadEventsAndRaw;
|
use termion::input::TermReadEventsAndRaw;
|
||||||
|
use zellij_tile::data::{Help, InputMode};
|
||||||
|
|
||||||
use super::keybinds::key_to_actions;
|
use super::keybinds::key_to_actions;
|
||||||
|
|
||||||
|
|
@ -269,42 +268,6 @@ impl InputHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Describes the different input modes, which change the way that keystrokes will be interpreted.
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, EnumIter, Serialize, Deserialize)]
|
|
||||||
pub enum InputMode {
|
|
||||||
/// In `Normal` mode, input is always written to the terminal, except for one special input that
|
|
||||||
/// triggers the switch to [`InputMode::Command`] mode.
|
|
||||||
Normal,
|
|
||||||
/// In `Command` mode, input is bound to actions (more precisely, sequences of actions).
|
|
||||||
/// `Command` mode gives access to the other modes non-`InputMode::Normal` modes.
|
|
||||||
/// etc.
|
|
||||||
Command,
|
|
||||||
/// `Resize` mode allows resizing the different existing panes.
|
|
||||||
Resize,
|
|
||||||
/// `Pane` mode allows creating and closing panes, as well as moving between them.
|
|
||||||
Pane,
|
|
||||||
/// `Tab` mode allows creating and closing tabs, as well as moving between them.
|
|
||||||
Tab,
|
|
||||||
/// `Scroll` mode allows scrolling up and down within a pane.
|
|
||||||
Scroll,
|
|
||||||
RenameTab,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Represents the contents of the help message that is printed in the status bar,
|
|
||||||
/// which indicates the current [`InputMode`] and what the keybinds for that mode
|
|
||||||
/// are. Related to the default `status-bar` plugin.
|
|
||||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct Help {
|
|
||||||
pub mode: InputMode,
|
|
||||||
pub keybinds: Vec<(String, String)>, // <shortcut> => <shortcut description>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for InputMode {
|
|
||||||
fn default() -> InputMode {
|
|
||||||
InputMode::Normal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a [`Help`] struct indicating the current [`InputMode`] and its keybinds
|
/// Creates a [`Help`] struct indicating the current [`InputMode`] and its keybinds
|
||||||
/// (as pairs of [`String`]s).
|
/// (as pairs of [`String`]s).
|
||||||
// TODO this should probably be automatically generated in some way
|
// TODO this should probably be automatically generated in some way
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
//! Mapping of inputs to sequences of actions.
|
//! Mapping of inputs to sequences of actions.
|
||||||
|
|
||||||
use super::actions::{Action, Direction};
|
use super::actions::{Action, Direction};
|
||||||
use super::handler::InputMode;
|
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
use termion::event::Key;
|
use termion::event::Key;
|
||||||
|
use zellij_tile::data::*;
|
||||||
|
|
||||||
type Keybinds = HashMap<InputMode, ModeKeybinds>;
|
type Keybinds = HashMap<InputMode, ModeKeybinds>;
|
||||||
type ModeKeybinds = HashMap<Key, Vec<Action>>;
|
type ModeKeybinds = HashMap<Key, Vec<Action>>;
|
||||||
|
|
|
||||||
|
|
@ -16,27 +16,26 @@ use std::thread;
|
||||||
use std::{cell::RefCell, sync::mpsc::TrySendError};
|
use std::{cell::RefCell, sync::mpsc::TrySendError};
|
||||||
use std::{collections::HashMap, fs};
|
use std::{collections::HashMap, fs};
|
||||||
|
|
||||||
use crate::panes::PaneId;
|
|
||||||
use directories_next::ProjectDirs;
|
|
||||||
use input::handler::InputMode;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use termion::input::TermRead;
|
|
||||||
use wasm_vm::PluginEnv;
|
|
||||||
use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value};
|
|
||||||
use wasmer_wasi::{Pipe, WasiState};
|
|
||||||
|
|
||||||
use crate::cli::CliArgs;
|
use crate::cli::CliArgs;
|
||||||
use crate::layout::Layout;
|
use crate::layout::Layout;
|
||||||
|
use crate::panes::PaneId;
|
||||||
use command_is_executing::CommandIsExecuting;
|
use command_is_executing::CommandIsExecuting;
|
||||||
|
use directories_next::ProjectDirs;
|
||||||
use errors::{AppContext, ContextType, ErrorContext, PluginContext, PtyContext, ScreenContext};
|
use errors::{AppContext, ContextType, ErrorContext, PluginContext, PtyContext, ScreenContext};
|
||||||
use input::handler::input_loop;
|
use input::handler::input_loop;
|
||||||
use os_input_output::OsApi;
|
use os_input_output::OsApi;
|
||||||
use pty_bus::{PtyBus, PtyInstruction};
|
use pty_bus::{PtyBus, PtyInstruction};
|
||||||
use screen::{Screen, ScreenInstruction};
|
use screen::{Screen, ScreenInstruction};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use termion::input::TermRead;
|
||||||
use utils::consts::{ZELLIJ_IPC_PIPE, ZELLIJ_ROOT_PLUGIN_DIR};
|
use utils::consts::{ZELLIJ_IPC_PIPE, ZELLIJ_ROOT_PLUGIN_DIR};
|
||||||
|
use wasm_vm::PluginEnv;
|
||||||
use wasm_vm::{
|
use wasm_vm::{
|
||||||
wasi_stdout, wasi_write_string, zellij_imports, EventType, PluginInputType, PluginInstruction,
|
wasi_stdout, wasi_write_string, zellij_imports, EventType, PluginInputType, PluginInstruction,
|
||||||
};
|
};
|
||||||
|
use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value};
|
||||||
|
use wasmer_wasi::{Pipe, WasiState};
|
||||||
|
use zellij_tile::data::InputMode;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub enum ApiCommand {
|
pub enum ApiCommand {
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,12 @@ use super::{AppInstruction, SenderWithContext};
|
||||||
use crate::os_input_output::OsApi;
|
use crate::os_input_output::OsApi;
|
||||||
use crate::panes::PositionAndSize;
|
use crate::panes::PositionAndSize;
|
||||||
use crate::pty_bus::{PtyInstruction, VteEvent};
|
use crate::pty_bus::{PtyInstruction, VteEvent};
|
||||||
use crate::tab::{Tab, TabData};
|
use crate::tab::Tab;
|
||||||
use crate::{errors::ErrorContext, wasm_vm::PluginInstruction};
|
use crate::{errors::ErrorContext, wasm_vm::PluginInstruction};
|
||||||
use crate::{layout::Layout, panes::PaneId};
|
use crate::{layout::Layout, panes::PaneId};
|
||||||
|
|
||||||
|
use zellij_tile::data::TabData;
|
||||||
|
|
||||||
/// Instructions that can be sent to the [`Screen`].
|
/// Instructions that can be sent to the [`Screen`].
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum ScreenInstruction {
|
pub enum ScreenInstruction {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use crate::tab::TabData;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
|
|
@ -6,6 +5,7 @@ use std::{
|
||||||
};
|
};
|
||||||
use wasmer::{imports, Function, ImportObject, Store, WasmerEnv};
|
use wasmer::{imports, Function, ImportObject, Store, WasmerEnv};
|
||||||
use wasmer_wasi::WasiEnv;
|
use wasmer_wasi::WasiEnv;
|
||||||
|
use zellij_tile::data::TabData;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
input::handler::get_help, pty_bus::PtyInstruction, screen::ScreenInstruction, AppInstruction,
|
input::handler::get_help, pty_bus::PtyInstruction, screen::ScreenInstruction, AppInstruction,
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,6 @@ license = "MIT"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
strum = "0.20.0"
|
||||||
|
strum_macros = "0.20.0"
|
||||||
68
zellij-tile/src/data.rs
Normal file
68
zellij-tile/src/data.rs
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use strum_macros::EnumIter;
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum Key {
|
||||||
|
Backspace,
|
||||||
|
Left,
|
||||||
|
Right,
|
||||||
|
Up,
|
||||||
|
Down,
|
||||||
|
Home,
|
||||||
|
End,
|
||||||
|
PageUp,
|
||||||
|
PageDown,
|
||||||
|
BackTab,
|
||||||
|
Delete,
|
||||||
|
Insert,
|
||||||
|
F(u8),
|
||||||
|
Char(char),
|
||||||
|
Alt(char),
|
||||||
|
Ctrl(char),
|
||||||
|
Null,
|
||||||
|
Esc,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Describes the different input modes, which change the way that keystrokes will be interpreted.
|
||||||
|
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, EnumIter, Serialize, Deserialize)]
|
||||||
|
pub enum InputMode {
|
||||||
|
/// In `Normal` mode, input is always written to the terminal, except for one special input that
|
||||||
|
/// triggers the switch to [`InputMode::Command`] mode.
|
||||||
|
Normal,
|
||||||
|
/// In `Command` mode, input is bound to actions (more precisely, sequences of actions).
|
||||||
|
/// `Command` mode gives access to the other modes non-`InputMode::Normal` modes.
|
||||||
|
/// etc.
|
||||||
|
Command,
|
||||||
|
/// `Resize` mode allows resizing the different existing panes.
|
||||||
|
Resize,
|
||||||
|
/// `Pane` mode allows creating and closing panes, as well as moving between them.
|
||||||
|
Pane,
|
||||||
|
/// `Tab` mode allows creating and closing tabs, as well as moving between them.
|
||||||
|
Tab,
|
||||||
|
/// `Scroll` mode allows scrolling up and down within a pane.
|
||||||
|
Scroll,
|
||||||
|
RenameTab,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for InputMode {
|
||||||
|
fn default() -> InputMode {
|
||||||
|
InputMode::Normal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Represents the contents of the help message that is printed in the status bar,
|
||||||
|
/// which indicates the current [`InputMode`] and what the keybinds for that mode
|
||||||
|
/// are. Related to the default `status-bar` plugin.
|
||||||
|
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct Help {
|
||||||
|
pub mode: InputMode,
|
||||||
|
pub keybinds: Vec<(String, String)>, // <shortcut> => <shortcut description>
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
pub struct TabData {
|
||||||
|
/* subset of fields to publish to plugins */
|
||||||
|
pub position: usize,
|
||||||
|
pub name: String,
|
||||||
|
pub active: bool,
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
mod shim;
|
pub mod data;
|
||||||
|
pub mod prelude;
|
||||||
|
pub mod shim;
|
||||||
|
|
||||||
|
use data::*;
|
||||||
|
|
||||||
pub use shim::*;
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
pub trait ZellijTile {
|
pub trait ZellijTile {
|
||||||
fn load(&mut self) {}
|
fn load(&mut self) {}
|
||||||
|
|
@ -34,14 +37,16 @@ macro_rules! register_tile {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn handle_key() {
|
pub fn handle_key() {
|
||||||
STATE.with(|state| {
|
STATE.with(|state| {
|
||||||
state.borrow_mut().handle_key($crate::get_key());
|
state.borrow_mut().handle_key($crate::shim::get_key());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn handle_global_key() {
|
pub fn handle_global_key() {
|
||||||
STATE.with(|state| {
|
STATE.with(|state| {
|
||||||
state.borrow_mut().handle_global_key($crate::get_key());
|
state
|
||||||
|
.borrow_mut()
|
||||||
|
.handle_global_key($crate::shim::get_key());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,7 +62,7 @@ macro_rules! register_tile {
|
||||||
STATE.with(|state| {
|
STATE.with(|state| {
|
||||||
state
|
state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.handle_tab_rename_keypress($crate::get_key());
|
.handle_tab_rename_keypress($crate::shim::get_key());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
3
zellij-tile/src/prelude.rs
Normal file
3
zellij-tile/src/prelude.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
pub use crate::data::*;
|
||||||
|
pub use crate::shim::*;
|
||||||
|
pub use crate::*;
|
||||||
|
|
@ -1,61 +1,7 @@
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::de::DeserializeOwned;
|
||||||
use std::{io, path::Path};
|
use std::{io, path::Path};
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
use crate::data::*;
|
||||||
pub enum Key {
|
|
||||||
Backspace,
|
|
||||||
Left,
|
|
||||||
Right,
|
|
||||||
Up,
|
|
||||||
Down,
|
|
||||||
Home,
|
|
||||||
End,
|
|
||||||
PageUp,
|
|
||||||
PageDown,
|
|
||||||
BackTab,
|
|
||||||
Delete,
|
|
||||||
Insert,
|
|
||||||
F(u8),
|
|
||||||
Char(char),
|
|
||||||
Alt(char),
|
|
||||||
Ctrl(char),
|
|
||||||
Null,
|
|
||||||
Esc,
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: use same struct from main crate?
|
|
||||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct Help {
|
|
||||||
pub mode: InputMode,
|
|
||||||
pub keybinds: Vec<(String, String)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: use same struct from main crate?
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
||||||
pub enum InputMode {
|
|
||||||
Normal,
|
|
||||||
Command,
|
|
||||||
Resize,
|
|
||||||
Pane,
|
|
||||||
Tab,
|
|
||||||
RenameTab,
|
|
||||||
Scroll,
|
|
||||||
Exiting,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
||||||
pub struct TabData {
|
|
||||||
/* subset of fields to publish to plugins */
|
|
||||||
pub position: usize,
|
|
||||||
pub name: String,
|
|
||||||
pub active: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for InputMode {
|
|
||||||
fn default() -> InputMode {
|
|
||||||
InputMode::Normal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_key() -> Key {
|
pub fn get_key() -> Key {
|
||||||
deserialize_from_stdin().unwrap()
|
deserialize_from_stdin().unwrap()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue