Skip to main content

Mountain/IPC/WindServiceHandlers/Terminal/
TerminalShow.rs

1#![allow(non_snake_case)]
2
3//! Bring a terminal to the foreground in the panel. When
4//! `PreserveFocus` is `true`, the active editor keeps keyboard
5//! focus (mirrors `vscode.Terminal.show(preserveFocus)`).
6
7use std::sync::Arc;
8
9use CommonLibrary::Terminal::TerminalProvider::TerminalProvider;
10use serde_json::Value;
11
12use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
13
14pub async fn TerminalShow(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
15	let TerminalId = Arguments.first().and_then(|V| V.as_u64()).unwrap_or(0);
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}