-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added support for user-defined keybinding descriptions (#97)
- New TOML keybinding syntax was introduced, which allows specifying optional descriptions for each keybinding, as well as shorter syntax for specifying the operations. - The UI of the help menu has been revamped. It now displays the keybindings hashmap, as well as the env variables, in an ascii table. - A new config setting `keybindings-help-menu-format` has been introduced, which allows users to set exactly which columns should be shown (key, description, operations), and in which order.
- Loading branch information
1 parent
34d3d3a
commit 31856c0
Showing
13 changed files
with
614 additions
and
211 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use anyhow::{Error, Result}; | ||
use derive_more::IntoIterator; | ||
use parse_display::{Display, FromStr}; | ||
use serde::Deserialize; | ||
use std::str; | ||
|
||
/// Specifies which columns should be included in the keybindings help menu, | ||
/// and in what order. | ||
#[derive(Debug, Deserialize, Clone, IntoIterator)] | ||
#[cfg_attr(test, derive(PartialEq))] | ||
pub struct KeybindingsHelpMenuFormat(#[into_iterator(ref)] Vec<KeybindingsHelpMenuColumn>); | ||
|
||
#[derive(Debug, Deserialize, FromStr, Display, Clone)] | ||
#[cfg_attr(test, derive(PartialEq))] | ||
#[serde(rename_all = "kebab-case")] | ||
#[display(style = "kebab-case")] | ||
pub enum KeybindingsHelpMenuColumn { | ||
Key, | ||
Operations, | ||
Description, | ||
} | ||
|
||
// TODO: should get generated by e.g. parse_display directly | ||
impl str::FromStr for KeybindingsHelpMenuFormat { | ||
type Err = Error; | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
let help_menu_columns = s | ||
.split(',') | ||
.map(KeybindingsHelpMenuColumn::from_str) | ||
.collect::<Result<_, _>>()?; | ||
Ok(Self(help_menu_columns)) | ||
} | ||
} |
Oops, something went wrong.