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