Skip to content

Commit

Permalink
feat(plz): make the defualt selected item configrable
Browse files Browse the repository at this point in the history
  • Loading branch information
0x61nas committed Aug 21, 2023
1 parent 218316a commit ad409ab
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/config/plz_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,23 @@ const CHEATSHEETS_URL_TEMPLATE: &str =

/// Plz menu config.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PlzMenu(pub Vec<PlzMenuItem>);
pub struct PlzMenu {
/// The default selected poison in the menu.
pub selected_pos: PlzMenuSelection,
/// The menu items.
pub items: Vec<PlzMenuItem>,
}

/// Plz menu selection position.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum PlzMenuSelection {
/// The first item in the menu.
Start,
/// The middle item in the menu (in case of even number of items, the first item in the second half).
Center,
/// The last item in the menu.
End,
}

/// Plz menu item.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand All @@ -45,7 +61,9 @@ pub enum PlzMenuOperation {

impl Default for PlzMenu {
fn default() -> Self {
PlzMenu(vec![
PlzMenu{
selected_pos: PlzMenuSelection::Center,
items: vec![
PlzMenuItem {
display_msg: "Show man page".to_string(),
operation: PlzMenuOperation::Command,
Expand All @@ -71,6 +89,6 @@ impl Default for PlzMenu {
operation: PlzMenuOperation::Local,
args: vec!["~/info".to_string()],
},
])
]}
}
}

0 comments on commit ad409ab

Please sign in to comment.