Skip to main content

rmux_core/input/
writer.rs

1//! Screen-write abstraction used by the VT input parser.
2
3use super::cell::CellState;
4use super::InputEndType;
5
6/// Screen-write abstraction trait.
7///
8/// The parser calls these methods to effect terminal changes. `rmux-server`
9/// implements this trait against its pane/grid runtime.
10#[allow(unused_variables)]
11pub trait ScreenWriter {
12    // ─── Character output ──────────────────────────────────────
13    /// Add a printable character with current cell attributes.
14    fn collect_add(&mut self, ch: char, cell: &CellState);
15
16    /// Add a printable character, applying ACS charset if `acs` is true.
17    fn collect_add_with_charset(&mut self, ch: char, cell: &CellState, acs: bool) {
18        self.collect_add(ch, cell);
19    }
20
21    /// Add a run of printable ASCII bytes with the current cell attributes.
22    fn collect_add_ascii_run(&mut self, bytes: &[u8], cell: &CellState, acs: bool) {
23        for &byte in bytes {
24            self.collect_add_with_charset(char::from(byte), cell, acs);
25        }
26    }
27
28    /// End character collection (flush). Called before non-print transitions.
29    fn collect_end(&mut self) {}
30
31    // ─── Cursor movement ───────────────────────────────────────
32    /// Move cursor up by `n` rows.
33    fn cursor_up(&mut self, n: u32) {}
34    /// Move cursor down by `n` rows.
35    fn cursor_down(&mut self, n: u32) {}
36    /// Move cursor left by `n` columns.
37    fn cursor_left(&mut self, n: u32) {}
38    /// Move cursor right by `n` columns.
39    fn cursor_right(&mut self, n: u32) {}
40    /// Move cursor to absolute position. -1 means "don't change".
41    fn cursor_move(&mut self, col: i32, row: i32, origin_mode: bool) {}
42
43    // ─── Line operations ───────────────────────────────────────
44    /// Insert `n` blank lines at cursor, scrolling down.
45    fn insert_line(&mut self, n: u32, bg: i32) {}
46    /// Delete `n` lines at cursor, scrolling up.
47    fn delete_line(&mut self, n: u32, bg: i32) {}
48    /// Scroll up by `n` lines.
49    fn scroll_up(&mut self, n: u32, bg: i32) {}
50    /// Scroll down by `n` lines.
51    fn scroll_down(&mut self, n: u32, bg: i32) {}
52    /// Line feed.
53    fn linefeed(&mut self, wrapped: bool, bg: i32) {}
54    /// Reverse index (scroll down or move up).
55    fn reverse_index(&mut self, bg: i32) {}
56    /// Carriage return.
57    fn carriage_return(&mut self) {}
58    /// Backspace.
59    fn backspace(&mut self) {}
60
61    // ─── Character operations ──────────────────────────────────
62    /// Insert `n` blank characters at cursor.
63    fn insert_character(&mut self, n: u32, bg: i32) {}
64    /// Delete `n` characters at cursor.
65    fn delete_character(&mut self, n: u32, bg: i32) {}
66    /// Erase (clear) `n` characters at cursor.
67    fn clear_character(&mut self, n: u32, bg: i32) {}
68
69    // ─── Erase operations ──────────────────────────────────────
70    /// Clear to end of screen.
71    fn clear_end_of_screen(&mut self, bg: i32) {}
72    /// Clear from start of screen.
73    fn clear_start_of_screen(&mut self, bg: i32) {}
74    /// Clear entire screen.
75    fn clear_screen(&mut self, bg: i32) {}
76    /// Clear scrollback history.
77    fn clear_history(&mut self) {}
78    /// Clear to end of line.
79    fn clear_end_of_line(&mut self, bg: i32) {}
80    /// Clear from start of line.
81    fn clear_start_of_line(&mut self, bg: i32) {}
82    /// Clear entire line.
83    fn clear_line(&mut self, bg: i32) {}
84
85    // ─── Mode operations ───────────────────────────────────────
86    /// Set mode bits.
87    fn mode_set(&mut self, mode: u32) {}
88    /// Clear mode bits.
89    fn mode_clear(&mut self, mode: u32) {}
90
91    // ─── Scroll region ─────────────────────────────────────────
92    /// Set scroll region (top and bottom margins, 0-based).
93    fn set_scroll_region(&mut self, top: u32, bottom: u32) {}
94
95    // ─── Alternate screen ──────────────────────────────────────
96    /// Switch to alternate screen. `save_cursor` = true for 1049.
97    fn alternate_on(&mut self, bg: i32, save_cursor: bool) {}
98    /// Switch back from alternate screen.
99    fn alternate_off(&mut self, bg: i32, restore_cursor: bool) {}
100
101    // ─── Attributes ────────────────────────────────────────────
102    /// Reset cell attributes to default.
103    fn reset_attributes(&mut self) {}
104
105    // ─── Tab handling ──────────────────────────────────────────
106    /// Handle a horizontal tab.
107    fn tab(&mut self) {}
108    /// Move cursor backward `n` tab stops (CBT).
109    fn cursor_backward_tab(&mut self, n: u32) {}
110    /// Set a tab stop at the current cursor column.
111    fn set_tab_stop(&mut self) {}
112    /// Clear a tab stop at the current cursor column.
113    fn clear_tab_stop(&mut self) {}
114    /// Clear all tab stops.
115    fn clear_all_tab_stops(&mut self) {}
116
117    // ─── Title/path ────────────────────────────────────────────
118    /// Set the pane/window title.
119    fn set_title(&mut self, title: &str) {}
120    /// Set the window name (from rename string).
121    fn set_window_name(&mut self, name: &str) {}
122    /// Set the current directory path (OSC 7).
123    fn set_path(&mut self, path: &str) {}
124
125    // ─── Cursor save/restore ───────────────────────────────────
126    /// Save cursor state (DECSC).
127    fn save_cursor(&mut self) {}
128    /// Restore cursor state (DECRC).
129    fn restore_cursor(&mut self) {}
130
131    // ─── Alignment test ────────────────────────────────────────
132    /// Fill screen with 'E' characters (DECALN).
133    fn alignment_test(&mut self) {}
134
135    // ─── Full reset ────────────────────────────────────────────
136    /// Full terminal reset (RIS).
137    fn full_reset(&mut self) {}
138
139    // ─── Synchronized output ───────────────────────────────────
140    /// Start synchronized output.
141    fn start_sync(&mut self) {}
142    /// Stop synchronized output and redraw.
143    fn stop_sync(&mut self) {}
144
145    // ─── Cursor style ──────────────────────────────────────────
146    /// Set cursor style (DECSCUSR). `n` is the Ps value 0-6.
147    fn set_cursor_style(&mut self, n: u32) {}
148
149    // ─── OSC handlers ──────────────────────────────────────────
150    /// Handle OSC 4 palette colour.
151    fn osc_palette(&mut self, data: &str, end: InputEndType) {}
152    /// Handle OSC 8 hyperlink.
153    fn osc_hyperlink(&mut self, data: &str) {}
154    /// Returns the active OSC 8 hyperlink inner ID.
155    fn current_hyperlink_id(&self) -> u32 {
156        0
157    }
158    /// Handle OSC 9 notification.
159    fn osc_notification(&mut self, data: &str) {}
160    /// Handle OSC 10 fg colour query/set.
161    fn osc_fg_colour(&mut self, data: &str, end: InputEndType) {}
162    /// Handle OSC 11 bg colour query/set.
163    fn osc_bg_colour(&mut self, data: &str, end: InputEndType) {}
164    /// Handle OSC 12 cursor colour query/set.
165    fn osc_cursor_colour(&mut self, data: &str, end: InputEndType) {}
166    /// Handle OSC 52 clipboard.
167    fn osc_clipboard(&mut self, data: &str, end: InputEndType) {}
168    /// Handle OSC 104 reset palette.
169    fn osc_reset_palette(&mut self, data: &str) {}
170    /// Handle OSC 110 reset fg.
171    fn osc_reset_fg(&mut self) {}
172    /// Handle OSC 111 reset bg.
173    fn osc_reset_bg(&mut self) {}
174    /// Handle OSC 112 reset cursor colour.
175    fn osc_reset_cursor(&mut self) {}
176    /// Handle OSC 133 shell integration.
177    fn osc_shell_integration(&mut self, data: &str) {}
178
179    // ─── DCS handlers ──────────────────────────────────────────
180    /// Handle DCS passthrough string.
181    fn dcs_passthrough(&mut self, data: &[u8]) {}
182
183    /// Handle an opaque SIXEL DCS passthrough string.
184    fn sixel_passthrough(&mut self, data: &[u8]) {}
185
186    // ─── APC handlers ──────────────────────────────────────────
187    /// Handle an opaque APC passthrough string.
188    fn apc_passthrough(&mut self, data: &[u8]) {}
189
190    // ─── Paste/focus/notify ────────────────────────────────────
191    /// Ring the bell (BEL).
192    fn bell(&mut self) {}
193
194    // ─── Query responses ───────────────────────────────────────
195    /// Get screen width in columns.
196    fn screen_size_x(&self) -> u32 {
197        80
198    }
199    /// Get screen height in rows.
200    fn screen_size_y(&self) -> u32 {
201        24
202    }
203    /// Get current cursor column (0-based).
204    fn cursor_x(&self) -> u32 {
205        0
206    }
207    /// Get current cursor row (0-based).
208    fn cursor_y(&self) -> u32 {
209        0
210    }
211    /// Get current screen mode flags.
212    fn current_mode(&self) -> u32 {
213        0
214    }
215
216    // ─── Title stack ───────────────────────────────────────────
217    /// Push current title onto the stack.
218    fn push_title(&mut self) {}
219    /// Pop title from the stack.
220    fn pop_title(&mut self) {}
221
222    // ─── Pane notification ─────────────────────────────────────
223    /// Signal that the pane title changed.
224    fn notify_pane_title_changed(&mut self) {}
225}