Skip to content

Commit

Permalink
cmd: Add :list-themes and :theme <name>
Browse files Browse the repository at this point in the history
  • Loading branch information
vv9k committed Jun 17, 2021
1 parent 08bfe54 commit 103bd14
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,24 @@ mod cmd {
quit_all_impl(editor, args, event, true)
}

fn theme(editor: &mut Editor, args: &[&str], event: PromptEvent) {
let theme = if let Some(theme) = args.first() {
theme
} else {
editor.set_error("theme name not provided".into());
return;
};

editor.set_theme_from_name(theme);
}

fn list_themes(editor: &mut Editor, args: &[&str], event: PromptEvent) {
let mut themes = editor.theme_loader.as_ref().names();
themes.push("default".into());
let status = format!("Available themes: {}", themes.join(", "));
editor.set_status(status);
}

pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
TypableCommand {
name: "quit",
Expand Down Expand Up @@ -1400,6 +1418,20 @@ mod cmd {
fun: force_quit_all,
completer: None,
},
TypableCommand {
name: "theme",
alias: None,
doc: "Change the theme of current view. Requires theme name as argument (:theme <name>)",
fun: theme,
completer: None,
},
TypableCommand {
name: "list-themes",
alias: None,
doc: "List available themes.",
fun: list_themes,
completer: None,
},

];

Expand Down Expand Up @@ -2812,7 +2844,7 @@ fn hover(cx: &mut Context) {

// skip if contents empty

let contents = ui::Markdown::new(contents);
let contents = ui::Markdown::new(contents, editor.syn_loader.clone());
let mut popup = Popup::new(contents);
compositor.push(Box::new(popup));
}
Expand Down

0 comments on commit 103bd14

Please sign in to comment.