@vibecook/ghosttea-react 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/TerminalSurface.d.ts +28 -0
- package/dist/TerminalSurface.d.ts.map +1 -0
- package/dist/TerminalSurface.js +614 -0
- package/dist/TerminalSurface.js.map +1 -0
- package/dist/bindings/action-route.d.ts +155 -0
- package/dist/bindings/action-route.d.ts.map +1 -0
- package/dist/bindings/action-route.js +196 -0
- package/dist/bindings/action-route.js.map +1 -0
- package/dist/bindings/fixtures/extensions.json +10 -0
- package/dist/bindings/fixtures/keybinds-linux-default.json +505 -0
- package/dist/bindings/fixtures/keybinds-macos-default.json +660 -0
- package/dist/bindings/ghostty-actions.d.ts +247 -0
- package/dist/bindings/ghostty-actions.d.ts.map +1 -0
- package/dist/bindings/ghostty-actions.js +431 -0
- package/dist/bindings/ghostty-actions.js.map +1 -0
- package/dist/bindings/ghostty-bindings.d.ts +88 -0
- package/dist/bindings/ghostty-bindings.d.ts.map +1 -0
- package/dist/bindings/ghostty-bindings.js +122 -0
- package/dist/bindings/ghostty-bindings.js.map +1 -0
- package/dist/bindings/ghostty-triggers.d.ts +47 -0
- package/dist/bindings/ghostty-triggers.d.ts.map +1 -0
- package/dist/bindings/ghostty-triggers.js +378 -0
- package/dist/bindings/ghostty-triggers.js.map +1 -0
- package/dist/bindings/index.d.ts +5 -0
- package/dist/bindings/index.d.ts.map +1 -0
- package/dist/bindings/index.js +5 -0
- package/dist/bindings/index.js.map +1 -0
- package/dist/catalog-budget.d.ts +22 -0
- package/dist/catalog-budget.d.ts.map +1 -0
- package/dist/catalog-budget.js +53 -0
- package/dist/catalog-budget.js.map +1 -0
- package/dist/cell-width.d.ts +3 -0
- package/dist/cell-width.d.ts.map +1 -0
- package/dist/cell-width.js +19 -0
- package/dist/cell-width.js.map +1 -0
- package/dist/context.d.ts +9 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +13 -0
- package/dist/context.js.map +1 -0
- package/dist/cursor-invalidation.d.ts +3 -0
- package/dist/cursor-invalidation.d.ts.map +1 -0
- package/dist/cursor-invalidation.js +4 -0
- package/dist/cursor-invalidation.js.map +1 -0
- package/dist/frame-resync.d.ts +16 -0
- package/dist/frame-resync.d.ts.map +1 -0
- package/dist/frame-resync.js +164 -0
- package/dist/frame-resync.js.map +1 -0
- package/dist/frame-sequence.d.ts +14 -0
- package/dist/frame-sequence.d.ts.map +1 -0
- package/dist/frame-sequence.js +16 -0
- package/dist/frame-sequence.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard-input.d.ts +18 -0
- package/dist/keyboard-input.d.ts.map +1 -0
- package/dist/keyboard-input.js +101 -0
- package/dist/keyboard-input.js.map +1 -0
- package/dist/performance.d.ts +66 -0
- package/dist/performance.d.ts.map +1 -0
- package/dist/performance.js +21 -0
- package/dist/performance.js.map +1 -0
- package/dist/renderers/canvas-renderer.d.ts +12 -0
- package/dist/renderers/canvas-renderer.d.ts.map +1 -0
- package/dist/renderers/canvas-renderer.js +117 -0
- package/dist/renderers/canvas-renderer.js.map +1 -0
- package/dist/renderers/render-damage.d.ts +7 -0
- package/dist/renderers/render-damage.d.ts.map +1 -0
- package/dist/renderers/render-damage.js +16 -0
- package/dist/renderers/render-damage.js.map +1 -0
- package/dist/renderers/types.d.ts +65 -0
- package/dist/renderers/types.d.ts.map +1 -0
- package/dist/renderers/types.js +31 -0
- package/dist/renderers/types.js.map +1 -0
- package/dist/renderers/webgpu-renderer.d.ts +27 -0
- package/dist/renderers/webgpu-renderer.d.ts.map +1 -0
- package/dist/renderers/webgpu-renderer.js +1746 -0
- package/dist/renderers/webgpu-renderer.js.map +1 -0
- package/dist/runtime.d.ts +70 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1021 -0
- package/dist/runtime.js.map +1 -0
- package/dist/scroll-input.d.ts +6 -0
- package/dist/scroll-input.d.ts.map +1 -0
- package/dist/scroll-input.js +14 -0
- package/dist/scroll-input.js.map +1 -0
- package/dist/selection-input.d.ts +16 -0
- package/dist/selection-input.d.ts.map +1 -0
- package/dist/selection-input.js +67 -0
- package/dist/selection-input.js.map +1 -0
- package/dist/selection-text.d.ts +4 -0
- package/dist/selection-text.d.ts.map +1 -0
- package/dist/selection-text.js +28 -0
- package/dist/selection-text.js.map +1 -0
- package/dist/styles.css +75 -0
- package/dist/terminal-bindings.d.ts +22 -0
- package/dist/terminal-bindings.d.ts.map +1 -0
- package/dist/terminal-bindings.js +22 -0
- package/dist/terminal-bindings.js.map +1 -0
- package/dist/terminal-render.worker.d.ts +2 -0
- package/dist/terminal-render.worker.d.ts.map +1 -0
- package/dist/terminal-render.worker.js +3165 -0
- package/dist/terminal-render.worker.js.map +7 -0
- package/dist/worker-messages.d.ts +111 -0
- package/dist/worker-messages.d.ts.map +1 -0
- package/dist/worker-messages.js +2 -0
- package/dist/worker-messages.js.map +1 -0
- package/dist/workspace/RemoteSessionPalette.d.ts +12 -0
- package/dist/workspace/RemoteSessionPalette.d.ts.map +1 -0
- package/dist/workspace/RemoteSessionPalette.js +135 -0
- package/dist/workspace/RemoteSessionPalette.js.map +1 -0
- package/dist/workspace/Workspace.d.ts +69 -0
- package/dist/workspace/Workspace.d.ts.map +1 -0
- package/dist/workspace/Workspace.js +536 -0
- package/dist/workspace/Workspace.js.map +1 -0
- package/dist/workspace/hotkeys.d.ts +27 -0
- package/dist/workspace/hotkeys.d.ts.map +1 -0
- package/dist/workspace/hotkeys.js +29 -0
- package/dist/workspace/hotkeys.js.map +1 -0
- package/dist/workspace/index.d.ts +8 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +8 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/pane-layout.d.ts +35 -0
- package/dist/workspace/pane-layout.d.ts.map +1 -0
- package/dist/workspace/pane-layout.js +139 -0
- package/dist/workspace/pane-layout.js.map +1 -0
- package/dist/workspace/pending-cache.d.ts +5 -0
- package/dist/workspace/pending-cache.d.ts.map +1 -0
- package/dist/workspace/pending-cache.js +22 -0
- package/dist/workspace/pending-cache.js.map +1 -0
- package/dist/workspace/session-scope.d.ts +3 -0
- package/dist/workspace/session-scope.d.ts.map +1 -0
- package/dist/workspace/session-scope.js +6 -0
- package/dist/workspace/session-scope.js.map +1 -0
- package/dist/workspace/themes.d.ts +18 -0
- package/dist/workspace/themes.d.ts.map +1 -0
- package/dist/workspace/themes.js +19 -0
- package/dist/workspace/themes.js.map +1 -0
- package/dist/workspace/workspace-model.d.ts +59 -0
- package/dist/workspace/workspace-model.d.ts.map +1 -0
- package/dist/workspace/workspace-model.js +257 -0
- package/dist/workspace/workspace-model.js.map +1 -0
- package/dist/workspace/workspace-tabs.d.ts +41 -0
- package/dist/workspace/workspace-tabs.d.ts.map +1 -0
- package/dist/workspace/workspace-tabs.js +133 -0
- package/dist/workspace/workspace-tabs.js.map +1 -0
- package/dist/workspace.css +453 -0
- package/package.json +75 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed mirror of Ghostty's `input.Binding.Action` (src/input/Binding.zig).
|
|
3
|
+
*
|
|
4
|
+
* Action *names* and parameter formats are ground truth from Ghostty.
|
|
5
|
+
* Ghosttea may not implement every action yet; parsing still accepts the full set
|
|
6
|
+
* so golden binding tests can lock the catalog.
|
|
7
|
+
*/
|
|
8
|
+
export type SplitDirection = "right" | "down" | "left" | "up" | "auto";
|
|
9
|
+
export type SplitFocusDirection = "previous" | "next" | "up" | "left" | "down" | "right";
|
|
10
|
+
export type SplitResizeDirection = "up" | "down" | "left" | "right";
|
|
11
|
+
export type GotoWindow = "previous" | "next";
|
|
12
|
+
export type CopyToClipboard = "plain" | "vt" | "html" | "mixed";
|
|
13
|
+
export type WriteScreenAction = "copy" | "paste" | "open";
|
|
14
|
+
export type WriteScreenFormat = "plain" | "vt" | "html";
|
|
15
|
+
export type CloseTabMode = "this" | "other" | "right";
|
|
16
|
+
export type InspectorMode = "toggle" | "show" | "hide";
|
|
17
|
+
export type NavigateSearch = "previous" | "next";
|
|
18
|
+
export type AdjustSelection = "left" | "right" | "up" | "down" | "page_up" | "page_down" | "home" | "end" | "beginning_of_line" | "end_of_line";
|
|
19
|
+
export type CrashThread = "main" | "io" | "render";
|
|
20
|
+
export type GhosttyAction = {
|
|
21
|
+
type: "ignore";
|
|
22
|
+
} | {
|
|
23
|
+
type: "unbind";
|
|
24
|
+
} | {
|
|
25
|
+
type: "csi";
|
|
26
|
+
value: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: "esc";
|
|
29
|
+
value: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: "text";
|
|
32
|
+
value: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: "cursor_key";
|
|
35
|
+
normal: string;
|
|
36
|
+
application: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: "reset";
|
|
39
|
+
} | {
|
|
40
|
+
type: "copy_to_clipboard";
|
|
41
|
+
format: CopyToClipboard;
|
|
42
|
+
} | {
|
|
43
|
+
type: "paste_from_clipboard";
|
|
44
|
+
} | {
|
|
45
|
+
type: "paste_from_selection";
|
|
46
|
+
} | {
|
|
47
|
+
type: "copy_url_to_clipboard";
|
|
48
|
+
} | {
|
|
49
|
+
type: "copy_title_to_clipboard";
|
|
50
|
+
} | {
|
|
51
|
+
type: "increase_font_size";
|
|
52
|
+
amount: number;
|
|
53
|
+
} | {
|
|
54
|
+
type: "decrease_font_size";
|
|
55
|
+
amount: number;
|
|
56
|
+
} | {
|
|
57
|
+
type: "reset_font_size";
|
|
58
|
+
} | {
|
|
59
|
+
type: "set_font_size";
|
|
60
|
+
size: number;
|
|
61
|
+
} | {
|
|
62
|
+
type: "search";
|
|
63
|
+
query: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: "search_selection";
|
|
66
|
+
} | {
|
|
67
|
+
type: "navigate_search";
|
|
68
|
+
direction: NavigateSearch;
|
|
69
|
+
} | {
|
|
70
|
+
type: "start_search";
|
|
71
|
+
} | {
|
|
72
|
+
type: "end_search";
|
|
73
|
+
} | {
|
|
74
|
+
type: "clear_screen";
|
|
75
|
+
} | {
|
|
76
|
+
type: "select_all";
|
|
77
|
+
} | {
|
|
78
|
+
type: "scroll_to_top";
|
|
79
|
+
} | {
|
|
80
|
+
type: "scroll_to_bottom";
|
|
81
|
+
} | {
|
|
82
|
+
type: "scroll_to_selection";
|
|
83
|
+
} | {
|
|
84
|
+
type: "scroll_to_row";
|
|
85
|
+
row: number;
|
|
86
|
+
} | {
|
|
87
|
+
type: "scroll_page_up";
|
|
88
|
+
} | {
|
|
89
|
+
type: "scroll_page_down";
|
|
90
|
+
} | {
|
|
91
|
+
type: "scroll_page_fractional";
|
|
92
|
+
amount: number;
|
|
93
|
+
} | {
|
|
94
|
+
type: "scroll_page_lines";
|
|
95
|
+
lines: number;
|
|
96
|
+
} | {
|
|
97
|
+
type: "adjust_selection";
|
|
98
|
+
direction: AdjustSelection;
|
|
99
|
+
} | {
|
|
100
|
+
type: "jump_to_prompt";
|
|
101
|
+
offset: number;
|
|
102
|
+
} | {
|
|
103
|
+
type: "write_scrollback_file";
|
|
104
|
+
action: WriteScreenAction;
|
|
105
|
+
format: WriteScreenFormat;
|
|
106
|
+
} | {
|
|
107
|
+
type: "write_screen_file";
|
|
108
|
+
action: WriteScreenAction;
|
|
109
|
+
format: WriteScreenFormat;
|
|
110
|
+
} | {
|
|
111
|
+
type: "write_selection_file";
|
|
112
|
+
action: WriteScreenAction;
|
|
113
|
+
format: WriteScreenFormat;
|
|
114
|
+
} | {
|
|
115
|
+
type: "new_window";
|
|
116
|
+
} | {
|
|
117
|
+
type: "new_tab";
|
|
118
|
+
} | {
|
|
119
|
+
type: "previous_tab";
|
|
120
|
+
} | {
|
|
121
|
+
type: "next_tab";
|
|
122
|
+
} | {
|
|
123
|
+
type: "last_tab";
|
|
124
|
+
} | {
|
|
125
|
+
type: "goto_tab";
|
|
126
|
+
index: number;
|
|
127
|
+
} | {
|
|
128
|
+
type: "move_tab";
|
|
129
|
+
offset: number;
|
|
130
|
+
} | {
|
|
131
|
+
type: "toggle_tab_overview";
|
|
132
|
+
} | {
|
|
133
|
+
type: "prompt_surface_title";
|
|
134
|
+
} | {
|
|
135
|
+
type: "prompt_tab_title";
|
|
136
|
+
} | {
|
|
137
|
+
type: "set_surface_title";
|
|
138
|
+
title: string;
|
|
139
|
+
} | {
|
|
140
|
+
type: "set_tab_title";
|
|
141
|
+
title: string;
|
|
142
|
+
} | {
|
|
143
|
+
type: "new_split";
|
|
144
|
+
direction: SplitDirection;
|
|
145
|
+
} | {
|
|
146
|
+
type: "goto_split";
|
|
147
|
+
direction: SplitFocusDirection;
|
|
148
|
+
} | {
|
|
149
|
+
type: "goto_window";
|
|
150
|
+
direction: GotoWindow;
|
|
151
|
+
} | {
|
|
152
|
+
type: "toggle_split_zoom";
|
|
153
|
+
} | {
|
|
154
|
+
type: "toggle_readonly";
|
|
155
|
+
} | {
|
|
156
|
+
type: "resize_split";
|
|
157
|
+
direction: SplitResizeDirection;
|
|
158
|
+
amount: number;
|
|
159
|
+
} | {
|
|
160
|
+
type: "equalize_splits";
|
|
161
|
+
} | {
|
|
162
|
+
type: "reset_window_size";
|
|
163
|
+
} | {
|
|
164
|
+
type: "inspector";
|
|
165
|
+
mode: InspectorMode;
|
|
166
|
+
} | {
|
|
167
|
+
type: "show_gtk_inspector";
|
|
168
|
+
} | {
|
|
169
|
+
type: "show_on_screen_keyboard";
|
|
170
|
+
} | {
|
|
171
|
+
type: "open_config";
|
|
172
|
+
} | {
|
|
173
|
+
type: "reload_config";
|
|
174
|
+
} | {
|
|
175
|
+
type: "close_surface";
|
|
176
|
+
} | {
|
|
177
|
+
type: "close_tab";
|
|
178
|
+
mode: CloseTabMode;
|
|
179
|
+
} | {
|
|
180
|
+
type: "close_window";
|
|
181
|
+
} | {
|
|
182
|
+
type: "close_all_windows";
|
|
183
|
+
} | {
|
|
184
|
+
type: "toggle_maximize";
|
|
185
|
+
} | {
|
|
186
|
+
type: "toggle_fullscreen";
|
|
187
|
+
} | {
|
|
188
|
+
type: "toggle_window_decorations";
|
|
189
|
+
} | {
|
|
190
|
+
type: "toggle_window_float_on_top";
|
|
191
|
+
} | {
|
|
192
|
+
type: "toggle_secure_input";
|
|
193
|
+
} | {
|
|
194
|
+
type: "toggle_mouse_reporting";
|
|
195
|
+
} | {
|
|
196
|
+
type: "toggle_command_palette";
|
|
197
|
+
} | {
|
|
198
|
+
type: "toggle_quick_terminal";
|
|
199
|
+
} | {
|
|
200
|
+
type: "toggle_visibility";
|
|
201
|
+
} | {
|
|
202
|
+
type: "toggle_background_opacity";
|
|
203
|
+
} | {
|
|
204
|
+
type: "check_for_updates";
|
|
205
|
+
} | {
|
|
206
|
+
type: "undo";
|
|
207
|
+
} | {
|
|
208
|
+
type: "redo";
|
|
209
|
+
} | {
|
|
210
|
+
type: "end_key_sequence";
|
|
211
|
+
} | {
|
|
212
|
+
type: "activate_key_table";
|
|
213
|
+
name: string;
|
|
214
|
+
} | {
|
|
215
|
+
type: "activate_key_table_once";
|
|
216
|
+
name: string;
|
|
217
|
+
} | {
|
|
218
|
+
type: "deactivate_key_table";
|
|
219
|
+
} | {
|
|
220
|
+
type: "deactivate_all_key_tables";
|
|
221
|
+
} | {
|
|
222
|
+
type: "quit";
|
|
223
|
+
} | {
|
|
224
|
+
type: "crash";
|
|
225
|
+
thread: CrashThread;
|
|
226
|
+
};
|
|
227
|
+
/** Ghosttea product extensions (not Ghostty). */
|
|
228
|
+
export type GhostteaExtensionAction = {
|
|
229
|
+
type: "ghosttea.remote_sessions";
|
|
230
|
+
};
|
|
231
|
+
export type GhostteaBindingAction = GhosttyAction | GhostteaExtensionAction;
|
|
232
|
+
export declare class GhosttyActionParseError extends Error {
|
|
233
|
+
constructor(message: string);
|
|
234
|
+
}
|
|
235
|
+
/** Decode a Ghostty action string such as `goto_tab:3` or `new_split:right`. */
|
|
236
|
+
export declare function parseGhosttyAction(raw: string): GhosttyAction;
|
|
237
|
+
/**
|
|
238
|
+
* Decode the subset of Zig string-literal escapes used in Ghostty config dumps.
|
|
239
|
+
*
|
|
240
|
+
* Ghostty `+list-keybinds` prints text actions with a doubled backslash
|
|
241
|
+
* (`text:\\x05`) so the line is pasteable into a config file. Accept both
|
|
242
|
+
* `\\xNN` (dump form) and `\xNN` (single-escaped).
|
|
243
|
+
*/
|
|
244
|
+
export declare function decodeZigStringLiteral(value: string): string;
|
|
245
|
+
export declare function formatGhosttyAction(action: GhosttyAction): string;
|
|
246
|
+
export declare function parseGhostteaBindingAction(raw: string): GhostteaBindingAction;
|
|
247
|
+
//# sourceMappingURL=ghostty-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ghostty-actions.d.ts","sourceRoot":"","sources":["../../src/bindings/ghostty-actions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;AACvE,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACzF,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACpE,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;AAC7C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC;AAChE,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAC1D,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;AACxD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;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E,GAC5C;IAAE,IAAI,EAAE,yBAAyB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,sBAAsB,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,2BAA2B,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC;AAE3C,iDAAiD;AACjD,MAAM,MAAM,uBAAuB,GAAG;IAAE,IAAI,EAAE,0BAA0B,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG,uBAAuB,CAAC;AAE5E,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AA0BD,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CA0P7D;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAqD5D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAgEjE;AAiBD,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAG7E"}
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed mirror of Ghostty's `input.Binding.Action` (src/input/Binding.zig).
|
|
3
|
+
*
|
|
4
|
+
* Action *names* and parameter formats are ground truth from Ghostty.
|
|
5
|
+
* Ghosttea may not implement every action yet; parsing still accepts the full set
|
|
6
|
+
* so golden binding tests can lock the catalog.
|
|
7
|
+
*/
|
|
8
|
+
export class GhosttyActionParseError extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "GhosttyActionParseError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function requireParam(raw, name) {
|
|
15
|
+
const idx = raw.indexOf(":");
|
|
16
|
+
if (idx < 0)
|
|
17
|
+
throw new GhosttyActionParseError(`${name} requires a parameter`);
|
|
18
|
+
return raw.slice(idx + 1);
|
|
19
|
+
}
|
|
20
|
+
function parseEnum(value, allowed, label) {
|
|
21
|
+
if (allowed.includes(value))
|
|
22
|
+
return value;
|
|
23
|
+
throw new GhosttyActionParseError(`invalid ${label}: ${value}`);
|
|
24
|
+
}
|
|
25
|
+
function parseNumber(value, label) {
|
|
26
|
+
const n = Number(value);
|
|
27
|
+
if (!Number.isFinite(n))
|
|
28
|
+
throw new GhosttyActionParseError(`invalid ${label}: ${value}`);
|
|
29
|
+
return n;
|
|
30
|
+
}
|
|
31
|
+
function parseWriteScreen(param) {
|
|
32
|
+
const [actionRaw, formatRaw] = param.split(",", 2);
|
|
33
|
+
const action = parseEnum(actionRaw ?? "", ["copy", "paste", "open"], "write screen action");
|
|
34
|
+
const format = formatRaw ? parseEnum(formatRaw, ["plain", "vt", "html"], "write screen format") : "plain";
|
|
35
|
+
return { action, format };
|
|
36
|
+
}
|
|
37
|
+
/** Decode a Ghostty action string such as `goto_tab:3` or `new_split:right`. */
|
|
38
|
+
export function parseGhosttyAction(raw) {
|
|
39
|
+
const input = raw.trim();
|
|
40
|
+
if (!input)
|
|
41
|
+
throw new GhosttyActionParseError("empty action");
|
|
42
|
+
const colon = input.indexOf(":");
|
|
43
|
+
const name = colon < 0 ? input : input.slice(0, colon);
|
|
44
|
+
const param = colon < 0 ? "" : input.slice(colon + 1);
|
|
45
|
+
switch (name) {
|
|
46
|
+
case "ignore":
|
|
47
|
+
return { type: "ignore" };
|
|
48
|
+
case "unbind":
|
|
49
|
+
return { type: "unbind" };
|
|
50
|
+
case "csi":
|
|
51
|
+
return { type: "csi", value: param };
|
|
52
|
+
case "esc":
|
|
53
|
+
return { type: "esc", value: param };
|
|
54
|
+
case "text":
|
|
55
|
+
return { type: "text", value: decodeZigStringLiteral(param) };
|
|
56
|
+
case "cursor_key": {
|
|
57
|
+
const [normal, application] = param.split(",", 2);
|
|
58
|
+
if (!normal || application === undefined) {
|
|
59
|
+
throw new GhosttyActionParseError("cursor_key requires normal,application");
|
|
60
|
+
}
|
|
61
|
+
return { type: "cursor_key", normal, application };
|
|
62
|
+
}
|
|
63
|
+
case "reset":
|
|
64
|
+
return { type: "reset" };
|
|
65
|
+
case "copy_to_clipboard":
|
|
66
|
+
return {
|
|
67
|
+
type: "copy_to_clipboard",
|
|
68
|
+
format: param ? parseEnum(param, ["plain", "vt", "html", "mixed"], "copy format") : "mixed",
|
|
69
|
+
};
|
|
70
|
+
case "paste_from_clipboard":
|
|
71
|
+
return { type: "paste_from_clipboard" };
|
|
72
|
+
case "paste_from_selection":
|
|
73
|
+
return { type: "paste_from_selection" };
|
|
74
|
+
case "copy_url_to_clipboard":
|
|
75
|
+
return { type: "copy_url_to_clipboard" };
|
|
76
|
+
case "copy_title_to_clipboard":
|
|
77
|
+
return { type: "copy_title_to_clipboard" };
|
|
78
|
+
case "increase_font_size":
|
|
79
|
+
return { type: "increase_font_size", amount: parseNumber(param || "1", "font size") };
|
|
80
|
+
case "decrease_font_size":
|
|
81
|
+
return { type: "decrease_font_size", amount: parseNumber(param || "1", "font size") };
|
|
82
|
+
case "reset_font_size":
|
|
83
|
+
return { type: "reset_font_size" };
|
|
84
|
+
case "set_font_size":
|
|
85
|
+
return { type: "set_font_size", size: parseNumber(requireParam(input, "set_font_size"), "font size") };
|
|
86
|
+
case "search":
|
|
87
|
+
return { type: "search", query: param };
|
|
88
|
+
case "search_selection":
|
|
89
|
+
return { type: "search_selection" };
|
|
90
|
+
case "navigate_search":
|
|
91
|
+
return {
|
|
92
|
+
type: "navigate_search",
|
|
93
|
+
direction: parseEnum(param, ["previous", "next"], "navigate_search"),
|
|
94
|
+
};
|
|
95
|
+
case "start_search":
|
|
96
|
+
return { type: "start_search" };
|
|
97
|
+
case "end_search":
|
|
98
|
+
return { type: "end_search" };
|
|
99
|
+
case "clear_screen":
|
|
100
|
+
return { type: "clear_screen" };
|
|
101
|
+
case "select_all":
|
|
102
|
+
return { type: "select_all" };
|
|
103
|
+
case "scroll_to_top":
|
|
104
|
+
return { type: "scroll_to_top" };
|
|
105
|
+
case "scroll_to_bottom":
|
|
106
|
+
return { type: "scroll_to_bottom" };
|
|
107
|
+
case "scroll_to_selection":
|
|
108
|
+
return { type: "scroll_to_selection" };
|
|
109
|
+
case "scroll_to_row":
|
|
110
|
+
return { type: "scroll_to_row", row: parseNumber(requireParam(input, "scroll_to_row"), "row") };
|
|
111
|
+
case "scroll_page_up":
|
|
112
|
+
return { type: "scroll_page_up" };
|
|
113
|
+
case "scroll_page_down":
|
|
114
|
+
return { type: "scroll_page_down" };
|
|
115
|
+
case "scroll_page_fractional":
|
|
116
|
+
return {
|
|
117
|
+
type: "scroll_page_fractional",
|
|
118
|
+
amount: parseNumber(requireParam(input, "scroll_page_fractional"), "fraction"),
|
|
119
|
+
};
|
|
120
|
+
case "scroll_page_lines":
|
|
121
|
+
return {
|
|
122
|
+
type: "scroll_page_lines",
|
|
123
|
+
lines: parseNumber(requireParam(input, "scroll_page_lines"), "lines"),
|
|
124
|
+
};
|
|
125
|
+
case "adjust_selection":
|
|
126
|
+
return {
|
|
127
|
+
type: "adjust_selection",
|
|
128
|
+
direction: parseEnum(param, [
|
|
129
|
+
"left",
|
|
130
|
+
"right",
|
|
131
|
+
"up",
|
|
132
|
+
"down",
|
|
133
|
+
"page_up",
|
|
134
|
+
"page_down",
|
|
135
|
+
"home",
|
|
136
|
+
"end",
|
|
137
|
+
"beginning_of_line",
|
|
138
|
+
"end_of_line",
|
|
139
|
+
], "adjust_selection"),
|
|
140
|
+
};
|
|
141
|
+
case "jump_to_prompt":
|
|
142
|
+
return { type: "jump_to_prompt", offset: parseNumber(requireParam(input, "jump_to_prompt"), "offset") };
|
|
143
|
+
case "write_scrollback_file": {
|
|
144
|
+
const parsed = parseWriteScreen(param || "copy");
|
|
145
|
+
return { type: "write_scrollback_file", ...parsed };
|
|
146
|
+
}
|
|
147
|
+
case "write_screen_file": {
|
|
148
|
+
const parsed = parseWriteScreen(param || "copy");
|
|
149
|
+
return { type: "write_screen_file", ...parsed };
|
|
150
|
+
}
|
|
151
|
+
case "write_selection_file": {
|
|
152
|
+
const parsed = parseWriteScreen(param || "copy");
|
|
153
|
+
return { type: "write_selection_file", ...parsed };
|
|
154
|
+
}
|
|
155
|
+
case "new_window":
|
|
156
|
+
return { type: "new_window" };
|
|
157
|
+
case "new_tab":
|
|
158
|
+
return { type: "new_tab" };
|
|
159
|
+
case "previous_tab":
|
|
160
|
+
return { type: "previous_tab" };
|
|
161
|
+
case "next_tab":
|
|
162
|
+
return { type: "next_tab" };
|
|
163
|
+
case "last_tab":
|
|
164
|
+
return { type: "last_tab" };
|
|
165
|
+
case "goto_tab":
|
|
166
|
+
return { type: "goto_tab", index: parseNumber(requireParam(input, "goto_tab"), "tab index") };
|
|
167
|
+
case "move_tab":
|
|
168
|
+
return { type: "move_tab", offset: parseNumber(requireParam(input, "move_tab"), "offset") };
|
|
169
|
+
case "toggle_tab_overview":
|
|
170
|
+
return { type: "toggle_tab_overview" };
|
|
171
|
+
case "prompt_surface_title":
|
|
172
|
+
return { type: "prompt_surface_title" };
|
|
173
|
+
case "prompt_tab_title":
|
|
174
|
+
return { type: "prompt_tab_title" };
|
|
175
|
+
case "set_surface_title":
|
|
176
|
+
return { type: "set_surface_title", title: param };
|
|
177
|
+
case "set_tab_title":
|
|
178
|
+
return { type: "set_tab_title", title: param };
|
|
179
|
+
case "new_split":
|
|
180
|
+
return {
|
|
181
|
+
type: "new_split",
|
|
182
|
+
direction: parseEnum(param || "auto", ["right", "down", "left", "up", "auto"], "split"),
|
|
183
|
+
};
|
|
184
|
+
case "goto_split": {
|
|
185
|
+
// Ghostty accepts top/bottom as aliases for up/down.
|
|
186
|
+
const normalized = param === "top" ? "up" : param === "bottom" ? "down" : param;
|
|
187
|
+
return {
|
|
188
|
+
type: "goto_split",
|
|
189
|
+
direction: parseEnum(normalized, ["previous", "next", "up", "left", "down", "right"], "goto_split"),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
case "goto_window":
|
|
193
|
+
return {
|
|
194
|
+
type: "goto_window",
|
|
195
|
+
direction: parseEnum(param, ["previous", "next"], "goto_window"),
|
|
196
|
+
};
|
|
197
|
+
case "toggle_split_zoom":
|
|
198
|
+
return { type: "toggle_split_zoom" };
|
|
199
|
+
case "toggle_readonly":
|
|
200
|
+
return { type: "toggle_readonly" };
|
|
201
|
+
case "resize_split": {
|
|
202
|
+
const [dir, amountRaw] = param.split(",", 2);
|
|
203
|
+
return {
|
|
204
|
+
type: "resize_split",
|
|
205
|
+
direction: parseEnum(dir ?? "", ["up", "down", "left", "right"], "resize_split"),
|
|
206
|
+
amount: parseNumber(amountRaw || "10", "resize amount"),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
case "equalize_splits":
|
|
210
|
+
return { type: "equalize_splits" };
|
|
211
|
+
case "reset_window_size":
|
|
212
|
+
return { type: "reset_window_size" };
|
|
213
|
+
case "inspector":
|
|
214
|
+
return {
|
|
215
|
+
type: "inspector",
|
|
216
|
+
mode: parseEnum(param || "toggle", ["toggle", "show", "hide"], "inspector"),
|
|
217
|
+
};
|
|
218
|
+
case "show_gtk_inspector":
|
|
219
|
+
return { type: "show_gtk_inspector" };
|
|
220
|
+
case "show_on_screen_keyboard":
|
|
221
|
+
return { type: "show_on_screen_keyboard" };
|
|
222
|
+
case "open_config":
|
|
223
|
+
return { type: "open_config" };
|
|
224
|
+
case "reload_config":
|
|
225
|
+
return { type: "reload_config" };
|
|
226
|
+
case "close_surface":
|
|
227
|
+
return { type: "close_surface" };
|
|
228
|
+
case "close_tab":
|
|
229
|
+
return {
|
|
230
|
+
type: "close_tab",
|
|
231
|
+
mode: parseEnum(param || "this", ["this", "other", "right"], "close_tab"),
|
|
232
|
+
};
|
|
233
|
+
case "close_window":
|
|
234
|
+
return { type: "close_window" };
|
|
235
|
+
case "close_all_windows":
|
|
236
|
+
return { type: "close_all_windows" };
|
|
237
|
+
case "toggle_maximize":
|
|
238
|
+
return { type: "toggle_maximize" };
|
|
239
|
+
case "toggle_fullscreen":
|
|
240
|
+
return { type: "toggle_fullscreen" };
|
|
241
|
+
case "toggle_window_decorations":
|
|
242
|
+
return { type: "toggle_window_decorations" };
|
|
243
|
+
case "toggle_window_float_on_top":
|
|
244
|
+
return { type: "toggle_window_float_on_top" };
|
|
245
|
+
case "toggle_secure_input":
|
|
246
|
+
return { type: "toggle_secure_input" };
|
|
247
|
+
case "toggle_mouse_reporting":
|
|
248
|
+
return { type: "toggle_mouse_reporting" };
|
|
249
|
+
case "toggle_command_palette":
|
|
250
|
+
return { type: "toggle_command_palette" };
|
|
251
|
+
case "toggle_quick_terminal":
|
|
252
|
+
return { type: "toggle_quick_terminal" };
|
|
253
|
+
case "toggle_visibility":
|
|
254
|
+
return { type: "toggle_visibility" };
|
|
255
|
+
case "toggle_background_opacity":
|
|
256
|
+
return { type: "toggle_background_opacity" };
|
|
257
|
+
case "check_for_updates":
|
|
258
|
+
return { type: "check_for_updates" };
|
|
259
|
+
case "undo":
|
|
260
|
+
return { type: "undo" };
|
|
261
|
+
case "redo":
|
|
262
|
+
return { type: "redo" };
|
|
263
|
+
case "end_key_sequence":
|
|
264
|
+
return { type: "end_key_sequence" };
|
|
265
|
+
case "activate_key_table":
|
|
266
|
+
return { type: "activate_key_table", name: param };
|
|
267
|
+
case "activate_key_table_once":
|
|
268
|
+
return { type: "activate_key_table_once", name: param };
|
|
269
|
+
case "deactivate_key_table":
|
|
270
|
+
return { type: "deactivate_key_table" };
|
|
271
|
+
case "deactivate_all_key_tables":
|
|
272
|
+
return { type: "deactivate_all_key_tables" };
|
|
273
|
+
case "quit":
|
|
274
|
+
return { type: "quit" };
|
|
275
|
+
case "crash":
|
|
276
|
+
return {
|
|
277
|
+
type: "crash",
|
|
278
|
+
thread: parseEnum(param || "main", ["main", "io", "render"], "crash"),
|
|
279
|
+
};
|
|
280
|
+
default:
|
|
281
|
+
throw new GhosttyActionParseError(`unknown action: ${name}`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Decode the subset of Zig string-literal escapes used in Ghostty config dumps.
|
|
286
|
+
*
|
|
287
|
+
* Ghostty `+list-keybinds` prints text actions with a doubled backslash
|
|
288
|
+
* (`text:\\x05`) so the line is pasteable into a config file. Accept both
|
|
289
|
+
* `\\xNN` (dump form) and `\xNN` (single-escaped).
|
|
290
|
+
*/
|
|
291
|
+
export function decodeZigStringLiteral(value) {
|
|
292
|
+
let out = "";
|
|
293
|
+
for (let i = 0; i < value.length; i++) {
|
|
294
|
+
const ch = value[i];
|
|
295
|
+
if (ch !== "\\") {
|
|
296
|
+
out += ch;
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
const next = value[i + 1];
|
|
300
|
+
// Dump form: \\x05 → one control character
|
|
301
|
+
if (next === "\\" && (value[i + 2] === "x" || value[i + 2] === "X")) {
|
|
302
|
+
const hex = value.slice(i + 3, i + 5);
|
|
303
|
+
if (/^[0-9a-fA-F]{2}$/.test(hex)) {
|
|
304
|
+
out += String.fromCharCode(parseInt(hex, 16));
|
|
305
|
+
i += 4;
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (next === "x" || next === "X") {
|
|
310
|
+
const hex = value.slice(i + 2, i + 4);
|
|
311
|
+
if (/^[0-9a-fA-F]{2}$/.test(hex)) {
|
|
312
|
+
out += String.fromCharCode(parseInt(hex, 16));
|
|
313
|
+
i += 3;
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (next === "n") {
|
|
318
|
+
out += "\n";
|
|
319
|
+
i += 1;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (next === "r") {
|
|
323
|
+
out += "\r";
|
|
324
|
+
i += 1;
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
if (next === "t") {
|
|
328
|
+
out += "\t";
|
|
329
|
+
i += 1;
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
if (next === "\\" || next === '"' || next === "'") {
|
|
333
|
+
out += next;
|
|
334
|
+
i += 1;
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
// Unknown escape: keep the following char.
|
|
338
|
+
if (next !== undefined) {
|
|
339
|
+
out += next;
|
|
340
|
+
i += 1;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return out;
|
|
344
|
+
}
|
|
345
|
+
export function formatGhosttyAction(action) {
|
|
346
|
+
switch (action.type) {
|
|
347
|
+
case "csi":
|
|
348
|
+
case "esc":
|
|
349
|
+
return `${action.type}:${action.value}`;
|
|
350
|
+
case "text":
|
|
351
|
+
return `text:${encodeZigStringLiteral(action.value)}`;
|
|
352
|
+
case "cursor_key":
|
|
353
|
+
return `cursor_key:${action.normal},${action.application}`;
|
|
354
|
+
case "copy_to_clipboard":
|
|
355
|
+
return `copy_to_clipboard:${action.format}`;
|
|
356
|
+
case "increase_font_size":
|
|
357
|
+
return `increase_font_size:${action.amount}`;
|
|
358
|
+
case "decrease_font_size":
|
|
359
|
+
return `decrease_font_size:${action.amount}`;
|
|
360
|
+
case "set_font_size":
|
|
361
|
+
return `set_font_size:${action.size}`;
|
|
362
|
+
case "search":
|
|
363
|
+
return `search:${action.query}`;
|
|
364
|
+
case "navigate_search":
|
|
365
|
+
return `navigate_search:${action.direction}`;
|
|
366
|
+
case "scroll_to_row":
|
|
367
|
+
return `scroll_to_row:${action.row}`;
|
|
368
|
+
case "scroll_page_fractional":
|
|
369
|
+
return `scroll_page_fractional:${action.amount}`;
|
|
370
|
+
case "scroll_page_lines":
|
|
371
|
+
return `scroll_page_lines:${action.lines}`;
|
|
372
|
+
case "adjust_selection":
|
|
373
|
+
return `adjust_selection:${action.direction}`;
|
|
374
|
+
case "jump_to_prompt":
|
|
375
|
+
return `jump_to_prompt:${action.offset}`;
|
|
376
|
+
case "write_scrollback_file":
|
|
377
|
+
case "write_screen_file":
|
|
378
|
+
case "write_selection_file":
|
|
379
|
+
return `${action.type}:${action.action},${action.format}`;
|
|
380
|
+
case "goto_tab":
|
|
381
|
+
return `goto_tab:${action.index}`;
|
|
382
|
+
case "move_tab":
|
|
383
|
+
return `move_tab:${action.offset}`;
|
|
384
|
+
case "set_surface_title":
|
|
385
|
+
return `set_surface_title:${action.title}`;
|
|
386
|
+
case "set_tab_title":
|
|
387
|
+
return `set_tab_title:${action.title}`;
|
|
388
|
+
case "new_split":
|
|
389
|
+
return `new_split:${action.direction}`;
|
|
390
|
+
case "goto_split":
|
|
391
|
+
return `goto_split:${action.direction}`;
|
|
392
|
+
case "goto_window":
|
|
393
|
+
return `goto_window:${action.direction}`;
|
|
394
|
+
case "resize_split":
|
|
395
|
+
return `resize_split:${action.direction},${action.amount}`;
|
|
396
|
+
case "inspector":
|
|
397
|
+
return `inspector:${action.mode}`;
|
|
398
|
+
case "close_tab":
|
|
399
|
+
return `close_tab:${action.mode}`;
|
|
400
|
+
case "activate_key_table":
|
|
401
|
+
return `activate_key_table:${action.name}`;
|
|
402
|
+
case "activate_key_table_once":
|
|
403
|
+
return `activate_key_table_once:${action.name}`;
|
|
404
|
+
case "crash":
|
|
405
|
+
return `crash:${action.thread}`;
|
|
406
|
+
default:
|
|
407
|
+
return action.type;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function encodeZigStringLiteral(value) {
|
|
411
|
+
let out = "";
|
|
412
|
+
for (const ch of value) {
|
|
413
|
+
const code = ch.codePointAt(0);
|
|
414
|
+
if (code < 0x20 || code === 0x7f) {
|
|
415
|
+
out += `\\x${code.toString(16).padStart(2, "0")}`;
|
|
416
|
+
}
|
|
417
|
+
else if (ch === "\\") {
|
|
418
|
+
out += "\\\\";
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
out += ch;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return out;
|
|
425
|
+
}
|
|
426
|
+
export function parseGhostteaBindingAction(raw) {
|
|
427
|
+
if (raw === "ghosttea.remote_sessions")
|
|
428
|
+
return { type: "ghosttea.remote_sessions" };
|
|
429
|
+
return parseGhosttyAction(raw);
|
|
430
|
+
}
|
|
431
|
+
//# sourceMappingURL=ghostty-actions.js.map
|