1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4pub type SessionId = String;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct Rgb {
8 pub r: u8,
9 pub g: u8,
10 pub b: u8,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
14#[serde(rename_all = "camelCase")]
15pub struct CellAttrs {
16 pub bold: bool,
17 pub italic: bool,
18 pub underline: UnderlineStyle,
19 #[serde(skip_serializing_if = "Option::is_none")]
20 pub underline_color: Option<Rgb>,
21 pub strikethrough: bool,
22 pub dim: bool,
23 pub blink: bool,
24 pub reverse: bool,
25 pub hidden: bool,
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(rename_all = "camelCase")]
30pub enum UnderlineStyle {
31 None,
32 Single,
33 Double,
34 Curly,
35 Dotted,
36 Dashed,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(rename_all = "camelCase")]
41pub struct CellData {
42 pub char: String,
43 pub width: u8,
44 pub fg: Rgb,
45 pub bg: Rgb,
46 pub attrs: CellAttrs,
47 #[serde(skip_serializing_if = "Option::is_none")]
48 pub hyperlink: Option<String>,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(rename_all = "camelCase")]
53pub struct CursorState {
54 pub row: u32,
55 pub col: u32,
56 pub visible: bool,
57 pub shape: CursorShape,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(rename_all = "camelCase")]
62pub enum CursorShape {
63 Block,
64 Underline,
65 Bar,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(rename_all = "camelCase")]
70pub struct ScreenRegion {
71 pub top: u32,
72 pub left: u32,
73 pub bottom: u32,
74 pub right: u32,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(rename_all = "camelCase")]
79pub struct SessionInfo {
80 pub session_id: SessionId,
81 pub title: String,
82 #[serde(skip_serializing_if = "Option::is_none")]
83 pub cwd: Option<String>,
84 pub cols: u16,
85 pub rows: u16,
86 #[serde(skip_serializing_if = "Option::is_none")]
87 pub pid: Option<u32>,
88 pub running: bool,
89 pub alternate_screen: bool,
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum KeyInput {
97 Shorthand(String),
98 Structured(KeyEvent),
99}
100
101#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(rename_all = "camelCase")]
103pub struct KeyEvent {
104 pub key: KeyType,
105 #[serde(skip_serializing_if = "Option::is_none")]
106 pub char: Option<String>,
107 #[serde(skip_serializing_if = "Option::is_none")]
108 pub n: Option<u8>,
109 #[serde(default, skip_serializing_if = "Vec::is_empty")]
110 pub modifiers: Vec<Modifier>,
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize)]
114pub enum KeyType {
115 Char,
116 Enter,
117 Tab,
118 Backspace,
119 Delete,
120 Escape,
121 ArrowUp,
122 ArrowDown,
123 ArrowLeft,
124 ArrowRight,
125 Home,
126 End,
127 PageUp,
128 PageDown,
129 Insert,
130 F,
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize)]
134pub enum Modifier {
135 Ctrl,
136 Alt,
137 Shift,
138 Meta,
139}
140
141#[derive(Debug, Clone, Serialize, Deserialize)]
144#[serde(rename_all = "camelCase")]
145pub enum ScreenshotFormat {
146 Text,
147 Ansi,
148 Json,
149 Svg,
150 Png,
151}
152
153#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(rename_all = "camelCase")]
157pub struct Capabilities {
158 pub screenshot: Vec<ScreenshotFormat>,
159 pub max_sessions: u32,
160 pub supports_resize: bool,
161 pub supports_scrollback: bool,
162 pub supports_mouse: bool,
163 pub supports_session_create: bool,
164 pub supports_color_palette: bool,
165 pub supports_raw_output: bool,
166 pub supports_shell_integration: bool,
167 pub events: Vec<String>,
168}
169
170#[derive(Debug, Clone, Serialize, Deserialize)]
171#[serde(rename_all = "camelCase")]
172pub enum AuthenticationMode {
173 None,
174 Password,
175}
176
177#[derive(Debug, Clone, Serialize, Deserialize)]
178#[serde(rename_all = "camelCase")]
179pub struct ServerInfo {
180 pub version: String,
181 pub implementation: String,
182 #[serde(skip_serializing_if = "Option::is_none")]
183 pub name: Option<String>,
184 pub authentication: AuthenticationMode,
185 pub capabilities: Capabilities,
186}
187
188#[derive(Debug, Clone, Serialize, Deserialize)]
191#[serde(rename_all = "camelCase")]
192pub struct TerminalModes {
193 pub cursor_key_mode: String,
194 pub keypad_mode: String,
195 pub alternate_screen: bool,
196 pub bracketed_paste: bool,
197 pub mouse_tracking: String,
198 pub mouse_encoding: String,
199 pub focus_reporting: bool,
200 pub cursor_visible: bool,
201 pub cursor_style: String,
202 pub auto_wrap: bool,
203 pub reverse_video: bool,
204 pub origin_mode: bool,
205 pub synchronized_output: bool,
206}
207
208#[derive(Debug, Clone, Serialize, Deserialize)]
211pub struct ColorPalette(pub HashMap<String, Rgb>);