1#![allow(non_snake_case)]
7#![allow(clippy::too_many_arguments)]
8#![allow(clippy::new_without_default)]
9
10pub mod builders;
11
12use js_sys::Array;
13use js_sys::Boolean;
14use js_sys::Function;
15use js_sys::JsOption;
16use js_sys::JsString;
17use js_sys::Number;
18use js_sys::Object;
19use js_sys::Promise;
20use js_sys::Set;
21use js_sys::Uint8Array;
22use js_sys::Undefined;
23use js_sys::WebAssembly;
24pub use wasm_bindgen::JsGeneric;
25use wasm_bindgen::prelude::*;
26use web_sys::HtmlCanvasElement;
27use web_sys::HtmlElement;
28use web_sys::HtmlTextAreaElement;
29use web_sys::KeyboardEvent;
30use web_sys::MouseEvent;
31use web_sys::WheelEvent;
32
33pub type TerminalHandle = f64;
35
36pub type IEvent<T> = Function<fn(Function<fn(T) -> Undefined>) -> IDisposable>;
38
39pub type IEventVoid = Function<fn(Function<fn() -> Undefined>) -> IDisposable>;
41
42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
44#[repr(transparent)]
45pub struct CellFlags(pub u32);
46
47impl CellFlags
48{
49 pub const BOLD: Self = Self(1);
50 pub const ITALIC: Self = Self(2);
51 pub const UNDERLINE: Self = Self(4);
52 pub const STRIKETHROUGH: Self = Self(8);
53 pub const INVERSE: Self = Self(16);
54 pub const INVISIBLE: Self = Self(32);
55 pub const BLINK: Self = Self(64);
56 pub const FAINT: Self = Self(128);
57
58 #[inline]
59 pub const fn bits(self) -> u32 { self.0 }
60
61 #[inline]
62 pub const fn contains(self, other: Self) -> bool { (self.0 & other.0) == other.0 }
63}
64
65impl core::ops::BitOr for CellFlags
66{
67 type Output = Self;
68 #[inline]
69 fn bitor(self, rhs: Self) -> Self { Self(self.0 | rhs.0) }
70}
71
72impl core::ops::BitAnd for CellFlags
73{
74 type Output = Self;
75 #[inline]
76 fn bitand(self, rhs: Self) -> Self { Self(self.0 & rhs.0) }
77}
78
79#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
81#[repr(u32)]
82pub enum DirtyState
83{
84 None = 0,
85 Partial = 1,
86 Full = 2,
87}
88
89impl DirtyState
90{
91 pub fn from_u32(value: u32) -> Self
92 {
93 match value
94 {
95 1 => Self::Partial,
96 2 => Self::Full,
97 _ => Self::None,
98 }
99 }
100}
101
102#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
104#[repr(u32)]
105pub enum KeyAction
106{
107 Release = 0,
108 Press = 1,
109 Repeat = 2,
110}
111
112#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
114#[repr(u32)]
115pub enum KeyEncoderOption
116{
117 CursorKeyApplication = 0,
119 KeypadKeyApplication = 1,
121 IgnoreKeypadWithNumlock = 2,
123 AltEscPrefix = 3,
125 ModifyOtherKeysState2 = 4,
127 KittyKeyboardFlags = 5,
128}
129
130#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
134#[repr(transparent)]
135pub struct KittyKeyFlags(pub u32);
136
137impl KittyKeyFlags
138{
139 pub const DISABLED: Self = Self(0);
140 pub const DISAMBIGUATE: Self = Self(1);
142 pub const REPORT_EVENTS: Self = Self(2);
144 pub const REPORT_ALTERNATES: Self = Self(4);
146 pub const REPORT_ALL: Self = Self(8);
148 pub const REPORT_ASSOCIATED: Self = Self(16);
150 pub const ALL: Self = Self(31);
151
152 #[inline]
153 pub const fn bits(self) -> u32 { self.0 }
154}
155
156impl core::ops::BitOr for KittyKeyFlags
157{
158 type Output = Self;
159 #[inline]
160 fn bitor(self, rhs: Self) -> Self { Self(self.0 | rhs.0) }
161}
162
163#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
165#[repr(transparent)]
166pub struct Mods(pub u32);
167
168impl Mods
169{
170 pub const NONE: Self = Self(0);
171 pub const SHIFT: Self = Self(1);
172 pub const CTRL: Self = Self(2);
173 pub const ALT: Self = Self(4);
174 pub const SUPER: Self = Self(8);
176 pub const CAPSLOCK: Self = Self(16);
177 pub const NUMLOCK: Self = Self(32);
178
179 #[inline]
180 pub const fn bits(self) -> u32 { self.0 }
181
182 #[inline]
183 pub const fn contains(self, other: Self) -> bool { (self.0 & other.0) == other.0 }
184}
185
186impl core::ops::BitOr for Mods
187{
188 type Output = Self;
189 #[inline]
190 fn bitor(self, rhs: Self) -> Self { Self(self.0 | rhs.0) }
191}
192
193impl core::ops::BitAnd for Mods
194{
195 type Output = Self;
196 #[inline]
197 fn bitand(self, rhs: Self) -> Self { Self(self.0 & rhs.0) }
198}
199
200#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
205#[repr(u32)]
206pub enum Key
207{
208 Unidentified = 0,
209 Grave = 1,
211 Backslash = 2,
213 BracketLeft = 3,
215 BracketRight = 4,
217 Comma = 5,
219 Zero = 6,
220 One = 7,
221 Two = 8,
222 Three = 9,
223 Four = 10,
224 Five = 11,
225 Six = 12,
226 Seven = 13,
227 Eight = 14,
228 Nine = 15,
229 Equal = 16,
231 IntlBackslash = 17,
232 IntlRo = 18,
233 IntlYen = 19,
234 A = 20,
235 B = 21,
236 C = 22,
237 D = 23,
238 E = 24,
239 F = 25,
240 G = 26,
241 H = 27,
242 I = 28,
243 J = 29,
244 K = 30,
245 L = 31,
246 M = 32,
247 N = 33,
248 O = 34,
249 P = 35,
250 Q = 36,
251 R = 37,
252 S = 38,
253 T = 39,
254 U = 40,
255 V = 41,
256 W = 42,
257 X = 43,
258 Y = 44,
259 Z = 45,
260 Minus = 46,
262 Period = 47,
264 Quote = 48,
266 Semicolon = 49,
268 Slash = 50,
270 AltLeft = 51,
271 AltRight = 52,
272 Backspace = 53,
273 CapsLock = 54,
274 ContextMenu = 55,
275 ControlLeft = 56,
276 ControlRight = 57,
277 Enter = 58,
278 MetaLeft = 59,
279 MetaRight = 60,
280 ShiftLeft = 61,
281 ShiftRight = 62,
282 Space = 63,
283 Tab = 64,
284 Convert = 65,
285 KanaMode = 66,
286 NonConvert = 67,
287 Delete = 68,
288 End = 69,
289 Help = 70,
290 Home = 71,
291 Insert = 72,
292 PageDown = 73,
293 PageUp = 74,
294 Down = 75,
295 Left = 76,
296 Right = 77,
297 Up = 78,
298 NumLock = 79,
299 Kp0 = 80,
300 Kp1 = 81,
301 Kp2 = 82,
302 Kp3 = 83,
303 Kp4 = 84,
304 Kp5 = 85,
305 Kp6 = 86,
306 Kp7 = 87,
307 Kp8 = 88,
308 Kp9 = 89,
309 KpPlus = 90,
311 KpBackspace = 91,
312 KpClear = 92,
313 KpClearEntry = 93,
314 KpComma = 94,
315 KpPeriod = 95,
317 KpDivide = 96,
319 KpEnter = 97,
321 KpEqual = 98,
322 KpMemoryAdd = 99,
323 KpMemoryClear = 100,
324 KpMemoryRecall = 101,
325 KpMemoryStore = 102,
326 KpMemorySubtract = 103,
327 KpMultiply = 104,
329 KpParenLeft = 105,
330 KpParenRight = 106,
331 KpMinus = 107,
333 KpSeparator = 108,
334 NumpadUp = 109,
335 NumpadDown = 110,
336 NumpadRight = 111,
337 NumpadLeft = 112,
338 NumpadBegin = 113,
339 NumpadHome = 114,
340 NumpadEnd = 115,
341 NumpadInsert = 116,
342 NumpadDelete = 117,
343 NumpadPageUp = 118,
344 NumpadPageDown = 119,
345 Escape = 120,
346 F1 = 121,
347 F2 = 122,
348 F3 = 123,
349 F4 = 124,
350 F5 = 125,
351 F6 = 126,
352 F7 = 127,
353 F8 = 128,
354 F9 = 129,
355 F10 = 130,
356 F11 = 131,
357 F12 = 132,
358 F13 = 133,
359 F14 = 134,
360 F15 = 135,
361 F16 = 136,
362 F17 = 137,
363 F18 = 138,
364 F19 = 139,
365 F20 = 140,
366 F21 = 141,
367 F22 = 142,
368 F23 = 143,
369 F24 = 144,
370 F25 = 145,
371 FnLock = 146,
372 PrintScreen = 147,
373 ScrollLock = 148,
374 Pause = 149,
375 BrowserBack = 150,
376 BrowserFavorites = 151,
377 BrowserForward = 152,
378 BrowserHome = 153,
379 BrowserRefresh = 154,
380 BrowserSearch = 155,
381 BrowserStop = 156,
382 Eject = 157,
383 LaunchApp1 = 158,
384 LaunchApp2 = 159,
385 LaunchMail = 160,
386 MediaPlayPause = 161,
387 MediaSelect = 162,
388 MediaStop = 163,
389 MediaTrackNext = 164,
390 MediaTrackPrevious = 165,
391 Power = 166,
392 Sleep = 167,
393 AudioVolumeDown = 168,
394 AudioVolumeMute = 169,
395 AudioVolumeUp = 170,
396 WakeUp = 171,
397 Copy = 172,
398 Cut = 173,
399 Paste = 174,
400}
401
402#[wasm_bindgen]
403extern "C" {
404 #[wasm_bindgen(extends = Object)]
405 #[derive(Clone, Debug)]
406 pub type ITheme;
407
408 #[wasm_bindgen(method, setter, js_name = foreground)]
409 pub fn set_foreground(this: &ITheme, value: &str);
410 #[wasm_bindgen(method, setter, js_name = background)]
411 pub fn set_background(this: &ITheme, value: &str);
412 #[wasm_bindgen(method, setter, js_name = cursor)]
413 pub fn set_cursor(this: &ITheme, value: &str);
414 #[wasm_bindgen(method, setter, js_name = cursorAccent)]
415 pub fn set_cursor_accent(this: &ITheme, value: &str);
416 #[wasm_bindgen(method, setter, js_name = selectionBackground)]
417 pub fn set_selection_background(this: &ITheme, value: &str);
418 #[wasm_bindgen(method, setter, js_name = selectionForeground)]
419 pub fn set_selection_foreground(this: &ITheme, value: &str);
420 #[wasm_bindgen(method, setter)]
421 pub fn set_black(this: &ITheme, value: &str);
422 #[wasm_bindgen(method, setter)]
423 pub fn set_red(this: &ITheme, value: &str);
424 #[wasm_bindgen(method, setter)]
425 pub fn set_green(this: &ITheme, value: &str);
426 #[wasm_bindgen(method, setter)]
427 pub fn set_yellow(this: &ITheme, value: &str);
428 #[wasm_bindgen(method, setter)]
429 pub fn set_blue(this: &ITheme, value: &str);
430 #[wasm_bindgen(method, setter)]
431 pub fn set_magenta(this: &ITheme, value: &str);
432 #[wasm_bindgen(method, setter)]
433 pub fn set_cyan(this: &ITheme, value: &str);
434 #[wasm_bindgen(method, setter)]
435 pub fn set_white(this: &ITheme, value: &str);
436 #[wasm_bindgen(method, setter, js_name = brightBlack)]
437 pub fn set_bright_black(this: &ITheme, value: &str);
438 #[wasm_bindgen(method, setter, js_name = brightRed)]
439 pub fn set_bright_red(this: &ITheme, value: &str);
440 #[wasm_bindgen(method, setter, js_name = brightGreen)]
441 pub fn set_bright_green(this: &ITheme, value: &str);
442 #[wasm_bindgen(method, setter, js_name = brightYellow)]
443 pub fn set_bright_yellow(this: &ITheme, value: &str);
444 #[wasm_bindgen(method, setter, js_name = brightBlue)]
445 pub fn set_bright_blue(this: &ITheme, value: &str);
446 #[wasm_bindgen(method, setter, js_name = brightMagenta)]
447 pub fn set_bright_magenta(this: &ITheme, value: &str);
448 #[wasm_bindgen(method, setter, js_name = brightCyan)]
449 pub fn set_bright_cyan(this: &ITheme, value: &str);
450 #[wasm_bindgen(method, setter, js_name = brightWhite)]
451 pub fn set_bright_white(this: &ITheme, value: &str);
452}
453
454impl ITheme
455{
456 pub fn new() -> Self { Object::new().unchecked_into() }
457}
458
459#[wasm_bindgen]
460extern "C" {
461 #[wasm_bindgen(extends = Object)]
462 #[derive(Clone, Debug)]
463 pub type ITerminalOptions;
464
465 #[wasm_bindgen(method, setter)]
466 pub fn set_cols(this: &ITerminalOptions, value: u32);
467 #[wasm_bindgen(method, setter)]
468 pub fn set_rows(this: &ITerminalOptions, value: u32);
469 #[wasm_bindgen(method, setter, js_name = cursorBlink)]
470 pub fn set_cursor_blink(this: &ITerminalOptions, value: bool);
471 #[wasm_bindgen(method, setter, js_name = cursorStyle)]
473 pub fn set_cursor_style(this: &ITerminalOptions, value: &str);
474 #[wasm_bindgen(method, setter)]
475 pub fn set_theme(this: &ITerminalOptions, value: &ITheme);
476 #[wasm_bindgen(method, setter)]
477 pub fn set_scrollback(this: &ITerminalOptions, value: u32);
478 #[wasm_bindgen(method, setter, js_name = fontSize)]
479 pub fn set_font_size(this: &ITerminalOptions, value: f64);
480 #[wasm_bindgen(method, setter, js_name = fontFamily)]
481 pub fn set_font_family(this: &ITerminalOptions, value: &str);
482 #[wasm_bindgen(method, setter, js_name = allowTransparency)]
483 pub fn set_allow_transparency(this: &ITerminalOptions, value: bool);
484 #[wasm_bindgen(method, setter, js_name = convertEol)]
485 pub fn set_convert_eol(this: &ITerminalOptions, value: bool);
486 #[wasm_bindgen(method, setter, js_name = disableStdin)]
487 pub fn set_disable_stdin(this: &ITerminalOptions, value: bool);
488 #[wasm_bindgen(method, setter, js_name = smoothScrollDuration)]
489 pub fn set_smooth_scroll_duration(this: &ITerminalOptions, value: f64);
490 #[wasm_bindgen(method, setter)]
491 pub fn set_ghostty(this: &ITerminalOptions, value: &Ghostty);
492}
493
494impl ITerminalOptions
495{
496 pub fn new() -> Self { Object::new().unchecked_into() }
497}
498
499#[wasm_bindgen]
500extern "C" {
501 #[wasm_bindgen(extends = Object)]
502 #[derive(Clone, Debug)]
503 pub type RendererOptions;
504
505 #[wasm_bindgen(method, setter, js_name = fontSize)]
506 pub fn set_font_size(this: &RendererOptions, value: f64);
507 #[wasm_bindgen(method, setter, js_name = fontFamily)]
508 pub fn set_font_family(this: &RendererOptions, value: &str);
509 #[wasm_bindgen(method, setter, js_name = cursorStyle)]
511 pub fn set_cursor_style(this: &RendererOptions, value: &str);
512 #[wasm_bindgen(method, setter, js_name = cursorBlink)]
513 pub fn set_cursor_blink(this: &RendererOptions, value: bool);
514 #[wasm_bindgen(method, setter)]
515 pub fn set_theme(this: &RendererOptions, value: &ITheme);
516 #[wasm_bindgen(method, setter, js_name = devicePixelRatio)]
517 pub fn set_device_pixel_ratio(this: &RendererOptions, value: f64);
518}
519
520impl RendererOptions
521{
522 pub fn new() -> Self { Object::new().unchecked_into() }
523}
524
525#[wasm_bindgen]
526extern "C" {
527 #[wasm_bindgen(extends = Object)]
532 #[derive(Clone, Debug)]
533 pub type GhosttyTerminalConfig;
534
535 #[wasm_bindgen(method, setter, js_name = scrollbackLimit)]
536 pub fn set_scrollback_limit(this: &GhosttyTerminalConfig, value: u32);
537 #[wasm_bindgen(method, setter, js_name = fgColor)]
538 pub fn set_fg_color(this: &GhosttyTerminalConfig, value: u32);
539 #[wasm_bindgen(method, setter, js_name = bgColor)]
540 pub fn set_bg_color(this: &GhosttyTerminalConfig, value: u32);
541 #[wasm_bindgen(method, setter, js_name = cursorColor)]
542 pub fn set_cursor_color(this: &GhosttyTerminalConfig, value: u32);
543 #[wasm_bindgen(method, setter)]
544 pub fn set_palette(this: &GhosttyTerminalConfig, value: &Array<Number>);
545}
546
547impl GhosttyTerminalConfig
548{
549 pub fn new() -> Self { Object::new().unchecked_into() }
550}
551
552#[wasm_bindgen]
553extern "C" {
554 #[wasm_bindgen(extends = Object)]
556 #[derive(Clone, Debug)]
557 pub type KeyEvent;
558
559 #[wasm_bindgen(method, setter)]
560 pub fn set_action(this: &KeyEvent, value: u32);
561 #[wasm_bindgen(method, setter)]
562 pub fn set_key(this: &KeyEvent, value: u32);
563 #[wasm_bindgen(method, setter)]
564 pub fn set_mods(this: &KeyEvent, value: u32);
565 #[wasm_bindgen(method, setter, js_name = consumedMods)]
566 pub fn set_consumed_mods(this: &KeyEvent, value: u32);
567 #[wasm_bindgen(method, setter)]
568 pub fn set_composing(this: &KeyEvent, value: bool);
569 #[wasm_bindgen(method, setter)]
570 pub fn set_utf8(this: &KeyEvent, value: &str);
571 #[wasm_bindgen(method, setter, js_name = unshiftedCodepoint)]
572 pub fn set_unshifted_codepoint(this: &KeyEvent, value: u32);
573}
574
575impl KeyEvent
576{
577 pub fn new() -> Self { Object::new().unchecked_into() }
578}
579
580#[wasm_bindgen]
581extern "C" {
582 #[wasm_bindgen(extends = Object)]
583 #[derive(Clone, Debug)]
584 pub type IDisposable;
585
586 #[wasm_bindgen(method)]
587 pub fn dispose(this: &IDisposable);
588}
589
590#[wasm_bindgen]
591extern "C" {
592 #[wasm_bindgen(extends = Object)]
594 #[derive(Clone, Debug)]
595 pub type RGB;
596
597 #[wasm_bindgen(method, getter)]
598 pub fn r(this: &RGB) -> u8;
599 #[wasm_bindgen(method, getter)]
600 pub fn g(this: &RGB) -> u8;
601 #[wasm_bindgen(method, getter)]
602 pub fn b(this: &RGB) -> u8;
603}
604
605#[wasm_bindgen]
606extern "C" {
607 #[wasm_bindgen(extends = Object)]
608 #[derive(Clone, Debug)]
609 pub type FontMetrics;
610
611 #[wasm_bindgen(method, getter)]
612 pub fn width(this: &FontMetrics) -> f64;
613 #[wasm_bindgen(method, getter)]
614 pub fn height(this: &FontMetrics) -> f64;
615 #[wasm_bindgen(method, getter)]
616 pub fn baseline(this: &FontMetrics) -> f64;
617}
618
619#[wasm_bindgen]
620extern "C" {
621 #[wasm_bindgen(extends = Object)]
623 #[derive(Clone, Debug)]
624 pub type Cursor;
625
626 #[wasm_bindgen(method, getter)]
627 pub fn x(this: &Cursor) -> u32;
628 #[wasm_bindgen(method, getter)]
629 pub fn y(this: &Cursor) -> u32;
630 #[wasm_bindgen(method, getter)]
631 pub fn visible(this: &Cursor) -> bool;
632}
633
634#[wasm_bindgen]
635extern "C" {
636 #[wasm_bindgen(extends = Object)]
638 #[derive(Clone, Debug)]
639 pub type GhosttyCell;
640
641 #[wasm_bindgen(method, getter)]
642 pub fn codepoint(this: &GhosttyCell) -> u32;
643 #[wasm_bindgen(method, getter)]
644 pub fn fg_r(this: &GhosttyCell) -> u8;
645 #[wasm_bindgen(method, getter)]
646 pub fn fg_g(this: &GhosttyCell) -> u8;
647 #[wasm_bindgen(method, getter)]
648 pub fn fg_b(this: &GhosttyCell) -> u8;
649 #[wasm_bindgen(method, getter)]
650 pub fn bg_r(this: &GhosttyCell) -> u8;
651 #[wasm_bindgen(method, getter)]
652 pub fn bg_g(this: &GhosttyCell) -> u8;
653 #[wasm_bindgen(method, getter)]
654 pub fn bg_b(this: &GhosttyCell) -> u8;
655 #[wasm_bindgen(method, getter)]
656 pub fn flags(this: &GhosttyCell) -> u32;
657 #[wasm_bindgen(method, getter)]
658 pub fn width(this: &GhosttyCell) -> u8;
659 #[wasm_bindgen(method, getter)]
660 pub fn hyperlink_id(this: &GhosttyCell) -> u32;
661 #[wasm_bindgen(method, getter)]
662 pub fn grapheme_len(this: &GhosttyCell) -> u8;
663}
664
665#[wasm_bindgen]
666extern "C" {
667 #[wasm_bindgen(extends = Object)]
673 #[derive(Clone, Debug)]
674 pub type RenderStateCursor;
675
676 #[wasm_bindgen(method, getter)]
677 pub fn x(this: &RenderStateCursor) -> u32;
678 #[wasm_bindgen(method, getter)]
679 pub fn y(this: &RenderStateCursor) -> u32;
680 #[wasm_bindgen(method, getter, js_name = viewportX)]
681 pub fn viewport_x(this: &RenderStateCursor) -> i32;
682 #[wasm_bindgen(method, getter, js_name = viewportY)]
683 pub fn viewport_y(this: &RenderStateCursor) -> i32;
684 #[wasm_bindgen(method, getter)]
685 pub fn visible(this: &RenderStateCursor) -> bool;
686 #[wasm_bindgen(method, getter)]
687 pub fn blinking(this: &RenderStateCursor) -> bool;
688 #[wasm_bindgen(method, getter)]
690 pub fn style(this: &RenderStateCursor) -> JsString;
691}
692
693#[wasm_bindgen]
694extern "C" {
695 #[wasm_bindgen(extends = Object)]
697 #[derive(Clone, Debug)]
698 pub type RenderStateColors;
699
700 #[wasm_bindgen(method, getter)]
701 pub fn background(this: &RenderStateColors) -> RGB;
702 #[wasm_bindgen(method, getter)]
703 pub fn foreground(this: &RenderStateColors) -> RGB;
704 #[wasm_bindgen(method, getter)]
705 pub fn cursor(this: &RenderStateColors) -> Option<RGB>;
706}
707
708#[wasm_bindgen]
709extern "C" {
710 #[wasm_bindgen(extends = Object)]
712 #[derive(Clone, Debug)]
713 pub type IBufferCellPosition;
714
715 #[wasm_bindgen(method, getter)]
716 pub fn x(this: &IBufferCellPosition) -> u32;
717 #[wasm_bindgen(method, getter)]
718 pub fn y(this: &IBufferCellPosition) -> u32;
719}
720
721#[wasm_bindgen]
722extern "C" {
723 #[wasm_bindgen(extends = Object)]
725 #[derive(Clone, Debug)]
726 pub type IBufferRange;
727
728 #[wasm_bindgen(method, getter)]
729 pub fn start(this: &IBufferRange) -> IBufferCellPosition;
730 #[wasm_bindgen(method, getter)]
731 pub fn end(this: &IBufferRange) -> IBufferCellPosition;
732}
733
734#[wasm_bindgen]
735extern "C" {
736 #[wasm_bindgen(extends = Object)]
737 #[derive(Clone, Debug)]
738 pub type SelectionCoordinates;
739
740 #[wasm_bindgen(method, getter, js_name = startCol)]
741 pub fn start_col(this: &SelectionCoordinates) -> u32;
742 #[wasm_bindgen(method, getter, js_name = startRow)]
743 pub fn start_row(this: &SelectionCoordinates) -> u32;
744 #[wasm_bindgen(method, getter, js_name = endCol)]
745 pub fn end_col(this: &SelectionCoordinates) -> u32;
746 #[wasm_bindgen(method, getter, js_name = endRow)]
747 pub fn end_row(this: &SelectionCoordinates) -> u32;
748}
749
750#[wasm_bindgen]
751extern "C" {
752 #[wasm_bindgen(extends = Object)]
753 #[derive(Clone, Debug)]
754 pub type ITerminalDimensions;
755
756 #[wasm_bindgen(method, getter)]
757 pub fn cols(this: &ITerminalDimensions) -> u32;
758 #[wasm_bindgen(method, getter)]
759 pub fn rows(this: &ITerminalDimensions) -> u32;
760}
761
762#[wasm_bindgen]
763extern "C" {
764 #[wasm_bindgen(extends = Object)]
765 #[derive(Clone, Debug)]
766 pub type ResizeEvent;
767
768 #[wasm_bindgen(method, getter)]
769 pub fn cols(this: &ResizeEvent) -> u32;
770 #[wasm_bindgen(method, getter)]
771 pub fn rows(this: &ResizeEvent) -> u32;
772}
773
774#[wasm_bindgen]
775extern "C" {
776 #[wasm_bindgen(extends = Object)]
777 #[derive(Clone, Debug)]
778 pub type RenderEvent;
779
780 #[wasm_bindgen(method, getter)]
781 pub fn start(this: &RenderEvent) -> u32;
782 #[wasm_bindgen(method, getter)]
783 pub fn end(this: &RenderEvent) -> u32;
784}
785
786#[wasm_bindgen]
787extern "C" {
788 #[wasm_bindgen(extends = Object)]
789 #[derive(Clone, Debug)]
790 pub type Dimensions;
791
792 #[wasm_bindgen(method, getter)]
793 pub fn cols(this: &Dimensions) -> u32;
794 #[wasm_bindgen(method, getter)]
795 pub fn rows(this: &Dimensions) -> u32;
796}
797
798#[wasm_bindgen]
799extern "C" {
800 #[wasm_bindgen(extends = Object)]
802 #[derive(Clone, Debug)]
803 pub type IKeyEvent;
804
805 #[wasm_bindgen(method, getter)]
806 pub fn key(this: &IKeyEvent) -> JsString;
807 #[wasm_bindgen(method, getter, js_name = domEvent)]
808 pub fn dom_event(this: &IKeyEvent) -> KeyboardEvent;
809}
810
811#[wasm_bindgen]
812extern "C" {
813 #[wasm_bindgen(extends = Object)]
814 #[derive(Clone, Debug)]
815 pub type HoveredLinkRange;
816
817 #[wasm_bindgen(method, getter, js_name = startX)]
818 pub fn start_x(this: &HoveredLinkRange) -> u32;
819 #[wasm_bindgen(method, getter, js_name = startY)]
820 pub fn start_y(this: &HoveredLinkRange) -> u32;
821 #[wasm_bindgen(method, getter, js_name = endX)]
822 pub fn end_x(this: &HoveredLinkRange) -> u32;
823 #[wasm_bindgen(method, getter, js_name = endY)]
824 pub fn end_y(this: &HoveredLinkRange) -> u32;
825}
826
827#[wasm_bindgen]
828extern "C" {
829 #[wasm_bindgen(extends = Object)]
831 #[derive(Clone, Debug)]
832 pub type ILink;
833
834 #[wasm_bindgen(method, getter)]
836 pub fn text(this: &ILink) -> JsString;
837 #[wasm_bindgen(method, getter)]
839 pub fn range(this: &ILink) -> IBufferRange;
840 #[wasm_bindgen(method)]
842 pub fn activate(this: &ILink, event: &MouseEvent);
843 #[wasm_bindgen(method)]
845 pub fn hover(this: &ILink, is_hovered: bool);
846 #[wasm_bindgen(method)]
848 pub fn dispose(this: &ILink);
849}
850
851#[wasm_bindgen]
852extern "C" {
853 #[wasm_bindgen(extends = Object)]
857 #[derive(Clone, Debug)]
858 pub type ILinkProvider;
859
860 #[wasm_bindgen(method, js_name = provideLinks)]
865 pub fn provide_links(
866 this: &ILinkProvider,
867 y: u32,
868 callback: &Function<fn(JsOption<Array<ILink>>) -> Undefined>,
869 );
870 #[wasm_bindgen(method)]
872 pub fn dispose(this: &ILinkProvider);
873}
874
875#[wasm_bindgen]
876extern "C" {
877 #[wasm_bindgen(extends = Object)]
879 #[derive(Clone, Debug)]
880 pub type IBufferCell;
881
882 #[wasm_bindgen(method, js_name = getChars)]
884 pub fn get_chars(this: &IBufferCell) -> JsString;
885 #[wasm_bindgen(method, js_name = getCode)]
887 pub fn get_code(this: &IBufferCell) -> u32;
888 #[wasm_bindgen(method, js_name = getWidth)]
890 pub fn get_width(this: &IBufferCell) -> u8;
891 #[wasm_bindgen(method, js_name = getFgColorMode)]
893 pub fn get_fg_color_mode(this: &IBufferCell) -> i32;
894 #[wasm_bindgen(method, js_name = getBgColorMode)]
896 pub fn get_bg_color_mode(this: &IBufferCell) -> i32;
897 #[wasm_bindgen(method, js_name = getFgColor)]
899 pub fn get_fg_color(this: &IBufferCell) -> u32;
900 #[wasm_bindgen(method, js_name = getBgColor)]
902 pub fn get_bg_color(this: &IBufferCell) -> u32;
903 #[wasm_bindgen(method, js_name = isBold)]
905 pub fn is_bold(this: &IBufferCell) -> u32;
906 #[wasm_bindgen(method, js_name = isItalic)]
908 pub fn is_italic(this: &IBufferCell) -> u32;
909 #[wasm_bindgen(method, js_name = isUnderline)]
911 pub fn is_underline(this: &IBufferCell) -> u32;
912 #[wasm_bindgen(method, js_name = isStrikethrough)]
914 pub fn is_strikethrough(this: &IBufferCell) -> u32;
915 #[wasm_bindgen(method, js_name = isBlink)]
917 pub fn is_blink(this: &IBufferCell) -> u32;
918 #[wasm_bindgen(method, js_name = isInverse)]
920 pub fn is_inverse(this: &IBufferCell) -> u32;
921 #[wasm_bindgen(method, js_name = isInvisible)]
923 pub fn is_invisible(this: &IBufferCell) -> u32;
924 #[wasm_bindgen(method, js_name = isFaint)]
926 pub fn is_faint(this: &IBufferCell) -> u32;
927 #[wasm_bindgen(method, js_name = getHyperlinkId)]
929 pub fn get_hyperlink_id(this: &IBufferCell) -> u32;
930 #[wasm_bindgen(method, js_name = getCodepoint)]
932 pub fn get_codepoint(this: &IBufferCell) -> u32;
933 #[wasm_bindgen(method, js_name = isDim)]
935 pub fn is_dim(this: &IBufferCell) -> bool;
936}
937
938#[wasm_bindgen]
939extern "C" {
940 #[wasm_bindgen(extends = Object)]
942 #[derive(Clone, Debug)]
943 pub type IBufferLine;
944
945 #[wasm_bindgen(method, getter)]
947 pub fn length(this: &IBufferLine) -> u32;
948 #[wasm_bindgen(method, getter, js_name = isWrapped)]
950 pub fn is_wrapped(this: &IBufferLine) -> bool;
951 #[wasm_bindgen(method, js_name = getCell)]
957 pub fn get_cell(this: &IBufferLine, x: u32) -> Option<IBufferCell>;
958 #[wasm_bindgen(method, js_name = translateToString)]
964 pub fn translate_to_string(
965 this: &IBufferLine,
966 trim_right: Option<bool>,
967 start_column: Option<u32>,
968 end_column: Option<u32>,
969 ) -> JsString;
970}
971
972#[wasm_bindgen]
973extern "C" {
974 #[wasm_bindgen(extends = Object)]
976 #[derive(Clone, Debug)]
977 pub type IBuffer;
978
979 #[wasm_bindgen(method, getter, js_name = type)]
981 pub fn type_(this: &IBuffer) -> JsString;
982 #[wasm_bindgen(method, getter, js_name = cursorX)]
984 pub fn cursor_x(this: &IBuffer) -> u32;
985 #[wasm_bindgen(method, getter, js_name = cursorY)]
987 pub fn cursor_y(this: &IBuffer) -> u32;
988 #[wasm_bindgen(method, getter, js_name = viewportY)]
990 pub fn viewport_y(this: &IBuffer) -> u32;
991 #[wasm_bindgen(method, getter, js_name = baseY)]
993 pub fn base_y(this: &IBuffer) -> u32;
994 #[wasm_bindgen(method, getter)]
997 pub fn length(this: &IBuffer) -> u32;
998 #[wasm_bindgen(method, js_name = getLine)]
1004 pub fn get_line(this: &IBuffer, y: u32) -> Option<IBufferLine>;
1005 #[wasm_bindgen(method, js_name = getNullCell)]
1007 pub fn get_null_cell(this: &IBuffer) -> IBufferCell;
1008}
1009
1010#[wasm_bindgen]
1011extern "C" {
1012 #[wasm_bindgen(extends = Object)]
1016 #[derive(Clone, Debug)]
1017 pub type IBufferNamespace;
1018
1019 #[wasm_bindgen(method, getter)]
1021 pub fn active(this: &IBufferNamespace) -> IBuffer;
1022 #[wasm_bindgen(method, getter)]
1024 pub fn normal(this: &IBufferNamespace) -> IBuffer;
1025 #[wasm_bindgen(method, getter)]
1027 pub fn alternate(this: &IBufferNamespace) -> IBuffer;
1028 #[wasm_bindgen(method, getter, js_name = onBufferChange)]
1030 pub fn on_buffer_change(this: &IBufferNamespace) -> IEvent<IBuffer>;
1031}
1032
1033#[wasm_bindgen]
1034extern "C" {
1035 #[wasm_bindgen(extends = Object)]
1037 #[derive(Clone, Debug)]
1038 pub type IUnicodeVersionProvider;
1039
1040 #[wasm_bindgen(method, getter, js_name = activeVersion)]
1041 pub fn active_version(this: &IUnicodeVersionProvider) -> JsString;
1042}
1043
1044#[wasm_bindgen]
1045extern "C" {
1046 #[wasm_bindgen(extends = Object)]
1047 #[derive(Clone, Debug)]
1048 pub type IRenderable;
1049
1050 #[wasm_bindgen(method, js_name = getLine)]
1051 pub fn get_line(this: &IRenderable, y: u32) -> Option<Array<GhosttyCell>>;
1052 #[wasm_bindgen(method, js_name = getCursor)]
1053 pub fn get_cursor(this: &IRenderable) -> Cursor;
1054 #[wasm_bindgen(method, js_name = getDimensions)]
1055 pub fn get_dimensions(this: &IRenderable) -> Dimensions;
1056 #[wasm_bindgen(method, js_name = isRowDirty)]
1057 pub fn is_row_dirty(this: &IRenderable, y: u32) -> bool;
1058 #[wasm_bindgen(method, js_name = needsFullRedraw)]
1060 pub fn needs_full_redraw(this: &IRenderable) -> bool;
1061 #[wasm_bindgen(method, js_name = clearDirty)]
1062 pub fn clear_dirty(this: &IRenderable);
1063 #[wasm_bindgen(method, js_name = getGraphemeString)]
1068 pub fn get_grapheme_string(this: &IRenderable, row: u32, col: u32) -> JsString;
1069}
1070
1071#[wasm_bindgen]
1072extern "C" {
1073 #[wasm_bindgen(extends = Object)]
1074 #[derive(Clone, Debug)]
1075 pub type IScrollbackProvider;
1076
1077 #[wasm_bindgen(method, js_name = getScrollbackLine)]
1078 pub fn get_scrollback_line(
1079 this: &IScrollbackProvider,
1080 offset: u32,
1081 ) -> Option<Array<GhosttyCell>>;
1082 #[wasm_bindgen(method, js_name = getScrollbackLength)]
1083 pub fn get_scrollback_length(this: &IScrollbackProvider) -> u32;
1084}
1085
1086#[wasm_bindgen]
1087extern "C" {
1088 #[wasm_bindgen(extends = Object)]
1089 #[derive(Clone, Debug)]
1090 pub type ITerminalAddon;
1091
1092 #[wasm_bindgen(method)]
1093 pub fn activate(this: &ITerminalAddon, terminal: &ITerminalCore);
1094 #[wasm_bindgen(method)]
1095 pub fn dispose(this: &ITerminalAddon);
1096}
1097
1098#[wasm_bindgen]
1099extern "C" {
1100 #[wasm_bindgen(extends = Object)]
1101 #[derive(Clone, Debug)]
1102 pub type ITerminalCore;
1103
1104 #[wasm_bindgen(method, getter)]
1105 pub fn cols(this: &ITerminalCore) -> u32;
1106 #[wasm_bindgen(method, getter)]
1107 pub fn rows(this: &ITerminalCore) -> u32;
1108 #[wasm_bindgen(method, getter)]
1109 pub fn element(this: &ITerminalCore) -> Option<HtmlElement>;
1110 #[wasm_bindgen(method, getter)]
1111 pub fn textarea(this: &ITerminalCore) -> Option<HtmlTextAreaElement>;
1112}
1113
1114#[wasm_bindgen(js_namespace = GhosttyWeb)]
1115extern "C" {
1116 #[wasm_bindgen]
1124 pub async fn init();
1125
1126 #[wasm_bindgen(js_name = EventEmitter)]
1127 pub type EventEmitter<T>;
1128
1129 #[wasm_bindgen(constructor, js_class = "EventEmitter")]
1130 pub fn new<T: JsGeneric>() -> EventEmitter<T>;
1131
1132 #[wasm_bindgen(method)]
1133 pub fn fire<T: JsGeneric>(this: &EventEmitter<T>, arg: T);
1134
1135 #[wasm_bindgen(method, js_name = event)]
1137 pub fn event<T: JsGeneric>(this: &EventEmitter<T>) -> IEvent<T>;
1138
1139 #[wasm_bindgen(method)]
1140 pub fn dispose<T>(this: &EventEmitter<T>);
1141
1142 #[wasm_bindgen(js_name = Ghostty)]
1144 pub type Ghostty;
1145
1146 #[wasm_bindgen(constructor, js_class = "Ghostty")]
1147 pub fn new(wasm_instance: &WebAssembly::Instance) -> Ghostty;
1148
1149 #[wasm_bindgen(method, js_name = createKeyEncoder)]
1150 pub fn create_key_encoder(this: &Ghostty) -> KeyEncoder;
1151
1152 #[wasm_bindgen(method, js_name = createTerminal)]
1153 pub fn create_terminal(
1154 this: &Ghostty,
1155 cols: Option<u32>,
1156 rows: Option<u32>,
1157 config: Option<&GhosttyTerminalConfig>,
1158 ) -> GhosttyTerminal;
1159
1160 #[wasm_bindgen(static_method_of = Ghostty, js_class = "Ghostty")]
1161 pub fn load(wasm_path: Option<&str>) -> Promise<Ghostty>;
1162
1163 #[wasm_bindgen(js_name = GhosttyTerminal)]
1170 pub type GhosttyTerminal;
1171
1172 #[wasm_bindgen(method, getter)]
1173 pub fn cols(this: &GhosttyTerminal) -> u32;
1174 #[wasm_bindgen(method, getter)]
1175 pub fn rows(this: &GhosttyTerminal) -> u32;
1176
1177 #[wasm_bindgen(method, js_name = write)]
1178 pub fn write_str(this: &GhosttyTerminal, data: &str);
1179 #[wasm_bindgen(method, js_name = write)]
1180 pub fn write_u8_array(this: &GhosttyTerminal, data: &Uint8Array);
1181
1182 #[wasm_bindgen(method)]
1183 pub fn resize(this: &GhosttyTerminal, cols: u32, rows: u32);
1184 #[wasm_bindgen(method)]
1185 pub fn free(this: &GhosttyTerminal);
1186
1187 #[wasm_bindgen(method, js_name = update)]
1201 pub fn update_raw(this: &GhosttyTerminal) -> u32;
1202
1203 #[wasm_bindgen(method, js_name = getCursor)]
1207 pub fn get_cursor(this: &GhosttyTerminal) -> RenderStateCursor;
1208 #[wasm_bindgen(method, js_name = getColors)]
1210 pub fn get_colors(this: &GhosttyTerminal) -> RenderStateColors;
1211 #[wasm_bindgen(method, js_name = isRowDirty)]
1213 pub fn is_row_dirty(this: &GhosttyTerminal, y: u32) -> bool;
1214 #[wasm_bindgen(method, js_name = markClean)]
1216 pub fn mark_clean(this: &GhosttyTerminal);
1217 #[wasm_bindgen(method, js_name = getViewport)]
1222 pub fn get_viewport(this: &GhosttyTerminal) -> Array<GhosttyCell>;
1223 #[wasm_bindgen(method, js_name = getLine)]
1228 pub fn get_line(this: &GhosttyTerminal, y: u32) -> Option<Array<GhosttyCell>>;
1229 #[wasm_bindgen(method, js_name = isDirty)]
1231 pub fn is_dirty(this: &GhosttyTerminal) -> bool;
1232 #[wasm_bindgen(method, js_name = needsFullRedraw)]
1237 pub fn needs_full_redraw(this: &GhosttyTerminal) -> bool;
1238 #[wasm_bindgen(method, js_name = clearDirty)]
1240 pub fn clear_dirty(this: &GhosttyTerminal);
1241 #[wasm_bindgen(method, js_name = isAlternateScreen)]
1242 pub fn is_alternate_screen(this: &GhosttyTerminal) -> bool;
1243 #[wasm_bindgen(method, js_name = hasBracketedPaste)]
1244 pub fn has_bracketed_paste(this: &GhosttyTerminal) -> bool;
1245 #[wasm_bindgen(method, js_name = hasFocusEvents)]
1246 pub fn has_focus_events(this: &GhosttyTerminal) -> bool;
1247 #[wasm_bindgen(method, js_name = hasMouseTracking)]
1248 pub fn has_mouse_tracking(this: &GhosttyTerminal) -> bool;
1249 #[wasm_bindgen(method, js_name = getDimensions)]
1251 pub fn get_dimensions(this: &GhosttyTerminal) -> Dimensions;
1252 #[wasm_bindgen(method, js_name = getScrollbackLength)]
1254 pub fn get_scrollback_length(this: &GhosttyTerminal) -> u32;
1255 #[wasm_bindgen(method, js_name = getScrollbackLine)]
1261 pub fn get_scrollback_line(this: &GhosttyTerminal, offset: u32) -> Option<Array<GhosttyCell>>;
1262 #[wasm_bindgen(method, js_name = isRowWrapped)]
1265 pub fn is_row_wrapped(this: &GhosttyTerminal, row: u32) -> bool;
1266 #[wasm_bindgen(method, js_name = getHyperlinkUri)]
1268 pub fn get_hyperlink_uri(this: &GhosttyTerminal, id: u32) -> Option<JsString>;
1269 #[wasm_bindgen(method, js_name = hasResponse)]
1274 pub fn has_response(this: &GhosttyTerminal) -> bool;
1275 #[wasm_bindgen(method, js_name = readResponse)]
1283 pub fn read_response(this: &GhosttyTerminal) -> Option<JsString>;
1284 #[wasm_bindgen(method, js_name = getMode)]
1290 pub fn get_mode(this: &GhosttyTerminal, mode: u32, is_ansi: Option<bool>) -> bool;
1291 #[wasm_bindgen(method, js_name = getGrapheme)]
1298 pub fn get_grapheme(this: &GhosttyTerminal, row: u32, col: u32) -> Option<Array<Number>>;
1299 #[wasm_bindgen(method, js_name = getGraphemeString)]
1303 pub fn get_grapheme_string(this: &GhosttyTerminal, row: u32, col: u32) -> JsString;
1304 #[wasm_bindgen(method, js_name = getScrollbackGrapheme)]
1311 pub fn get_scrollback_grapheme(
1312 this: &GhosttyTerminal,
1313 offset: u32,
1314 col: u32,
1315 ) -> Option<Array<Number>>;
1316 #[wasm_bindgen(method, js_name = getScrollbackGraphemeString)]
1318 pub fn get_scrollback_grapheme_string(
1319 this: &GhosttyTerminal,
1320 offset: u32,
1321 col: u32,
1322 ) -> JsString;
1323}
1324
1325impl GhosttyTerminal
1326{
1327 pub fn update(&self) -> DirtyState { DirtyState::from_u32(self.update_raw()) }
1332}
1333
1334#[wasm_bindgen(js_namespace = GhosttyWeb)]
1335extern "C" {
1336 #[wasm_bindgen(js_name = KeyEncoder)]
1338 pub type KeyEncoder;
1339
1340 #[wasm_bindgen(method, js_name = setOption)]
1341 pub fn set_option(this: &KeyEncoder, option: u32, value: &JsValue);
1342 #[wasm_bindgen(method, js_name = setKittyFlags)]
1343 pub fn set_kitty_flags(this: &KeyEncoder, flags: u32);
1344 #[wasm_bindgen(method)]
1345 pub fn encode(this: &KeyEncoder, event: &KeyEvent) -> Uint8Array;
1346 #[wasm_bindgen(method)]
1347 pub fn dispose(this: &KeyEncoder);
1348
1349 #[wasm_bindgen(js_name = CanvasRenderer)]
1350 pub type CanvasRenderer;
1351
1352 #[wasm_bindgen(constructor, js_class = "CanvasRenderer")]
1353 pub fn new(canvas: &HtmlCanvasElement, options: Option<&RendererOptions>) -> CanvasRenderer;
1354
1355 #[wasm_bindgen(method, js_name = remeasureFont)]
1357 pub fn remeasure_font(this: &CanvasRenderer);
1358 #[wasm_bindgen(method)]
1360 pub fn resize(this: &CanvasRenderer, cols: u32, rows: u32);
1361 #[wasm_bindgen(method)]
1363 pub fn render(
1364 this: &CanvasRenderer,
1365 buffer: &IRenderable,
1366 force_all: Option<bool>,
1367 viewport_y: Option<f64>,
1368 scrollback_provider: Option<&IScrollbackProvider>,
1369 scrollbar_opacity: Option<f64>,
1370 );
1371 #[wasm_bindgen(method, js_name = setTheme)]
1373 pub fn set_theme(this: &CanvasRenderer, theme: &ITheme);
1374 #[wasm_bindgen(method, js_name = setFontSize)]
1376 pub fn set_font_size(this: &CanvasRenderer, size: f64);
1377 #[wasm_bindgen(method, js_name = setFontFamily)]
1379 pub fn set_font_family(this: &CanvasRenderer, family: &str);
1380 #[wasm_bindgen(method, js_name = setCursorStyle)]
1384 pub fn set_cursor_style(this: &CanvasRenderer, style: &str);
1385 #[wasm_bindgen(method, js_name = setCursorBlink)]
1387 pub fn set_cursor_blink(this: &CanvasRenderer, enabled: bool);
1388 #[wasm_bindgen(method, js_name = getMetrics)]
1390 pub fn get_metrics(this: &CanvasRenderer) -> FontMetrics;
1391 #[wasm_bindgen(method, js_name = getCanvas)]
1393 pub fn get_canvas(this: &CanvasRenderer) -> HtmlCanvasElement;
1394 #[wasm_bindgen(method, js_name = setSelectionManager)]
1396 pub fn set_selection_manager(this: &CanvasRenderer, manager: &SelectionManager);
1397 #[wasm_bindgen(method, js_name = setHoveredHyperlinkId)]
1399 pub fn set_hovered_hyperlink_id(this: &CanvasRenderer, hyperlink_id: u32);
1400 #[wasm_bindgen(method, js_name = setHoveredLinkRange)]
1405 pub fn set_hovered_link_range(this: &CanvasRenderer, range: Option<&HoveredLinkRange>);
1406 #[wasm_bindgen(method, getter, js_name = charWidth)]
1408 pub fn char_width(this: &CanvasRenderer) -> f64;
1409 #[wasm_bindgen(method, getter, js_name = charHeight)]
1411 pub fn char_height(this: &CanvasRenderer) -> f64;
1412 #[wasm_bindgen(method)]
1414 pub fn clear(this: &CanvasRenderer);
1415 #[wasm_bindgen(method)]
1417 pub fn dispose(this: &CanvasRenderer);
1418
1419 #[wasm_bindgen(js_name = FitAddon, extends = ITerminalAddon)]
1420 pub type FitAddon;
1421
1422 #[wasm_bindgen(constructor, js_class = "FitAddon")]
1423 pub fn new() -> FitAddon;
1424
1425 #[wasm_bindgen(method)]
1427 pub fn activate(this: &FitAddon, terminal: &ITerminalCore);
1428 #[wasm_bindgen(method)]
1430 pub fn dispose(this: &FitAddon);
1431 #[wasm_bindgen(method)]
1436 pub fn fit(this: &FitAddon);
1437 #[wasm_bindgen(method, js_name = proposeDimensions)]
1447 pub fn propose_dimensions(this: &FitAddon) -> Option<ITerminalDimensions>;
1448 #[wasm_bindgen(method, js_name = observeResize)]
1456 pub fn observe_resize(this: &FitAddon);
1457
1458 #[wasm_bindgen(js_name = InputHandler)]
1463 pub type InputHandler;
1464
1465 #[wasm_bindgen(constructor, js_class = "InputHandler")]
1477 pub fn new(
1478 ghostty: &Ghostty,
1479 container: &HtmlElement,
1480 on_data: &Function<fn(JsString) -> Undefined>,
1481 on_bell: &Function<fn() -> Undefined>,
1482 on_key: Option<&Function<fn(IKeyEvent) -> Undefined>>,
1483 custom_key_event_handler: Option<&Function<fn(KeyboardEvent) -> Boolean>>,
1484 get_mode: Option<&Function<fn(Number) -> Boolean>>,
1485 ) -> InputHandler;
1486
1487 #[wasm_bindgen(method, js_name = setCustomKeyEventHandler)]
1489 pub fn set_custom_key_event_handler(
1490 this: &InputHandler,
1491 handler: &Function<fn(KeyboardEvent) -> Boolean>,
1492 );
1493 #[wasm_bindgen(method)]
1495 pub fn dispose(this: &InputHandler);
1496 #[wasm_bindgen(method, js_name = isActive)]
1498 pub fn is_active(this: &InputHandler) -> bool;
1499
1500 #[wasm_bindgen(js_name = LinkDetector)]
1503 pub type LinkDetector;
1504
1505 #[wasm_bindgen(constructor, js_class = "LinkDetector")]
1506 pub fn new(terminal: &JsValue) -> LinkDetector;
1507
1508 #[wasm_bindgen(method, js_name = registerProvider)]
1510 pub fn register_provider(this: &LinkDetector, provider: &ILinkProvider);
1511 #[wasm_bindgen(method, js_name = getLinkAt)]
1518 pub fn get_link_at(this: &LinkDetector, col: u32, row: u32) -> Promise<JsOption<ILink>>;
1519 #[wasm_bindgen(method, js_name = invalidateCache)]
1523 pub fn invalidate_cache(this: &LinkDetector);
1524 #[wasm_bindgen(method, js_name = invalidateRows)]
1528 pub fn invalidate_rows(this: &LinkDetector, start_row: u32, end_row: u32);
1529 #[wasm_bindgen(method)]
1531 pub fn dispose(this: &LinkDetector);
1532
1533 #[wasm_bindgen(js_name = OSC8LinkProvider)]
1539 pub type Osc8LinkProvider;
1540
1541 #[wasm_bindgen(constructor, js_class = "OSC8LinkProvider")]
1542 pub fn new(terminal: &JsValue) -> Osc8LinkProvider;
1543
1544 #[wasm_bindgen(method, js_name = provideLinks)]
1548 pub fn provide_links(
1549 this: &Osc8LinkProvider,
1550 y: u32,
1551 callback: &Function<fn(JsOption<Array<ILink>>) -> Undefined>,
1552 );
1553 #[wasm_bindgen(method)]
1554 pub fn dispose(this: &Osc8LinkProvider);
1555
1556 #[wasm_bindgen(js_name = UrlRegexProvider)]
1568 pub type UrlRegexProvider;
1569
1570 #[wasm_bindgen(constructor, js_class = "UrlRegexProvider")]
1571 pub fn new(terminal: &JsValue) -> UrlRegexProvider;
1572
1573 #[wasm_bindgen(method, js_name = provideLinks)]
1575 pub fn provide_links(
1576 this: &UrlRegexProvider,
1577 y: u32,
1578 callback: &Function<fn(JsOption<Array<ILink>>) -> Undefined>,
1579 );
1580 #[wasm_bindgen(method)]
1581 pub fn dispose(this: &UrlRegexProvider);
1582
1583 #[wasm_bindgen(js_name = SelectionManager)]
1584 pub type SelectionManager;
1585
1586 #[wasm_bindgen(constructor, js_class = "SelectionManager")]
1587 pub fn new(
1588 terminal: &Terminal,
1589 renderer: &CanvasRenderer,
1590 wasm_term: &GhosttyTerminal,
1591 textarea: &HtmlTextAreaElement,
1592 ) -> SelectionManager;
1593
1594 #[wasm_bindgen(method, js_name = getSelection)]
1596 pub fn get_selection(this: &SelectionManager) -> JsString;
1597 #[wasm_bindgen(method, js_name = hasSelection)]
1599 pub fn has_selection(this: &SelectionManager) -> bool;
1600 #[wasm_bindgen(method, js_name = clearSelection)]
1602 pub fn clear_selection(this: &SelectionManager);
1603 #[wasm_bindgen(method, js_name = selectAll)]
1605 pub fn select_all(this: &SelectionManager);
1606 #[wasm_bindgen(method)]
1610 pub fn select(this: &SelectionManager, column: u32, row: u32, length: u32);
1611 #[wasm_bindgen(method, js_name = selectLines)]
1615 pub fn select_lines(this: &SelectionManager, start: u32, end: u32);
1616 #[wasm_bindgen(method, js_name = getSelectionPosition)]
1620 pub fn get_selection_position(this: &SelectionManager) -> Option<IBufferRange>;
1621 #[wasm_bindgen(method)]
1625 pub fn deselect(this: &SelectionManager);
1626 #[wasm_bindgen(method)]
1628 pub fn focus(this: &SelectionManager);
1629 #[wasm_bindgen(method, js_name = getSelectionCoords)]
1631 pub fn get_selection_coords(this: &SelectionManager) -> Option<SelectionCoordinates>;
1632 #[wasm_bindgen(method, js_name = getDirtySelectionRows)]
1634 pub fn get_dirty_selection_rows(this: &SelectionManager) -> Set<Number>;
1635 #[wasm_bindgen(method, js_name = clearDirtySelectionRows)]
1637 pub fn clear_dirty_selection_rows(this: &SelectionManager);
1638 #[wasm_bindgen(method, getter, js_name = onSelectionChange)]
1640 pub fn on_selection_change(this: &SelectionManager) -> IEventVoid;
1641 #[wasm_bindgen(method)]
1643 pub fn dispose(this: &SelectionManager);
1644
1645 #[wasm_bindgen(js_name = Terminal)]
1646 pub type Terminal;
1647
1648 #[wasm_bindgen(constructor, js_class = "Terminal")]
1649 pub fn new(options: Option<&ITerminalOptions>) -> Terminal;
1650
1651 #[wasm_bindgen(method, getter)]
1652 pub fn cols(this: &Terminal) -> u32;
1653 #[wasm_bindgen(method, setter)]
1654 pub fn set_cols(this: &Terminal, value: u32);
1655 #[wasm_bindgen(method, getter)]
1656 pub fn rows(this: &Terminal) -> u32;
1657 #[wasm_bindgen(method, setter)]
1658 pub fn set_rows(this: &Terminal, value: u32);
1659 #[wasm_bindgen(method, getter)]
1660 pub fn element(this: &Terminal) -> Option<HtmlElement>;
1661 #[wasm_bindgen(method, getter)]
1662 pub fn textarea(this: &Terminal) -> Option<HtmlTextAreaElement>;
1663 #[wasm_bindgen(method, getter)]
1664 pub fn buffer(this: &Terminal) -> IBufferNamespace;
1665 #[wasm_bindgen(method, getter)]
1666 pub fn unicode(this: &Terminal) -> IUnicodeVersionProvider;
1667 #[wasm_bindgen(method, getter)]
1668 pub fn options(this: &Terminal) -> ITerminalOptions;
1669 #[wasm_bindgen(method, getter, js_name = wasmTerm)]
1670 pub fn wasm_term(this: &Terminal) -> Option<GhosttyTerminal>;
1671 #[wasm_bindgen(method, getter)]
1672 pub fn renderer(this: &Terminal) -> Option<CanvasRenderer>;
1673 #[wasm_bindgen(method, getter, js_name = viewportY)]
1674 pub fn viewport_y(this: &Terminal) -> f64;
1675 #[wasm_bindgen(method, setter, js_name = viewportY)]
1676 pub fn set_viewport_y(this: &Terminal, value: f64);
1677
1678 #[wasm_bindgen(method, js_name = onData)]
1679 pub fn on_data(this: &Terminal, listener: &Function<fn(JsString) -> Undefined>) -> IDisposable;
1680 #[wasm_bindgen(method, js_name = onResize)]
1681 pub fn on_resize(
1682 this: &Terminal,
1683 listener: &Function<fn(ResizeEvent) -> Undefined>,
1684 ) -> IDisposable;
1685 #[wasm_bindgen(method, js_name = onBell)]
1686 pub fn on_bell(this: &Terminal, listener: &Function<fn() -> Undefined>) -> IDisposable;
1687 #[wasm_bindgen(method, js_name = onSelectionChange)]
1688 pub fn on_selection_change(
1689 this: &Terminal,
1690 listener: &Function<fn() -> Undefined>,
1691 ) -> IDisposable;
1692 #[wasm_bindgen(method, js_name = onKey)]
1693 pub fn on_key(this: &Terminal, listener: &Function<fn(IKeyEvent) -> Undefined>) -> IDisposable;
1694 #[wasm_bindgen(method, js_name = onTitleChange)]
1695 pub fn on_title_change(
1696 this: &Terminal,
1697 listener: &Function<fn(JsString) -> Undefined>,
1698 ) -> IDisposable;
1699 #[wasm_bindgen(method, js_name = onScroll)]
1700 pub fn on_scroll(this: &Terminal, listener: &Function<fn(Number) -> Undefined>) -> IDisposable;
1701 #[wasm_bindgen(method, js_name = onRender)]
1702 pub fn on_render(
1703 this: &Terminal,
1704 listener: &Function<fn(RenderEvent) -> Undefined>,
1705 ) -> IDisposable;
1706 #[wasm_bindgen(method, js_name = onCursorMove)]
1707 pub fn on_cursor_move(this: &Terminal, listener: &Function<fn() -> Undefined>) -> IDisposable;
1708
1709 #[wasm_bindgen(method)]
1714 pub fn open(this: &Terminal, parent: &HtmlElement);
1715
1716 #[wasm_bindgen(method, js_name = write)]
1718 pub fn write_str(this: &Terminal, data: &str, callback: Option<&Function<fn() -> Undefined>>);
1719 #[wasm_bindgen(method, js_name = write)]
1721 pub fn write_u8_array(
1722 this: &Terminal,
1723 data: &Uint8Array,
1724 callback: Option<&Function<fn() -> Undefined>>,
1725 );
1726
1727 #[wasm_bindgen(method, js_name = writeln)]
1729 pub fn writeln_str(this: &Terminal, data: &str, callback: Option<&Function<fn() -> Undefined>>);
1730 #[wasm_bindgen(method, js_name = writeln)]
1732 pub fn writeln_u8_array(
1733 this: &Terminal,
1734 data: &Uint8Array,
1735 callback: Option<&Function<fn() -> Undefined>>,
1736 );
1737
1738 #[wasm_bindgen(method)]
1740 pub fn paste(this: &Terminal, data: &str);
1741 #[wasm_bindgen(method)]
1746 pub fn input(this: &Terminal, data: &str, was_user_input: Option<bool>);
1747 #[wasm_bindgen(method)]
1749 pub fn resize(this: &Terminal, cols: u32, rows: u32);
1750 #[wasm_bindgen(method)]
1752 pub fn clear(this: &Terminal);
1753 #[wasm_bindgen(method)]
1755 pub fn reset(this: &Terminal);
1756 #[wasm_bindgen(method)]
1758 pub fn focus(this: &Terminal);
1759 #[wasm_bindgen(method)]
1761 pub fn blur(this: &Terminal);
1762 #[wasm_bindgen(method, js_name = loadAddon)]
1764 pub fn load_addon(this: &Terminal, addon: &ITerminalAddon);
1765
1766 #[wasm_bindgen(method, js_name = getSelection)]
1768 pub fn get_selection(this: &Terminal) -> JsString;
1769 #[wasm_bindgen(method, js_name = hasSelection)]
1771 pub fn has_selection(this: &Terminal) -> bool;
1772 #[wasm_bindgen(method, js_name = clearSelection)]
1774 pub fn clear_selection(this: &Terminal);
1775 #[wasm_bindgen(method, js_name = selectAll)]
1777 pub fn select_all(this: &Terminal);
1778 #[wasm_bindgen(method)]
1780 pub fn select(this: &Terminal, column: u32, row: u32, length: u32);
1781 #[wasm_bindgen(method, js_name = selectLines)]
1783 pub fn select_lines(this: &Terminal, start: u32, end: u32);
1784 #[wasm_bindgen(method, js_name = getViewportY)]
1789 pub fn get_viewport_y(this: &Terminal) -> f64;
1790 #[wasm_bindgen(method, js_name = getSelectionPosition)]
1792 pub fn get_selection_position(this: &Terminal) -> Option<IBufferRange>;
1793
1794 #[wasm_bindgen(method, js_name = attachCustomKeyEventHandler)]
1798 pub fn attach_custom_key_event_handler(
1799 this: &Terminal,
1800 handler: &Function<fn(KeyboardEvent) -> Boolean>,
1801 );
1802 #[wasm_bindgen(method, js_name = attachCustomWheelEventHandler)]
1806 pub fn attach_custom_wheel_event_handler(
1807 this: &Terminal,
1808 handler: Option<&Function<fn(WheelEvent) -> Boolean>>,
1809 );
1810 #[wasm_bindgen(method, js_name = registerLinkProvider)]
1814 pub fn register_link_provider(this: &Terminal, provider: &ILinkProvider);
1815
1816 #[wasm_bindgen(method, js_name = scrollLines)]
1820 pub fn scroll_lines(this: &Terminal, amount: i32);
1821 #[wasm_bindgen(method, js_name = scrollPages)]
1825 pub fn scroll_pages(this: &Terminal, amount: i32);
1826 #[wasm_bindgen(method, js_name = scrollToTop)]
1828 pub fn scroll_to_top(this: &Terminal);
1829 #[wasm_bindgen(method, js_name = scrollToBottom)]
1831 pub fn scroll_to_bottom(this: &Terminal);
1832 #[wasm_bindgen(method, js_name = scrollToLine)]
1836 pub fn scroll_to_line(this: &Terminal, line: u32);
1837
1838 #[wasm_bindgen(method)]
1840 pub fn dispose(this: &Terminal);
1841
1842 #[wasm_bindgen(method, js_name = getScrollbackLine)]
1846 pub fn get_scrollback_line(this: &Terminal, offset: u32) -> Option<Array<GhosttyCell>>;
1847 #[wasm_bindgen(method, js_name = getScrollbackLength)]
1851 pub fn get_scrollback_length(this: &Terminal) -> u32;
1852 #[wasm_bindgen(method, js_name = getMode)]
1859 pub fn get_mode(this: &Terminal, mode: u32, is_ansi: Option<bool>) -> bool;
1860 #[wasm_bindgen(method, js_name = hasBracketedPaste)]
1862 pub fn has_bracketed_paste(this: &Terminal) -> bool;
1863 #[wasm_bindgen(method, js_name = hasFocusEvents)]
1865 pub fn has_focus_events(this: &Terminal) -> bool;
1866 #[wasm_bindgen(method, js_name = hasMouseTracking)]
1868 pub fn has_mouse_tracking(this: &Terminal) -> bool;
1869}