Rename Help to ModeInfo
This commit is contained in:
parent
f2f7758384
commit
0ea8ce497d
5 changed files with 11 additions and 11 deletions
|
|
@ -287,7 +287,7 @@ pub fn superkey() -> LinePart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ctrl_keys(help: &Help, max_len: usize) -> LinePart {
|
pub fn ctrl_keys(help: &ModeInfo, max_len: usize) -> LinePart {
|
||||||
match &help.mode {
|
match &help.mode {
|
||||||
InputMode::Locked => key_indicators(
|
InputMode::Locked => key_indicators(
|
||||||
max_len,
|
max_len,
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ fn select_pane_shortcut(is_first_shortcut: bool) -> LinePart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn full_shortcut_list(help: &Help) -> LinePart {
|
fn full_shortcut_list(help: &ModeInfo) -> LinePart {
|
||||||
match help.mode {
|
match help.mode {
|
||||||
InputMode::Normal => LinePart::default(),
|
InputMode::Normal => LinePart::default(),
|
||||||
InputMode::Locked => locked_interface_indication(),
|
InputMode::Locked => locked_interface_indication(),
|
||||||
|
|
@ -116,7 +116,7 @@ fn full_shortcut_list(help: &Help) -> LinePart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shortened_shortcut_list(help: &Help) -> LinePart {
|
fn shortened_shortcut_list(help: &ModeInfo) -> LinePart {
|
||||||
match help.mode {
|
match help.mode {
|
||||||
InputMode::Normal => LinePart::default(),
|
InputMode::Normal => LinePart::default(),
|
||||||
InputMode::Locked => locked_interface_indication(),
|
InputMode::Locked => locked_interface_indication(),
|
||||||
|
|
@ -135,7 +135,7 @@ fn shortened_shortcut_list(help: &Help) -> LinePart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn best_effort_shortcut_list(help: &Help, max_len: usize) -> LinePart {
|
fn best_effort_shortcut_list(help: &ModeInfo, max_len: usize) -> LinePart {
|
||||||
match help.mode {
|
match help.mode {
|
||||||
InputMode::Normal => LinePart::default(),
|
InputMode::Normal => LinePart::default(),
|
||||||
InputMode::Locked => {
|
InputMode::Locked => {
|
||||||
|
|
@ -169,7 +169,7 @@ fn best_effort_shortcut_list(help: &Help, max_len: usize) -> LinePart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn keybinds(help: &Help, max_width: usize) -> LinePart {
|
pub fn keybinds(help: &ModeInfo, max_width: usize) -> LinePart {
|
||||||
let full_shortcut_list = full_shortcut_list(help);
|
let full_shortcut_list = full_shortcut_list(help);
|
||||||
if full_shortcut_list.len <= max_width {
|
if full_shortcut_list.len <= max_width {
|
||||||
return full_shortcut_list;
|
return full_shortcut_list;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use crate::wasm_vm::{NaughtyEventType, PluginInputType, PluginInstruction};
|
||||||
use crate::CommandIsExecuting;
|
use crate::CommandIsExecuting;
|
||||||
|
|
||||||
use termion::input::{TermRead, TermReadEventsAndRaw};
|
use termion::input::{TermRead, TermReadEventsAndRaw};
|
||||||
use zellij_tile::data::{Help, InputMode, Key};
|
use zellij_tile::data::{InputMode, Key, ModeInfo};
|
||||||
|
|
||||||
use super::keybinds::key_to_actions;
|
use super::keybinds::key_to_actions;
|
||||||
|
|
||||||
|
|
@ -273,7 +273,7 @@ impl InputHandler {
|
||||||
/// 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
|
||||||
pub fn get_help(mode: InputMode) -> Help {
|
pub fn get_help(mode: InputMode) -> ModeInfo {
|
||||||
let mut keybinds: Vec<(String, String)> = vec![];
|
let mut keybinds: Vec<(String, String)> = vec![];
|
||||||
match mode {
|
match mode {
|
||||||
InputMode::Normal | InputMode::Locked => {}
|
InputMode::Normal | InputMode::Locked => {}
|
||||||
|
|
@ -302,7 +302,7 @@ pub fn get_help(mode: InputMode) -> Help {
|
||||||
keybinds.push(("Enter".to_string(), "when done".to_string()));
|
keybinds.push(("Enter".to_string(), "when done".to_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Help { mode, keybinds }
|
ModeInfo { mode, keybinds }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Entry point to the module. Instantiates an [`InputHandler`] and starts
|
/// Entry point to the module. Instantiates an [`InputHandler`] and starts
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ pub enum Key {
|
||||||
#[strum_discriminants(derive(EnumString, Hash, Serialize, Deserialize))]
|
#[strum_discriminants(derive(EnumString, Hash, Serialize, Deserialize))]
|
||||||
#[strum_discriminants(name(EventType))]
|
#[strum_discriminants(name(EventType))]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
ModeUpdate(Help), // FIXME: Rename the `Help` struct
|
ModeUpdate(ModeInfo),
|
||||||
TabUpdate(TabInfo),
|
TabUpdate(TabInfo),
|
||||||
KeyPress(Key),
|
KeyPress(Key),
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +62,7 @@ impl Default for InputMode {
|
||||||
/// which indicates the current [`InputMode`] and what the keybinds for that mode
|
/// which indicates the current [`InputMode`] and what the keybinds for that mode
|
||||||
/// are. Related to the default `status-bar` plugin.
|
/// are. Related to the default `status-bar` plugin.
|
||||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Help {
|
pub struct ModeInfo {
|
||||||
pub mode: InputMode,
|
pub mode: InputMode,
|
||||||
// FIXME: This should probably return Keys and Actions, then sort out strings plugin-side
|
// FIXME: This should probably return Keys and Actions, then sort out strings plugin-side
|
||||||
pub keybinds: Vec<(String, String)>, // <shortcut> => <shortcut description>
|
pub keybinds: Vec<(String, String)>, // <shortcut> => <shortcut description>
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ pub fn set_selectable(selectable: bool) {
|
||||||
unsafe { host_set_selectable(selectable) };
|
unsafe { host_set_selectable(selectable) };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_help() -> Help {
|
pub fn get_help() -> ModeInfo {
|
||||||
unsafe { host_get_help() };
|
unsafe { host_get_help() };
|
||||||
deserialize_from_stdin().unwrap_or_default()
|
deserialize_from_stdin().unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue