Skip to main content

Mountain/RPC/CocoonService/Terminal/
ResizeTerminal.rs

1#![allow(non_snake_case)]
2
3//! Notify Sky/Wind of new terminal dimensions on `sky://terminal/resize`.
4//! TODO(P1): also call `portable_pty::MasterPty::resize` once the master
5//! handle is stored in `TerminalStateDTO` (requires wrapping in
6//! `Arc<Mutex>`).
7
8use serde_json::json;
9use tauri::Emitter;
10use tonic::{Response, Status};
11
12use crate::{
13	RPC::CocoonService::CocoonServiceImpl,
14	Vine::Generated::{Empty, ResizeTerminalRequest},
15	dev_log,
16};
17
18pub async fn Fn(Service:&CocoonServiceImpl, Request:ResizeTerminalRequest) -> Result<Response<Empty>, Status> {
19	dev_log!(
20		"cocoon",
21		"[CocoonService] resize_terminal: id={} cols={} rows={}",
22		Request.terminal_id,
23		Request.cols,
24		Request.rows
25	);
26
27	let _ = Service.environment.ApplicationHandle.emit(
28		"sky://terminal/resize",
29		json!({ "id": Request.terminal_id, "cols": Request.cols, "rows": Request.rows }),
30	);
31
32	Ok(Response::new(Empty {}))
33}