Skip to main content

Mountain/IPC/WindServiceHandlers/UI/
KeybindingAdd.rs

1#![allow(unused_variables)]
2
3//! Wire method: `keybinding:add`.
4
5use std::sync::Arc;
6
7use serde_json::Value;
8
9use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
10
11pub async fn Fn(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
12	let CommandId = Arguments
13		.first()
14		.and_then(|V| V.as_str())
15		.ok_or("keybinding:add requires commandId".to_string())?
16		.to_owned();
17
18	let KeyExpression = Arguments
19		.get(1)
20		.and_then(|V| V.as_str())
21		.ok_or("keybinding:add requires keybinding".to_string())?
22		.to_owned();
23
24	let When = Arguments.get(2).and_then(|V| V.as_str()).map(str::to_owned);
25
26	RunTime
27		.Environment
28		.ApplicationState
29		.Feature
30		.Keybindings
31		.AddKeybinding(CommandId, KeyExpression, When);
32
33	Ok(Value::Null)
34}