Skip to main content

Mountain/IPC/WindServiceHandlers/Output/
OutputAppendLine.rs

1
2//! Append a line (text + `\n`) to an output channel. Twin of
3//! `OutputAppend` with the newline pre-applied so the renderer
4//! doesn't need its own line-mode toggle.
5
6use CommonLibrary::IPC::SkyEvent::SkyEvent;
7use serde_json::{Value, json};
8use tauri::{AppHandle, Emitter};
9
10pub async fn Fn(ApplicationHandle:AppHandle, Arguments:Vec<Value>) -> Result<Value, String> {
11	let ChannelName = Arguments.first().and_then(|V| V.as_str()).unwrap_or("").to_string();
12
13	let Text = Arguments.get(1).and_then(|V| V.as_str()).unwrap_or("").to_string();
14
15	let Line = format!("{}\n", Text);
16
17	let _ = ApplicationHandle.emit(SkyEvent::OutputAppend.AsStr(), json!({ "channel": ChannelName, "text": Line }));
18
19	Ok(Value::Null)
20}