Mountain/RPC/CocoonService/GenericRequest/WindowDialogs/ShowTextDocument.rs
1use serde_json::{Value, json};
2use tauri::Emitter;
3use tonic::Response;
4use ::Vine::Generated::GenericResponse;
5
6use crate::Environment::MountainEnvironment::MountainEnvironment;
7
8pub fn Fn(RequestId:u64, Params:Value, Env:&MountainEnvironment) -> Response<GenericResponse> {
9 let Uri = Params
10 .get("uri")
11 .and_then(|V| V.get("value").or(Some(V)))
12 .and_then(|V| V.as_str())
13 .unwrap_or("")
14 .to_string();
15
16 let ViewColumn = Params.get("viewColumn").and_then(|V| V.as_i64()).map(|N| N + 2);
17
18 let PreserveFocus = Params.get("preserveFocus").and_then(|V| V.as_bool()).unwrap_or(false);
19
20 let _ = Env.ApplicationHandle.emit(
21 "sky://editor/openDocument",
22 json!({ "uri": Uri, "viewColumn": ViewColumn, "preserveFocus": PreserveFocus }),
23 );
24
25 super::super::FileSystem::OkResponse(RequestId, &json!({ "success": true }))
26}