Skip to main content

rmux_core/input/
commands.rs

1//! Terminal input command types surfaced by the VT parser tables.
2
3/// ESC sequence commands (15 entries).
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum EscCommand {
6    /// ESC ( 0 — G0 ACS on.
7    Scsg0On,
8    /// ESC ) 0 — G1 ACS on.
9    Scsg1On,
10    /// ESC 7 — Save cursor (DECSC).
11    Decsc,
12    /// ESC 8 — Restore cursor (DECRC).
13    Decrc,
14    /// ESC # 8 — Alignment test (DECALN).
15    Decaln,
16    /// ESC = — Keypad application mode (DECKPAM).
17    Deckpam,
18    /// ESC > — Keypad numeric mode (DECKPNM).
19    Deckpnm,
20    /// ESC ( B — G0 ACS off.
21    Scsg0Off,
22    /// ESC ) B — G1 ACS off.
23    Scsg1Off,
24    /// ESC D — Index (IND).
25    Ind,
26    /// ESC E — Next line (NEL).
27    Nel,
28    /// ESC H — Horizontal tab set (HTS).
29    Hts,
30    /// ESC M — Reverse index (RI).
31    Ri,
32    /// ESC \ — String terminator (ST).
33    St,
34    /// ESC c — Reset to initial state (RIS).
35    Ris,
36}
37
38/// CSI command types (40 entries).
39#[derive(Debug, Clone, Copy, PartialEq, Eq)]
40pub enum CsiCommand {
41    /// ICH — Insert Character (@).
42    Ich,
43    /// CUU — Cursor Up (A).
44    Cuu,
45    /// CUD — Cursor Down (B).
46    Cud,
47    /// CUF — Cursor Forward (C).
48    Cuf,
49    /// CUB — Cursor Back (D).
50    Cub,
51    /// CNL — Cursor Next Line (E).
52    Cnl,
53    /// CPL — Cursor Previous Line (F).
54    Cpl,
55    /// HPA — Horizontal Position Absolute (G or \`).
56    Hpa,
57    /// CUP — Cursor Position (H or f).
58    Cup,
59    /// ED — Erase in Display (J).
60    Ed,
61    /// EL — Erase in Line (K).
62    El,
63    /// IL — Insert Line (L).
64    Il,
65    /// DL — Delete Line (M).
66    Dl,
67    /// DCH — Delete Character (P).
68    Dch,
69    /// SU — Scroll Up (S).
70    Su,
71    /// SM_GRAPHICS — Set/query graphics mode (?S).
72    SmGraphics,
73    /// SD — Scroll Down (T).
74    Sd,
75    /// ECH — Erase Character (X).
76    Ech,
77    /// CBT — Cursor Backward Tabulation (Z).
78    Cbt,
79    /// REP — Repeat preceding character (b).
80    Rep,
81    /// DA — Device Attributes primary (c).
82    Da,
83    /// DA_TWO — Device Attributes secondary (>c).
84    DaTwo,
85    /// VPA — Vertical Position Absolute (d).
86    Vpa,
87    /// TBC — Tab Clear (g).
88    Tbc,
89    /// SM — Set Mode (h).
90    Sm,
91    /// SM_PRIVATE — Set Private Mode (?h).
92    SmPrivate,
93    /// RM — Reset Mode (l).
94    Rm,
95    /// RM_PRIVATE — Reset Private Mode (?l).
96    RmPrivate,
97    /// SGR — Select Graphic Rendition (m).
98    Sgr,
99    /// MODSET — Set modifier key mode (>m).
100    Modset,
101    /// KITTY_KEYBOARD_SET — Set Kitty keyboard enhancement flags (=u).
102    KittyKeyboardSet,
103    /// KITTY_KEYBOARD_PUSH — Push Kitty keyboard enhancement flags (>u).
104    KittyKeyboardPush,
105    /// KITTY_KEYBOARD_POP — Pop Kitty keyboard enhancement flags (<u).
106    KittyKeyboardPop,
107    /// KITTY_KEYBOARD_QUERY — Query Kitty keyboard enhancement flags (?u).
108    KittyKeyboardQuery,
109    /// DSR — Device Status Report (n).
110    Dsr,
111    /// MODOFF — Reset modifier key mode (>n).
112    Modoff,
113    /// DSR_PRIVATE — Private Device Status Report (?n).
114    DsrPrivate,
115    /// QUERY_PRIVATE — DECRPM Query (?$p).
116    QueryPrivate,
117    /// DECSCUSR — Set Cursor Style ( q).
118    Decscusr,
119    /// XDA — Extended Device Attributes (>q).
120    Xda,
121    /// DECSTBM — Set Top and Bottom Margins (r).
122    Decstbm,
123    /// SCP — Save Cursor Position (s).
124    Scp,
125    /// WINOPS — Window Operations (t).
126    Winops,
127    /// RCP — Restore Cursor Position (u).
128    Rcp,
129}
130
131/// OSC command numbers.
132#[derive(Debug, Clone, Copy, PartialEq, Eq)]
133pub enum OscCommand {
134    /// OSC 0/2 — Set title.
135    SetTitle,
136    /// OSC 4 — Set/query palette colour.
137    Palette,
138    /// OSC 7 — Set current directory path.
139    SetPath,
140    /// OSC 8 — Hyperlink.
141    Hyperlink,
142    /// OSC 9 — Desktop notification.
143    Notification,
144    /// OSC 10 — Set/query foreground colour.
145    FgColour,
146    /// OSC 11 — Set/query background colour.
147    BgColour,
148    /// OSC 12 — Set/query cursor colour.
149    CursorColour,
150    /// OSC 52 — Clipboard.
151    Clipboard,
152    /// OSC 104 — Reset palette colour.
153    ResetPalette,
154    /// OSC 110 — Reset foreground colour.
155    ResetFg,
156    /// OSC 111 — Reset background colour.
157    ResetBg,
158    /// OSC 112 — Reset cursor colour.
159    ResetCursor,
160    /// OSC 133 — Shell integration / prompt mark.
161    ShellIntegration,
162}
163
164/// DCS payload delivered to the screen writer.
165#[derive(Debug, Clone)]
166pub enum DcsPayload {
167    /// DECRQSS query (the string after `$q`).
168    Decrqss(Vec<u8>),
169    /// tmux passthrough (data after `tmux;` prefix).
170    Passthrough(Vec<u8>),
171    /// Sixel image data (deferred/deferred).
172    Sixel(Vec<u8>),
173}
174
175/// Actions that the parser surfaces to the caller.
176#[derive(Debug, Clone)]
177pub enum InputAction {
178    /// A reply string to write back to the PTY fd.
179    Reply(Vec<u8>),
180}