Mountain/IPC/WindServiceHandlers/Terminal/TerminalShow.rs
1
2//! Bring a terminal to the foreground in the panel. When
3//! `PreserveFocus` is `true`, the active editor keeps keyboard
4//! focus (mirrors `vscode.Terminal.show(preserveFocus)`).
5
6use std::sync::Arc;
7
8use CommonLibrary::Terminal::TerminalProvider::TerminalProvider;
9use serde_json::Value;
10
11use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
12
13pub async fn Fn(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
14 let TerminalId = Arguments.first().and_then(|V| V.as_u64()).unwrap_or(0);
15
16 let PreserveFocus = Arguments.get(1).and_then(|V| V.as_bool()).unwrap_or(false);
17
18 RunTime
19 .Environment
20 .ShowTerminal(TerminalId, PreserveFocus)
21 .await
22 .map(|()| Value::Null)
23 .map_err(|Error| format!("terminal:show failed: {}", Error))
24}