Rename Help to ModeInfo

This commit is contained in:
Brooks J Rady 2021-03-25 14:30:31 +00:00
parent f2f7758384
commit 0ea8ce497d
5 changed files with 11 additions and 11 deletions

View File

@ -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 {
InputMode::Locked => key_indicators(
max_len,

View File

@ -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 {
InputMode::Normal => LinePart::default(),
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 {
InputMode::Normal => LinePart::default(),
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 {
InputMode::Normal => LinePart::default(),
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);
if full_shortcut_list.len <= max_width {
return full_shortcut_list;

View File

@ -11,7 +11,7 @@ use crate::wasm_vm::{NaughtyEventType, PluginInputType, PluginInstruction};
use crate::CommandIsExecuting;
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;
@ -273,7 +273,7 @@ impl InputHandler {
/// Creates a [`Help`] struct indicating the current [`InputMode`] and its keybinds
/// (as pairs of [`String`]s).
// 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![];
match mode {
InputMode::Normal | InputMode::Locked => {}
@ -302,7 +302,7 @@ pub fn get_help(mode: InputMode) -> Help {
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

View File

@ -27,7 +27,7 @@ pub enum Key {
#[strum_discriminants(derive(EnumString, Hash, Serialize, Deserialize))]
#[strum_discriminants(name(EventType))]
pub enum Event {
ModeUpdate(Help), // FIXME: Rename the `Help` struct
ModeUpdate(ModeInfo),
TabUpdate(TabInfo),
KeyPress(Key),
}
@ -62,7 +62,7 @@ impl Default for InputMode {
/// 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 struct ModeInfo {
pub mode: InputMode,
// FIXME: This should probably return Keys and Actions, then sort out strings plugin-side
pub keybinds: Vec<(String, String)>, // <shortcut> => <shortcut description>

View File

@ -36,7 +36,7 @@ pub fn set_selectable(selectable: bool) {
unsafe { host_set_selectable(selectable) };
}
pub fn get_help() -> Help {
pub fn get_help() -> ModeInfo {
unsafe { host_get_help() };
deserialize_from_stdin().unwrap_or_default()
}