Visual Studio Code, rebuilt in Rust
Rust
feat(terminal): replace alacritty_terminal with libghostty-vt 1.0.2
rokartur621a8a97c1ee
diff --git a/native/Cargo.lock b/native/Cargo.lockindex 52e11c3fd72..a41b178809b 100644--- a/native/Cargo.lock+++ b/native/Cargo.lock@@ -153,31 +153,6 @@ dependencies = ["memchr",]-[[package]]-name = "alacritty_terminal"-version = "0.25.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "46319972e74179d707445f64aaa2893bbf6a111de3a9af29b7eb382f8b39e282"-dependencies = [- "base64 0.22.1",- "bitflags 2.13.2",- "home",- "libc",- "log",- "miow",- "parking_lot",- "piper",- "polling",- "regex-automata",- "rustix",- "rustix-openpty",- "serde",- "signal-hook",- "unicode-width",- "vte",- "windows-sys 0.59.0",-]-[[package]]name = "aligned"version = "0.4.3"@@ -227,7 +202,6 @@ checksum = "2cb931c189b85683d69a5cfad41d4d418671e1ac413dd209f3f2fc31e3cfd902"name = "app"version = "0.1.0"dependencies = [- "alacritty_terminal","anyhow","ashpd","async-openssl",@@ -242,6 +216,7 @@ dependencies = ["futures","gdkx11","getrandom 0.3.4",+ "ghostty_vt","gpui","gpui_platform","gtk",@@ -793,9 +768,6 @@ name = "bitflags"version = "2.13.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"-dependencies = [- "serde_core",-][[package]]name = "bitstream-io"@@ -1443,12 +1415,6 @@ dependencies = ["linktime-proc-macro",]-[[package]]-name = "cursor-icon"-version = "1.2.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f"-[[package]]name = "curve25519-dalek"version = "4.1.3"@@ -2394,6 +2360,13 @@ dependencies = ["wasm-bindgen",]+[[package]]+name = "ghostty_vt"+version = "0.1.0"+dependencies = [+ "sha2",+]+[[package]]name = "gif"version = "0.14.2"@@ -3061,15 +3034,6 @@ dependencies = ["digest",]-[[package]]-name = "home"-version = "0.5.12"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d"-dependencies = [- "windows-sys 0.61.2",-]-[[package]]name = "http"version = "1.5.0"@@ -3975,15 +3939,6 @@ dependencies = ["windows-sys 0.61.2",]-[[package]]-name = "miow"-version = "0.6.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "536bfad37a309d62069485248eeaba1e8d9853aaf951caaeaed0585a95346f08"-dependencies = [- "windows-sys 0.61.2",-]-[[package]]name = "moxcms"version = "0.8.1"@@ -5578,17 +5533,6 @@ dependencies = ["windows-sys 0.61.2",]-[[package]]-name = "rustix-openpty"-version = "0.2.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "1de16c7c59892b870a6336f185dc10943517f1327447096bbb7bb32cd85e2393"-dependencies = [- "errno",- "libc",- "rustix",-]-[[package]]name = "rustls-pki-types"version = "1.16.0"@@ -5912,16 +5856,6 @@ version = "2.0.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"-[[package]]-name = "signal-hook"-version = "0.3.18"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"-dependencies = [- "libc",- "signal-hook-registry",-]-[[package]]name = "signal-hook-registry"version = "1.4.8"@@ -7088,20 +7022,6 @@ dependencies = ["libc",]-[[package]]-name = "vte"-version = "0.15.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a5924018406ce0063cd67f8e008104968b74b563ee1b85dde3ed1f7cb87d3dbd"-dependencies = [- "arrayvec",- "bitflags 2.13.2",- "cursor-icon",- "log",- "memchr",- "serde",-]-[[package]]name = "wait-timeout"version = "0.2.1"@@ -7832,15 +7752,6 @@ dependencies = ["windows-targets",]-[[package]]-name = "windows-sys"-version = "0.59.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"-dependencies = [- "windows-targets",-]-[[package]]name = "windows-sys"version = "0.61.2"diff --git a/native/crates/app/Cargo.toml b/native/crates/app/Cargo.tomlindex 997ac72f500..47d017b2aa9 100644--- a/native/crates/app/Cargo.toml+++ b/native/crates/app/Cargo.toml@@ -12,7 +12,7 @@ path = "src/main.rs"workspace = true[dependencies]-alacritty_terminal = "0.25"+ghostty_vt = { path = "../ghostty_vt" }libc = "0.2"anyhow.workspace = truebase64 = "0.22"diff --git a/native/crates/app/src/terminal.rs b/native/crates/app/src/terminal.rsindex b00a4eb84ac..69acabf4042 100644--- a/native/crates/app/src/terminal.rs+++ b/native/crates/app/src/terminal.rs@@ -1,5 +1,5 @@//! The integrated terminal's model: one `TerminalInstance` per terminal (terminalInstance.ts), its shell in a-//! PTY (terminalProcess.ts over node-pty) and its screen in alacritty_terminal standing in for xterm.js.+//! PTY (terminalProcess.ts over node-pty) and its screen in libghostty-vt standing in for xterm.js.pub mod accessible_buffer;pub mod auto_replies;@@ -34,37 +34,14 @@ use std::path::PathBuf;use std::rc::Rc;use std::time::{Duration, Instant};-use alacritty_terminal::event::{Event, EventListener, WindowSize};-use alacritty_terminal::grid::{Dimensions, Scroll};-use alacritty_terminal::index::{Column, Line, Point, Side};-use alacritty_terminal::selection::{Selection, SelectionType};-use alacritty_terminal::term::{Config, Term, TermMode};-use alacritty_terminal::vte::ansi::{ClearMode, Handler, Processor, Rgb};+use base64::Engine;use futures::channel::mpsc::{UnboundedReceiver, unbounded};+use ghostty_vt::{Column, Config, DefaultColors, Line, Point, Rgb, Scroll, SelectionType, Side, Term, TermMode};use serde_json::json;use self::pty::{Pty, PtyEvent};use self::shell_integration::{BufferPoint, ShellEvent, ShellIntegration};-struct GridSize {- cols: u16,- rows: u16,-}--impl Dimensions for GridSize {- fn total_lines(&self) -> usize {- self.rows as usize- }-- fn screen_lines(&self) -> usize {- self.rows as usize- }-- fn columns(&self) -> usize {- self.cols as usize- }-}-/// What a terminal launches (terminal.ts `IShellLaunchConfig`, resolved).#[derive(Clone, Debug, Default, PartialEq)]pub struct ShellLaunchConfig {@@ -87,23 +64,11 @@ pub struct ShellLaunchConfig {pub nonce: String,}-/// The events alacritty_terminal raises while it parses, handled after each chunk.-#[derive(Clone, Default)]-pub struct Listener(Rc<RefCell<Vec<Event>>>);--impl EventListener for Listener {- fn send_event(&self, event: Event) {- self.0.borrow_mut().push(event);- }-}-pub struct TerminalInstance {/// `instanceId`, unique in the window, counting from 1.pub id: u32,pub launch: ShellLaunchConfig,- pub term: Term<Listener>,- parser: Processor,- events: Listener,+ pub term: Term,pty: Option<Pty>,pub pid: Option<i32>,/// When the instance was created; the resize overlay waits a second after it.@@ -136,8 +101,8 @@ pub struct TerminalInstance {/// OSC 99 notification sequences, the data after `99;`, for the workbench's handler.pub osc99_sequences: Vec<String>,pub osc99: osc99::Osc99,- /// OSC 52 `?` queries, each formatting the clipboard text into its reply.- pub clipboard_loads: Vec<std::sync::Arc<dyn Fn(&str) -> String + Sync + Send>>,+ /// The selection parameter (`c`, `p`, ...) of each OSC 52 `?` query, answered with the clipboard's text.+ pub clipboard_loads: Vec<String>,/// The bell rang since it was last read.pub bell: bool,/// `terminal.integrated.autoReplies` as last read, and its responders.@@ -146,8 +111,6 @@ pub struct TerminalInstance {launched: Instant,/// `ProcessState.KilledByUser`: the kill command ended the process.pub killed_by_user: bool,- /// What `Term` was last configured with: `set_options` resets its history size and damage, so it runs on change only.- config: Config,pub shell_integration: ShellIntegration,/// The bytes of a UTF-8 character the last chunk cut off.utf8_tail: Vec<u8>,@@ -224,16 +187,13 @@ const ERROR_LAUNCH_THRESHOLD: Duration = Duration::from_millis(500);impl TerminalInstance {pub fn new(id: u32, launch: ShellLaunchConfig, cols: u16, rows: u16, config: Config) -> (Self, Option<UnboundedReceiver<PtyEvent>>) {- let events = Listener::default();- let term = Term::new(config.clone(), &GridSize { cols, rows }, events.clone());+ let term = Term::new(cols, rows, config);let process_title = launch.executable.file_name().map(|name| name.to_string_lossy().into_owned()).unwrap_or_default();let nonce = launch.nonce.clone();let mut instance = TerminalInstance {id,launch,term,- parser: Processor::new(),- events,pty: None,pid: None,user_title: None,@@ -258,7 +218,6 @@ impl TerminalInstance {auto_responders: Vec::new(),launched: Instant::now(),killed_by_user: false,- config,shell_integration: ShellIntegration::new(nonce),utf8_tail: Vec::new(),process_input: None,@@ -370,6 +329,9 @@ impl TerminalInstance {if let Some(data) = sequence.payload.strip_prefix("99;") {self.osc99_sequences.push(data.to_owned());}+ if let Some(data) = sequence.payload.strip_prefix("52;") {+ self.clipboard_sequence(data);+ }let cursor = self.buffer_cursor();let command_start = self.shell_integration.command_start_point();input_changed |= self.prompt_sequence(&sequence.payload, cursor);@@ -469,35 +431,37 @@ impl TerminalInstance {}}+ /// The OSC 4, 10, 11 and 12 queries answer with the theme's colors and `CSI 14 t` with the cell size, so both+ /// are set before the text is parsed.fn feed(&mut self, text: &str, colors: &colors::TerminalColors) {- self.parser.advance(&mut self.term, text.as_bytes());- let events = std::mem::take(&mut *self.events.0.borrow_mut());- for event in events {- match event {- Event::PtyWrite(text) => self.write_to_pty(text.as_bytes()),- Event::Title(title) => self.sequence_title = Some(title),- Event::ResetTitle => self.sequence_title = None,- Event::Bell => self.bell = true,- Event::ClipboardStore(_, text) => self.clipboard_requests.push(text),- Event::ClipboardLoad(_, format) => self.clipboard_loads.push(format),- Event::ColorRequest(index, format) => {- let color = match index {- 0..256 => colors.palette[index],- 256 => colors.foreground,- 257 => colors.background,- _ => colors.cursor,- };- let byte = |channel: f32| (channel * 255.).round() as u8;- let reply = format(Rgb { r: byte(color.r), g: byte(color.g), b: byte(color.b) });- self.write_to_pty(reply.as_bytes());- }- Event::TextAreaSizeRequest(format) => {- let size = WindowSize { num_lines: self.term.screen_lines() as u16, num_cols: self.term.columns() as u16, cell_width: self.cell_size.0 as u16, cell_height: self.cell_size.1 as u16 };- self.write_to_pty(format(size).as_bytes());- }- _ => {}- }+ let rgb = |color: gpui::Rgba| {+ let byte = |channel: f32| (channel * 255.).round() as u8;+ Rgb { r: byte(color.r), g: byte(color.g), b: byte(color.b) }+ };+ self.term.set_default_colors(DefaultColors { palette: colors.palette.map(rgb), foreground: rgb(colors.foreground), background: rgb(colors.background), cursor: rgb(colors.cursor) });+ self.term.set_cell_size(self.cell_size.0 as u32, self.cell_size.1 as u32);+ self.term.advance(text.as_bytes());+ let effects = self.term.take_effects();+ if !effects.pty_write.is_empty() {+ self.write_to_pty(&effects.pty_write);+ }+ if let Some(title) = effects.title {+ self.sequence_title = Some(title).filter(|title| !title.is_empty());}+ self.bell |= effects.bell;+ }++ /// ClipboardAddon's `_setOrReportClipboard`: `?` queries the clipboard, anything else is base64 text for it.+ fn clipboard_sequence(&mut self, data: &str) {+ let mut args = data.split(';');+ let (Some(selection), Some(payload)) = (args.next(), args.next()) else { return };+ if payload == "?" {+ self.clipboard_loads.push(selection.to_owned());+ return;+ }+ // `decodeText` failing leaves the text empty.+ let decoded = base64::engine::general_purpose::STANDARD.decode(payload).ok().and_then(|bytes| String::from_utf8(bytes).ok());+ self.clipboard_requests.push(decoded.unwrap_or_default());}/// The chunk as text; a character cut at its end waits for the next chunk (the PTY reads in 64 KiB pieces).@@ -515,7 +479,7 @@ impl TerminalInstance {}fn buffer_cursor(&self) -> BufferPoint {- let cursor = self.term.grid().cursor.point;+ let cursor = self.term.cursor().point;BufferPoint { line: self.term.history_size() as i64 + cursor.line.0 as i64, column: cursor.column.0 }}@@ -589,7 +553,7 @@ impl TerminalInstance {fn write_input(&mut self, data: &str) {self.term.scroll_display(Scroll::Bottom);- self.term.selection = None;+ self.term.clear_selection();self.prompt_input.user_input(data);self.write_to_pty(data.as_bytes());if let Some(on_input) = &mut self.on_input {@@ -616,8 +580,9 @@ impl TerminalInstance {/// Answers the OSC 52 queries with the clipboard's text.pub fn answer_clipboard_loads(&mut self, text: &str) {- for format in std::mem::take(&mut self.clipboard_loads) {- self.write_to_pty(format(text).as_bytes());+ let encoded = base64::engine::general_purpose::STANDARD.encode(text);+ for selection in std::mem::take(&mut self.clipboard_loads) {+ self.write_to_pty(format!("\x1b]52;{selection};{encoded}\x07").as_bytes());}}@@ -634,7 +599,7 @@ impl TerminalInstance {if self.term.columns() == cols as usize && self.term.screen_lines() == rows as usize {return false;}- self.term.resize(GridSize { cols, rows });+ self.term.resize(cols, rows);if let Some(pty) = &self.pty {pty.resize(cols, rows);}@@ -690,20 +655,18 @@ impl TerminalInstance {/// xterm.js `clear`: the cursor's line becomes the buffer's first and the scrollback goes.pub fn clear(&mut self) {- let cursor = self.term.grid().cursor.point;+ let cursor = self.term.cursor().point;self.term.scroll_display(Scroll::Bottom);- self.term.scroll_up(cursor.line.0.max(0) as usize);- self.term.clear_screen(ClearMode::Saved);- self.term.goto(0, cursor.column.0);- self.term.selection = None;+ // SU (no scrollback in a full scroll region), ED 3 and CUP, as xterm.js `clear` moves the lines.+ let lines = cursor.line.0;+ let sequences = format!("{}\x1b[3J\x1b[1;{}H", if lines > 0 { format!("\x1b[{lines}S") } else { String::new() }, cursor.column.0 + 1);+ self.term.advance(sequences.as_bytes());+ self.term.clear_selection();}/// The settings xterm.js reads live (`scrollback`, `wordSeparators`, `cursorStyle`) changed.pub fn configure(&mut self, config: Config) {- if config != self.config {- self.term.set_options(config.clone());- self.config = config;- }+ self.term.set_options(config);}pub fn scroll(&mut self, scroll: Scroll) {@@ -713,22 +676,19 @@ impl TerminalInstance {/// Starts a selection at a cell of the viewport (line 0 is the viewport's first line).pub fn start_selection(&mut self, kind: SelectionType, line: i32, column: usize, side: Side) {let point = self.viewport_point(line, column);- self.term.selection = Some(Selection::new(kind, point, side));+ self.term.start_selection(kind, point, side);}pub fn extend_selection(&mut self, line: i32, column: usize, side: Side) {let point = self.viewport_point(line, column);- if let Some(selection) = &mut self.term.selection {- selection.update(point, side);- }+ self.term.update_selection(point, side);}pub fn select_all(&mut self) {let top = Point::new(Line(-(self.term.history_size() as i32)), Column(0));let bottom = Point::new(Line(self.term.screen_lines() as i32 - 1), Column(self.term.columns() - 1));- let mut selection = Selection::new(SelectionType::Simple, top, Side::Left);- selection.update(bottom, Side::Right);- self.term.selection = Some(selection);+ self.term.start_selection(SelectionType::Simple, top, Side::Left);+ self.term.update_selection(bottom, Side::Right);}pub fn selection_text(&self) -> Option<String> {@@ -737,7 +697,7 @@ impl TerminalInstance {/// `serializeAsHTML({ onlySelection: true })`.pub fn selection_html(&self, colors: &colors::TerminalColors, font_family: &str, font_size: f32) -> Option<String> {- let range = self.term.selection.as_ref()?.to_range(&self.term)?;+ let range = self.term.selection_range()?;let history = self.term.history_size() as i64;let start = (range.start.line.0 as i64 + history, range.start.column.0);let end = (range.end.line.0 as i64 + history, range.end.column.0 + 1);@@ -745,7 +705,7 @@ impl TerminalInstance {}fn viewport_point(&self, line: i32, column: usize) -> Point {- let offset = self.term.grid().display_offset() as i32;+ let offset = self.term.display_offset() as i32;let last_line = self.term.screen_lines() as i32 - 1;Point::new(Line(line.clamp(0, last_line) - offset), Column(column.min(self.term.columns() - 1)))}diff --git a/native/crates/app/src/terminal/accessible_buffer.rs b/native/crates/app/src/terminal/accessible_buffer.rsindex eb4c34304f3..6643a7f5d25 100644--- a/native/crates/app/src/terminal/accessible_buffer.rs+++ b/native/crates/app/src/terminal/accessible_buffer.rs@@ -1,9 +1,7 @@//! bufferContentTracker.ts and terminalAccessibleBufferProvider.ts: the buffer as the accessible view's lines, a//! wrapped row joined to the row it continues, blank lines left out, and the editor line of each command.--use alacritty_terminal::grid::Dimensions;-use alacritty_terminal::index::{Column, Line};-use alacritty_terminal::term::cell::Flags;+use ghostty_vt::{Column, Line};+use ghostty_vt::Flags;use super::TerminalInstance;@@ -25,7 +23,7 @@ impl TerminalInstance {let mut current = String::new();for line in 0..total {editor_line_of.push(lines.len());- let row = &self.term.grid()[Line((line - history) as i32)];+ let row = &self.term.row(Line((line - history) as i32));let wrapped = line + 1 < total && row[Column(self.term.columns() - 1)].flags.contains(Flags::WRAPLINE);let text: String = (0..self.term.columns()).map(|column| row[Column(column)].c).collect();// `translateToString(!isWrapped)`: a row that continues keeps its trailing blanks.@@ -50,7 +48,7 @@ impl TerminalInstance {#[cfg(test)]mod tests {- use alacritty_terminal::term::Config;+ use ghostty_vt::Config;use super::super::{ShellLaunchConfig, TerminalInstance, colors};diff --git a/native/crates/app/src/terminal/fixed_dims.rs b/native/crates/app/src/terminal/fixed_dims.rsindex dc92ef35c40..c202015059e 100644--- a/native/crates/app/src/terminal/fixed_dims.rs+++ b/native/crates/app/src/terminal/fixed_dims.rs@@ -1,6 +1,4 @@-use alacritty_terminal::grid::Dimensions;-use alacritty_terminal::index::{Column, Line};-use alacritty_terminal::term::cell::Flags;+use ghostty_vt::{Column, Line};use super::TerminalInstance;@@ -26,15 +24,14 @@ impl TerminalInstance {/// xtermTerminal.ts `getLongestViewportWrappedLineLength`: each viewport line joined with the rows it wraps/// from, less the blanks ending its last row.fn longest_viewport_wrapped_line_length(&self) -> usize {- let grid = self.term.grid();let cols = self.term.columns();- let viewport_top = -(grid.display_offset() as i32);+ let viewport_top = -(self.term.display_offset() as i32);let topmost = -(self.term.history_size() as i32);- let wraps = |line: i32| grid[Line(line)][Column(cols - 1)].flags.contains(Flags::WRAPLINE);+ let wraps = |line: i32| self.term.wraps(Line(line));let mut longest = 0;let mut line = self.term.screen_lines() as i32 - 1;while line >= viewport_top {- let row = &grid[Line(line)];+ let row = self.term.row(Line(line));let end_spaces = (0..cols).rev().take_while(|&column| matches!(row[Column(column)].c, ' ' | '\0')).count();let mut first = line;while first > topmost && wraps(first - 1) {@@ -50,8 +47,7 @@ impl TerminalInstance {#[cfg(test)]mod tests {- use alacritty_terminal::grid::Dimensions;- use alacritty_terminal::term::Config;+ use ghostty_vt::Config;use super::super::{ShellLaunchConfig, TerminalInstance, colors};diff --git a/native/crates/app/src/terminal/marks.rs b/native/crates/app/src/terminal/marks.rsindex 6d600a07084..085d228b714 100644--- a/native/crates/app/src/terminal/marks.rs+++ b/native/crates/app/src/terminal/marks.rs@@ -3,7 +3,7 @@use std::time::{Duration, Instant};-use alacritty_terminal::grid::{Dimensions, Scroll};+use ghostty_vt::Scroll;use super::TerminalInstance;@@ -117,7 +117,7 @@ impl TerminalInstance {}pub fn viewport_y(&self) -> i64 {- self.term.history_size() as i64 - self.term.grid().display_offset() as i64+ self.term.history_size() as i64 - self.term.display_offset() as i64}}@@ -142,7 +142,7 @@ pub const OUTLINE_DURATION: Duration = Duration::from_millis(350);#[cfg(test)]mod tests {- use alacritty_terminal::term::Config;+ use ghostty_vt::Config;use super::super::{ShellLaunchConfig, TerminalInstance, colors};@@ -172,7 +172,7 @@ mod tests {assert_eq!(viewport(&instance), 9);instance.scroll_to_next_mark();assert_eq!((viewport(&instance), highlighted(&instance)), (16, None), "past the last mark: the bottom");- instance.term.scroll_display(alacritty_terminal::grid::Scroll::Delta(5));+ instance.term.scroll_display(ghostty_vt::Scroll::Delta(5));instance.scroll_to_previous_mark();assert_eq!(viewport(&instance), 9, "scrolled away: counted from the viewport top (11)");instance.input("x");diff --git a/native/crates/app/src/terminal/mouse.rs b/native/crates/app/src/terminal/mouse.rsindex c98faea32ab..ec0045a7428 100644--- a/native/crates/app/src/terminal/mouse.rs+++ b/native/crates/app/src/terminal/mouse.rs@@ -1,7 +1,7 @@//! Mouse reports to the process (xterm.js CoreMouseService with its DEFAULT and SGR encodings): the buttons,//! wheel and motion a program asked for with DECSET 1000, 1002, 1003 and 1006.-use alacritty_terminal::term::TermMode;+use ghostty_vt::TermMode;#[derive(Clone, Copy, Debug, PartialEq)]pub enum MouseButton {diff --git a/native/crates/app/src/terminal/prompt_input.rs b/native/crates/app/src/terminal/prompt_input.rsindex b893d7c7507..4583414e97f 100644--- a/native/crates/app/src/terminal/prompt_input.rs+++ b/native/crates/app/src/terminal/prompt_input.rs@@ -3,12 +3,7 @@// Nothing calls the model yet; the terminal instance and terminal-suggest will.#![allow(dead_code)]-use alacritty_terminal::event::EventListener;-use alacritty_terminal::grid::{Dimensions, Grid, Row};-use alacritty_terminal::index::{Column, Line};-use alacritty_terminal::term::Term;-use alacritty_terminal::term::cell::{Cell, Flags};-use alacritty_terminal::vte::ansi::Color;+use ghostty_vt::{Cell, Color, Column, Flags, Line, Row, Term};use super::shell_integration::BufferPoint;@@ -91,13 +86,13 @@ impl PromptInputModel {}/// promptInputModel.ts `setContinuationPrompt`. Returns whether the input changed.- pub fn set_continuation_prompt<T: EventListener>(&mut self, term: &Term<T>, value: &str) -> bool {+ pub fn set_continuation_prompt(&mut self, term: &Term, value: &str) -> bool {self.continuation_prompt = Some(value.to_owned());self.sync(term)}/// promptInputModel.ts `setLastPromptLine`. Returns whether the input changed.- pub fn set_last_prompt_line<T: EventListener>(&mut self, term: &Term<T>, value: &str) -> bool {+ pub fn set_last_prompt_line(&mut self, term: &Term, value: &str) -> bool {self.last_prompt_line = Some(value.to_owned());self.sync(term)}@@ -140,7 +135,7 @@ impl PromptInputModel {/// promptInputModel.ts `_handleCommandStart`, with `start` where the command line begins (the B sequence's/// cursor). Returns whether input started (`onDidStartInput`).- pub fn command_start<T: EventListener>(&mut self, term: &Term<T>, start: BufferPoint) -> bool {+ pub fn command_start(&mut self, term: &Term, start: BufferPoint) -> bool {if self.state == PromptInputState::Input {return false;}@@ -162,7 +157,7 @@ impl PromptInputModel {}/// promptInputModel.ts `_handleCommandStartChanged`: the command now starts at the cursor's column.- pub fn command_start_changed<T: EventListener>(&mut self, term: &Term<T>) {+ pub fn command_start_changed(&mut self, term: &Term) {if self.state != PromptInputState::Input {return;}@@ -195,7 +190,7 @@ impl PromptInputModel {/// promptInputModel.ts `_sync`: reads the input from the command start to the cursor and below it. Call it/// after each parsed write, cursor move and user input. Returns whether the input changed (`onDidChangeInput`).- pub fn sync<T: EventListener>(&mut self, term: &Term<T>) -> bool {+ pub fn sync(&mut self, term: &Term) -> bool {if self.state != PromptInputState::Input {return false;}@@ -350,8 +345,8 @@ impl PromptInputModel {let Some(cell) = buffer.cell(y, x) else {break;};- if !cell_text(cell).trim().is_empty() {- proceed_with_ghost_text_check = !is_styled_like_ghost_text(cell);+ if !cell_text(&cell).trim().is_empty() {+ proceed_with_ghost_text_check = !is_styled_like_ghost_text(&cell);break;}}@@ -363,11 +358,11 @@ impl PromptInputModel {let Some(cell) = buffer.cell(y, x) else {break;};- if is_styled_like_ghost_text(cell) {+ if is_styled_like_ghost_text(&cell) {ghost_text_index = cursor_index + offset;break;}- offset += length(&cell_text(cell));+ offset += length(&cell_text(&cell));}}if ghost_text_index == -1 {@@ -390,25 +385,25 @@ impl PromptInputModel {let mut styles: Vec<(Style, Vec<usize>)> = Vec::new();let mut position = buffer.cursor_x;let mut last_non_whitespace_cell = buffer.cell(y, position);- let mut next_cell = last_non_whitespace_cell;+ let mut next_cell = last_non_whitespace_cell.clone();while let Some(cell) = next_cell {- let style = Style::of(cell);+ let style = Style::of(&cell);match styles.iter_mut().find(|(known, _)| *known == style) {Some((_, positions)) => positions.push(position),None => styles.push((style, vec![position])),}position += 1;next_cell = buffer.cell(y, position);- if next_cell.is_some_and(|cell| !cell_text(cell).trim().is_empty()) {- last_non_whitespace_cell = next_cell;+ if next_cell.as_ref().is_some_and(|cell| !cell_text(cell).trim().is_empty()) {+ last_non_whitespace_cell = next_cell.clone();}}let Some(last_cell) = last_non_whitespace_cell.filter(|cell| !cell_text(cell).trim().is_empty()) else {return -1;};- let last_style = Style::of(last_cell);- if buffer.cell(y, self.command_start_x).is_some_and(|cell| Style::of(cell) == last_style) {+ let last_style = Style::of(&last_cell);+ if buffer.cell(y, self.command_start_x).is_some_and(|cell| Style::of(&cell) == last_style) {return -1;}let Some((_, positions)) = styles.iter().find(|(style, _)| *style == last_style) else {@@ -432,7 +427,7 @@ impl PromptInputModel {fn is_position_right_prompt(&self, buffer: &Buffer, y: i64, position: usize) -> bool {let mut count = 0;for x in (self.command_start_x..position).rev() {- let blank = buffer.cell(y, x).is_none_or(|cell| cell_text(cell).trim().is_empty());+ let blank = buffer.cell(y, x).is_none_or(|cell| cell_text(&cell).trim().is_empty());if !blank {count = 0;continue;@@ -474,7 +469,7 @@ impl PromptInputModel {let Some(cell) = cell else {break;};- text.push_str(&cell_text(cell));+ text.push_str(&cell_text(&cell));}x}@@ -482,7 +477,7 @@ impl PromptInputModel {/// The xterm.js `IBuffer` reads the model makes, over absolute lines (scrollback line 0 is 0, as `BufferPoint`).struct Buffer<'a> {- grid: &'a Grid<Cell>,+ term: &'a Term,history: i64,rows: i64,cursor_y: i64,@@ -491,39 +486,39 @@ struct Buffer<'a> {}impl<'a> Buffer<'a> {- fn new<T>(term: &'a Term<T>) -> Self {- let grid = term.grid();- let history = grid.history_size() as i64;- let cursor = &grid.cursor;+ fn new(term: &'a Term) -> Self {+ let history = term.history_size() as i64;+ let cursor = term.cursor();Buffer {- grid,+ term,history,- rows: grid.screen_lines() as i64,+ rows: term.screen_lines() as i64,cursor_y: history + cursor.point.line.0 as i64,cursor_x: cursor.point.column.0 + cursor.input_needs_wrap as usize,}}/// `buffer.getLine`.- fn row(&self, y: i64) -> Option<&'a Row<Cell>> {+ fn row(&self, y: i64) -> Option<Row> {+ self.line(y).map(|line| self.term.row(line))+ }++ fn line(&self, y: i64) -> Option<Line> {let line = y - self.history;- if y < 0 || line >= self.rows {- return None;- }- Some(&self.grid[Line(line as i32)])+ (y >= 0 && line < self.rows).then_some(Line(line as i32))}/// `getLine(y).getCell(x)`.- fn cell(&self, y: i64, x: usize) -> Option<&'a Cell> {- self.row(y).filter(|row| x < row.len()).map(|row| &row[Column(x)])+ fn cell(&self, y: i64, x: usize) -> Option<Cell> {+ self.line(y).filter(|_| x < self.term.columns()).map(|line| self.term.cell(ghostty_vt::Point::new(line, Column(x))))}- /// `IBufferLine.isWrapped`: alacritty marks the wrap on the last cell of the line before.+ /// `IBufferLine.isWrapped`: the line before continues on this one.fn is_wrapped(&self, y: i64) -> bool {- self.row(y - 1).is_some_and(|row| row[Column(row.len() - 1)].flags.contains(Flags::WRAPLINE))+ self.line(y - 1).is_some_and(|line| self.term.wraps(line))}- /// The cell after the last one holding a character. xterm.js tells an erased cell from a typed space, alacritty+ /// The cell after the last one holding a character. xterm.js tells an erased cell from a typed space, Ghostty/// does not, so on the cursor's line the cells before the cursor count as typed: `ls |` keeps its space.fn content_end(&self, y: i64) -> usize {let Some(row) = self.row(y) else {@@ -560,7 +555,7 @@ impl<'a> Buffer<'a> {}}-/// `_getCellStyleAsString` / `_cellStylesMatch`: colors and the attribute flags; alacritty has no blink or overline.+/// `_getCellStyleAsString` / `_cellStylesMatch`: colors and the attribute flags; the cells carry no blink or overline.#[derive(Clone, Copy, PartialEq)]struct Style {fg: Color,@@ -603,16 +598,12 @@ fn substring(text: &str, start: usize, end: usize) -> &str {#[cfg(test)]mod tests {- use alacritty_terminal::event::VoidListener;- use alacritty_terminal::term::Config;- use alacritty_terminal::term::test::TermSize;- use alacritty_terminal::vte::ansi::Processor;+ use ghostty_vt::Config;use super::*;struct Session {- term: Term<VoidListener>,- parser: Processor,+ term: Term,model: PromptInputModel,}@@ -622,13 +613,13 @@ mod tests {}fn with_size(columns: usize, rows: usize) -> Self {- let term = Term::new(Config::default(), &TermSize::new(columns, rows), VoidListener);- Session { term, parser: Processor::new(), model: PromptInputModel::default() }+ let term = Term::new(columns as u16, rows as u16, Config::default());+ Session { term, model: PromptInputModel::default() }}/// `writePromise`: xterm.js syncs the model after each parsed write.fn write(&mut self, data: &str) {- self.parser.advance(&mut self.term, data.as_bytes());+ self.term.advance(data.as_bytes());self.model.sync(&self.term);}diff --git a/native/crates/app/src/terminal/quick_fix.rs b/native/crates/app/src/terminal/quick_fix.rsindex ca29618f440..a47a5713e68 100644--- a/native/crates/app/src/terminal/quick_fix.rs+++ b/native/crates/app/src/terminal/quick_fix.rs@@ -1,10 +1,7 @@//! quickFix.ts, the builtin actions of terminalQuickFixBuiltinActions.ts and the matching of quickFixAddon.ts//! `getQuickFixesForCommand` and terminalCommand.ts `getOutputMatch`: what a finished command's line and output//! offer as fixes. Extension providers get their lines from `lines_for_command` and match in the workbench.--use alacritty_terminal::grid::Dimensions;-use alacritty_terminal::index::{Column, Line};-use alacritty_terminal::term::cell::Flags;+use ghostty_vt::Line;use regex::Regex;use super::{FinishedCommand, TerminalInstance};@@ -273,7 +270,7 @@ impl TerminalInstance {if previous < -history || previous >= self.term.screen_lines() as i64 {return false;}- self.term.grid()[Line(previous as i32)][Column(self.term.columns() - 1)].flags.contains(Flags::WRAPLINE)+ self.term.wraps(Line(previous as i32))}/// `getXtermLineContent`: the rows' text, each trimmed at its end.@@ -284,7 +281,7 @@ impl TerminalInstance {#[cfg(test)]mod tests {- use alacritty_terminal::term::Config;+ use ghostty_vt::Config;use super::*;use crate::terminal::{ShellLaunchConfig, colors};diff --git a/native/crates/app/src/terminal/search.rs b/native/crates/app/src/terminal/search.rsindex 55a628da535..61db1cbe4a7 100644--- a/native/crates/app/src/terminal/search.rs+++ b/native/crates/app/src/terminal/search.rs@@ -1,12 +1,10 @@//! The find model of the search addon (@xterm/addon-search): matches over the whole buffer, wrapped lines joined.-use alacritty_terminal::event::EventListener;-use alacritty_terminal::grid::Dimensions;-use alacritty_terminal::index::{Column, Line, Point};-use alacritty_terminal::term::Term;-use alacritty_terminal::term::cell::Flags;-use alacritty_terminal::term::search::Match;+use ghostty_vt::{Column, Flags, Line, Point, Term};use regex::RegexBuilder;+/// A match from its first cell to its last, both inclusive.+pub type Match = std::ops::RangeInclusive<Point>;+/// Ports `Constants.DEFAULT_HIGHLIGHT_LIMIT` (`XtermTerminalConstants.SearchHighlightLimit`).pub const HIGHLIGHT_LIMIT: usize = 1000;@@ -28,7 +26,7 @@ pub enum Direction {}/// Ports `SearchAddon._highlightAllMatches`: every match in buffer order, scrollback included, capped at `HIGHLIGHT_LIMIT`.-pub fn find_matches<T: EventListener>(term: &Term<T>, query: &str, options: SearchOptions) -> Vec<Match> {+pub fn find_matches(term: &Term, query: &str, options: SearchOptions) -> Vec<Match> {if query.is_empty() {return Vec::new();}@@ -95,14 +93,13 @@ impl LogicalLine {}}-fn read_logical_line<T: EventListener>(term: &Term<T>, first: Line) -> LogicalLine {- let grid = term.grid();+fn read_logical_line(term: &Term, first: Line) -> LogicalLine {let last_column = term.last_column();let mut text = String::new();let mut cells = Vec::new();let mut line = first;loop {- let row = &grid[line];+ let row = term.row(line);for column in 0..=last_column.0 {let cell = &row[Column(column)];if cell.flags.intersects(Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER) {@@ -135,18 +132,14 @@ fn is_whole_word(text: &str, start: usize, end: usize) -> bool {#[cfg(test)]mod tests {- use alacritty_terminal::event::VoidListener;- use alacritty_terminal::term::Config;- use alacritty_terminal::term::test::TermSize;- use alacritty_terminal::vte::ansi::Processor;+ use ghostty_vt::Config;use super::*;- fn terminal(columns: usize, rows: usize, data: &str) -> Term<VoidListener> {+ fn terminal(columns: u16, rows: u16, data: &str) -> Term {let config = Config { scrolling_history: 1000, ..Config::default() };- let mut term = Term::new(config, &TermSize::new(columns, rows), VoidListener);- let mut parser: Processor = Processor::new();- parser.advance(&mut term, data.as_bytes());+ let mut term = Term::new(columns, rows, config);+ term.advance(data.as_bytes());term}@@ -154,7 +147,7 @@ mod tests {Point::new(Line(line), Column(column))}- fn find(term: &Term<VoidListener>, query: &str, options: SearchOptions) -> Vec<Match> {+ fn find(term: &Term, query: &str, options: SearchOptions) -> Vec<Match> {find_matches(term, query, options)}diff --git a/native/crates/app/src/terminal/serialize.rs b/native/crates/app/src/terminal/serialize.rsindex eaf78410c2e..4e03c55b67b 100644--- a/native/crates/app/src/terminal/serialize.rs+++ b/native/crates/app/src/terminal/serialize.rs@@ -1,10 +1,6 @@//! @xterm/addon-serialize `StringSerializeHandler`: the normal buffer as the escape sequences that redraw it, for//! ptyService.ts `serializeNormalBuffer` (`excludeModes`, `excludeAltBuffer`).--use alacritty_terminal::grid::Dimensions;-use alacritty_terminal::index::{Column, Line};-use alacritty_terminal::term::cell::{Cell, Flags};-use alacritty_terminal::vte::ansi::{Color, NamedColor};+use ghostty_vt::{Cell, Color, Column, Flags, Line, Point};use super::TerminalInstance;@@ -12,7 +8,7 @@ const UNDERLINES: Flags = Flags::ALL_UNDERLINES;impl TerminalInstance {/// `serialize({ scrollback })` of the normal buffer: the last `scrollback` lines over the screen, then the cursor.- // alacritty_terminal keeps `inactive_grid` private, so a terminal on the alternate screen serializes that one.+ // Ghostty's points address the active screen only, so a terminal on the alternate screen serializes that one.pub fn serialize_buffer(&self, scrollback: usize) -> String {let history = self.term.history_size();let rows = self.term.screen_lines();@@ -65,13 +61,13 @@ impl<'a> Handler<'a> {}/// Buffer row `row` counts from the top of the scrollback, as xterm's `buffer.getLine`.- fn cell(&self, row: usize, column: usize) -> &'a Cell {+ fn cell(&self, row: usize, column: usize) -> Cell {let line = row as i32 - self.instance.term.history_size() as i32;- &self.instance.term.grid()[Line(line)][Column(column)]+ self.instance.term.cell(Point::new(Line(line), Column(column)))}fn content_end(&self, row: usize) -> usize {- (0..self.instance.term.columns()).rev().find(|&column| !is_blank(self.cell(row, column))).map_or(0, |column| column + 1)+ (0..self.instance.term.columns()).rev().find(|&column| !is_blank(&self.cell(row, column))).map_or(0, |column| column + 1)}fn next_cell(&mut self, row: usize, column: usize) {@@ -80,7 +76,7 @@ impl<'a> Handler<'a> {return;}let empty = column >= self.content_end;- let sgr = diff_style(cell, &self.cursor_style);+ let sgr = diff_style(&cell, &self.cursor_style);let style_changed = if empty { cell.bg != self.cursor_style.bg } else { !sgr.is_empty() };if style_changed {if self.null_cell_count > 0 {@@ -167,11 +163,11 @@ impl<'a> Handler<'a> {return false;}let has_char = |cell: &Cell| !is_blank(cell) || cell.flags.contains(Flags::WIDE_CHAR_SPACER);- if has_char(last) && last.bg == next_first.bg {+ if has_char(&last) && last.bg == next_first.bg {return true;}let second_last = self.cell(row, cols.saturating_sub(2));- next_wide && has_char(second_last) && last.bg == next_first.bg && second_last.bg == next_first.bg+ next_wide && has_char(&second_last) && last.bg == next_first.bg && second_last.bg == next_first.bg}fn finish(mut self) -> String {@@ -190,7 +186,7 @@ impl<'a> Handler<'a> {content += &self.separators[index];}}- let cursor = term.grid().cursor.point;+ let cursor = term.cursor().point;let real_row = (term.history_size() as i32 + cursor.line.0) as i64;let real_column = cursor.column.0 as i64;let down = real_row - self.last_cursor.0 as i64;@@ -205,7 +201,7 @@ impl<'a> Handler<'a> {} else if right < 0 {content += &format!("\x1b[{}D", -right);}- let sgr = diff_style(&term.grid().cursor.template, &self.cursor_style);+ let sgr = diff_style(&term.cursor_template(), &self.cursor_style);if !sgr.is_empty() {content += &format!("\x1b[{}m", sgr.join(";"));}@@ -213,14 +209,14 @@ impl<'a> Handler<'a> {}}-/// Alacritty stores an erased cell and a typed space alike, so a blank is xterm's empty cell only past the row's content.+/// Ghostty stores an erased cell and a typed space alike, so a blank is xterm's empty cell only past the row's content.fn is_blank(cell: &Cell) -> bool {matches!(cell.c, ' ' | '\0') && cell.zerowidth().is_none()}fn is_default(cell: &Cell) -> bool {let style = cell.flags & !(Flags::WRAPLINE | Flags::WIDE_CHAR | Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER);- cell.fg == Color::Named(NamedColor::Foreground) && cell.bg == Color::Named(NamedColor::Background) && style.is_empty() && cell.underline_color().is_none()+ cell.fg == Color::Foreground && cell.bg == Color::Background && style.is_empty() && cell.underline_color().is_none()}/// `_diffStyle`: the SGR parameters that turn `old`'s attributes into `cell`'s.@@ -260,8 +256,7 @@ fn diff_style(cell: &Cell, old: &Cell) -> Vec<String> {match color {Some(Color::Spec(rgb)) => sgr.push(format!("58:2::{}:{}:{}", rgb.r, rgb.g, rgb.b)),Some(Color::Indexed(index)) => sgr.push(format!("58:5:{index}")),- Some(Color::Named(named)) => sgr.push(format!("58:5:{}", named as usize)),- None => {}+ Some(Color::Foreground | Color::Background) | None => {}}}}@@ -287,8 +282,7 @@ fn color_sgr(color: Color, normal: u8, bright: u8, extended: u8, default: u8) ->Color::Spec(rgb) => format!("{extended};2;{};{};{}", rgb.r, rgb.g, rgb.b),Color::Indexed(index) if index >= 16 => format!("{extended};5;{index}"),Color::Indexed(index) => palette_sgr(index as usize, normal, bright),- Color::Named(named) if (named as usize) < 16 => palette_sgr(named as usize, normal, bright),- Color::Named(_) => default.to_string(),+ Color::Foreground | Color::Background => default.to_string(),}}@@ -315,7 +309,7 @@ fn underline_style(flags: Flags) -> u8 {#[cfg(test)]mod tests {- use alacritty_terminal::term::Config;+ use ghostty_vt::Config;use super::super::{ShellLaunchConfig, TerminalInstance, colors};@@ -328,9 +322,8 @@ mod tests {}fn screen(instance: &TerminalInstance) -> Vec<String> {- use alacritty_terminal::grid::Dimensions;- use alacritty_terminal::index::{Column, Line};- (0..instance.term.screen_lines() as i32).map(|line| (0..instance.term.columns()).map(|column| instance.term.grid()[Line(line)][Column(column)].c).collect::<String>().trim_end().to_owned()).collect()+ use ghostty_vt::{Column, Line, Point};+ (0..instance.term.screen_lines() as i32).map(|line| (0..instance.term.columns()).map(|column| instance.term.cell(Point::new(Line(line), Column(column))).c).collect::<String>().trim_end().to_owned()).collect()}#[test]@@ -342,7 +335,7 @@ mod tests {let (mut revived, _) = instance(10);revived.process(serialized.as_bytes(), &colors);assert_eq!(screen(&revived), screen(&source));- assert_eq!(revived.term.grid().cursor.point, source.term.grid().cursor.point);+ assert_eq!(revived.term.cursor().point, source.term.cursor().point);}#[test]diff --git a/native/crates/app/src/terminal/serialize_html.rs b/native/crates/app/src/terminal/serialize_html.rsindex e357532472d..6e95d932d54 100644--- a/native/crates/app/src/terminal/serialize_html.rs+++ b/native/crates/app/src/terminal/serialize_html.rs@@ -1,10 +1,6 @@//! @xterm/addon-serialize `HTMLSerializeHandler`: buffer cells as the HTML a copy puts beside the text, one//! `<div><span>` per row and a styled `<span>` wherever the cell attributes change.--use alacritty_terminal::grid::Dimensions;-use alacritty_terminal::index::{Column, Line};-use alacritty_terminal::term::cell::{Cell, Flags};-use alacritty_terminal::vte::ansi::{Color, NamedColor};+use ghostty_vt::{Cell, Color, Column, Flags, Line};use gpui::Rgba;use super::TerminalInstance;@@ -22,7 +18,7 @@ impl TerminalInstance {if screen_line < -history || screen_line >= self.term.screen_lines() as i64 {continue;}- let row = &self.term.grid()[Line(screen_line as i32)];+ let row = &self.term.row(Line(screen_line as i32));let first = if line == start.0 { start.1 } else { 0 };let last = if line == end.0 { end.1.min(columns) } else { columns };html.push_str("<div><span>");@@ -111,9 +107,7 @@ fn hex(color: Color, palette: &[Rgba; 256]) -> Option<String> {let (r, g, b) = match color {Color::Spec(rgb) => (rgb.r, rgb.g, rgb.b),Color::Indexed(index) => to_bytes(palette[index as usize]),- Color::Named(named) if (named as usize) < 16 => to_bytes(palette[named as usize]),- Color::Named(named) if (NamedColor::DimBlack as usize..=NamedColor::DimWhite as usize).contains(&(named as usize)) => to_bytes(palette[named as usize - NamedColor::DimBlack as usize]),- Color::Named(_) => return None,+ Color::Foreground | Color::Background => return None,};Some(format!("#{r:02x}{g:02x}{b:02x}"))}@@ -136,7 +130,7 @@ fn escape(c: char, html: &mut String) {#[cfg(test)]mod tests {- use alacritty_terminal::term::Config;+ use ghostty_vt::Config;use super::super::{ShellLaunchConfig, TerminalInstance, colors};diff --git a/native/crates/app/src/terminal/sticky_scroll.rs b/native/crates/app/src/terminal/sticky_scroll.rsindex 7d65bd6630f..3821ab5985e 100644--- a/native/crates/app/src/terminal/sticky_scroll.rs+++ b/native/crates/app/src/terminal/sticky_scroll.rs@@ -1,9 +1,7 @@//! terminalStickyScrollOverlay.ts `_refreshNow` and `_updateContent`: the prompt and command lines of the command//! at the top of the viewport, shown over it while its output scrolls by.--use alacritty_terminal::grid::Dimensions;-use alacritty_terminal::index::{Column, Line};-use alacritty_terminal::term::TermMode;+use ghostty_vt::{Column, Line};+use ghostty_vt::TermMode;use super::{FinishedCommand, TerminalInstance};@@ -31,7 +29,7 @@ impl TerminalInstance {return None;}let base_y = self.term.history_size() as i64;- let viewport_y = base_y - self.term.grid().display_offset() as i64;+ let viewport_y = base_y - self.term.display_offset() as i64;let partial = self.current.prompt_line.is_some_and(|line| viewport_y >= line);let command = if partial { &self.current } else { self.command_for_line(viewport_y)? };let trimmed = command.command.trim().to_lowercase();@@ -58,7 +56,7 @@ impl TerminalInstance {return None;}- let cursor = self.term.grid().cursor.point;+ let cursor = self.term.cursor().point;if partial && viewport_y == base_y && cursor.line.0 == rows as i32 - 1 {let last_row = self.row_text(base_y + rows as i64 - 1);if (cursor.column.0 == 1 && last_row.starts_with(':')) || (cursor.column.0 == 5 && last_row.starts_with("(END)")) {@@ -99,7 +97,7 @@ impl TerminalInstance {if line < -history || line >= self.term.screen_lines() as i64 {return String::new();}- let row = &self.term.grid()[Line(line as i32)];+ let row = &self.term.row(Line(line as i32));let text: String = (0..self.term.columns()).map(|column| row[Column(column)].c).collect();text.trim_end_matches([' ', '\0']).to_owned()}diff --git a/native/crates/app/src/terminal/sticky_scroll/tests.rs b/native/crates/app/src/terminal/sticky_scroll/tests.rsindex 02bf2c7d68d..4907f1b6cc3 100644--- a/native/crates/app/src/terminal/sticky_scroll/tests.rs+++ b/native/crates/app/src/terminal/sticky_scroll/tests.rs@@ -1,5 +1,5 @@-use alacritty_terminal::grid::{Dimensions, Scroll};-use alacritty_terminal::term::Config;+use ghostty_vt::Scroll;+use ghostty_vt::Config;use super::super::{ShellLaunchConfig, TerminalInstance, colors};@@ -69,6 +69,6 @@ fn reveal_scrolls_a_quarter_of_the_rows_above_the_command() {let (mut instance, colors) = terminal(8);instance.process(output(40).as_bytes(), &colors);instance.reveal_rows(20, 20);- let viewport_y = instance.term.history_size() as i64 - instance.term.grid().display_offset() as i64;+ let viewport_y = instance.term.history_size() as i64 - instance.term.display_offset() as i64;assert_eq!(viewport_y, 18);}diff --git a/native/crates/app/src/terminal/tests.rs b/native/crates/app/src/terminal/tests.rsindex 5ad3cb4e965..f494c3b833d 100644--- a/native/crates/app/src/terminal/tests.rs+++ b/native/crates/app/src/terminal/tests.rs@@ -1,7 +1,7 @@use std::collections::HashMap;use std::time::{Duration, Instant};-use alacritty_terminal::index::{Column, Line, Point};+use ghostty_vt::{Column, Line, Point};use super::pty::PtyEvent;use super::*;@@ -24,7 +24,7 @@ fn shell(sh_script: &str, cmd_script: &str) -> ShellLaunchConfig {fn screen_line(instance: &TerminalInstance, line: i32) -> String {let columns = instance.term.columns();- (0..columns).map(|column| instance.term.grid()[Point::new(Line(line), Column(column))].c).collect::<String>().trim_end().to_owned()+ (0..columns).map(|column| instance.term.cell(Point::new(Line(line), Column(column))).c).collect::<String>().trim_end().to_owned()}#[test]@@ -55,8 +55,8 @@ fn a_shell_runs_in_a_pty_and_its_output_reaches_the_screen() {assert_eq!(instance.exit_code, Some(Some(3)));assert_eq!(screen_line(&instance, 0), "cols=40");assert_eq!(screen_line(&instance, 1), "red");- let red = &instance.term.grid()[Point::new(Line(1), Column(0))];- assert_eq!(red.fg, alacritty_terminal::vte::ansi::Color::Named(alacritty_terminal::vte::ansi::NamedColor::Red));+ let red = &instance.term.cell(Point::new(Line(1), Column(0)));+ assert_eq!(red.fg, ghostty_vt::Color::Indexed(1));}/// childProcessMonitor.ts `hasChildProcesses`: a background job of the shell counts, a shell alone does not.@@ -165,7 +165,7 @@ fn a_recording_keeps_each_kind_of_event() {#[test]fn osc_52_stores_and_reads_the_clipboard() {let launch = ShellLaunchConfig { extension_pty: true, cwd: std::env::temp_dir(), ..Default::default() };- let (mut instance, _receiver) = TerminalInstance::new(1, launch, 20, 3, Config { osc52: alacritty_terminal::term::Osc52::CopyPaste, ..Config::default() });+ let (mut instance, _receiver) = TerminalInstance::new(1, launch, 20, 3, Config::default());let written = Rc::new(RefCell::new(String::new()));let sink = written.clone();instance.process_input = Some(Box::new(move |data: &str| sink.borrow_mut().push_str(data)));@@ -188,7 +188,7 @@ fn clear_keeps_the_cursor_line_as_the_first_line() {assert_eq!(instance.term.history_size(), 0);assert_eq!(screen_line(&instance, 0), "$ ab");assert_eq!(screen_line(&instance, 1), "");- assert_eq!(instance.term.grid().cursor.point, Point::new(Line(0), Column(4)));+ assert_eq!(instance.term.cursor().point, Point::new(Line(0), Column(4)));}/// terminalInstance.ts `_onProcessExit`: after the launch, an exit alert shows with `showExitAlert` unless the lastdiff --git a/native/crates/app/src/workbench/scroll_frame_time.rs b/native/crates/app/src/workbench/scroll_frame_time.rsindex 336f6551397..4efa56ed19a 100644--- a/native/crates/app/src/workbench/scroll_frame_time.rs+++ b/native/crates/app/src/workbench/scroll_frame_time.rs@@ -2,7 +2,7 @@//! installed and running: each frame is one 30px pixel wheel event, then the draw. Text is laid out by gpui's//! NoopTextSystem (CoreText needs the main thread, which libtest never gives) and nothing reaches the GPU. The gate//! is 8 ms at the median and p95, a 120 Hz frame. Run in release:-//! `cargo test --release -p app -- --ignored scroll_frame_time --nocapture`.+//! `cargo test --release -p app -- --ignored frame_time --nocapture`.use std::path::{Path, PathBuf};use std::sync::{Arc, Mutex};@@ -145,3 +145,31 @@ fn settings_scroll_frame_time() {fixture.cx.run_until_parked();fixture.measure("Settings, whole tree", point(px(900.), px(500.)), 100., |workbench| workbench.settings_editor.tree.logical_scroll_top().item_ix as f32);}++/// A key typed in the terminal panel, echoed by the shell, then drawn: each frame is one byte of output through+/// `terminal_data` and the draw, over a full 10000-line scrollback. The gate is 16 ms at p95, a 60 Hz frame.+#[test]+#[ignore]+fn terminal_typing_frame_time() {+ let mut fixture = fixture("terminal");+ fixture.run("workbench.action.terminal.new", Vec::new());+ let id = fixture.window.update(&mut fixture.cx, |workbench, _, _| workbench.terminal_view.active_instance_id().unwrap()).unwrap();+ let output = |fixture: &mut Fixture, bytes: &[u8]| {+ fixture.window.update(&mut fixture.cx, |workbench, window, cx| drop(workbench.terminal_data(id, bytes, window, cx))).unwrap();+ };+ let history: String = (0..12000).map(|line| format!("\x1b[32m-rw-r--r--\x1b[0m 1 user staff {line:>8} \x1b[1;34mfile_{line}.txt\x1b[0m\r\n")).collect();+ output(&mut fixture, history.as_bytes());+ output(&mut fixture, b"$ ");+ fixture.frame(None);+ let mut times = Vec::new();+ for index in 0..FRAMES {+ let start = Instant::now();+ output(&mut fixture, if index % 80 == 79 { b"\r\n$ " } else { b"x" });+ times.push(start.elapsed().as_secs_f64() * 1000. + fixture.frame(None));+ }+ std::fs::remove_dir_all(&fixture.dir).unwrap();+ times.sort_by(f64::total_cmp);+ let (median, p95, max) = (times[times.len() / 2], times[times.len() * 95 / 100], times[times.len() - 1]);+ eprintln!("Terminal typing: median {median:.2} ms, p95 {p95:.2} ms, max {max:.2} ms");+ assert!(p95 < 16., "terminal typing: p95 {p95:.2} ms, the gate is 16 ms");+}diff --git a/native/crates/app/src/workbench/terminal_contrib.rs b/native/crates/app/src/workbench/terminal_contrib.rsindex b7489ef4f86..240db5fc4ac 100644--- a/native/crates/app/src/workbench/terminal_contrib.rs+++ b/native/crates/app/src/workbench/terminal_contrib.rs@@ -2,8 +2,6 @@//! developer contribution's Write Data to Terminal and Record Terminal Session.use std::time::{Duration, Instant};--use alacritty_terminal::grid::Dimensions;use gpui::{ClipboardItem, Context, ScrollDelta, Window};use serde_json::json;diff --git a/native/crates/app/src/workbench/terminal_decorations.rs b/native/crates/app/src/workbench/terminal_decorations.rsindex 8528bb4eecb..9abe9e99394 100644--- a/native/crates/app/src/workbench/terminal_decorations.rs+++ b/native/crates/app/src/workbench/terminal_decorations.rs@@ -1,8 +1,6 @@//! decorationAddon.ts and decorationStyles.ts, the gutter part: a circle left of each command's prompt line,//! filled in `terminalCommandDecoration.successBackground` for exit code 0, an error mark in `errorBackground`//! otherwise, and an outline in `defaultBackground` while the command runs or the prompt waits.--use alacritty_terminal::grid::Dimensions;use gpui::{AnyElement, Bounds, ClipboardItem, MouseButton, MouseDownEvent, prelude::*, px};use serde_json::{Value, json};@@ -236,7 +234,7 @@ impl Workbench {let (Some(instance), Some(pane), Some(metrics)) = (self.terminal_view.instance(id), self.terminal_view.pane_bounds.get(&id), self.terminal_view.metrics.as_ref()) else { return Vec::new() };let rows = instance.term.screen_lines() as i64;let origin = grid::grid_origin(*pane, instance) - pane.origin;- let viewport_y = instance.term.history_size() as i64 - instance.term.grid().display_offset() as i64;+ let viewport_y = instance.term.history_size() as i64 - instance.term.display_offset() as i64;// `updateLayout`: smaller than the default font scales the decoration down, never up.let font_size = self.setting("terminal.integrated.fontSize").as_f64().unwrap_or(12.) as f32;let line_height = self.setting("terminal.integrated.lineHeight").as_f64().unwrap_or(1.) as f32;diff --git a/native/crates/app/src/workbench/terminal_editor.rs b/native/crates/app/src/workbench/terminal_editor.rsindex 97c5784c52b..ff0533bf63e 100644--- a/native/crates/app/src/workbench/terminal_editor.rs+++ b/native/crates/app/src/workbench/terminal_editor.rs@@ -2,8 +2,6 @@//! a `vscode-terminal` editor whose body is the instance's pane.use std::path::{Path, PathBuf};--use alacritty_terminal::grid::Dimensions;use gpui::{Context, Div, Rgba, Window, div, prelude::*, px};use serde_json::{Value, json};diff --git a/native/crates/app/src/workbench/terminal_editor/tests.rs b/native/crates/app/src/workbench/terminal_editor/tests.rsindex b11049a273f..b8ea6111d32 100644--- a/native/crates/app/src/workbench/terminal_editor/tests.rs+++ b/native/crates/app/src/workbench/terminal_editor/tests.rs@@ -314,10 +314,9 @@ fn a_terminal_editor_revives_with_its_history_after_a_restart(cx: &mut TestAppComove |_: &mut gpui::Window, cx: &mut gpui::Context<Workbench>| Workbench::new(theme, app_root, None, Languages::new(&[]), settings, HostSync::new(std::sync::mpsc::channel().0), cx)};let screen = |workbench: &Workbench, id: u32| {- use alacritty_terminal::grid::Dimensions;- use alacritty_terminal::index::{Column, Line};+ use ghostty_vt::{Column, Line, Point};let term = &workbench.terminal_view.instance(id).unwrap().term;- (0..term.screen_lines() as i32).map(|line| (0..term.columns()).map(|column| term.grid()[Line(line)][Column(column)].c).collect::<String>().trim_end().to_owned()).collect::<Vec<_>>()+ (0..term.screen_lines() as i32).map(|line| (0..term.columns()).map(|column| term.cell(Point::new(Line(line), Column(column))).c).collect::<String>().trim_end().to_owned()).collect::<Vec<_>>()};// terminalService.ts `_onWillShutdown`: the editor's terminal and its buffer are stored on quit.@@ -364,9 +363,9 @@ fn panel_terminals_revive_in_their_groups_after_a_restart(cx: &mut TestAppContexmove |_: &mut gpui::Window, cx: &mut gpui::Context<Workbench>| Workbench::new(theme, app_root, None, Languages::new(&[]), settings, HostSync::new(std::sync::mpsc::channel().0), cx)};let first_line = |workbench: &Workbench, id: u32| {- use alacritty_terminal::index::{Column, Line};+ use ghostty_vt::{Column, Line, Point};let term = &workbench.terminal_view.instance(id).unwrap().term;- (0..8).map(|column| term.grid()[Line(0)][Column(column)].c).collect::<String>()+ (0..8).map(|column| term.cell(Point::new(Line(0), Column(column))).c).collect::<String>()};let (first, first_cx) = cx.add_window_view(new_workbench());diff --git a/native/crates/app/src/workbench/terminal_find.rs b/native/crates/app/src/workbench/terminal_find.rsindex 702fd21e257..7726f68909e 100644--- a/native/crates/app/src/workbench/terminal_find.rs+++ b/native/crates/app/src/workbench/terminal_find.rs@@ -1,10 +1,8 @@//! terminalFindWidget.ts over the search addon: the find input with its case, whole word and regex toggles, the//! result count, previous, next and close, drawn over the terminal's top right corner. The matches come from//! `terminal/search.rs`; the grid paints them.--use alacritty_terminal::grid::Dimensions;-use alacritty_terminal::index::{Column, Point};-use alacritty_terminal::term::search::Match;+use ghostty_vt::{Column, Point};+use crate::terminal::search::Match;use gpui::{Context, Div, FocusHandle, MouseButton, MouseDownEvent, Window, div, prelude::*, px};use super::Workbench;diff --git a/native/crates/app/src/workbench/terminal_history.rs b/native/crates/app/src/workbench/terminal_history.rsindex 2ec6d3bcddb..6346c2a6764 100644--- a/native/crates/app/src/workbench/terminal_history.rs+++ b/native/crates/app/src/workbench/terminal_history.rs@@ -3,7 +3,7 @@use std::path::PathBuf;-use alacritty_terminal::grid::{Dimensions, Scroll};+use ghostty_vt::Scroll;use gpui::{Context, Window};use serde_json::{Value, json};@@ -342,10 +342,10 @@ impl Workbench {let Some(line) = command.prompt_line.or(command.command_line) else { return };let saved = &mut self.terminal_view.history.saved_scroll;let terminal = self.terminal_view.instances.iter_mut().find(|terminal| terminal.id == instance).expect("found above");- saved.get_or_insert((instance, terminal.term.grid().display_offset()));+ saved.get_or_insert((instance, terminal.term.display_offset()));let history_size = terminal.term.history_size() as i64;let offset = (history_size - line).clamp(0, history_size);- let delta = offset - terminal.term.grid().display_offset() as i64;+ let delta = offset - terminal.term.display_offset() as i64;terminal.term.scroll_display(Scroll::Delta(delta as i32));cx.notify();}@@ -353,7 +353,7 @@ impl Workbench {fn restore_recent_scroll(&mut self, cx: &mut Context<Self>) {let Some((instance, offset)) = self.terminal_view.history.saved_scroll.take() else { return };if let Some(terminal) = self.terminal_view.instance_mut(instance) {- let delta = offset as i64 - terminal.term.grid().display_offset() as i64;+ let delta = offset as i64 - terminal.term.display_offset() as i64;terminal.term.scroll_display(Scroll::Delta(delta as i32));}cx.notify();diff --git a/native/crates/app/src/workbench/terminal_host.rs b/native/crates/app/src/workbench/terminal_host.rsindex 1509b9a373b..a833074e06e 100644--- a/native/crates/app/src/workbench/terminal_host.rs+++ b/native/crates/app/src/workbench/terminal_host.rs@@ -5,8 +5,6 @@use std::collections::HashMap;use std::path::PathBuf;use std::time::{Duration, Instant};--use alacritty_terminal::grid::Dimensions;use exthost::session::ForwardedRequest;use gpui::{Context, Window};use serde_json::{Value, json};diff --git a/native/crates/app/src/workbench/terminal_initial_hint.rs b/native/crates/app/src/workbench/terminal_initial_hint.rsindex eb18498cb0c..63be2b3554c 100644--- a/native/crates/app/src/workbench/terminal_initial_hint.rs+++ b/native/crates/app/src/workbench/terminal_initial_hint.rs@@ -1,7 +1,5 @@//! terminal.initialHint.contribution.ts with AI features hidden: at a new terminal's empty prompt, "Show//! suggestions ⌃Space." and "Start typing to dismiss or don't show this again.", dismissed by any key or click.--use alacritty_terminal::grid::Dimensions;use gpui::{AnyElement, Bounds, MouseButton, MouseDownEvent, div, prelude::*, px};use serde_json::{Value, json};@@ -35,10 +33,10 @@ impl Workbench {if launch.extension_pty || launch.is_feature_terminal || launch.hide_from_user || instance.prompt_input.state() == crate::terminal::prompt_input::PromptInputState::Unknown {return None;}- if !instance.commands.is_empty() || !instance.prompt_input.value().is_empty() || instance.term.grid().display_offset() != 0 {+ if !instance.commands.is_empty() || !instance.prompt_input.value().is_empty() || instance.term.display_offset() != 0 {return None;}- let cursor = instance.term.grid().cursor.point;+ let cursor = instance.term.cursor().point;let cols = instance.term.columns();if cursor.column.0 == 0 {return None;diff --git a/native/crates/app/src/workbench/terminal_links.rs b/native/crates/app/src/workbench/terminal_links.rsindex f7867c06807..684f0f85c20 100644--- a/native/crates/app/src/workbench/terminal_links.rs+++ b/native/crates/app/src/workbench/terminal_links.rs@@ -7,10 +7,7 @@use std::collections::HashMap;use std::path::{Path, PathBuf};--use alacritty_terminal::grid::Dimensions;-use alacritty_terminal::index::{Column, Line, Point};-use alacritty_terminal::term::cell::Flags;+use ghostty_vt::{Column, Flags, Line};use gpui::{Bounds, Context, Modifiers, Window, point, px, size};use serde_json::{Value, json};@@ -86,7 +83,7 @@ impl Workbench {if !(0..instance.term.screen_lines() as i32).contains(&row) {return None;}- let line = row - instance.term.grid().display_offset() as i32;+ let line = row - instance.term.display_offset() as i32;let (text, cells) = wrapped_line_text(instance, line);let index = cells.iter().position(|&(cell_line, cell_column)| cell_line == line && cell_column >= column)?;let line_text = extension_line_text(&text);@@ -125,7 +122,7 @@ impl Workbench {if !(0..instance.term.screen_lines() as i32).contains(&row) {return;}- let (text, _) = wrapped_line_text(instance, row - instance.term.grid().display_offset() as i32);+ let (text, _) = wrapped_line_text(instance, row - instance.term.display_offset() as i32);let line_text = extension_line_text(&text).to_owned();if line_text.is_empty() || line_text.encode_utf16().count() > MAX_EXTENSION_LINE_LENGTH {return;@@ -169,7 +166,7 @@ impl Workbench {let (first, last) = (hovered.cells[0], *hovered.cells.last().expect("a link covers a cell"));let Some(instance) = self.terminal_view.instance(id) else { return };let origin = grid::grid_origin(pane, instance);- let offset = instance.term.grid().display_offset() as i32;+ let offset = instance.term.display_offset() as i32;let cell = |(line, column): (i32, usize)| point(origin.x + px(column as f32 * metrics.cell_width), origin.y + px((line + offset) as f32 * metrics.cell_height));let top_left = cell(if first.0 == last.0 { first } else { (first.0, 0) });let bottom_right = cell((last.0, last.1 + 1)) + point(px(0.), px(metrics.cell_height));@@ -246,11 +243,10 @@ impl Workbench {/// The characters of the wrapped line through `row` (the rows it continues and those continuing it) and the screen/// cell of each; a wide character's spacer cell adds none.fn wrapped_line_text(instance: &crate::terminal::TerminalInstance, row: i32) -> (String, Vec<(i32, usize)>) {- let grid = instance.term.grid();let columns = instance.term.columns();let top = -(instance.term.history_size() as i32);let bottom = instance.term.screen_lines() as i32 - 1;- let wraps = |row: i32| grid[Line(row)][Column(columns - 1)].flags.contains(Flags::WRAPLINE);+ let wraps = |row: i32| instance.term.wraps(Line(row));let mut first = row;while first > top && wraps(first - 1) {first -= 1;@@ -262,8 +258,9 @@ fn wrapped_line_text(instance: &crate::terminal::TerminalInstance, row: i32) ->let mut text = String::new();let mut cells = Vec::new();for row in first..=last {+ let cells_of_row = instance.term.row(Line(row));for column in 0..columns {- let cell = &grid[Point::new(Line(row), Column(column))];+ let cell = &cells_of_row[Column(column)];if cell.flags.contains(Flags::WIDE_CHAR_SPACER) {continue;}@@ -384,7 +381,7 @@ mod tests {let themes = exthost::scan::scan_extension(&app_root.join("extensions/theme-defaults"), true).unwrap();let colors = crate::terminal::colors::TerminalColors::new(&crate::theme::load_theme(&[themes], "Dark Modern").unwrap());let launch = crate::terminal::ShellLaunchConfig { extension_pty: true, cwd: std::env::temp_dir(), ..Default::default() };- let (mut instance, _) = crate::terminal::TerminalInstance::new(1, launch, 20, 4, alacritty_terminal::term::Config::default());+ let (mut instance, _) = crate::terminal::TerminalInstance::new(1, launch, 20, 4, ghostty_vt::Config::default());instance.process(b"go https://example.com/abc/def ok", &colors);let (text, cells) = wrapped_line_text(&instance, 1);assert!(text.starts_with("go https://example.com/abc/def ok"), "{text:?}");diff --git a/native/crates/app/src/workbench/terminal_quick_fix.rs b/native/crates/app/src/workbench/terminal_quick_fix.rsindex 2cb40334d90..b76688d3944 100644--- a/native/crates/app/src/workbench/terminal_quick_fix.rs+++ b/native/crates/app/src/workbench/terminal_quick_fix.rs@@ -68,7 +68,7 @@ impl Workbench {let Some(command) = instance.commands.last().cloned() else { return };let index = instance.commands.len() - 1;// `registerMarker()`: the light bulb goes on the cursor's line, the next prompt.- let line = instance.term.grid().cursor.point.line.0 as i64 + alacritty_terminal::grid::Dimensions::history_size(&instance.term) as i64;+ let line = instance.term.cursor().point.line.0 as i64 + instance.term.history_size() as i64;let builtin = instance.builtin_quick_fixes(&command);let mut requests = Vec::new();for selector in selectors {diff --git a/native/crates/app/src/workbench/terminal_resize_overlay.rs b/native/crates/app/src/workbench/terminal_resize_overlay.rsindex 6b383d829b8..1fc413372f4 100644--- a/native/crates/app/src/workbench/terminal_resize_overlay.rs+++ b/native/crates/app/src/workbench/terminal_resize_overlay.rs@@ -2,8 +2,6 @@//! from a second after it started (`terminal.integrated.resizeDimensionsOverlay.enabled`).use std::time::Duration;--use alacritty_terminal::grid::Dimensions;use gpui::{BoxShadow, Context, div, point, prelude::*, px, rgba};use super::Workbench;diff --git a/native/crates/app/src/workbench/terminal_suggest.rs b/native/crates/app/src/workbench/terminal_suggest.rsindex 3b624827265..d0ae44d9d36 100644--- a/native/crates/app/src/workbench/terminal_suggest.rs+++ b/native/crates/app/src/workbench/terminal_suggest.rs@@ -564,8 +564,8 @@ impl Workbench {let bounds = *self.terminal_view.pane_bounds.get(&id)?;let metrics = self.terminal_view.metrics.clone()?;let instance = self.terminal_view.instance(id)?;- let cursor = instance.term.grid().cursor.point;- let row = cursor.line.0 + instance.term.grid().display_offset() as i32;+ let cursor = instance.term.cursor().point;+ let row = cursor.line.0 + instance.term.display_offset() as i32;let origin = grid::grid_origin(bounds, instance);let cursor_left = f32::from(origin.x) + cursor.column.0 as f32 * metrics.cell_width;let cursor_top = f32::from(origin.y) + row as f32 * metrics.cell_height;diff --git a/native/crates/app/src/workbench/terminal_view.rs b/native/crates/app/src/workbench/terminal_view.rsindex c87da407626..90f62fac8a1 100644--- a/native/crates/app/src/workbench/terminal_view.rs+++ b/native/crates/app/src/workbench/terminal_view.rs@@ -9,13 +9,9 @@ use std::collections::HashMap;use std::path::PathBuf;use std::time::Duration;-use alacritty_terminal::grid::{Dimensions, Scroll};-use alacritty_terminal::index::Side;-use alacritty_terminal::selection::SelectionType;-use alacritty_terminal::term::{Config, TermMode};-use alacritty_terminal::vte::ansi::{CursorShape, CursorStyle};use futures::StreamExt;use futures::channel::mpsc::UnboundedReceiver;+use ghostty_vt::{Config, CursorShape, CursorStyle, Scroll, SelectionType, Side, TermMode};use gpui::{Bounds, ClipboardItem, Context, Div, FocusHandle, FontWeight, Keystroke, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, Point, ScrollDelta, ScrollWheelEvent, SharedString, Size, Window, canvas, div, prelude::*, px};use config::configuration::Overrides;use config::service::Target;@@ -483,7 +479,7 @@ impl Workbench {});self.commands.register("workbench.action.terminal.clearSelection", |workbench, _, _, cx| {if let Some(instance) = workbench.terminal_view.active_instance_mut() {- instance.term.selection = None;+ instance.term.clear_selection();}workbench.sync_terminals_to_host();cx.notify();@@ -1229,7 +1225,7 @@ impl Workbench {context.insert("terminalFindVisible".into(), json!(view.find.visible));context.insert("terminalFindFocused".into(), json!(find_focused));context.insert("terminalFindInputFocused".into(), json!(find_focused));- let selected = view.active_instance_id().and_then(|id| view.instance(id)).is_some_and(|instance| instance.term.selection.as_ref().is_some_and(|selection| !selection.is_empty()));+ let selected = view.active_instance_id().and_then(|id| view.instance(id)).is_some_and(|instance| instance.term.has_nonempty_selection());context.insert("terminalFocus".into(), json!(focused));context.insert("terminalFocusInAny".into(), json!(focused || find_focused));context.insert("terminalHasBeenCreated".into(), json!(view.has_been_created));@@ -1500,7 +1496,7 @@ impl Workbench {};let id = self.active_or_create_terminal(window, cx);let instance = self.terminal_view.instance_mut(id).expect("just made active");- let text = match instance.term.mode().contains(alacritty_terminal::term::TermMode::BRACKETED_PASTE) {+ let text = match instance.term.mode().contains(ghostty_vt::TermMode::BRACKETED_PASTE) {true => format!("\x1b[200~{text}\x1b[201~"),false => text,};@@ -1705,8 +1701,6 @@ impl Workbench {scrolling_history: self.setting("terminal.integrated.scrollback").as_u64().unwrap_or(1000) as usize,semantic_escape_chars: self.setting("terminal.integrated.wordSeparators").as_str().unwrap_or_default().to_owned(),default_cursor_style: CursorStyle { shape, blinking: self.setting("terminal.integrated.cursorBlinking") == true },- osc52: alacritty_terminal::term::Osc52::CopyPaste,- ..Config::default()}}@@ -1746,7 +1740,7 @@ impl Workbench {match selection.filter(|_| behavior == "copyPaste") {Some(text) => {cx.write_to_clipboard(ClipboardItem::new_string(text));- instance.term.selection = None;+ instance.term.clear_selection();}None => {if let Some(text) = cx.read_from_clipboard().and_then(|item| item.text()) {@@ -1795,7 +1789,7 @@ impl Workbench {return;}let Some(instance) = self.terminal_view.instance_mut(id) else { return };- let mode = *instance.term.mode();+ let mode = instance.term.mode();let button = match event.button {MouseButton::Left => mouse::MouseButton::Left,MouseButton::Middle => mouse::MouseButton::Middle,@@ -1817,7 +1811,7 @@ impl Workbench {(MouseButton::Left, _) => SelectionType::Simple,_ => return,};- if event.button == MouseButton::Left && event.click_count == 1 && event.modifiers.shift && instance.term.selection.is_some() {+ if event.button == MouseButton::Left && event.click_count == 1 && event.modifiers.shift && instance.term.has_selection() {instance.extend_selection(row, column, side);} else {instance.start_selection(kind, row, column, side);@@ -1848,7 +1842,7 @@ impl Workbench {instance.extend_selection(row, column, side);return cx.notify();}- let mode = *instance.term.mode();+ let mode = instance.term.mode();let button = match event.pressed_button {Some(MouseButton::Left) => mouse::MouseButton::Left,Some(MouseButton::Middle) => mouse::MouseButton::Middle,@@ -1873,7 +1867,7 @@ impl Workbench {}return self.sync_terminals_to_host();}- let mode = *instance.term.mode();+ let mode = instance.term.mode();let (row, column, _) = grid::cell_at(bounds, event.position, instance, &metrics);if mouse::wants(mode, mouse::MouseButton::Left, MouseAction::Up) && let Some(report) = mouse::report(mode, mouse::MouseButton::Left, MouseAction::Up, column, row.max(0) as usize, event.modifiers.shift, event.modifiers.alt, event.modifiers.control) {instance.input(&report);@@ -1910,7 +1904,7 @@ impl Workbench {}let bounds = self.terminal_view.pane_bounds.get(&id).copied();let Some(instance) = self.terminal_view.instance_mut(id) else { return };- let mode = *instance.term.mode();+ let mode = instance.term.mode();let up = whole > 0.;let count = whole.abs() as usize;if mode.intersects(TermMode::MOUSE_MODE) {diff --git a/native/crates/app/src/workbench/terminal_view/grid.rs b/native/crates/app/src/workbench/terminal_view/grid.rsindex 9c8232f4de4..094827b4286 100644--- a/native/crates/app/src/workbench/terminal_view/grid.rs+++ b/native/crates/app/src/workbench/terminal_view/grid.rs@@ -2,12 +2,7 @@//! decorations and cursor, and the overlay scrollbar of xterm's viewport.use std::collections::HashMap;--use alacritty_terminal::grid::Dimensions;-use alacritty_terminal::index::{Column, Line, Side};-use alacritty_terminal::term::cell::{Cell, Flags};-use alacritty_terminal::term::color::Colors;-use alacritty_terminal::vte::ansi::{Color, CursorShape, NamedColor};+use ghostty_vt::{Cell, Color, ColorOverrides, Column, CursorShape, Flags, Line, Point, Side};use gpui::{BoxShadow, Corners, Bounds, Font, FontStyle, FontWeight, Hsla, Pixels, Rgba, SharedString, StrikethroughStyle, TextRun, UnderlineStyle, Window, fill, font, outline, point, px, size};use crate::terminal::TerminalInstance;@@ -113,7 +108,7 @@ pub struct Look<'a> {/// The hovered link's cells (grid line, column) while the link modifier is down: xterm's link underline.pub link_underline: &'a [(i32, usize)],/// The find widget's matches, the selected one, and their `terminal.findMatch*Background` colors.- pub find_matches: &'a [alacritty_terminal::term::search::Match],+ pub find_matches: &'a [crate::terminal::search::Match],pub find_current: Option<usize>,pub find_match: Rgba,pub find_highlight: Rgba,@@ -137,34 +132,37 @@ pub fn paint(bounds: Bounds<Pixels>, instance: &TerminalInstance, look: &Look, wlet term = &instance.term;let (cols, rows) = (term.columns(), term.screen_lines());let origin = grid_origin(bounds, instance);- let content = term.renderable_content();- let offset = content.display_offset as i32;+ let display_offset = term.display_offset();+ let offset = display_offset as i32;let colors = look.colors;- let resolve = |color: Color, bold: bool| resolve_color(color, bold, content.colors, look);- let cursor = content.cursor;- let cursor_row = cursor.point.line.0 + offset;- let cursor_shown = look.cursor_initialized && cursor.shape != CursorShape::Hidden && !(look.focused && look.cursor_blink_off);- let block_cursor = look.focused && cursor_shown && cursor.shape == CursorShape::Block;+ let overrides = term.color_overrides();+ let resolve = |color: Color, bold: bool| resolve_color(color, bold, &overrides, look);+ let cursor_point = term.cursor().point;+ let cursor_shape = term.cursor_style().shape;+ let selection = term.selection_range();+ let cursor_row = cursor_point.line.0 + offset;+ let cursor_shown = look.cursor_initialized && cursor_shape != CursorShape::Hidden && !(look.focused && look.cursor_blink_off);+ let block_cursor = look.focused && cursor_shown && cursor_shape == CursorShape::Block;let mut contrast_cache: HashMap<([u32; 4], [u32; 4]), Option<Rgba>> = HashMap::new();let mut rows_text: Vec<RowText> = (0..rows).map(|_| RowText::default()).collect();let cell = |column: usize, row: usize| Bounds::new(origin + point(px(column as f32 * metrics.cell_width), px(row as f32 * metrics.cell_height)), size(px(metrics.cell_width), px(metrics.cell_height)));let (top, bottom) = (-offset, rows as i32 - 1 - offset);- let visible_matches: Vec<(usize, &alacritty_terminal::term::search::Match)> = look.find_matches.iter().enumerate().filter(|(_, found)| found.end().line.0 >= top && found.start().line.0 <= bottom).collect();- for indexed in content.display_iter {- let row = (indexed.point.line.0 + offset) as usize;- let column = indexed.point.column.0;- if row >= rows || column >= cols {- continue;- }- let flags = indexed.cell.flags;+ let visible_matches: Vec<(usize, &crate::terminal::search::Match)> = look.find_matches.iter().enumerate().filter(|(_, found)| found.end().line.0 >= top && found.start().line.0 <= bottom).collect();+ for (row, column, line_cells) in (0..rows).flat_map(|row| {+ let line_cells = std::rc::Rc::new(term.row(Line(row as i32 - offset)));+ (0..cols).map(move |column| (row, column, line_cells.clone()))+ }) {+ let point = Point::new(Line(row as i32 - offset), Column(column));+ let content = &line_cells[Column(column)];+ let flags = content.flags;if flags.intersects(Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER) {continue;}let bold = flags.contains(Flags::BOLD);- let mut fg = resolve(indexed.cell.fg, bold);- let mut bg = match indexed.cell.bg {- Color::Named(NamedColor::Background) => None,+ let mut fg = resolve(content.fg, bold);+ let mut bg = match content.bg {+ Color::Background => None,color => Some(resolve(color, false)),};if flags.contains(Flags::INVERSE) {@@ -176,8 +174,8 @@ pub fn paint(bounds: Bounds<Pixels>, instance: &TerminalInstance, look: &Look, wfg.a *= 0.5;}let width = if flags.contains(Flags::WIDE_CHAR) { 2 } else { 1 };- let is_cursor = indexed.point == cursor.point && cursor.shape != CursorShape::Hidden;- let selected = content.selection.is_some_and(|selection| selection.contains(indexed.point));+ let is_cursor = point == cursor_point && cursor_shape != CursorShape::Hidden;+ let selected = selection.as_ref().is_some_and(|selection| selection.contains(point));if selected && let Some(selection_foreground) = colors.selection_foreground {fg = selection_foreground;}@@ -196,14 +194,14 @@ pub fn paint(bounds: Bounds<Pixels>, instance: &TerminalInstance, look: &Look, wif let Some(bg) = bg {window.paint_quad(fill(cell_bounds, bg));}- if let Some((index, _)) = visible_matches.iter().find(|(_, found)| found.contains(&indexed.point)) {+ if let Some((index, _)) = visible_matches.iter().find(|(_, found)| found.contains(&point)) {window.paint_quad(fill(cell_bounds, if look.find_current == Some(*index) { look.find_match } else { look.find_highlight }));}if selected && !(is_cursor && block_cursor) {let selection = if look.focused { colors.selection } else { colors.inactive_selection };window.paint_quad(fill(cell_bounds, selection));}- push_cell_text(indexed.cell, column, fg, cell_bounds, &mut rows_text[row], &resolve, metrics, window);+ push_cell_text(content, column, fg, cell_bounds, &mut rows_text[row], &resolve, metrics, window);}let baseline = |row: usize| {@@ -224,9 +222,9 @@ pub fn paint(bounds: Bounds<Pixels>, instance: &TerminalInstance, look: &Look, w}if cursor_shown && (0..rows as i32).contains(&cursor_row) {- let bounds = cell(cursor.point.column.0.min(cols - 1), cursor_row as usize);+ let bounds = cell(cursor_point.column.0.min(cols - 1), cursor_row as usize);let thickness = px(look.cursor_width.max(1.));- let shape = if look.focused { Some(cursor.shape) } else { inactive_shape(look.cursor_inactive_style) };+ let shape = if look.focused { Some(cursor_shape) } else { inactive_shape(look.cursor_inactive_style) };match shape {Some(CursorShape::Beam) => window.paint_quad(fill(Bounds::new(bounds.origin, size(thickness, bounds.size.height)), colors.cursor)),Some(CursorShape::Underline) => window.paint_quad(fill(Bounds::new(point(bounds.origin.x, bounds.bottom() - thickness), size(bounds.size.width, thickness)), colors.cursor)),@@ -237,12 +235,12 @@ pub fn paint(bounds: Bounds<Pixels>, instance: &TerminalInstance, look: &Look, w}let history = term.history_size();- if let Some(ruler) = look.overview_ruler.as_ref().filter(|_| !term.mode().contains(alacritty_terminal::term::TermMode::ALT_SCREEN)) {+ if let Some(ruler) = look.overview_ruler.as_ref().filter(|_| !term.mode().contains(ghostty_vt::TermMode::ALT_SCREEN)) {let canvas = Bounds::new(point(bounds.right() - px(look.scrollbar_width), origin.y), size(px(look.scrollbar_width), px(rows as f32 * metrics.cell_height)));paint_overview_ruler(canvas, history + rows, ruler, window);}if look.hovered && history > 0 {- paint_scrollbar(bounds, rows, history, content.display_offset, look, window);+ paint_scrollbar(bounds, rows, history, display_offset, look, window);}}@@ -277,22 +275,24 @@ pub fn paint_sticky_scroll(bounds: Bounds<Pixels>, instance: &TerminalInstance,}let origin = point(overlay.origin.x + px(GUTTER), overlay.origin.y);- let resolve = |color: Color, bold: bool| resolve_color(color, bold, term.colors(), look);+ let overrides = term.color_overrides();+ let resolve = |color: Color, bold: bool| resolve_color(color, bold, &overrides, look);let mut contrast_cache: HashMap<([u32; 4], [u32; 4]), Option<Rgba>> = HashMap::new();for row in 0..sticky.count {let line = sticky.start + row as i64;let y = origin.y + px(row as f32 * metrics.cell_height);let mut text = RowText::default();let mut last_column = None;+ let line_cells = term.row(Line((line - term.history_size() as i64) as i32));for column in 0..term.columns() {- let cell = &term.grid()[Line((line - term.history_size() as i64) as i32)][Column(column)];+ let cell = &line_cells[Column(column)];if cell.flags.intersects(Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER) {continue;}let bold = cell.flags.contains(Flags::BOLD);let mut fg = resolve(cell.fg, bold);let mut bg = match cell.bg {- Color::Named(NamedColor::Background) => None,+ Color::Background => None,color => Some(resolve(color, false)),};if cell.flags.contains(Flags::INVERSE) {@@ -360,27 +360,22 @@ fn push_cell_text(cell: &Cell, column: usize, fg: Rgba, cell_bounds: Bounds<Pixe/// xterm's color lookup: an OSC 4/10/11 override, else the theme palette, bold colors brightened when/// `drawBoldTextInBrightColors` is on.-fn resolve_color(color: Color, bold: bool, overrides: &Colors, look: &Look) -> Rgba {+fn resolve_color(color: Color, bold: bool, overrides: &ColorOverrides, look: &Look) -> Rgba {let colors = look.colors;let index = match color {Color::Spec(rgb) => return rgba(rgb.r, rgb.g, rgb.b),Color::Indexed(index) if bold && look.draw_bold_text_in_bright_colors && index < 8 => index as usize + 8,Color::Indexed(index) => index as usize,- Color::Named(named) if bold && look.draw_bold_text_in_bright_colors && (named as usize) < 8 => named as usize + 8,- Color::Named(named) => named as usize,+ Color::Foreground => 256,+ Color::Background => 257,};if let Some(rgb) = overrides[index] {return rgba(rgb.r, rgb.g, rgb.b);}match index {0..256 => colors.palette[index],- index if index == NamedColor::Background as usize => colors.background,- index if index == NamedColor::Cursor as usize => colors.cursor,- index if (NamedColor::DimBlack as usize..=NamedColor::DimWhite as usize).contains(&index) => {- let color = colors.palette[index - NamedColor::DimBlack as usize];- Rgba { a: color.a * 0.5, ..color }- }- _ => colors.foreground,+ 256 => colors.foreground,+ _ => colors.background,}}diff --git a/native/crates/app/src/workbench/terminal_view/tests.rs b/native/crates/app/src/workbench/terminal_view/tests.rsindex 95dec42eb11..a17249b0289 100644--- a/native/crates/app/src/workbench/terminal_view/tests.rs+++ b/native/crates/app/src/workbench/terminal_view/tests.rs@@ -1,5 +1,4 @@use super::super::Workbench;-use alacritty_terminal::grid::Dimensions;use gpui::{FontWeight, px, size};use std::path::Path;diff --git a/native/crates/ghostty_vt/Cargo.toml b/native/crates/ghostty_vt/Cargo.tomlnew file mode 100644index 00000000000..cdffad1cfe5--- /dev/null+++ b/native/crates/ghostty_vt/Cargo.toml@@ -0,0 +1,10 @@+[package]+name = "ghostty_vt"+version = "0.1.0"+edition.workspace = true+license.workspace = true+build = "build.rs"+links = "ghostty-vt"++[build-dependencies]+sha2 = "0.10"diff --git a/native/crates/ghostty_vt/build.rs b/native/crates/ghostty_vt/build.rsnew file mode 100644index 00000000000..a4799742469--- /dev/null+++ b/native/crates/ghostty_vt/build.rs@@ -0,0 +1,92 @@+//! Builds libghostty-vt from its pinned release with Zig, or links a prebuilt one from `GHOSTTY_VT_LIB_DIR`.++use std::path::{Path, PathBuf};+use std::process::Command;++use sha2::{Digest, Sha256};++const VERSION: &str = "1.0.2";+const SOURCE_SHA256: &str = "1dcafa8a3357f3a6bbf4f2696e61de611400c5469518716793dfffd35f008b3e";+const DEPS_SHA256: &str = "c56156dbea82fdf71f13bf0d704cdf4393b6a04208d7f9691e0d7f60c7f9ca4d";++fn main() {+ println!("cargo:rerun-if-changed=build.rs");+ println!("cargo:rerun-if-env-changed=GHOSTTY_VT_LIB_DIR");+ println!("cargo:rerun-if-env-changed=MACOSX_DEPLOYMENT_TARGET");+ let target = std::env::var("TARGET").unwrap();+ let lib_dir = match std::env::var_os("GHOSTTY_VT_LIB_DIR") {+ Some(dir) => PathBuf::from(dir),+ None => build(&target),+ };+ println!("cargo:rustc-link-search=native={}", lib_dir.display());+ // Zig names the Windows static archive apart from the DLL's import library.+ let name = if target.contains("windows") { "ghostty-vt-static" } else { "ghostty-vt" };+ println!("cargo:rustc-link-lib=static={name}");+}++fn build(target: &str) -> PathBuf {+ let out = PathBuf::from(std::env::var("OUT_DIR").unwrap());+ let prefix = out.join("install");+ let source = fetch(&out, &format!("libghostty-vt-{VERSION}.tar.gz"), SOURCE_SHA256);+ keep_variation_selectors_after_modifier_bases(&source);+ let deps = fetch(&out, &format!("libghostty-vt-{VERSION}-deps.tar.gz"), DEPS_SHA256);+ let status = Command::new("zig")+ .current_dir(&source)+ .args(["build", "-Doptimize=ReleaseFast", "-Dcpu=baseline"])+ .arg(format!("-Dtarget={}", zig_target(target)))+ .arg("--system")+ .arg(&deps)+ .arg("--prefix")+ .arg(&prefix)+ .arg("--cache-dir")+ .arg(out.join("zig-cache"))+ .status()+ .unwrap_or_else(|error| panic!("zig 0.17 builds libghostty-vt and must be on PATH: {error}"));+ assert!(status.success(), "zig build of libghostty-vt {VERSION} failed");+ prefix.join("lib")+}++/// Downloads a release tarball, checks it against its SHA256SUMS entry and unpacks it into `out`.+fn fetch(out: &Path, file: &str, sha256: &str) -> PathBuf {+ let tarball = out.join(file);+ let url = format!("https://release.files.ghostty.org/libghostty-vt/{VERSION}/{file}");+ let status = Command::new("curl").args(["-sSfL", "--retry", "3", "-o"]).arg(&tarball).arg(&url).status().expect("curl downloads libghostty-vt");+ assert!(status.success(), "downloading {url} failed");+ let digest = Sha256::digest(std::fs::read(&tarball).unwrap());+ let hex: String = digest.iter().map(|byte| format!("{byte:02x}")).collect();+ assert_eq!(hex, sha256, "{file} does not match its pinned SHA-256");+ let status = Command::new("tar").arg("-xzf").arg(&tarball).arg("-C").arg(out).status().expect("tar unpacks libghostty-vt");+ assert!(status.success(), "unpacking {file} failed");+ out.join(file.trim_end_matches(".tar.gz"))+}++/// Ghostty 1.0.2 drops VS16 after an emoji modifier base (U+270C, U+1F44D) outside mode 2027, as uucode gives+/// those `emoji_modifier_base` rather than `extended_pictographic`; xterm.js keeps it, so copied text keeps it.+fn keep_variation_selectors_after_modifier_bases(source: &Path) {+ let file = source.join("src/terminal/Terminal.zig");+ let zig = std::fs::read_to_string(&file).unwrap();+ let check = "const emoji = prev_props.grapheme_break == .extended_pictographic;";+ assert_eq!(zig.matches(check).count(), 1, "Terminal.zig changed: revisit the VS16 patch");+ let fixed = "const emoji = prev_props.grapheme_break == .extended_pictographic or prev_props.grapheme_break == .emoji_modifier_base;";+ std::fs::write(&file, zig.replace(check, fixed)).unwrap();+}++/// Zig 0.17 cannot compile the bundled C++ (simdutf, highway) against cargo-xwin's MSVC SDK, so an MSVC cross+/// build links the GNU target's archive: lld-link takes it, Microsoft link.exe rejects its COMDATs (LNK1143).+fn zig_target(target: &str) -> String {+ let arch = target.split('-').next().unwrap();+ if target.ends_with("apple-darwin") {+ let deployment = std::env::var("MACOSX_DEPLOYMENT_TARGET").unwrap_or_else(|_| "12.0".into());+ return format!("{arch}-macos.{deployment}");+ }+ if target.ends_with("linux-gnu") {+ return format!("{arch}-linux-gnu");+ }+ if target.ends_with("windows-msvc") && cfg!(windows) {+ return format!("{arch}-windows-msvc");+ }+ if target.contains("windows") {+ return format!("{arch}-windows-gnu");+ }+ panic!("no libghostty-vt build for {target}");+}diff --git a/native/crates/ghostty_vt/src/lib.rs b/native/crates/ghostty_vt/src/lib.rsnew file mode 100644index 00000000000..783df146547--- /dev/null+++ b/native/crates/ghostty_vt/src/lib.rs@@ -0,0 +1,928 @@+//! libghostty-vt behind safe types: the terminal screen the integrated terminal draws, in the shape the port+//! used from alacritty_terminal (lines relative to the active area's top, negative into the scrollback).+//! Every `unsafe` of the crate is in this file, each one a call into the C API with the pointers it documents.++mod selection;+#[allow(clippy::all)]+mod sys;++use std::ffi::c_void;+use std::ops::{Add, AddAssign, Index, Sub, SubAssign};+use std::ptr;++pub use selection::{SelectionRange, SelectionType};++#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]+pub struct Line(pub i32);++#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]+pub struct Column(pub usize);++/// A cell: `line` 0 is the active area's first line, negative lines are in the scrollback.+#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]+pub struct Point {+ pub line: Line,+ pub column: Column,+}++impl Point {+ pub fn new(line: Line, column: Column) -> Point {+ Point { line, column }+ }+}++impl Add<i32> for Line {+ type Output = Line;+ fn add(self, rhs: i32) -> Line {+ Line(self.0 + rhs)+ }+}++impl Sub<i32> for Line {+ type Output = Line;+ fn sub(self, rhs: i32) -> Line {+ Line(self.0 - rhs)+ }+}++impl AddAssign<i32> for Line {+ fn add_assign(&mut self, rhs: i32) {+ self.0 += rhs;+ }+}++impl SubAssign<i32> for Line {+ fn sub_assign(&mut self, rhs: i32) {+ self.0 -= rhs;+ }+}++impl Add<usize> for Column {+ type Output = Column;+ fn add(self, rhs: usize) -> Column {+ Column(self.0 + rhs)+ }+}++impl Sub<usize> for Column {+ type Output = Column;+ fn sub(self, rhs: usize) -> Column {+ Column(self.0 - rhs)+ }+}++impl AddAssign<usize> for Column {+ fn add_assign(&mut self, rhs: usize) {+ self.0 += rhs;+ }+}++impl SubAssign<usize> for Column {+ fn sub_assign(&mut self, rhs: usize) {+ self.0 -= rhs;+ }+}++#[derive(Clone, Copy, Debug, Eq, PartialEq)]+pub enum Side {+ Left,+ Right,+}++#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]+pub struct Rgb {+ pub r: u8,+ pub g: u8,+ pub b: u8,+}++/// A cell's color as SGR set it: the default foreground or background, a palette index or a true color.+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]+pub enum Color {+ Foreground,+ Background,+ Indexed(u8),+ Spec(Rgb),+}++/// A cell's attributes and its place in a wide character or a wrapped line.+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]+pub struct Flags(u16);++impl Flags {+ pub const BOLD: Flags = Flags(1);+ pub const ITALIC: Flags = Flags(1 << 1);+ pub const DIM: Flags = Flags(1 << 2);+ pub const INVERSE: Flags = Flags(1 << 3);+ pub const HIDDEN: Flags = Flags(1 << 4);+ pub const STRIKEOUT: Flags = Flags(1 << 5);+ pub const UNDERLINE: Flags = Flags(1 << 6);+ pub const DOUBLE_UNDERLINE: Flags = Flags(1 << 7);+ pub const UNDERCURL: Flags = Flags(1 << 8);+ pub const DOTTED_UNDERLINE: Flags = Flags(1 << 9);+ pub const DASHED_UNDERLINE: Flags = Flags(1 << 10);+ pub const ALL_UNDERLINES: Flags = Flags(Self::UNDERLINE.0 | Self::DOUBLE_UNDERLINE.0 | Self::UNDERCURL.0 | Self::DOTTED_UNDERLINE.0 | Self::DASHED_UNDERLINE.0);+ /// The first cell of a double width character.+ pub const WIDE_CHAR: Flags = Flags(1 << 11);+ /// The second cell of a double width character.+ pub const WIDE_CHAR_SPACER: Flags = Flags(1 << 12);+ /// The last cell of a line whose double width character went to the next line.+ pub const LEADING_WIDE_CHAR_SPACER: Flags = Flags(1 << 13);+ /// The last cell of a line that continues on the next (a soft wrap).+ pub const WRAPLINE: Flags = Flags(1 << 14);++ pub fn empty() -> Flags {+ Flags(0)+ }++ pub fn is_empty(self) -> bool {+ self.0 == 0+ }++ pub fn contains(self, other: Flags) -> bool {+ self.0 & other.0 == other.0+ }++ pub fn intersects(self, other: Flags) -> bool {+ self.0 & other.0 != 0+ }++ pub fn insert(&mut self, other: Flags) {+ self.0 |= other.0;+ }+}++impl std::ops::BitOr for Flags {+ type Output = Flags;+ fn bitor(self, rhs: Flags) -> Flags {+ Flags(self.0 | rhs.0)+ }+}++impl std::ops::BitAnd for Flags {+ type Output = Flags;+ fn bitand(self, rhs: Flags) -> Flags {+ Flags(self.0 & rhs.0)+ }+}++impl std::ops::BitXor for Flags {+ type Output = Flags;+ fn bitxor(self, rhs: Flags) -> Flags {+ Flags(self.0 ^ rhs.0)+ }+}++impl std::ops::Not for Flags {+ type Output = Flags;+ fn not(self) -> Flags {+ Flags(!self.0)+ }+}++/// One cell's content and style. An empty cell reads as a space.+#[derive(Clone, Debug, Eq, PartialEq)]+pub struct Cell {+ pub c: char,+ /// The combining characters after `c`.+ pub zerowidth: Vec<char>,+ pub fg: Color,+ pub bg: Color,+ pub underline_color: Option<Color>,+ pub flags: Flags,+}++impl Default for Cell {+ fn default() -> Cell {+ Cell { c: ' ', zerowidth: Vec::new(), fg: Color::Foreground, bg: Color::Background, underline_color: None, flags: Flags::empty() }+ }+}++impl Cell {+ pub fn zerowidth(&self) -> Option<&[char]> {+ (!self.zerowidth.is_empty()).then_some(self.zerowidth.as_slice())+ }++ pub fn underline_color(&self) -> Option<Color> {+ self.underline_color+ }+}++/// A line's cells, read from the terminal at one moment.+pub struct Row(Vec<Cell>);++impl Row {+ pub fn len(&self) -> usize {+ self.0.len()+ }++ pub fn is_empty(&self) -> bool {+ self.0.is_empty()+ }++ pub fn iter(&self) -> std::slice::Iter<'_, Cell> {+ self.0.iter()+ }++ /// The columns up to the last one with text; the whole row when it wraps.+ pub fn line_length(&self) -> Column {+ if self.0.last().is_some_and(|cell| cell.flags.contains(Flags::WRAPLINE)) {+ return Column(self.0.len());+ }+ Column(self.0.iter().rposition(|cell| cell.c != ' ' || !cell.zerowidth.is_empty()).map_or(0, |index| index + 1))+ }+}++impl Index<Column> for Row {+ type Output = Cell;+ fn index(&self, column: Column) -> &Cell {+ &self.0[column.0]+ }+}++/// The terminal modes the port reads, as xterm.js names them in `modes` and `buffer.active.type`.+#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]+pub struct TermMode(u16);++impl TermMode {+ /// DECCKM (`?1`): cursor keys send application sequences.+ pub const APP_CURSOR: TermMode = TermMode(1);+ pub const BRACKETED_PASTE: TermMode = TermMode(1 << 1);+ /// The alternate screen is active.+ pub const ALT_SCREEN: TermMode = TermMode(1 << 2);+ /// `?1007`: the wheel sends arrow keys on the alternate screen.+ pub const ALTERNATE_SCROLL: TermMode = TermMode(1 << 3);+ /// `?1000`+ pub const MOUSE_REPORT_CLICK: TermMode = TermMode(1 << 4);+ /// `?1002`+ pub const MOUSE_DRAG: TermMode = TermMode(1 << 5);+ /// `?1003`+ pub const MOUSE_MOTION: TermMode = TermMode(1 << 6);+ pub const MOUSE_MODE: TermMode = TermMode(Self::MOUSE_REPORT_CLICK.0 | Self::MOUSE_DRAG.0 | Self::MOUSE_MOTION.0);+ /// `?1006`+ pub const SGR_MOUSE: TermMode = TermMode(1 << 7);+ /// `?1005`+ pub const UTF8_MOUSE: TermMode = TermMode(1 << 8);+ /// `?1004`+ pub const FOCUS_IN_OUT: TermMode = TermMode(1 << 9);+ /// DECTCEM (`?25`)+ pub const SHOW_CURSOR: TermMode = TermMode(1 << 10);++ pub fn contains(self, other: TermMode) -> bool {+ self.0 & other.0 == other.0+ }++ pub fn intersects(self, other: TermMode) -> bool {+ self.0 & other.0 != 0+ }+}++impl std::ops::BitOr for TermMode {+ type Output = TermMode;+ fn bitor(self, rhs: TermMode) -> TermMode {+ TermMode(self.0 | rhs.0)+ }+}++#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]+pub enum CursorShape {+ #[default]+ Block,+ Underline,+ Beam,+ HollowBlock,+ Hidden,+}++#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]+pub struct CursorStyle {+ pub shape: CursorShape,+ pub blinking: bool,+}++pub struct Cursor {+ pub point: Point,+ /// The cursor sits past the last column, so the next character wraps first.+ pub input_needs_wrap: bool,+}++#[derive(Clone, Copy, Debug, Eq, PartialEq)]+pub enum Scroll {+ /// Lines up into the scrollback (positive) or down (negative).+ Delta(i32),+ PageUp,+ PageDown,+ Top,+ Bottom,+}++/// What xterm.js reads from its options: `scrollback`, `wordSeparators`, `cursorStyle` and `cursorBlink`.+#[derive(Clone, Debug, Eq, PartialEq)]+pub struct Config {+ pub scrolling_history: usize,+ pub semantic_escape_chars: String,+ pub default_cursor_style: CursorStyle,+}++impl Default for Config {+ fn default() -> Config {+ Config { scrolling_history: 10_000, semantic_escape_chars: ",│`|:\"' ()[]{}<>\t".into(), default_cursor_style: CursorStyle::default() }+ }+}++/// The colors a program set with OSC 4, 10, 11 and 12 over the defaults the terminal was given; index 256 is the+/// foreground, 257 the background, 258 the cursor.+pub struct ColorOverrides(Vec<Option<Rgb>>);++impl Index<usize> for ColorOverrides {+ type Output = Option<Rgb>;+ fn index(&self, index: usize) -> &Option<Rgb> {+ &self.0[index]+ }+}++/// The colors the terminal answers OSC 4, 10, 11 and 12 queries with: the theme's.+#[derive(Clone, Debug, Eq, PartialEq)]+pub struct DefaultColors {+ pub palette: [Rgb; 256],+ pub foreground: Rgb,+ pub background: Rgb,+ pub cursor: Rgb,+}++/// What the terminal reported while it parsed, taken with `Term::take_effects`.+#[derive(Default)]+pub struct Effects {+ /// Replies for the program: device attributes, cursor and mode reports, color and size queries.+ pub pty_write: Vec<u8>,+ pub bell: bool,+ /// The title changed: `Some(title)`, `Some("")` after a reset.+ pub title: Option<String>,+}++/// The callbacks' state, boxed so its address stays the userdata the terminal holds.+struct Callbacks {+ effects: Effects,+ size: sys::GhosttySizeReportSize,+}++/// xterm.js 6.1's replies (`CSI c`, `CSI > c`, `CSI > q`), the ones VS Code's terminal gives.+const XTVERSION: &str = "xterm.js(6.1.0-beta.337)";++pub struct Term {+ raw: sys::GhosttyTerminal,+ render: sys::GhosttyRenderState,+ callbacks: Box<Callbacks>,+ config: Config,+ default_colors: Option<DefaultColors>,+ selection: Option<selection::Selection>,+}++impl Drop for Term {+ fn drop(&mut self) {+ self.selection = None;+ // SAFETY: both were created in `new` and are freed once, the terminal last as the selection's refs need it.+ unsafe {+ sys::ghostty_render_state_free(self.render);+ sys::ghostty_terminal_free(self.raw);+ }+ }+}++fn check(result: sys::GhosttyResult, call: &str) {+ assert!(result == sys::GHOSTTY_SUCCESS, "{call} failed: {result}");+}++impl Term {+ pub fn new(cols: u16, rows: u16, config: Config) -> Term {+ let mut raw = ptr::null_mut();+ let mut render = ptr::null_mut();+ // SAFETY: a null allocator is the library's default; the out pointers are valid locals.+ unsafe {+ check(sys::ghostty_terminal_new(ptr::null(), &mut raw, cols.max(1), rows.max(1)), "ghostty_terminal_new");+ check(sys::ghostty_render_state_new(ptr::null(), &mut render), "ghostty_render_state_new");+ }+ let size = sys::GhosttySizeReportSize { rows, columns: cols, cell_width: 0, cell_height: 0 };+ let mut term = Term { raw, render, callbacks: Box::new(Callbacks { effects: Effects::default(), size }), config: Config::default(), default_colors: None, selection: None };+ term.install_callbacks();+ let unlimited = usize::MAX;+ term.set(sys::GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_BYTES, &unlimited as *const usize as *const c_void);+ term.apply_config(&config);+ term.config = config;+ term+ }++ fn set(&mut self, option: sys::GhosttyTerminalOption, value: *const c_void) {+ // SAFETY: each caller passes the input type `terminal.h` documents for `option`, valid for the call.+ check(unsafe { sys::ghostty_terminal_set(self.raw, option, value) }, "ghostty_terminal_set");+ }++ fn install_callbacks(&mut self) {+ let userdata: *mut Callbacks = &mut *self.callbacks;+ self.set(sys::GHOSTTY_TERMINAL_OPT_USERDATA, userdata as *const c_void);+ let write_pty: unsafe extern "C" fn(sys::GhosttyTerminal, *mut c_void, *const u8, usize) = write_pty;+ let bell: unsafe extern "C" fn(sys::GhosttyTerminal, *mut c_void) = bell;+ let title: unsafe extern "C" fn(sys::GhosttyTerminal, *mut c_void) = title_changed;+ let size: unsafe extern "C" fn(sys::GhosttyTerminal, *mut c_void, *mut sys::GhosttySizeReportSize) -> bool = size;+ let attributes: unsafe extern "C" fn(sys::GhosttyTerminal, *mut c_void, *mut sys::GhosttyDeviceAttributes) -> bool = device_attributes;+ let xtversion: unsafe extern "C" fn(sys::GhosttyTerminal, *mut c_void) -> sys::GhosttyString = xtversion;+ self.set(sys::GHOSTTY_TERMINAL_OPT_WRITE_PTY, write_pty as *const c_void);+ self.set(sys::GHOSTTY_TERMINAL_OPT_BELL, bell as *const c_void);+ self.set(sys::GHOSTTY_TERMINAL_OPT_TITLE_CHANGED, title as *const c_void);+ self.set(sys::GHOSTTY_TERMINAL_OPT_SIZE, size as *const c_void);+ self.set(sys::GHOSTTY_TERMINAL_OPT_DEVICE_ATTRIBUTES, attributes as *const c_void);+ self.set(sys::GHOSTTY_TERMINAL_OPT_XTVERSION, xtversion as *const c_void);+ }++ /// Applies changed options: the scrollback limit, the word separators and the default cursor.+ pub fn set_options(&mut self, config: Config) {+ if config != self.config {+ self.apply_config(&config);+ self.config = config;+ }+ }++ fn apply_config(&mut self, config: &Config) {+ // Ghostty prunes whole pages, so it keeps more lines than this; `history_size` hides the rest.+ let lines = config.scrolling_history;+ self.set(sys::GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_LINES, &lines as *const usize as *const c_void);+ let style = match config.default_cursor_style.shape {+ CursorShape::Beam => sys::GHOSTTY_CURSOR_STYLE_BAR,+ CursorShape::Underline => sys::GHOSTTY_CURSOR_STYLE_UNDERLINE,+ CursorShape::HollowBlock => sys::GHOSTTY_CURSOR_STYLE_BLOCK_HOLLOW,+ CursorShape::Block | CursorShape::Hidden => sys::GHOSTTY_CURSOR_STYLE_BLOCK,+ };+ let blink = config.default_cursor_style.blinking;+ self.set(sys::GHOSTTY_TERMINAL_OPT_DEFAULT_CURSOR_STYLE, &style as *const _ as *const c_void);+ self.set(sys::GHOSTTY_TERMINAL_OPT_DEFAULT_CURSOR_BLINK, &blink as *const bool as *const c_void);+ }++ pub fn semantic_escape_chars(&self) -> &str {+ &self.config.semantic_escape_chars+ }++ /// The theme's colors, as the terminal's defaults: OSC queries answer with them and OSC sets override them.+ pub fn set_default_colors(&mut self, colors: DefaultColors) {+ if self.default_colors.as_ref() == Some(&colors) {+ return;+ }+ let rgb = |color: Rgb| sys::GhosttyColorRgb { r: color.r, g: color.g, b: color.b };+ let palette: Vec<sys::GhosttyColorRgb> = colors.palette.iter().map(|&color| rgb(color)).collect();+ let (foreground, background, cursor) = (rgb(colors.foreground), rgb(colors.background), rgb(colors.cursor));+ self.set(sys::GHOSTTY_TERMINAL_OPT_COLOR_PALETTE, palette.as_ptr() as *const c_void);+ self.set(sys::GHOSTTY_TERMINAL_OPT_COLOR_FOREGROUND, &foreground as *const _ as *const c_void);+ self.set(sys::GHOSTTY_TERMINAL_OPT_COLOR_BACKGROUND, &background as *const _ as *const c_void);+ self.set(sys::GHOSTTY_TERMINAL_OPT_COLOR_CURSOR, &cursor as *const _ as *const c_void);+ self.default_colors = Some(colors);+ }++ /// The colors OSC 4, 10, 11 and 12 changed from the defaults `set_default_colors` gave.+ pub fn color_overrides(&self) -> ColorOverrides {+ let mut overrides = vec![None; 259];+ let mut palette = [sys::GhosttyColorRgb::default(); 256];+ let mut defaults = [sys::GhosttyColorRgb::default(); 256];+ self.get(sys::GHOSTTY_TERMINAL_DATA_COLOR_PALETTE, &mut palette);+ self.get(sys::GHOSTTY_TERMINAL_DATA_COLOR_PALETTE_DEFAULT, &mut defaults);+ let rgb = |color: sys::GhosttyColorRgb| Rgb { r: color.r, g: color.g, b: color.b };+ let same = |a: sys::GhosttyColorRgb, b: sys::GhosttyColorRgb| (a.r, a.g, a.b) == (b.r, b.g, b.b);+ for index in 0..256 {+ if !same(palette[index], defaults[index]) {+ overrides[index] = Some(rgb(palette[index]));+ }+ }+ let pairs = [+ (sys::GHOSTTY_TERMINAL_DATA_COLOR_FOREGROUND, sys::GHOSTTY_TERMINAL_DATA_COLOR_FOREGROUND_DEFAULT),+ (sys::GHOSTTY_TERMINAL_DATA_COLOR_BACKGROUND, sys::GHOSTTY_TERMINAL_DATA_COLOR_BACKGROUND_DEFAULT),+ (sys::GHOSTTY_TERMINAL_DATA_COLOR_CURSOR, sys::GHOSTTY_TERMINAL_DATA_COLOR_CURSOR_DEFAULT),+ ];+ for (offset, (current, default)) in pairs.into_iter().enumerate() {+ let (mut value, mut fallback) = (sys::GhosttyColorRgb::default(), sys::GhosttyColorRgb::default());+ if self.try_get(current, &mut value) && (!self.try_get(default, &mut fallback) || !same(value, fallback)) {+ overrides[256 + offset] = Some(rgb(value));+ }+ }+ ColorOverrides(overrides)+ }++ /// Parses the program's output.+ pub fn advance(&mut self, bytes: &[u8]) {+ let screen = self.active_screen();+ // SAFETY: `bytes` is valid for its length; the callbacks write into `self.callbacks`, which outlives the call.+ unsafe { sys::ghostty_terminal_vt_write(self.raw, bytes.as_ptr(), bytes.len()) };+ // xterm.js clears the selection when the other buffer activates.+ if self.active_screen() != screen {+ self.selection = None;+ }+ }++ fn active_screen(&self) -> sys::GhosttyTerminalScreen {+ let mut screen: sys::GhosttyTerminalScreen = 0;+ self.get(sys::GHOSTTY_TERMINAL_DATA_ACTIVE_SCREEN, &mut screen);+ screen+ }++ pub fn take_effects(&mut self) -> Effects {+ std::mem::take(&mut self.callbacks.effects)+ }++ /// RIS: the screens, modes and colors back to their defaults.+ pub fn reset(&mut self) {+ // SAFETY: `raw` is a live terminal.+ unsafe { sys::ghostty_terminal_reset(self.raw) };+ }++ pub fn resize(&mut self, cols: u16, rows: u16) {+ self.selection = None;+ let size = &self.callbacks.size;+ let (width, height) = (size.cell_width, size.cell_height);+ // SAFETY: `raw` is a live terminal.+ check(unsafe { sys::ghostty_terminal_resize(self.raw, cols.max(1), rows.max(1), width, height) }, "ghostty_terminal_resize");+ self.callbacks.size.rows = rows;+ self.callbacks.size.columns = cols;+ }++ /// The cell size in pixels, for `CSI 14 t` and `CSI 16 t`.+ pub fn set_cell_size(&mut self, width: u32, height: u32) {+ self.callbacks.size.cell_width = width;+ self.callbacks.size.cell_height = height;+ }++ fn get<T>(&self, data: sys::GhosttyTerminalData, out: &mut T) {+ assert!(self.try_get(data, out), "ghostty_terminal_get({data}) failed");+ }++ fn try_get<T>(&self, data: sys::GhosttyTerminalData, out: &mut T) -> bool {+ // SAFETY: each caller passes the output type `terminal.h` documents for `data`.+ unsafe { sys::ghostty_terminal_get(self.raw, data, out as *mut T as *mut c_void) == sys::GHOSTTY_SUCCESS }+ }++ pub fn columns(&self) -> usize {+ let mut cols = 0u16;+ self.get(sys::GHOSTTY_TERMINAL_DATA_COLS, &mut cols);+ cols as usize+ }++ pub fn screen_lines(&self) -> usize {+ let mut rows = 0u16;+ self.get(sys::GHOSTTY_TERMINAL_DATA_ROWS, &mut rows);+ rows as usize+ }++ fn scrollback_rows(&self) -> usize {+ let mut rows = 0usize;+ self.get(sys::GHOSTTY_TERMINAL_DATA_SCROLLBACK_ROWS, &mut rows);+ rows+ }++ /// The scrollback's lines, at most `scrolling_history` as xterm.js's `scrollback`.+ pub fn history_size(&self) -> usize {+ self.scrollback_rows().min(self.config.scrolling_history)+ }++ /// The rows Ghostty keeps above the scrollback xterm.js would keep.+ fn hidden_rows(&self) -> usize {+ self.scrollback_rows().saturating_sub(self.config.scrolling_history)+ }++ pub fn topmost_line(&self) -> Line {+ Line(-(self.history_size() as i32))+ }++ pub fn bottommost_line(&self) -> Line {+ Line(self.screen_lines() as i32 - 1)+ }++ pub fn last_column(&self) -> Column {+ Column(self.columns() - 1)+ }++ pub fn mode(&self) -> TermMode {+ let modes = [+ (1, TermMode::APP_CURSOR),+ (2004, TermMode::BRACKETED_PASTE),+ (1007, TermMode::ALTERNATE_SCROLL),+ (1000, TermMode::MOUSE_REPORT_CLICK),+ (1002, TermMode::MOUSE_DRAG),+ (1003, TermMode::MOUSE_MOTION),+ (1006, TermMode::SGR_MOUSE),+ (1005, TermMode::UTF8_MOUSE),+ (1004, TermMode::FOCUS_IN_OUT),+ (25, TermMode::SHOW_CURSOR),+ ];+ let mut mode = TermMode::default();+ for (number, flag) in modes {+ let mut config = sys::GhosttyTerminalModeConfig { mode: number, value: false };+ self.get(sys::GHOSTTY_TERMINAL_DATA_MODE, &mut config);+ if config.value {+ mode = mode | flag;+ }+ }+ if self.active_screen() == sys::GHOSTTY_TERMINAL_SCREEN_ALTERNATE {+ mode = mode | TermMode::ALT_SCREEN;+ }+ mode+ }++ pub fn cursor(&self) -> Cursor {+ let (mut x, mut y, mut pending_wrap) = (0u16, 0u16, false);+ self.get(sys::GHOSTTY_TERMINAL_DATA_CURSOR_X, &mut x);+ self.get(sys::GHOSTTY_TERMINAL_DATA_CURSOR_Y, &mut y);+ self.get(sys::GHOSTTY_TERMINAL_DATA_CURSOR_PENDING_WRAP, &mut pending_wrap);+ Cursor { point: Point::new(Line(y as i32), Column(x as usize)), input_needs_wrap: pending_wrap }+ }++ /// The pen the next printed character takes (SGR state), as a blank cell.+ pub fn cursor_template(&self) -> Cell {+ let mut style = sys::GhosttyStyle::default();+ self.get(sys::GHOSTTY_TERMINAL_DATA_CURSOR_SGR_STYLE, &mut style);+ let mut cell = Cell::default();+ apply_style(&mut cell, &style);+ cell+ }++ /// The cursor's shape and blinking as DECSCUSR and the defaults set it; `Hidden` while DECTCEM hides it.+ pub fn cursor_style(&self) -> CursorStyle {+ let (mut style, mut visible, mut blinking): (sys::GhosttyCursorStyle, bool, bool) = (0, false, false);+ // SAFETY: the render state and terminal are live; the outputs have the types `render.h` documents.+ unsafe {+ check(sys::ghostty_render_state_update(self.render, self.raw), "ghostty_render_state_update");+ check(sys::ghostty_render_state_get(self.render, sys::GHOSTTY_RENDER_STATE_DATA_CURSOR_VISUAL_STYLE, &mut style as *mut _ as *mut c_void), "cursor style");+ check(sys::ghostty_render_state_get(self.render, sys::GHOSTTY_RENDER_STATE_DATA_CURSOR_VISIBLE, &mut visible as *mut bool as *mut c_void), "cursor visible");+ check(sys::ghostty_render_state_get(self.render, sys::GHOSTTY_RENDER_STATE_DATA_CURSOR_BLINKING, &mut blinking as *mut bool as *mut c_void), "cursor blinking");+ }+ let shape = match style {+ _ if !visible => CursorShape::Hidden,+ sys::GHOSTTY_CURSOR_STYLE_BAR => CursorShape::Beam,+ sys::GHOSTTY_CURSOR_STYLE_UNDERLINE => CursorShape::Underline,+ sys::GHOSTTY_CURSOR_STYLE_BLOCK_HOLLOW => CursorShape::HollowBlock,+ _ => CursorShape::Block,+ };+ CursorStyle { shape, blinking }+ }++ /// The viewport's distance from the bottom, in lines.+ pub fn display_offset(&self) -> usize {+ let mut scrollbar = sys::GhosttyTerminalScrollbar::default();+ self.get(sys::GHOSTTY_TERMINAL_DATA_SCROLLBAR, &mut scrollbar);+ (scrollbar.total - scrollbar.offset - scrollbar.len) as usize+ }++ pub fn scroll_display(&mut self, scroll: Scroll) {+ let page = self.screen_lines() as isize;+ let (tag, value) = match scroll {+ Scroll::Delta(lines) => (sys::GHOSTTY_TERMINAL_SCROLL_VIEWPORT_DELTA, sys::GhosttyTerminalScrollViewportValue { delta: -(lines as isize) }),+ Scroll::PageUp => (sys::GHOSTTY_TERMINAL_SCROLL_VIEWPORT_DELTA, sys::GhosttyTerminalScrollViewportValue { delta: -page }),+ Scroll::PageDown => (sys::GHOSTTY_TERMINAL_SCROLL_VIEWPORT_DELTA, sys::GhosttyTerminalScrollViewportValue { delta: page }),+ Scroll::Top => (sys::GHOSTTY_TERMINAL_SCROLL_VIEWPORT_ROW, sys::GhosttyTerminalScrollViewportValue { row: self.hidden_rows() }),+ Scroll::Bottom => (sys::GHOSTTY_TERMINAL_SCROLL_VIEWPORT_BOTTOM, sys::GhosttyTerminalScrollViewportValue::default()),+ };+ self.scroll_viewport(tag, value);+ let hidden = self.hidden_rows();+ if hidden > 0 && self.display_offset() > self.history_size() {+ self.scroll_viewport(sys::GHOSTTY_TERMINAL_SCROLL_VIEWPORT_ROW, sys::GhosttyTerminalScrollViewportValue { row: hidden });+ }+ }++ fn scroll_viewport(&mut self, tag: sys::GhosttyTerminalScrollViewportTag, value: sys::GhosttyTerminalScrollViewportValue) {+ // SAFETY: `raw` is a live terminal and `value` holds the field `tag` names.+ check(unsafe { sys::ghostty_terminal_scroll_viewport(self.raw, sys::GhosttyTerminalScrollViewport { tag, value }) }, "ghostty_terminal_scroll_viewport");+ }++ /// Scrolls so `point` is in the viewport, as little as needed.+ pub fn scroll_to_point(&mut self, point: Point) {+ let offset = self.display_offset() as i32;+ let rows = self.screen_lines() as i32;+ if point.line.0 < -offset {+ self.scroll_display(Scroll::Delta(-offset - point.line.0));+ } else if point.line.0 >= rows - offset {+ self.scroll_display(Scroll::Delta(rows - offset - 1 - point.line.0));+ }+ }++ /// The point as Ghostty addresses it. Active lines use the active tag, which Ghostty resolves from the bottom;+ /// scrollback lines count from the oldest row it keeps.+ fn screen_point(&self, point: Point) -> sys::GhosttyPoint {+ assert!(point.line >= self.topmost_line() && point.line <= self.bottommost_line(), "line {} is outside the terminal", point.line.0);+ let (tag, y) = match point.line.0 {+ line if line >= 0 => (sys::GHOSTTY_POINT_TAG_ACTIVE, line as usize),+ line => (sys::GHOSTTY_POINT_TAG_SCREEN, (self.scrollback_rows() as i64 + line as i64) as usize),+ };+ sys::GhosttyPoint { tag, value: sys::GhosttyPointValue { coordinate: sys::GhosttyPointCoordinate { x: point.column.0 as u16, y: y as u32 } } }+ }++ fn grid_ref(&self, point: Point) -> sys::GhosttyGridRef {+ let mut grid_ref = sys::GhosttyGridRef { node: ptr::null_mut(), x: 0, y: 0 };+ // SAFETY: `raw` is a live terminal; the ref is used before the terminal changes, as `&self` holds it still.+ check(unsafe { sys::ghostty_terminal_grid_ref(self.raw, self.screen_point(point), &mut grid_ref) }, "ghostty_terminal_grid_ref");+ grid_ref+ }++ /// Whether `line` continues on the next one.+ pub fn wraps(&self, line: Line) -> bool {+ let grid_ref = self.grid_ref(Point::new(line, Column(0)));+ let (mut row, mut wrap): (sys::GhosttyRow, bool) = (0, false);+ // SAFETY: `grid_ref` is fresh; the outputs have the documented types.+ unsafe {+ check(sys::ghostty_grid_ref_row(&grid_ref, &mut row), "ghostty_grid_ref_row");+ check(sys::ghostty_row_get(row, sys::GHOSTTY_ROW_DATA_WRAP, &mut wrap as *mut bool as *mut c_void), "ghostty_row_get");+ }+ wrap+ }++ pub fn cell(&self, point: Point) -> Cell {+ let grid_ref = self.grid_ref(point);+ let mut cell = self.read_cell(&grid_ref);+ if point.column.0 + 1 == self.columns() && self.wraps(point.line) {+ cell.flags.insert(Flags::WRAPLINE);+ }+ cell+ }++ pub fn row(&self, line: Line) -> Row {+ let columns = self.columns();+ let mut cells: Vec<Cell> = (0..columns).map(|column| self.read_cell(&self.grid_ref(Point::new(line, Column(column))))).collect();+ if self.wraps(line) {+ cells[columns - 1].flags.insert(Flags::WRAPLINE);+ }+ Row(cells)+ }++ fn read_cell(&self, grid_ref: &sys::GhosttyGridRef) -> Cell {+ let mut raw: sys::GhosttyCell = 0;+ let (mut codepoint, mut tag, mut wide): (u32, sys::GhosttyCellContentTag, sys::GhosttyCellWide) = (0, 0, 0);+ let mut style = sys::GhosttyStyle::default();+ // SAFETY: `grid_ref` came from this terminal with no change since; the outputs have the documented types.+ unsafe {+ check(sys::ghostty_grid_ref_cell(grid_ref, &mut raw), "ghostty_grid_ref_cell");+ check(sys::ghostty_cell_get(raw, sys::GHOSTTY_CELL_DATA_CODEPOINT, &mut codepoint as *mut u32 as *mut c_void), "codepoint");+ check(sys::ghostty_cell_get(raw, sys::GHOSTTY_CELL_DATA_CONTENT_TAG, &mut tag as *mut _ as *mut c_void), "content tag");+ check(sys::ghostty_cell_get(raw, sys::GHOSTTY_CELL_DATA_WIDE, &mut wide as *mut _ as *mut c_void), "wide");+ check(sys::ghostty_grid_ref_style(grid_ref, &mut style), "ghostty_grid_ref_style");+ }+ let mut cell = Cell { c: char::from_u32(codepoint).filter(|&c| c != '\0').unwrap_or(' '), ..Cell::default() };+ apply_style(&mut cell, &style);+ match tag {+ sys::GHOSTTY_CELL_CONTENT_CODEPOINT_GRAPHEME => cell.zerowidth = self.graphemes(grid_ref).into_iter().skip(1).collect(),+ sys::GHOSTTY_CELL_CONTENT_BG_COLOR_PALETTE => {+ let mut index: u8 = 0;+ // SAFETY: the tag says the cell holds a palette background.+ check(unsafe { sys::ghostty_cell_get(raw, sys::GHOSTTY_CELL_DATA_COLOR_PALETTE, &mut index as *mut u8 as *mut c_void) }, "palette");+ cell.bg = Color::Indexed(index);+ }+ sys::GHOSTTY_CELL_CONTENT_BG_COLOR_RGB => {+ let mut rgb = sys::GhosttyColorRgb::default();+ // SAFETY: the tag says the cell holds an RGB background.+ check(unsafe { sys::ghostty_cell_get(raw, sys::GHOSTTY_CELL_DATA_COLOR_RGB, &mut rgb as *mut _ as *mut c_void) }, "rgb");+ cell.bg = Color::Spec(Rgb { r: rgb.r, g: rgb.g, b: rgb.b });+ }+ _ => {}+ }+ match wide {+ sys::GHOSTTY_CELL_WIDE_WIDE => cell.flags.insert(Flags::WIDE_CHAR),+ sys::GHOSTTY_CELL_WIDE_SPACER_TAIL => cell.flags.insert(Flags::WIDE_CHAR_SPACER),+ sys::GHOSTTY_CELL_WIDE_SPACER_HEAD => cell.flags.insert(Flags::LEADING_WIDE_CHAR_SPACER),+ _ => {}+ }+ cell+ }++ fn graphemes(&self, grid_ref: &sys::GhosttyGridRef) -> Vec<char> {+ let mut buffer = [0u32; 16];+ let mut written = 0usize;+ // SAFETY: `buffer` holds `buffer.len()` codepoints; on OUT_OF_SPACE the heap buffer is sized to `written`.+ let mut result = unsafe { sys::ghostty_grid_ref_graphemes(grid_ref, buffer.as_mut_ptr(), buffer.len(), &mut written) };+ let mut heap = Vec::new();+ if result == sys::GHOSTTY_OUT_OF_SPACE {+ heap = vec![0u32; written];+ // SAFETY: as above, with the heap buffer of `written` codepoints.+ result = unsafe { sys::ghostty_grid_ref_graphemes(grid_ref, heap.as_mut_ptr(), heap.len(), &mut written) };+ }+ check(result, "ghostty_grid_ref_graphemes");+ let codepoints = if heap.is_empty() { &buffer[..written] } else { &heap[..written] };+ codepoints.iter().filter_map(|&codepoint| char::from_u32(codepoint)).collect()+ }++ /// A ref that follows `point`'s cell as output scrolls it up; `None` once the scrollback drops the cell.+ fn track(&self, point: Point) -> TrackedPoint {+ let mut tracked = ptr::null_mut();+ // SAFETY: `raw` is a live terminal; the ref is freed by `TrackedPoint`'s drop before the terminal's.+ check(unsafe { sys::ghostty_terminal_grid_ref_track(self.raw, self.screen_point(point), &mut tracked) }, "ghostty_terminal_grid_ref_track");+ TrackedPoint(tracked)+ }++ fn tracked_point(&self, tracked: &TrackedPoint) -> Option<Point> {+ let mut coordinate = sys::GhosttyPointCoordinate::default();+ // SAFETY: the ref belongs to this terminal, which is live.+ let found = unsafe { sys::ghostty_tracked_grid_ref_has_value(tracked.0) && sys::ghostty_tracked_grid_ref_point(tracked.0, sys::GHOSTTY_POINT_TAG_SCREEN, &mut coordinate) == sys::GHOSTTY_SUCCESS };+ let line = coordinate.y as i64 - self.scrollback_rows() as i64;+ (found && line >= -(self.history_size() as i64)).then(|| Point::new(Line(line as i32), Column(coordinate.x as usize)))+ }++ pub fn title(&self) -> String {+ let mut title = sys::GhosttyString { ptr: ptr::null(), len: 0 };+ self.get(sys::GHOSTTY_TERMINAL_DATA_TITLE, &mut title);+ borrowed_string(title)+ }+}++struct TrackedPoint(sys::GhosttyTrackedGridRef);++impl Drop for TrackedPoint {+ fn drop(&mut self) {+ // SAFETY: created by `ghostty_terminal_grid_ref_track` and freed once; `Term` drops its selection first.+ unsafe { sys::ghostty_tracked_grid_ref_free(self.0) };+ }+}++fn borrowed_string(string: sys::GhosttyString) -> String {+ if string.ptr.is_null() || string.len == 0 {+ return String::new();+ }+ // SAFETY: the library returned `len` bytes at `ptr`, valid until the terminal changes; they are copied now.+ String::from_utf8_lossy(unsafe { std::slice::from_raw_parts(string.ptr, string.len) }).into_owned()+}++fn style_color(color: &sys::GhosttyStyleColor) -> Option<Color> {+ // SAFETY: the tag names the union field the library wrote.+ match color.tag as sys::GhosttyStyleColorTag {+ sys::GHOSTTY_STYLE_COLOR_PALETTE => Some(Color::Indexed(unsafe { color.value.palette })),+ sys::GHOSTTY_STYLE_COLOR_RGB => {+ let rgb = unsafe { color.value.rgb };+ Some(Color::Spec(Rgb { r: rgb.r, g: rgb.g, b: rgb.b }))+ }+ _ => None,+ }+}++fn apply_style(cell: &mut Cell, style: &sys::GhosttyStyle) {+ cell.fg = style_color(&style.fg_color).unwrap_or(Color::Foreground);+ cell.bg = style_color(&style.bg_color).unwrap_or(Color::Background);+ cell.underline_color = style_color(&style.underline_color);+ let attributes = [(0, Flags::BOLD), (1, Flags::ITALIC), (2, Flags::DIM), (4, Flags::INVERSE), (5, Flags::HIDDEN), (6, Flags::STRIKEOUT)];+ for (bit, flag) in attributes {+ if style.flags & (1 << bit) != 0 {+ cell.flags.insert(flag);+ }+ }+ let underline = match (style.flags >> 8) & 0x7 {+ 1 => Flags::UNDERLINE,+ 2 => Flags::DOUBLE_UNDERLINE,+ 3 => Flags::UNDERCURL,+ 4 => Flags::DOTTED_UNDERLINE,+ 5 => Flags::DASHED_UNDERLINE,+ _ => Flags::empty(),+ };+ cell.flags.insert(underline);+}++/// # Safety+/// Ghostty calls it with the userdata `install_callbacks` set, a live `Callbacks`, and `len` bytes at `data`.+unsafe extern "C" fn write_pty(_: sys::GhosttyTerminal, userdata: *mut c_void, data: *const u8, len: usize) {+ let callbacks = unsafe { &mut *(userdata as *mut Callbacks) };+ callbacks.effects.pty_write.extend_from_slice(unsafe { std::slice::from_raw_parts(data, len) });+}++/// # Safety+/// As `write_pty`.+unsafe extern "C" fn bell(_: sys::GhosttyTerminal, userdata: *mut c_void) {+ unsafe { &mut *(userdata as *mut Callbacks) }.effects.bell = true;+}++/// # Safety+/// As `write_pty`; the terminal is live and not being written to from Rust.+unsafe extern "C" fn title_changed(terminal: sys::GhosttyTerminal, userdata: *mut c_void) {+ let mut title = sys::GhosttyString { ptr: ptr::null(), len: 0 };+ if unsafe { sys::ghostty_terminal_get(terminal, sys::GHOSTTY_TERMINAL_DATA_TITLE, &mut title as *mut _ as *mut c_void) } == sys::GHOSTTY_SUCCESS {+ unsafe { &mut *(userdata as *mut Callbacks) }.effects.title = Some(borrowed_string(title));+ }+}++/// # Safety+/// As `write_pty`, with `out` valid for one write.+unsafe extern "C" fn size(_: sys::GhosttyTerminal, userdata: *mut c_void, out: *mut sys::GhosttySizeReportSize) -> bool {+ unsafe { *out = (*(userdata as *mut Callbacks)).size };+ true+}++/// xterm.js `CSI c` (`?1;2c`) and `CSI > c` (`>0;276;0c`).+///+/// # Safety+/// `out` is valid for one write.+unsafe extern "C" fn device_attributes(_: sys::GhosttyTerminal, _: *mut c_void, out: *mut sys::GhosttyDeviceAttributes) -> bool {+ let mut attributes = sys::GhosttyDeviceAttributes::default();+ attributes.primary.conformance_level = 1;+ attributes.primary.features[0] = 2;+ attributes.primary.num_features = 1;+ attributes.secondary = sys::GhosttyDeviceAttributesSecondary { device_type: 0, firmware_version: 276, rom_cartridge: 0 };+ unsafe { *out = attributes };+ true+}++/// # Safety+/// Returns a pointer to a static string, which Ghostty copies.+unsafe extern "C" fn xtversion(_: sys::GhosttyTerminal, _: *mut c_void) -> sys::GhosttyString {+ sys::GhosttyString { ptr: XTVERSION.as_ptr(), len: XTVERSION.len() }+}++#[cfg(test)]+mod tests;diff --git a/native/crates/ghostty_vt/src/selection.rs b/native/crates/ghostty_vt/src/selection.rsnew file mode 100644index 00000000000..bf917a28f86--- /dev/null+++ b/native/crates/ghostty_vt/src/selection.rs@@ -0,0 +1,350 @@+//! Mouse selection with alacritty_terminal 0.25's rules (`selection.rs`, `term/search.rs`, `Term::selection_to_string`),+//! which the port's selection tests and copy behavior were written against. Its anchors follow their cells as output+//! scrolls, the way xterm.js's selection follows the buffer.++use std::mem;++use crate::{Column, Flags, Line, Point, Side, Term, TrackedPoint};++#[derive(Clone, Copy, Debug, Eq, PartialEq)]+pub enum SelectionType {+ Simple,+ Block,+ Semantic,+ Lines,+}++/// The selected cells, `start` to `end` inclusive.+#[derive(Clone, Copy, Debug, Eq, PartialEq)]+pub struct SelectionRange {+ pub start: Point,+ pub end: Point,+ pub is_block: bool,+}++impl SelectionRange {+ pub fn contains(&self, point: Point) -> bool {+ self.start.line <= point.line+ && self.end.line >= point.line+ && (self.start.column <= point.column || (self.start.line != point.line && !self.is_block))+ && (self.end.column >= point.column || (self.end.line != point.line && !self.is_block))+ }+}++struct Anchor {+ point: TrackedPoint,+ side: Side,+}++pub(crate) struct Selection {+ ty: SelectionType,+ start: Anchor,+ end: Anchor,+}++#[derive(Clone, Copy, PartialEq)]+struct Resolved {+ point: Point,+ side: Side,+}++const BRACKET_PAIRS: [(char, char); 4] = [('(', ')'), ('[', ']'), ('{', '}'), ('<', '>')];++impl Term {+ pub fn start_selection(&mut self, ty: SelectionType, point: Point, side: Side) {+ let point = self.clamp(point);+ self.selection = Some(Selection { ty, start: Anchor { point: self.track(point), side }, end: Anchor { point: self.track(point), side } });+ }++ pub fn update_selection(&mut self, point: Point, side: Side) {+ let point = self.clamp(point);+ let tracked = self.track(point);+ if let Some(selection) = &mut self.selection {+ selection.end = Anchor { point: tracked, side };+ }+ }++ pub fn clear_selection(&mut self) {+ self.selection = None;+ }++ pub fn has_selection(&self) -> bool {+ self.selection.is_some()+ }++ /// A selection that covers at least one cell.+ pub fn has_nonempty_selection(&self) -> bool {+ self.anchors().is_some_and(|(ty, start, end)| !is_empty(ty, start, end))+ }++ fn clamp(&self, point: Point) -> Point {+ let last = self.last_column();+ let mut point = Point::new(point.line, point.column.min(last));+ if point.line < self.topmost_line() {+ point = Point::new(self.topmost_line(), Column(0));+ } else if point.line > self.bottommost_line() {+ point = Point::new(self.bottommost_line(), last);+ }+ point+ }++ fn anchors(&self) -> Option<(SelectionType, Resolved, Resolved)> {+ let selection = self.selection.as_ref()?;+ let start = Resolved { point: self.tracked_point(&selection.start.point)?, side: selection.start.side };+ let end = Resolved { point: self.tracked_point(&selection.end.point)?, side: selection.end.side };+ Some((selection.ty, start, end))+ }++ pub fn selection_range(&self) -> Option<SelectionRange> {+ let (ty, mut start, mut end) = self.anchors()?;+ if start.point > end.point {+ mem::swap(&mut start, &mut end);+ }+ start.point = self.clamp(start.point);+ end.point = self.clamp(end.point);+ match ty {+ SelectionType::Simple => self.range_simple(ty, start, end),+ SelectionType::Block => range_block(ty, start, end),+ SelectionType::Semantic => Some(self.range_semantic(start.point, end.point)),+ SelectionType::Lines => Some(SelectionRange { start: self.line_search_left(start.point), end: self.line_search_right(end.point), is_block: false }),+ }+ }++ fn range_simple(&self, ty: SelectionType, mut start: Resolved, mut end: Resolved) -> Option<SelectionRange> {+ if is_empty(ty, start, end) {+ return None;+ }+ let columns = self.columns();+ if end.side == Side::Left && start.point != end.point {+ if end.point.column.0 == 0 {+ end.point = Point::new(end.point.line - 1, Column(columns - 1));+ } else {+ end.point.column -= 1;+ }+ }+ if start.side == Side::Right && start.point != end.point {+ start.point.column += 1;+ if start.point.column.0 == columns {+ start.point = Point::new(start.point.line + 1, Column(0));+ }+ }+ Some(SelectionRange { start: start.point, end: end.point, is_block: false })+ }++ fn range_semantic(&self, mut start: Point, mut end: Point) -> SelectionRange {+ if start == end+ && let Some(matching) = self.bracket_search(start)+ {+ if matching < start {+ start = matching;+ } else {+ end = matching;+ }+ return SelectionRange { start, end, is_block: false };+ }+ SelectionRange { start: self.semantic_search_left(start), end: self.semantic_search_right(end), is_block: false }+ }++ /// The cell after `point`, wrapping to the next line; `None` past the last cell.+ pub fn next_point(&self, point: Point) -> Option<Point> {+ if point.column < self.last_column() {+ return Some(Point::new(point.line, point.column + 1));+ }+ (point.line < self.bottommost_line()).then(|| Point::new(point.line + 1, Column(0)))+ }++ /// The cell before `point`, wrapping to the previous line; `None` before the first cell.+ pub fn previous_point(&self, point: Point) -> Option<Point> {+ if point.column.0 > 0 {+ return Some(Point::new(point.line, point.column - 1));+ }+ (point.line > self.topmost_line()).then(|| Point::new(point.line - 1, self.last_column()))+ }++ fn bracket_search(&self, point: Point) -> Option<Point> {+ let start_char = self.cell(point).c;+ let (forward, end_char) = BRACKET_PAIRS.iter().find_map(|&(open, close)| match start_char {+ c if c == open => Some((true, close)),+ c if c == close => Some((false, open)),+ _ => None,+ })?;+ let mut skip_pairs = 0;+ let mut point = point;+ loop {+ point = if forward { self.next_point(point)? } else { self.previous_point(point)? };+ let c = self.cell(point).c;+ if c == end_char && skip_pairs == 0 {+ return Some(point);+ } else if c == start_char {+ skip_pairs += 1;+ } else if c == end_char {+ skip_pairs -= 1;+ }+ }+ }++ pub fn semantic_search_left(&self, point: Point) -> Point {+ let spacers = Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER;+ match self.inline_search_left(point, self.semantic_escape_chars()) {+ Ok(found) => {+ let mut next = self.next_point(found);+ while let Some(point) = next {+ if !self.cell(point).flags.intersects(spacers) {+ return point;+ }+ next = self.next_point(point);+ }+ found+ }+ Err(point) => point,+ }+ }++ pub fn semantic_search_right(&self, point: Point) -> Point {+ match self.inline_search_right(point, self.semantic_escape_chars()) {+ Ok(found) => self.previous_point(found).unwrap_or(found),+ Err(point) => point,+ }+ }++ fn inline_search_left(&self, mut point: Point, needles: &str) -> Result<Point, Point> {+ point.line = point.line.max(self.topmost_line());+ let spacers = Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER;+ let mut previous = self.previous_point(point);+ while let Some(candidate) = previous {+ let cell = self.cell(candidate);+ if candidate.column == self.last_column() && !cell.flags.contains(Flags::WRAPLINE) {+ break;+ }+ point = candidate;+ if !cell.flags.intersects(spacers) && needles.contains(cell.c) {+ return Ok(point);+ }+ previous = self.previous_point(point);+ }+ Err(point)+ }++ fn inline_search_right(&self, mut point: Point, needles: &str) -> Result<Point, Point> {+ point.line = point.line.max(self.topmost_line());+ let spacers = Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER;+ let last_column = self.last_column();+ if point.column == last_column && !self.cell(point).flags.contains(Flags::WRAPLINE) {+ return Err(point);+ }+ let mut next = self.next_point(point);+ while let Some(candidate) = next {+ point = candidate;+ let cell = self.cell(point);+ if !cell.flags.intersects(spacers) && needles.contains(cell.c) {+ return Ok(point);+ }+ if point.column == last_column && !cell.flags.contains(Flags::WRAPLINE) {+ break;+ }+ next = self.next_point(point);+ }+ Err(point)+ }++ /// The first line of the logical line `point` is on.+ pub fn line_search_left(&self, mut point: Point) -> Point {+ while point.line > self.topmost_line() && self.wraps(point.line - 1) {+ point.line -= 1;+ }+ Point::new(point.line, Column(0))+ }++ /// The last line of the logical line `point` is on.+ pub fn line_search_right(&self, mut point: Point) -> Point {+ while point.line.0 + 1 < self.screen_lines() as i32 && self.wraps(point.line) {+ point.line += 1;+ }+ Point::new(point.line, self.last_column())+ }++ pub fn selection_to_string(&self) -> Option<String> {+ let ty = self.selection.as_ref()?.ty;+ let SelectionRange { start, end, .. } = self.selection_range()?;+ let mut text = String::new();+ match ty {+ SelectionType::Block => {+ for line in start.line.0..end.line.0 {+ text += self.line_to_string(Line(line), start.column, end.column, start.column.0 != 0).trim_end();+ text += "\n";+ }+ text += self.line_to_string(end.line, start.column, end.column, true).trim_end();+ }+ SelectionType::Lines => text = self.bounds_to_string(start, end) + "\n",+ _ => text = self.bounds_to_string(start, end),+ }+ Some(text)+ }++ pub fn bounds_to_string(&self, start: Point, end: Point) -> String {+ let mut text = String::new();+ for line in start.line.0..=end.line.0 {+ let line = Line(line);+ let start_column = if line == start.line { start.column } else { Column(0) };+ let end_column = if line == end.line { end.column } else { self.last_column() };+ text += &self.line_to_string(line, start_column, end_column, line == end.line);+ }+ text.strip_suffix('\n').map(str::to_owned).unwrap_or(text)+ }++ /// Columns `start..end` of `line` as alacritty's `line_to_string`: `end` itself is read too, up to the text's end.+ fn line_to_string(&self, line: Line, mut start: Column, end: Column, include_wrapped_wide: bool) -> String {+ let row = self.row(line);+ let length = row.line_length().min(end + 1);+ if row[start].flags.contains(Flags::WIDE_CHAR_SPACER) {+ start -= 1;+ }+ let mut text = String::new();+ for column in start.0..length.0 {+ let cell = &row[Column(column)];+ if !cell.flags.intersects(Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER) {+ text.push(cell.c);+ text.extend(&cell.zerowidth);+ }+ }+ if end >= self.last_column() && (length.0 == 0 || !row[length - 1].flags.contains(Flags::WRAPLINE)) {+ text.push('\n');+ }+ if length.0 == self.columns() && length.0 >= 2 && row[length - 1].flags.contains(Flags::LEADING_WIDE_CHAR_SPACER) && include_wrapped_wide {+ text.push(self.cell(Point::new(line - 1, Column(0))).c);+ }+ text+ }+}++fn is_empty(ty: SelectionType, start: Resolved, end: Resolved) -> bool {+ match ty {+ SelectionType::Simple => {+ let (start, end) = if start.point > end.point { (end, start) } else { (start, end) };+ start == end || (start.side == Side::Right && end.side == Side::Left && start.point.line == end.point.line && start.point.column + 1 == end.point.column)+ }+ SelectionType::Block => {+ (start.point.column == end.point.column && start.side == end.side)+ || (start.point.column + 1 == end.point.column && start.side == Side::Right && end.side == Side::Left)+ || (end.point.column + 1 == start.point.column && start.side == Side::Left && end.side == Side::Right)+ }+ SelectionType::Semantic | SelectionType::Lines => false,+ }+}++fn range_block(ty: SelectionType, mut start: Resolved, mut end: Resolved) -> Option<SelectionRange> {+ if is_empty(ty, start, end) {+ return None;+ }+ if start.point.column > end.point.column {+ mem::swap(&mut start.side, &mut end.side);+ mem::swap(&mut start.point.column, &mut end.point.column);+ }+ if end.side == Side::Left && start.point != end.point && end.point.column.0 > 0 {+ end.point.column -= 1;+ }+ if start.side == Side::Right && start.point != end.point {+ start.point.column += 1;+ }+ Some(SelectionRange { start: start.point, end: end.point, is_block: true })+}diff --git a/native/crates/ghostty_vt/src/sys.rs b/native/crates/ghostty_vt/src/sys.rsnew file mode 100644index 00000000000..22f107d226a--- /dev/null+++ b/native/crates/ghostty_vt/src/sys.rs@@ -0,0 +1,3220 @@+//! libghostty-vt 1.0.2 `include/ghostty/vt.h` through bindgen 0.72.1: allowlist `ghostty_.*`, `Ghostty.*` and+//! `GHOSTTY_.*`, enums as consts without their name prefix, `use_core`, no layout tests, `derive_default`.+#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case, dead_code, clippy::all)]+++pub const GHOSTTY_VT_VERSION_MAJOR: u32 = 1;+pub const GHOSTTY_VT_VERSION_MINOR: u32 = 0;+pub const GHOSTTY_VT_VERSION_PATCH: u32 = 2;+pub const GHOSTTY_VT_VERSION: &[u8; 6] = b"1.0.2\0";+pub const GHOSTTY_ENUM_MAX_VALUE: u32 = 2147483647;+pub const GHOSTTY_COLOR_NAMED_BLACK: u32 = 0;+pub const GHOSTTY_COLOR_NAMED_RED: u32 = 1;+pub const GHOSTTY_COLOR_NAMED_GREEN: u32 = 2;+pub const GHOSTTY_COLOR_NAMED_YELLOW: u32 = 3;+pub const GHOSTTY_COLOR_NAMED_BLUE: u32 = 4;+pub const GHOSTTY_COLOR_NAMED_MAGENTA: u32 = 5;+pub const GHOSTTY_COLOR_NAMED_CYAN: u32 = 6;+pub const GHOSTTY_COLOR_NAMED_WHITE: u32 = 7;+pub const GHOSTTY_COLOR_NAMED_BRIGHT_BLACK: u32 = 8;+pub const GHOSTTY_COLOR_NAMED_BRIGHT_RED: u32 = 9;+pub const GHOSTTY_COLOR_NAMED_BRIGHT_GREEN: u32 = 10;+pub const GHOSTTY_COLOR_NAMED_BRIGHT_YELLOW: u32 = 11;+pub const GHOSTTY_COLOR_NAMED_BRIGHT_BLUE: u32 = 12;+pub const GHOSTTY_COLOR_NAMED_BRIGHT_MAGENTA: u32 = 13;+pub const GHOSTTY_COLOR_NAMED_BRIGHT_CYAN: u32 = 14;+pub const GHOSTTY_COLOR_NAMED_BRIGHT_WHITE: u32 = 15;+pub const GHOSTTY_DA_CONFORMANCE_VT100: u32 = 1;+pub const GHOSTTY_DA_CONFORMANCE_VT101: u32 = 1;+pub const GHOSTTY_DA_CONFORMANCE_VT102: u32 = 6;+pub const GHOSTTY_DA_CONFORMANCE_VT125: u32 = 12;+pub const GHOSTTY_DA_CONFORMANCE_VT131: u32 = 7;+pub const GHOSTTY_DA_CONFORMANCE_VT132: u32 = 4;+pub const GHOSTTY_DA_CONFORMANCE_VT220: u32 = 62;+pub const GHOSTTY_DA_CONFORMANCE_VT240: u32 = 62;+pub const GHOSTTY_DA_CONFORMANCE_VT320: u32 = 63;+pub const GHOSTTY_DA_CONFORMANCE_VT340: u32 = 63;+pub const GHOSTTY_DA_CONFORMANCE_VT420: u32 = 64;+pub const GHOSTTY_DA_CONFORMANCE_VT510: u32 = 65;+pub const GHOSTTY_DA_CONFORMANCE_VT520: u32 = 65;+pub const GHOSTTY_DA_CONFORMANCE_VT525: u32 = 65;+pub const GHOSTTY_DA_CONFORMANCE_LEVEL_2: u32 = 62;+pub const GHOSTTY_DA_CONFORMANCE_LEVEL_3: u32 = 63;+pub const GHOSTTY_DA_CONFORMANCE_LEVEL_4: u32 = 64;+pub const GHOSTTY_DA_CONFORMANCE_LEVEL_5: u32 = 65;+pub const GHOSTTY_DA_FEATURE_COLUMNS_132: u32 = 1;+pub const GHOSTTY_DA_FEATURE_PRINTER: u32 = 2;+pub const GHOSTTY_DA_FEATURE_REGIS: u32 = 3;+pub const GHOSTTY_DA_FEATURE_SIXEL: u32 = 4;+pub const GHOSTTY_DA_FEATURE_SELECTIVE_ERASE: u32 = 6;+pub const GHOSTTY_DA_FEATURE_USER_DEFINED_KEYS: u32 = 8;+pub const GHOSTTY_DA_FEATURE_NATIONAL_REPLACEMENT: u32 = 9;+pub const GHOSTTY_DA_FEATURE_TECHNICAL_CHARACTERS: u32 = 15;+pub const GHOSTTY_DA_FEATURE_LOCATOR: u32 = 16;+pub const GHOSTTY_DA_FEATURE_TERMINAL_STATE: u32 = 17;+pub const GHOSTTY_DA_FEATURE_WINDOWING: u32 = 18;+pub const GHOSTTY_DA_FEATURE_HORIZONTAL_SCROLLING: u32 = 21;+pub const GHOSTTY_DA_FEATURE_ANSI_COLOR: u32 = 22;+pub const GHOSTTY_DA_FEATURE_RECTANGULAR_EDITING: u32 = 28;+pub const GHOSTTY_DA_FEATURE_ANSI_TEXT_LOCATOR: u32 = 29;+pub const GHOSTTY_DA_FEATURE_CLIPBOARD: u32 = 52;+pub const GHOSTTY_DA_DEVICE_TYPE_VT100: u32 = 0;+pub const GHOSTTY_DA_DEVICE_TYPE_VT220: u32 = 1;+pub const GHOSTTY_DA_DEVICE_TYPE_VT240: u32 = 2;+pub const GHOSTTY_DA_DEVICE_TYPE_VT330: u32 = 18;+pub const GHOSTTY_DA_DEVICE_TYPE_VT340: u32 = 19;+pub const GHOSTTY_DA_DEVICE_TYPE_VT320: u32 = 24;+pub const GHOSTTY_DA_DEVICE_TYPE_VT382: u32 = 32;+pub const GHOSTTY_DA_DEVICE_TYPE_VT420: u32 = 41;+pub const GHOSTTY_DA_DEVICE_TYPE_VT510: u32 = 61;+pub const GHOSTTY_DA_DEVICE_TYPE_VT520: u32 = 64;+pub const GHOSTTY_DA_DEVICE_TYPE_VT525: u32 = 65;+pub const GHOSTTY_STYLE_UNDERLINE_SHIFT: u32 = 8;+pub const GHOSTTY_FORMATTER_EXTRA_PALETTE: u32 = 1;+pub const GHOSTTY_FORMATTER_EXTRA_MODES: u32 = 2;+pub const GHOSTTY_FORMATTER_EXTRA_SCROLLING_REGION: u32 = 4;+pub const GHOSTTY_FORMATTER_EXTRA_TABSTOPS: u32 = 8;+pub const GHOSTTY_FORMATTER_EXTRA_PWD: u32 = 16;+pub const GHOSTTY_FORMATTER_EXTRA_KEYBOARD: u32 = 32;+pub const GHOSTTY_FORMATTER_EXTRA_CURSOR: u32 = 64;+pub const GHOSTTY_FORMATTER_EXTRA_STYLE: u32 = 128;+pub const GHOSTTY_FORMATTER_EXTRA_HYPERLINK: u32 = 256;+pub const GHOSTTY_FORMATTER_EXTRA_PROTECTION: u32 = 512;+pub const GHOSTTY_FORMATTER_EXTRA_KITTY_KEYBOARD: u32 = 1024;+pub const GHOSTTY_FORMATTER_EXTRA_CHARSETS: u32 = 2048;+pub const GHOSTTY_FORMATTER_EXTRAS_NONE: u32 = 0;+pub const GHOSTTY_FORMATTER_EXTRAS_ALL: u32 = 4095;+pub const GHOSTTY_FORMATTER_EXTRAS_DEFAULT: u32 = 385;+pub const GHOSTTY_MODS_SHIFT: u32 = 1;+pub const GHOSTTY_MODS_CTRL: u32 = 2;+pub const GHOSTTY_MODS_ALT: u32 = 4;+pub const GHOSTTY_MODS_SUPER: u32 = 8;+pub const GHOSTTY_MODS_CAPS_LOCK: u32 = 16;+pub const GHOSTTY_MODS_NUM_LOCK: u32 = 32;+pub const GHOSTTY_MODS_SHIFT_SIDE: u32 = 64;+pub const GHOSTTY_MODS_CTRL_SIDE: u32 = 128;+pub const GHOSTTY_MODS_ALT_SIDE: u32 = 256;+pub const GHOSTTY_MODS_SUPER_SIDE: u32 = 512;+pub const GHOSTTY_KITTY_KEY_DISABLED: u32 = 0;+pub const GHOSTTY_KITTY_KEY_DISAMBIGUATE: u32 = 1;+pub const GHOSTTY_KITTY_KEY_REPORT_EVENTS: u32 = 2;+pub const GHOSTTY_KITTY_KEY_REPORT_ALTERNATES: u32 = 4;+pub const GHOSTTY_KITTY_KEY_REPORT_ALL: u32 = 8;+pub const GHOSTTY_KITTY_KEY_REPORT_ASSOCIATED: u32 = 16;+pub const GHOSTTY_KITTY_KEY_ALL: u32 = 31;+pub const GHOSTTY_SUCCESS: GhosttyResult = 0;+pub const GHOSTTY_OUT_OF_MEMORY: GhosttyResult = -1;+pub const GHOSTTY_INVALID_VALUE: GhosttyResult = -2;+pub const GHOSTTY_OUT_OF_SPACE: GhosttyResult = -3;+pub const GHOSTTY_NO_VALUE: GhosttyResult = -4;+pub const GHOSTTY_IO_ERROR: GhosttyResult = -5;+pub const GHOSTTY_LIMIT_EXCEEDED: GhosttyResult = -6;+pub const GHOSTTY_REJECTED: GhosttyResult = -7;+pub const GHOSTTY_UNSUPPORTED: GhosttyResult = -8;+pub const GHOSTTY_RESULT_MAX_VALUE: GhosttyResult = 2147483647;+pub type GhosttyResult = ::core::ffi::c_int;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalImpl {+ _unused: [u8; 0],+}+pub type GhosttyTerminal = *mut GhosttyTerminalImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttySnapshotDecoderImpl {+ _unused: [u8; 0],+}+pub type GhosttySnapshotDecoder = *mut GhosttySnapshotDecoderImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTrackedGridRefImpl {+ _unused: [u8; 0],+}+pub type GhosttyTrackedGridRef = *mut GhosttyTrackedGridRefImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyKittyGraphicsImpl {+ _unused: [u8; 0],+}+pub type GhosttyKittyGraphics = *mut GhosttyKittyGraphicsImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyKittyGraphicsImageImpl {+ _unused: [u8; 0],+}+pub type GhosttyKittyGraphicsImage = *const GhosttyKittyGraphicsImageImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyKittyGraphicsPlacementIteratorImpl {+ _unused: [u8; 0],+}+pub type GhosttyKittyGraphicsPlacementIterator = *mut GhosttyKittyGraphicsPlacementIteratorImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyRenderStateImpl {+ _unused: [u8; 0],+}+pub type GhosttyRenderState = *mut GhosttyRenderStateImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyRenderStateRowIteratorImpl {+ _unused: [u8; 0],+}+pub type GhosttyRenderStateRowIterator = *mut GhosttyRenderStateRowIteratorImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyRenderStateRowCellsImpl {+ _unused: [u8; 0],+}+pub type GhosttyRenderStateRowCells = *mut GhosttyRenderStateRowCellsImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyRenderStateImageIteratorImpl {+ _unused: [u8; 0],+}+pub type GhosttyRenderStateImageIterator = *mut GhosttyRenderStateImageIteratorImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttySearchImpl {+ _unused: [u8; 0],+}+pub type GhosttySearch = *mut GhosttySearchImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttySgrParserImpl {+ _unused: [u8; 0],+}+pub type GhosttySgrParser = *mut GhosttySgrParserImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyFormatterImpl {+ _unused: [u8; 0],+}+pub type GhosttyFormatter = *mut GhosttyFormatterImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyOscParserImpl {+ _unused: [u8; 0],+}+pub type GhosttyOscParser = *mut GhosttyOscParserImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyOscCommandImpl {+ _unused: [u8; 0],+}+pub type GhosttyOscCommand = *mut GhosttyOscCommandImpl;+pub const GHOSTTY_FORMATTER_FORMAT_PLAIN: GhosttyFormatterFormat = 0;+pub const GHOSTTY_FORMATTER_FORMAT_VT: GhosttyFormatterFormat = 1;+pub const GHOSTTY_FORMATTER_FORMAT_HTML: GhosttyFormatterFormat = 2;+pub const GHOSTTY_FORMATTER_FORMAT_MAX_VALUE: GhosttyFormatterFormat = 2147483647;+pub type GhosttyFormatterFormat = ::core::ffi::c_uint;+pub const GHOSTTY_CURSOR_STYLE_BAR: GhosttyCursorStyle = 0;+pub const GHOSTTY_CURSOR_STYLE_BLOCK: GhosttyCursorStyle = 1;+pub const GHOSTTY_CURSOR_STYLE_UNDERLINE: GhosttyCursorStyle = 2;+pub const GHOSTTY_CURSOR_STYLE_BLOCK_HOLLOW: GhosttyCursorStyle = 3;+pub const GHOSTTY_CURSOR_STYLE_MAX_VALUE: GhosttyCursorStyle = 2147483647;+pub type GhosttyCursorStyle = ::core::ffi::c_uint;+pub const GHOSTTY_IMAGE_LAYER_BELOW_BACKGROUND: GhosttyImageLayer = 0;+pub const GHOSTTY_IMAGE_LAYER_BELOW_TEXT: GhosttyImageLayer = 1;+pub const GHOSTTY_IMAGE_LAYER_ABOVE_TEXT: GhosttyImageLayer = 2;+pub const GHOSTTY_IMAGE_LAYER_MAX_VALUE: GhosttyImageLayer = 2147483647;+pub type GhosttyImageLayer = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyString {+ pub ptr: *const u8,+ pub len: usize,+}+impl Default for GhosttyString {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyBuffer {+ pub ptr: *mut u8,+ pub cap: usize,+ pub len: usize,+}+impl Default for GhosttyBuffer {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttySurfacePosition {+ pub x: f64,+ pub y: f64,+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyCodepoints {+ pub ptr: *const u32,+ pub len: usize,+}+impl Default for GhosttyCodepoints {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyCodepointBuffer {+ pub ptr: *mut u32,+ pub cap: usize,+ pub len: usize,+}+impl Default for GhosttyCodepointBuffer {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyAllocatorAllocFn = ::core::option::Option<+ unsafe extern "C" fn(+ ctx: *mut ::core::ffi::c_void,+ len: usize,+ alignment: u8,+ ret_addr: usize,+ ) -> *mut ::core::ffi::c_void,+>;+pub type GhosttyAllocatorResizeFn = ::core::option::Option<+ unsafe extern "C" fn(+ ctx: *mut ::core::ffi::c_void,+ memory: *mut ::core::ffi::c_void,+ memory_len: usize,+ alignment: u8,+ new_len: usize,+ ret_addr: usize,+ ) -> bool,+>;+pub type GhosttyAllocatorRemapFn = ::core::option::Option<+ unsafe extern "C" fn(+ ctx: *mut ::core::ffi::c_void,+ memory: *mut ::core::ffi::c_void,+ memory_len: usize,+ alignment: u8,+ new_len: usize,+ ret_addr: usize,+ ) -> *mut ::core::ffi::c_void,+>;+pub type GhosttyAllocatorFreeFn = ::core::option::Option<+ unsafe extern "C" fn(+ ctx: *mut ::core::ffi::c_void,+ memory: *mut ::core::ffi::c_void,+ memory_len: usize,+ alignment: u8,+ ret_addr: usize,+ ),+>;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyAllocatorVtable {+ pub alloc: GhosttyAllocatorAllocFn,+ pub resize: GhosttyAllocatorResizeFn,+ pub remap: GhosttyAllocatorRemapFn,+ pub free: GhosttyAllocatorFreeFn,+ pub reserved: [*mut ::core::ffi::c_void; 4usize],+}+impl Default for GhosttyAllocatorVtable {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyAllocator {+ pub ctx: *mut ::core::ffi::c_void,+ pub vtable: *const GhosttyAllocatorVtable,+}+impl Default for GhosttyAllocator {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub const GHOSTTY_OPTIMIZE_DEBUG: GhosttyOptimizeMode = 0;+pub const GHOSTTY_OPTIMIZE_RELEASE_SAFE: GhosttyOptimizeMode = 1;+pub const GHOSTTY_OPTIMIZE_RELEASE_SMALL: GhosttyOptimizeMode = 2;+pub const GHOSTTY_OPTIMIZE_RELEASE_FAST: GhosttyOptimizeMode = 3;+pub const GHOSTTY_OPTIMIZE_MODE_MAX_VALUE: GhosttyOptimizeMode = 2147483647;+pub type GhosttyOptimizeMode = ::core::ffi::c_uint;+pub const GHOSTTY_BUILD_INFO_INVALID: GhosttyBuildInfo = 0;+pub const GHOSTTY_BUILD_INFO_SIMD: GhosttyBuildInfo = 1;+pub const GHOSTTY_BUILD_INFO_KITTY_GRAPHICS: GhosttyBuildInfo = 2;+pub const GHOSTTY_BUILD_INFO_TMUX_CONTROL_MODE: GhosttyBuildInfo = 3;+pub const GHOSTTY_BUILD_INFO_OPTIMIZE: GhosttyBuildInfo = 4;+pub const GHOSTTY_BUILD_INFO_VERSION_STRING: GhosttyBuildInfo = 5;+pub const GHOSTTY_BUILD_INFO_VERSION_MAJOR: GhosttyBuildInfo = 6;+pub const GHOSTTY_BUILD_INFO_VERSION_MINOR: GhosttyBuildInfo = 7;+pub const GHOSTTY_BUILD_INFO_VERSION_PATCH: GhosttyBuildInfo = 8;+pub const GHOSTTY_BUILD_INFO_VERSION_PRE: GhosttyBuildInfo = 9;+pub const GHOSTTY_BUILD_INFO_VERSION_BUILD: GhosttyBuildInfo = 10;+pub const GHOSTTY_BUILD_INFO_FEATURE_SNAPSHOT: GhosttyBuildInfo = 11;+pub const GHOSTTY_BUILD_INFO_FEATURE_FORMATTER: GhosttyBuildInfo = 12;+pub const GHOSTTY_BUILD_INFO_FEATURE_SELECTION: GhosttyBuildInfo = 13;+pub const GHOSTTY_BUILD_INFO_FEATURE_SEARCH: GhosttyBuildInfo = 14;+pub const GHOSTTY_BUILD_INFO_FEATURE_RENDER_STATE: GhosttyBuildInfo = 15;+pub const GHOSTTY_BUILD_INFO_FEATURE_INPUT_ENCODE: GhosttyBuildInfo = 16;+pub const GHOSTTY_BUILD_INFO_FEATURE_COLOR: GhosttyBuildInfo = 17;+pub const GHOSTTY_BUILD_INFO_FEATURE_GRID_INTROSPECTION: GhosttyBuildInfo = 18;+pub const GHOSTTY_BUILD_INFO_FEATURE_GLYPH_PROTOCOL: GhosttyBuildInfo = 19;+pub const GHOSTTY_BUILD_INFO_MAX_VALUE: GhosttyBuildInfo = 2147483647;+pub type GhosttyBuildInfo = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyColorRgb {+ pub r: u8,+ pub g: u8,+ pub b: u8,+}+pub type GhosttyColorPaletteIndex = u8;+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyColorPaletteMask {+ pub bits: [u64; 4usize],+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyColorX11Entry {+ pub name: *const ::core::ffi::c_char,+ pub color: GhosttyColorRgb,+}+impl Default for GhosttyColorX11Entry {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub const GHOSTTY_COLOR_SCHEME_LIGHT: GhosttyColorScheme = 0;+pub const GHOSTTY_COLOR_SCHEME_DARK: GhosttyColorScheme = 1;+pub const GHOSTTY_COLOR_SCHEME_MAX_VALUE: GhosttyColorScheme = 2147483647;+pub type GhosttyColorScheme = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyDeviceAttributesPrimary {+ pub conformance_level: u16,+ pub features: [u16; 64usize],+ pub num_features: usize,+}+impl Default for GhosttyDeviceAttributesPrimary {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyDeviceAttributesSecondary {+ pub device_type: u16,+ pub firmware_version: u16,+ pub rom_cartridge: u16,+}+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyDeviceAttributesTertiary {+ pub unit_id: u32,+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyDeviceAttributes {+ pub primary: GhosttyDeviceAttributesPrimary,+ pub secondary: GhosttyDeviceAttributesSecondary,+ pub tertiary: GhosttyDeviceAttributesTertiary,+}+impl Default for GhosttyDeviceAttributes {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub const GHOSTTY_FOCUS_GAINED: GhosttyFocusEvent = 0;+pub const GHOSTTY_FOCUS_LOST: GhosttyFocusEvent = 1;+pub const GHOSTTY_FOCUS_MAX_VALUE: GhosttyFocusEvent = 2147483647;+pub type GhosttyFocusEvent = ::core::ffi::c_uint;+pub type GhosttyReaderFn = ::core::option::Option<+ unsafe extern "C" fn(+ userdata: *mut ::core::ffi::c_void,+ buffer: *mut u8,+ capacity: usize,+ out_read: *mut usize,+ ) -> bool,+>;+pub type GhosttyWriterFn = ::core::option::Option<+ unsafe extern "C" fn(userdata: *mut ::core::ffi::c_void, data: *const u8, len: usize) -> bool,+>;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyReader {+ pub read: GhosttyReaderFn,+ pub userdata: *mut ::core::ffi::c_void,+}+impl Default for GhosttyReader {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyWriter {+ pub write: GhosttyWriterFn,+ pub userdata: *mut ::core::ffi::c_void,+}+impl Default for GhosttyWriter {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyMimeReaderFn = ::core::option::Option<+ unsafe extern "C" fn(+ userdata: *mut ::core::ffi::c_void,+ mime: GhosttyString,+ writer: GhosttyWriter,+ ) -> bool,+>;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyMimeReader {+ pub read: GhosttyMimeReaderFn,+ pub userdata: *mut ::core::ffi::c_void,+}+impl Default for GhosttyMimeReader {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyCell = u64;+pub type GhosttyRow = u64;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyCellsView {+ pub ptr: *const GhosttyCell,+ pub len: usize,+}+impl Default for GhosttyCellsView {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub const GHOSTTY_CELL_CONTENT_CODEPOINT: GhosttyCellContentTag = 0;+pub const GHOSTTY_CELL_CONTENT_CODEPOINT_GRAPHEME: GhosttyCellContentTag = 1;+pub const GHOSTTY_CELL_CONTENT_BG_COLOR_PALETTE: GhosttyCellContentTag = 2;+pub const GHOSTTY_CELL_CONTENT_BG_COLOR_RGB: GhosttyCellContentTag = 3;+pub const GHOSTTY_CELL_CONTENT_TAG_MAX_VALUE: GhosttyCellContentTag = 2147483647;+pub type GhosttyCellContentTag = ::core::ffi::c_uint;+pub const GHOSTTY_CELL_WIDE_NARROW: GhosttyCellWide = 0;+pub const GHOSTTY_CELL_WIDE_WIDE: GhosttyCellWide = 1;+pub const GHOSTTY_CELL_WIDE_SPACER_TAIL: GhosttyCellWide = 2;+pub const GHOSTTY_CELL_WIDE_SPACER_HEAD: GhosttyCellWide = 3;+pub const GHOSTTY_CELL_WIDE_MAX_VALUE: GhosttyCellWide = 2147483647;+pub type GhosttyCellWide = ::core::ffi::c_uint;+pub const GHOSTTY_CELL_SEMANTIC_OUTPUT: GhosttyCellSemanticContent = 0;+pub const GHOSTTY_CELL_SEMANTIC_INPUT: GhosttyCellSemanticContent = 1;+pub const GHOSTTY_CELL_SEMANTIC_PROMPT: GhosttyCellSemanticContent = 2;+pub const GHOSTTY_CELL_SEMANTIC_MAX_VALUE: GhosttyCellSemanticContent = 2147483647;+pub type GhosttyCellSemanticContent = ::core::ffi::c_uint;+pub const GHOSTTY_CELL_DATA_INVALID: GhosttyCellData = 0;+pub const GHOSTTY_CELL_DATA_CODEPOINT: GhosttyCellData = 1;+pub const GHOSTTY_CELL_DATA_CONTENT_TAG: GhosttyCellData = 2;+pub const GHOSTTY_CELL_DATA_WIDE: GhosttyCellData = 3;+pub const GHOSTTY_CELL_DATA_HAS_TEXT: GhosttyCellData = 4;+pub const GHOSTTY_CELL_DATA_HAS_STYLING: GhosttyCellData = 5;+pub const GHOSTTY_CELL_DATA_STYLE_ID: GhosttyCellData = 6;+pub const GHOSTTY_CELL_DATA_HAS_HYPERLINK: GhosttyCellData = 7;+pub const GHOSTTY_CELL_DATA_PROTECTED: GhosttyCellData = 8;+pub const GHOSTTY_CELL_DATA_SEMANTIC_CONTENT: GhosttyCellData = 9;+pub const GHOSTTY_CELL_DATA_COLOR_PALETTE: GhosttyCellData = 10;+pub const GHOSTTY_CELL_DATA_COLOR_RGB: GhosttyCellData = 11;+pub const GHOSTTY_CELL_DATA_MAX_VALUE: GhosttyCellData = 2147483647;+pub type GhosttyCellData = ::core::ffi::c_uint;+pub const GHOSTTY_ROW_SEMANTIC_NONE: GhosttyRowSemanticPrompt = 0;+pub const GHOSTTY_ROW_SEMANTIC_PROMPT: GhosttyRowSemanticPrompt = 1;+pub const GHOSTTY_ROW_SEMANTIC_PROMPT_CONTINUATION: GhosttyRowSemanticPrompt = 2;+pub const GHOSTTY_ROW_SEMANTIC_MAX_VALUE: GhosttyRowSemanticPrompt = 2147483647;+pub type GhosttyRowSemanticPrompt = ::core::ffi::c_uint;+pub const GHOSTTY_ROW_DATA_INVALID: GhosttyRowData = 0;+pub const GHOSTTY_ROW_DATA_WRAP: GhosttyRowData = 1;+pub const GHOSTTY_ROW_DATA_WRAP_CONTINUATION: GhosttyRowData = 2;+pub const GHOSTTY_ROW_DATA_GRAPHEME: GhosttyRowData = 3;+pub const GHOSTTY_ROW_DATA_STYLED: GhosttyRowData = 4;+pub const GHOSTTY_ROW_DATA_HYPERLINK: GhosttyRowData = 5;+pub const GHOSTTY_ROW_DATA_SEMANTIC_PROMPT: GhosttyRowData = 6;+pub const GHOSTTY_ROW_DATA_KITTY_VIRTUAL_PLACEHOLDER: GhosttyRowData = 7;+pub const GHOSTTY_ROW_DATA_DIRTY: GhosttyRowData = 8;+pub const GHOSTTY_ROW_DATA_MAX_VALUE: GhosttyRowData = 2147483647;+pub type GhosttyRowData = ::core::ffi::c_uint;+pub type GhosttyStyleId = u16;+pub const GHOSTTY_STYLE_COLOR_NONE: GhosttyStyleColorTag = 0;+pub const GHOSTTY_STYLE_COLOR_PALETTE: GhosttyStyleColorTag = 1;+pub const GHOSTTY_STYLE_COLOR_RGB: GhosttyStyleColorTag = 2;+pub const GHOSTTY_STYLE_COLOR_TAG_MAX_VALUE: GhosttyStyleColorTag = 2147483647;+pub type GhosttyStyleColorTag = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Copy, Clone)]+pub union GhosttyStyleColorValue {+ pub palette: GhosttyColorPaletteIndex,+ pub rgb: GhosttyColorRgb,+}+impl Default for GhosttyStyleColorValue {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Copy, Clone)]+pub struct GhosttyStyleColor {+ pub tag: u8,+ pub value: GhosttyStyleColorValue,+}+impl Default for GhosttyStyleColor {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyStyleFlags = u16;+#[repr(C)]+#[derive(Copy, Clone)]+pub struct GhosttyStyle {+ pub fg_color: GhosttyStyleColor,+ pub bg_color: GhosttyStyleColor,+ pub underline_color: GhosttyStyleColor,+ pub flags: GhosttyStyleFlags,+ pub reserved: u16,+}+impl Default for GhosttyStyle {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyGridRef {+ pub node: *mut ::core::ffi::c_void,+ pub x: u16,+ pub y: u16,+}+impl Default for GhosttyGridRef {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyPointCoordinate {+ pub x: u16,+ pub y: u32,+}+pub const GHOSTTY_POINT_TAG_ACTIVE: GhosttyPointTag = 0;+pub const GHOSTTY_POINT_TAG_VIEWPORT: GhosttyPointTag = 1;+pub const GHOSTTY_POINT_TAG_SCREEN: GhosttyPointTag = 2;+pub const GHOSTTY_POINT_TAG_HISTORY: GhosttyPointTag = 3;+pub const GHOSTTY_POINT_TAG_MAX_VALUE: GhosttyPointTag = 2147483647;+pub type GhosttyPointTag = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Copy, Clone)]+pub union GhosttyPointValue {+ pub coordinate: GhosttyPointCoordinate,+ pub _padding: [u64; 2usize],+}+impl Default for GhosttyPointValue {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Copy, Clone)]+pub struct GhosttyPoint {+ pub tag: GhosttyPointTag,+ pub value: GhosttyPointValue,+}+impl Default for GhosttyPoint {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttySelectionGestureImpl {+ _unused: [u8; 0],+}+pub type GhosttySelectionGesture = *mut GhosttySelectionGestureImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttySelectionGestureEventImpl {+ _unused: [u8; 0],+}+pub type GhosttySelectionGestureEvent = *mut GhosttySelectionGestureEventImpl;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttySelection {+ pub start: GhosttyGridRef,+ pub end: GhosttyGridRef,+ pub rectangle: bool,+}+impl Default for GhosttySelection {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttySelectionBuffer {+ pub ptr: *mut GhosttySelection,+ pub cap: usize,+ pub len: usize,+}+impl Default for GhosttySelectionBuffer {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalSelectWordOptions {+ pub size: usize,+ pub ref_: GhosttyGridRef,+ pub boundary_codepoints: *const u32,+ pub boundary_codepoints_len: usize,+}+impl Default for GhosttyTerminalSelectWordOptions {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalSelectWordBetweenOptions {+ pub size: usize,+ pub start: GhosttyGridRef,+ pub end: GhosttyGridRef,+ pub boundary_codepoints: *const u32,+ pub boundary_codepoints_len: usize,+}+impl Default for GhosttyTerminalSelectWordBetweenOptions {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalSelectLineOptions {+ pub size: usize,+ pub ref_: GhosttyGridRef,+ pub whitespace: *const u32,+ pub whitespace_len: usize,+ pub semantic_prompt_boundary: bool,+}+impl Default for GhosttyTerminalSelectLineOptions {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub const GHOSTTY_SELECTION_ORDER_FORWARD: GhosttySelectionOrder = 0;+pub const GHOSTTY_SELECTION_ORDER_REVERSE: GhosttySelectionOrder = 1;+pub const GHOSTTY_SELECTION_ORDER_MIRRORED_FORWARD: GhosttySelectionOrder = 2;+pub const GHOSTTY_SELECTION_ORDER_MIRRORED_REVERSE: GhosttySelectionOrder = 3;+pub const GHOSTTY_SELECTION_ORDER_MAX_VALUE: GhosttySelectionOrder = 2147483647;+pub type GhosttySelectionOrder = ::core::ffi::c_uint;+pub const GHOSTTY_SELECTION_ADJUST_LEFT: GhosttySelectionAdjust = 0;+pub const GHOSTTY_SELECTION_ADJUST_RIGHT: GhosttySelectionAdjust = 1;+pub const GHOSTTY_SELECTION_ADJUST_UP: GhosttySelectionAdjust = 2;+pub const GHOSTTY_SELECTION_ADJUST_DOWN: GhosttySelectionAdjust = 3;+pub const GHOSTTY_SELECTION_ADJUST_HOME: GhosttySelectionAdjust = 4;+pub const GHOSTTY_SELECTION_ADJUST_END: GhosttySelectionAdjust = 5;+pub const GHOSTTY_SELECTION_ADJUST_PAGE_UP: GhosttySelectionAdjust = 6;+pub const GHOSTTY_SELECTION_ADJUST_PAGE_DOWN: GhosttySelectionAdjust = 7;+pub const GHOSTTY_SELECTION_ADJUST_BEGINNING_OF_LINE: GhosttySelectionAdjust = 8;+pub const GHOSTTY_SELECTION_ADJUST_END_OF_LINE: GhosttySelectionAdjust = 9;+pub const GHOSTTY_SELECTION_ADJUST_MAX_VALUE: GhosttySelectionAdjust = 2147483647;+pub type GhosttySelectionAdjust = ::core::ffi::c_uint;+pub const GHOSTTY_SELECTION_GESTURE_BEHAVIOR_CELL: GhosttySelectionGestureBehavior = 0;+pub const GHOSTTY_SELECTION_GESTURE_BEHAVIOR_WORD: GhosttySelectionGestureBehavior = 1;+pub const GHOSTTY_SELECTION_GESTURE_BEHAVIOR_LINE: GhosttySelectionGestureBehavior = 2;+pub const GHOSTTY_SELECTION_GESTURE_BEHAVIOR_OUTPUT: GhosttySelectionGestureBehavior = 3;+pub const GHOSTTY_SELECTION_GESTURE_BEHAVIOR_MAX_VALUE: GhosttySelectionGestureBehavior =+ 2147483647;+pub type GhosttySelectionGestureBehavior = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttySelectionGestureBehaviors {+ pub single_click: GhosttySelectionGestureBehavior,+ pub double_click: GhosttySelectionGestureBehavior,+ pub triple_click: GhosttySelectionGestureBehavior,+}+impl Default for GhosttySelectionGestureBehaviors {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttySelectionGestureGeometry {+ pub columns: u32,+ pub cell_width: u32,+ pub padding_left: u32,+ pub screen_height: u32,+}+pub const GHOSTTY_SELECTION_GESTURE_AUTOSCROLL_NONE: GhosttySelectionGestureAutoscroll = 0;+pub const GHOSTTY_SELECTION_GESTURE_AUTOSCROLL_UP: GhosttySelectionGestureAutoscroll = 1;+pub const GHOSTTY_SELECTION_GESTURE_AUTOSCROLL_DOWN: GhosttySelectionGestureAutoscroll = 2;+pub const GHOSTTY_SELECTION_GESTURE_AUTOSCROLL_MAX_VALUE: GhosttySelectionGestureAutoscroll =+ 2147483647;+pub type GhosttySelectionGestureAutoscroll = ::core::ffi::c_uint;+pub const GHOSTTY_SELECTION_GESTURE_DATA_INVALID: GhosttySelectionGestureData = 0;+pub const GHOSTTY_SELECTION_GESTURE_DATA_CLICK_COUNT: GhosttySelectionGestureData = 1;+pub const GHOSTTY_SELECTION_GESTURE_DATA_DRAGGED: GhosttySelectionGestureData = 2;+pub const GHOSTTY_SELECTION_GESTURE_DATA_AUTOSCROLL: GhosttySelectionGestureData = 3;+pub const GHOSTTY_SELECTION_GESTURE_DATA_BEHAVIOR: GhosttySelectionGestureData = 4;+pub const GHOSTTY_SELECTION_GESTURE_DATA_ANCHOR: GhosttySelectionGestureData = 5;+pub const GHOSTTY_SELECTION_GESTURE_DATA_MAX_VALUE: GhosttySelectionGestureData = 2147483647;+pub type GhosttySelectionGestureData = ::core::ffi::c_uint;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_PRESS: GhosttySelectionGestureEventType = 0;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_RELEASE: GhosttySelectionGestureEventType = 1;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_DRAG: GhosttySelectionGestureEventType = 2;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_AUTOSCROLL_TICK: GhosttySelectionGestureEventType =+ 3;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_DEEP_PRESS: GhosttySelectionGestureEventType = 4;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_MAX_VALUE: GhosttySelectionGestureEventType =+ 2147483647;+pub type GhosttySelectionGestureEventType = ::core::ffi::c_uint;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_INVALID: GhosttySelectionGestureEventOption = 0;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_REF: GhosttySelectionGestureEventOption = 1;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_POSITION: GhosttySelectionGestureEventOption = 2;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_REPEAT_DISTANCE: GhosttySelectionGestureEventOption =+ 3;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_TIME_NS: GhosttySelectionGestureEventOption = 4;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_REPEAT_INTERVAL_NS:+ GhosttySelectionGestureEventOption = 5;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_WORD_BOUNDARY_CODEPOINTS:+ GhosttySelectionGestureEventOption = 6;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_BEHAVIORS: GhosttySelectionGestureEventOption = 7;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_RECTANGLE: GhosttySelectionGestureEventOption = 8;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_GEOMETRY: GhosttySelectionGestureEventOption = 9;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_VIEWPORT: GhosttySelectionGestureEventOption = 10;+pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_MAX_VALUE: GhosttySelectionGestureEventOption =+ 2147483647;+pub type GhosttySelectionGestureEventOption = ::core::ffi::c_uint;+pub type GhosttyMode = u16;+pub const GHOSTTY_MODE_REPORT_NOT_RECOGNIZED: GhosttyModeReportState = 0;+pub const GHOSTTY_MODE_REPORT_SET: GhosttyModeReportState = 1;+pub const GHOSTTY_MODE_REPORT_RESET: GhosttyModeReportState = 2;+pub const GHOSTTY_MODE_REPORT_PERMANENTLY_SET: GhosttyModeReportState = 3;+pub const GHOSTTY_MODE_REPORT_PERMANENTLY_RESET: GhosttyModeReportState = 4;+pub const GHOSTTY_MODE_REPORT_MAX_VALUE: GhosttyModeReportState = 2147483647;+pub type GhosttyModeReportState = ::core::ffi::c_uint;+pub const GHOSTTY_OSC_COMMAND_INVALID: GhosttyOscCommandType = 0;+pub const GHOSTTY_OSC_COMMAND_CHANGE_WINDOW_TITLE: GhosttyOscCommandType = 1;+pub const GHOSTTY_OSC_COMMAND_CHANGE_WINDOW_ICON: GhosttyOscCommandType = 2;+pub const GHOSTTY_OSC_COMMAND_SEMANTIC_PROMPT: GhosttyOscCommandType = 3;+pub const GHOSTTY_OSC_COMMAND_CLIPBOARD_CONTENTS: GhosttyOscCommandType = 4;+pub const GHOSTTY_OSC_COMMAND_REPORT_PWD: GhosttyOscCommandType = 5;+pub const GHOSTTY_OSC_COMMAND_MOUSE_SHAPE: GhosttyOscCommandType = 6;+pub const GHOSTTY_OSC_COMMAND_COLOR_OPERATION: GhosttyOscCommandType = 7;+pub const GHOSTTY_OSC_COMMAND_KITTY_COLOR_PROTOCOL: GhosttyOscCommandType = 8;+pub const GHOSTTY_OSC_COMMAND_SHOW_DESKTOP_NOTIFICATION: GhosttyOscCommandType = 9;+pub const GHOSTTY_OSC_COMMAND_HYPERLINK_START: GhosttyOscCommandType = 10;+pub const GHOSTTY_OSC_COMMAND_HYPERLINK_END: GhosttyOscCommandType = 11;+pub const GHOSTTY_OSC_COMMAND_CONEMU_SLEEP: GhosttyOscCommandType = 12;+pub const GHOSTTY_OSC_COMMAND_CONEMU_SHOW_MESSAGE_BOX: GhosttyOscCommandType = 13;+pub const GHOSTTY_OSC_COMMAND_CONEMU_CHANGE_TAB_TITLE: GhosttyOscCommandType = 14;+pub const GHOSTTY_OSC_COMMAND_CONEMU_PROGRESS_REPORT: GhosttyOscCommandType = 15;+pub const GHOSTTY_OSC_COMMAND_CONEMU_WAIT_INPUT: GhosttyOscCommandType = 16;+pub const GHOSTTY_OSC_COMMAND_CONEMU_GUIMACRO: GhosttyOscCommandType = 17;+pub const GHOSTTY_OSC_COMMAND_CONEMU_RUN_PROCESS: GhosttyOscCommandType = 18;+pub const GHOSTTY_OSC_COMMAND_CONEMU_OUTPUT_ENVIRONMENT_VARIABLE: GhosttyOscCommandType = 19;+pub const GHOSTTY_OSC_COMMAND_CONEMU_XTERM_EMULATION: GhosttyOscCommandType = 20;+pub const GHOSTTY_OSC_COMMAND_CONEMU_COMMENT: GhosttyOscCommandType = 21;+pub const GHOSTTY_OSC_COMMAND_KITTY_TEXT_SIZING: GhosttyOscCommandType = 22;+pub const GHOSTTY_OSC_COMMAND_KITTY_CLIPBOARD_PROTOCOL: GhosttyOscCommandType = 23;+pub const GHOSTTY_OSC_COMMAND_KITTY_DND_PROTOCOL: GhosttyOscCommandType = 24;+pub const GHOSTTY_OSC_COMMAND_HIERARCHICAL_CONTEXT: GhosttyOscCommandType = 25;+pub const GHOSTTY_OSC_COMMAND_KITTY_DESKTOP_NOTIFICATION: GhosttyOscCommandType = 26;+pub const GHOSTTY_OSC_COMMAND_UNKNOWN: GhosttyOscCommandType = 27;+pub const GHOSTTY_OSC_COMMAND_PROGRAM_STATUS: GhosttyOscCommandType = 28;+pub const GHOSTTY_OSC_COMMAND_TYPE_MAX_VALUE: GhosttyOscCommandType = 2147483647;+pub type GhosttyOscCommandType = ::core::ffi::c_uint;+pub const GHOSTTY_OSC_TERMINATOR_ST: GhosttyOscTerminator = 0;+pub const GHOSTTY_OSC_TERMINATOR_BEL: GhosttyOscTerminator = 1;+pub const GHOSTTY_OSC_TERMINATOR_MAX_VALUE: GhosttyOscTerminator = 2147483647;+pub type GhosttyOscTerminator = ::core::ffi::c_uint;+pub const GHOSTTY_OSC_OPT_INVALID: GhosttyOscOption = 0;+pub const GHOSTTY_OSC_OPT_UNKNOWN_MAX_BYTES: GhosttyOscOption = 1;+pub const GHOSTTY_OSC_OPT_MAX_VALUE: GhosttyOscOption = 2147483647;+pub type GhosttyOscOption = ::core::ffi::c_uint;+pub const GHOSTTY_OSC_DATA_INVALID: GhosttyOscCommandData = 0;+pub const GHOSTTY_OSC_DATA_CHANGE_WINDOW_TITLE_STR: GhosttyOscCommandData = 1;+pub const GHOSTTY_OSC_DATA_UNKNOWN_CONTENT: GhosttyOscCommandData = 2;+pub const GHOSTTY_OSC_DATA_UNKNOWN_TRUNCATED: GhosttyOscCommandData = 3;+pub const GHOSTTY_OSC_DATA_UNKNOWN_TERMINATOR: GhosttyOscCommandData = 4;+pub const GHOSTTY_OSC_DATA_MAX_VALUE: GhosttyOscCommandData = 2147483647;+pub type GhosttyOscCommandData = ::core::ffi::c_uint;+pub const GHOSTTY_SIZE_REPORT_MODE_2048: GhosttySizeReportStyle = 0;+pub const GHOSTTY_SIZE_REPORT_CSI_14_T: GhosttySizeReportStyle = 1;+pub const GHOSTTY_SIZE_REPORT_CSI_16_T: GhosttySizeReportStyle = 2;+pub const GHOSTTY_SIZE_REPORT_CSI_18_T: GhosttySizeReportStyle = 3;+pub const GHOSTTY_SIZE_REPORT_CSI_19_T: GhosttySizeReportStyle = 4;+pub const GHOSTTY_SIZE_REPORT_STYLE_MAX_VALUE: GhosttySizeReportStyle = 2147483647;+pub type GhosttySizeReportStyle = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttySizeReportSize {+ pub rows: u16,+ pub columns: u16,+ pub cell_width: u32,+ pub cell_height: u32,+}+pub const GHOSTTY_KITTY_GRAPHICS_DATA_INVALID: GhosttyKittyGraphicsData = 0;+pub const GHOSTTY_KITTY_GRAPHICS_DATA_PLACEMENT_ITERATOR: GhosttyKittyGraphicsData = 1;+pub const GHOSTTY_KITTY_GRAPHICS_DATA_GENERATION: GhosttyKittyGraphicsData = 2;+pub const GHOSTTY_KITTY_GRAPHICS_DATA_MAX_VALUE: GhosttyKittyGraphicsData = 2147483647;+pub type GhosttyKittyGraphicsData = ::core::ffi::c_uint;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_INVALID: GhosttyKittyGraphicsPlacementData = 0;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_IMAGE_ID: GhosttyKittyGraphicsPlacementData = 1;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_PLACEMENT_ID: GhosttyKittyGraphicsPlacementData = 2;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_IS_VIRTUAL: GhosttyKittyGraphicsPlacementData = 3;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_X_OFFSET: GhosttyKittyGraphicsPlacementData = 4;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_Y_OFFSET: GhosttyKittyGraphicsPlacementData = 5;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_X: GhosttyKittyGraphicsPlacementData = 6;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_Y: GhosttyKittyGraphicsPlacementData = 7;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_WIDTH: GhosttyKittyGraphicsPlacementData = 8;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_HEIGHT: GhosttyKittyGraphicsPlacementData =+ 9;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_COLUMNS: GhosttyKittyGraphicsPlacementData = 10;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_ROWS: GhosttyKittyGraphicsPlacementData = 11;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_Z: GhosttyKittyGraphicsPlacementData = 12;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_MAX_VALUE: GhosttyKittyGraphicsPlacementData =+ 2147483647;+pub type GhosttyKittyGraphicsPlacementData = ::core::ffi::c_uint;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_ITERATOR_OPT_INVALID:+ GhosttyKittyGraphicsPlacementIteratorOption = 0;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_ITERATOR_OPT_LAYER:+ GhosttyKittyGraphicsPlacementIteratorOption = 1;+pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_ITERATOR_OPT_MAX_VALUE:+ GhosttyKittyGraphicsPlacementIteratorOption = 2147483647;+pub type GhosttyKittyGraphicsPlacementIteratorOption = ::core::ffi::c_uint;+pub const GHOSTTY_KITTY_IMAGE_FORMAT_RGB: GhosttyKittyImageFormat = 0;+pub const GHOSTTY_KITTY_IMAGE_FORMAT_RGBA: GhosttyKittyImageFormat = 1;+pub const GHOSTTY_KITTY_IMAGE_FORMAT_PNG: GhosttyKittyImageFormat = 2;+pub const GHOSTTY_KITTY_IMAGE_FORMAT_GRAY_ALPHA: GhosttyKittyImageFormat = 3;+pub const GHOSTTY_KITTY_IMAGE_FORMAT_GRAY: GhosttyKittyImageFormat = 4;+pub const GHOSTTY_KITTY_IMAGE_FORMAT_MAX_VALUE: GhosttyKittyImageFormat = 2147483647;+pub type GhosttyKittyImageFormat = ::core::ffi::c_uint;+pub const GHOSTTY_KITTY_IMAGE_COMPRESSION_NONE: GhosttyKittyImageCompression = 0;+pub const GHOSTTY_KITTY_IMAGE_COMPRESSION_ZLIB_DEFLATE: GhosttyKittyImageCompression = 1;+pub const GHOSTTY_KITTY_IMAGE_COMPRESSION_MAX_VALUE: GhosttyKittyImageCompression = 2147483647;+pub type GhosttyKittyImageCompression = ::core::ffi::c_uint;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_INVALID: GhosttyKittyGraphicsImageData = 0;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_ID: GhosttyKittyGraphicsImageData = 1;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_NUMBER: GhosttyKittyGraphicsImageData = 2;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_WIDTH: GhosttyKittyGraphicsImageData = 3;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_HEIGHT: GhosttyKittyGraphicsImageData = 4;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_FORMAT: GhosttyKittyGraphicsImageData = 5;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_COMPRESSION: GhosttyKittyGraphicsImageData = 6;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_PIXELS: GhosttyKittyGraphicsImageData = 7;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_EXPECTED_LEN: GhosttyKittyGraphicsImageData = 8;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_GENERATION: GhosttyKittyGraphicsImageData = 9;+pub const GHOSTTY_KITTY_GRAPHICS_IMAGE_DATA_MAX_VALUE: GhosttyKittyGraphicsImageData = 2147483647;+pub type GhosttyKittyGraphicsImageData = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyKittyGraphicsPlacementRenderInfo {+ pub size: usize,+ pub pixel_width: u32,+ pub pixel_height: u32,+ pub grid_cols: u32,+ pub grid_rows: u32,+ pub viewport_col: i32,+ pub viewport_row: i32,+ pub viewport_visible: bool,+ pub source_x: u32,+ pub source_y: u32,+ pub source_width: u32,+ pub source_height: u32,+}+pub const GHOSTTY_TERMINAL_COMPRESSION_MODE_INCREMENTAL: GhosttyTerminalCompressionMode = 0;+pub const GHOSTTY_TERMINAL_COMPRESSION_MODE_FULL: GhosttyTerminalCompressionMode = 1;+pub const GHOSTTY_TERMINAL_COMPRESSION_MODE_MAX_VALUE: GhosttyTerminalCompressionMode = 2147483647;+pub type GhosttyTerminalCompressionMode = ::core::ffi::c_uint;+pub const GHOSTTY_TERMINAL_COMPRESSION_RESULT_UNSUPPORTED: GhosttyTerminalCompressionResult = 0;+pub const GHOSTTY_TERMINAL_COMPRESSION_RESULT_PENDING: GhosttyTerminalCompressionResult = 1;+pub const GHOSTTY_TERMINAL_COMPRESSION_RESULT_COMPLETE: GhosttyTerminalCompressionResult = 2;+pub const GHOSTTY_TERMINAL_COMPRESSION_RESULT_MAX_VALUE: GhosttyTerminalCompressionResult =+ 2147483647;+pub type GhosttyTerminalCompressionResult = ::core::ffi::c_uint;+pub const GHOSTTY_TERMINAL_SCROLL_VIEWPORT_TOP: GhosttyTerminalScrollViewportTag = 0;+pub const GHOSTTY_TERMINAL_SCROLL_VIEWPORT_BOTTOM: GhosttyTerminalScrollViewportTag = 1;+pub const GHOSTTY_TERMINAL_SCROLL_VIEWPORT_DELTA: GhosttyTerminalScrollViewportTag = 2;+pub const GHOSTTY_TERMINAL_SCROLL_VIEWPORT_ROW: GhosttyTerminalScrollViewportTag = 3;+pub const GHOSTTY_TERMINAL_SCROLL_VIEWPORT_DELTA_PROMPT: GhosttyTerminalScrollViewportTag = 4;+pub const GHOSTTY_TERMINAL_SCROLL_VIEWPORT_MAX_VALUE: GhosttyTerminalScrollViewportTag = 2147483647;+pub type GhosttyTerminalScrollViewportTag = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Copy, Clone)]+pub union GhosttyTerminalScrollViewportValue {+ pub delta: isize,+ pub row: usize,+ pub delta_prompt: isize,+ pub _padding: [u64; 2usize],+}+impl Default for GhosttyTerminalScrollViewportValue {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Copy, Clone)]+pub struct GhosttyTerminalScrollViewport {+ pub tag: GhosttyTerminalScrollViewportTag,+ pub value: GhosttyTerminalScrollViewportValue,+}+impl Default for GhosttyTerminalScrollViewport {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub const GHOSTTY_TERMINAL_SCREEN_PRIMARY: GhosttyTerminalScreen = 0;+pub const GHOSTTY_TERMINAL_SCREEN_ALTERNATE: GhosttyTerminalScreen = 1;+pub const GHOSTTY_TERMINAL_SCREEN_MAX_VALUE: GhosttyTerminalScreen = 2147483647;+pub type GhosttyTerminalScreen = ::core::ffi::c_uint;+pub const GHOSTTY_TERMINAL_BOUNDARY_GROUND: GhosttyTerminalBoundary = 1;+pub const GHOSTTY_TERMINAL_BOUNDARY_APC_START: GhosttyTerminalBoundary = 2;+pub const GHOSTTY_TERMINAL_BOUNDARY_APC_END: GhosttyTerminalBoundary = 4;+pub const GHOSTTY_TERMINAL_BOUNDARY_DCS_START: GhosttyTerminalBoundary = 8;+pub const GHOSTTY_TERMINAL_BOUNDARY_DCS_END: GhosttyTerminalBoundary = 16;+pub const GHOSTTY_TERMINAL_BOUNDARY_OSC_START: GhosttyTerminalBoundary = 32;+pub const GHOSTTY_TERMINAL_BOUNDARY_OSC_END: GhosttyTerminalBoundary = 64;+pub const GHOSTTY_TERMINAL_BOUNDARY_MAX_VALUE: GhosttyTerminalBoundary = 2147483647;+pub type GhosttyTerminalBoundary = ::core::ffi::c_uint;+pub const GHOSTTY_TERMINAL_STRING_KIND_APC: GhosttyTerminalStringKind = 0;+pub const GHOSTTY_TERMINAL_STRING_KIND_DCS: GhosttyTerminalStringKind = 1;+pub const GHOSTTY_TERMINAL_STRING_KIND_OSC: GhosttyTerminalStringKind = 2;+pub const GHOSTTY_TERMINAL_STRING_KIND_MAX_VALUE: GhosttyTerminalStringKind = 2147483647;+pub type GhosttyTerminalStringKind = ::core::ffi::c_uint;+pub const GHOSTTY_TERMINAL_STRING_INTRODUCER_ESC: GhosttyTerminalStringIntroducer = 0;+pub const GHOSTTY_TERMINAL_STRING_INTRODUCER_C1: GhosttyTerminalStringIntroducer = 1;+pub const GHOSTTY_TERMINAL_STRING_INTRODUCER_MAX_VALUE: GhosttyTerminalStringIntroducer =+ 2147483647;+pub type GhosttyTerminalStringIntroducer = ::core::ffi::c_uint;+pub const GHOSTTY_TERMINAL_STRING_END_ST_ESC: GhosttyTerminalStringEnd = 0;+pub const GHOSTTY_TERMINAL_STRING_END_ST_C1: GhosttyTerminalStringEnd = 1;+pub const GHOSTTY_TERMINAL_STRING_END_CANCELLED: GhosttyTerminalStringEnd = 2;+pub const GHOSTTY_TERMINAL_STRING_END_ABORTED: GhosttyTerminalStringEnd = 3;+pub const GHOSTTY_TERMINAL_STRING_END_BEL: GhosttyTerminalStringEnd = 4;+pub const GHOSTTY_TERMINAL_STRING_END_MAX_VALUE: GhosttyTerminalStringEnd = 2147483647;+pub type GhosttyTerminalStringEnd = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalWriteStop {+ pub size: usize,+ pub consumed: usize,+ pub reached: u32,+ pub kind: GhosttyTerminalStringKind,+ pub introducer: GhosttyTerminalStringIntroducer,+ pub end: GhosttyTerminalStringEnd,+ pub byte: u8,+}+impl Default for GhosttyTerminalWriteStop {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyTerminalScrollbar {+ pub total: u64,+ pub offset: u64,+ pub len: u64,+}+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyTerminalMemoryUsage {+ pub size: usize,+ pub compression_supported: bool,+ pub primary_pages: u64,+ pub primary_virtual_bytes: u64,+ pub primary_resident_bytes: u64,+ pub primary_compressed_pages: u64,+ pub primary_compressed_bytes: u64,+ pub primary_image_bytes: u64,+ pub alternate_pages: u64,+ pub alternate_virtual_bytes: u64,+ pub alternate_resident_bytes: u64,+ pub alternate_compressed_pages: u64,+ pub alternate_compressed_bytes: u64,+ pub alternate_image_bytes: u64,+}+pub type GhosttyTerminalBellFn = ::core::option::Option<+ unsafe extern "C" fn(terminal: GhosttyTerminal, userdata: *mut ::core::ffi::c_void),+>;+pub const GHOSTTY_TERMINAL_UNKNOWN_SEQUENCE_APC: GhosttyTerminalUnknownSequenceTag = 0;+pub const GHOSTTY_TERMINAL_UNKNOWN_SEQUENCE_OSC: GhosttyTerminalUnknownSequenceTag = 1;+pub const GHOSTTY_TERMINAL_UNKNOWN_SEQUENCE_MAX_VALUE: GhosttyTerminalUnknownSequenceTag =+ 2147483647;+pub type GhosttyTerminalUnknownSequenceTag = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalUnknownStringSequence {+ pub truncated: bool,+ pub content: GhosttyString,+}+impl Default for GhosttyTerminalUnknownStringSequence {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalUnknownOscSequence {+ pub truncated: bool,+ pub content: GhosttyString,+ pub terminator: GhosttyOscTerminator,+}+impl Default for GhosttyTerminalUnknownOscSequence {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Copy, Clone)]+pub union GhosttyTerminalUnknownSequenceValue {+ pub apc: GhosttyTerminalUnknownStringSequence,+ pub osc: GhosttyTerminalUnknownOscSequence,+ pub _padding: [u64; 16usize],+}+impl Default for GhosttyTerminalUnknownSequenceValue {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Copy, Clone)]+pub struct GhosttyTerminalUnknownSequence {+ pub tag: GhosttyTerminalUnknownSequenceTag,+ pub value: GhosttyTerminalUnknownSequenceValue,+}+impl Default for GhosttyTerminalUnknownSequence {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyTerminalUnknownSequenceFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ sequence: *const GhosttyTerminalUnknownSequence,+ ),+>;+pub const GHOSTTY_CLIPBOARD_LOCATION_STANDARD: GhosttyClipboardLocation = 0;+pub const GHOSTTY_CLIPBOARD_LOCATION_SELECTION: GhosttyClipboardLocation = 1;+pub const GHOSTTY_CLIPBOARD_LOCATION_PRIMARY: GhosttyClipboardLocation = 2;+pub const GHOSTTY_CLIPBOARD_LOCATION_MAX_VALUE: GhosttyClipboardLocation = 2147483647;+pub type GhosttyClipboardLocation = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyClipboardContent {+ pub mime: GhosttyString,+ pub data: GhosttyString,+}+impl Default for GhosttyClipboardContent {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_SUCCESS: GhosttyClipboardWriteResult = 0;+pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_DENIED: GhosttyClipboardWriteResult = 1;+pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_UNSUPPORTED: GhosttyClipboardWriteResult = 2;+pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_BUSY: GhosttyClipboardWriteResult = 3;+pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_INVALID_DATA: GhosttyClipboardWriteResult = 4;+pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_IO_ERROR: GhosttyClipboardWriteResult = 5;+pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_MAX_VALUE: GhosttyClipboardWriteResult = 2147483647;+pub type GhosttyClipboardWriteResult = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyClipboardWriteReply {+ pub size: usize,+ pub result: GhosttyClipboardWriteResult,+ pub remember: bool,+}+impl Default for GhosttyClipboardWriteReply {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyClipboardWriteReplyFn = ::core::option::Option<+ unsafe extern "C" fn(+ write: *const GhosttyClipboardWrite,+ reply: *const GhosttyClipboardWriteReply,+ ),+>;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyClipboardWrite {+ pub location: GhosttyClipboardLocation,+ pub contents: *const GhosttyClipboardContent,+ pub contents_len: usize,+ pub name: GhosttyString,+ pub granted: bool,+ pub can_remember: bool,+ pub ctx: *const ::core::ffi::c_void,+ pub reply: GhosttyClipboardWriteReplyFn,+}+impl Default for GhosttyClipboardWrite {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyTerminalClipboardWriteFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ write: *const GhosttyClipboardWrite,+ ),+>;+pub const GHOSTTY_CLIPBOARD_READ_RESULT_SUCCESS: GhosttyClipboardReadResult = 0;+pub const GHOSTTY_CLIPBOARD_READ_RESULT_DENIED: GhosttyClipboardReadResult = 1;+pub const GHOSTTY_CLIPBOARD_READ_RESULT_UNSUPPORTED: GhosttyClipboardReadResult = 2;+pub const GHOSTTY_CLIPBOARD_READ_RESULT_BUSY: GhosttyClipboardReadResult = 3;+pub const GHOSTTY_CLIPBOARD_READ_RESULT_IO_ERROR: GhosttyClipboardReadResult = 4;+pub const GHOSTTY_CLIPBOARD_READ_RESULT_MAX_VALUE: GhosttyClipboardReadResult = 2147483647;+pub type GhosttyClipboardReadResult = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyClipboardReadReply {+ pub size: usize,+ pub result: GhosttyClipboardReadResult,+ pub contents: *const GhosttyClipboardContent,+ pub contents_len: usize,+ pub available: *const GhosttyString,+ pub available_len: usize,+ pub remember: bool,+}+impl Default for GhosttyClipboardReadReply {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyClipboardReadReplyFn = ::core::option::Option<+ unsafe extern "C" fn(+ read: *const GhosttyClipboardRead,+ reply: *const GhosttyClipboardReadReply,+ ),+>;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyClipboardRead {+ pub location: GhosttyClipboardLocation,+ pub mimes: *const GhosttyString,+ pub mimes_len: usize,+ pub list: bool,+ pub name: GhosttyString,+ pub granted: bool,+ pub can_remember: bool,+ pub ctx: *const ::core::ffi::c_void,+ pub reply: GhosttyClipboardReadReplyFn,+}+impl Default for GhosttyClipboardRead {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyTerminalClipboardReadFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ read: *const GhosttyClipboardRead,+ ),+>;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalDesktopNotification {+ pub title: GhosttyString,+ pub body: GhosttyString,+}+impl Default for GhosttyTerminalDesktopNotification {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyTerminalDesktopNotificationFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ notification: *const GhosttyTerminalDesktopNotification,+ ),+>;+pub const GHOSTTY_TERMINAL_PROGRESS_STATE_REMOVE: GhosttyTerminalProgressState = 0;+pub const GHOSTTY_TERMINAL_PROGRESS_STATE_SET: GhosttyTerminalProgressState = 1;+pub const GHOSTTY_TERMINAL_PROGRESS_STATE_ERROR: GhosttyTerminalProgressState = 2;+pub const GHOSTTY_TERMINAL_PROGRESS_STATE_INDETERMINATE: GhosttyTerminalProgressState = 3;+pub const GHOSTTY_TERMINAL_PROGRESS_STATE_PAUSE: GhosttyTerminalProgressState = 4;+pub const GHOSTTY_TERMINAL_PROGRESS_STATE_MAX_VALUE: GhosttyTerminalProgressState = 2147483647;+pub type GhosttyTerminalProgressState = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalProgressReport {+ pub state: GhosttyTerminalProgressState,+ pub progress: i8,+}+impl Default for GhosttyTerminalProgressReport {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyTerminalProgressReportFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ report: *const GhosttyTerminalProgressReport,+ ),+>;+pub const GHOSTTY_PROGRAM_STATUS_STATE_IDLE: GhosttyProgramStatusState = 0;+pub const GHOSTTY_PROGRAM_STATUS_STATE_WORKING: GhosttyProgramStatusState = 1;+pub const GHOSTTY_PROGRAM_STATUS_STATE_DONE: GhosttyProgramStatusState = 2;+pub const GHOSTTY_PROGRAM_STATUS_STATE_BLOCKED: GhosttyProgramStatusState = 3;+pub const GHOSTTY_PROGRAM_STATUS_STATE_ERROR: GhosttyProgramStatusState = 4;+pub const GHOSTTY_PROGRAM_STATUS_STATE_CLEAR: GhosttyProgramStatusState = 5;+pub const GHOSTTY_PROGRAM_STATUS_STATE_MAX_VALUE: GhosttyProgramStatusState = 2147483647;+pub type GhosttyProgramStatusState = ::core::ffi::c_uint;+pub const GHOSTTY_PROGRAM_STATUS_KIND_NONE: GhosttyProgramStatusKind = 0;+pub const GHOSTTY_PROGRAM_STATUS_KIND_PERMISSION: GhosttyProgramStatusKind = 1;+pub const GHOSTTY_PROGRAM_STATUS_KIND_QUESTION: GhosttyProgramStatusKind = 2;+pub const GHOSTTY_PROGRAM_STATUS_KIND_AUTH: GhosttyProgramStatusKind = 3;+pub const GHOSTTY_PROGRAM_STATUS_KIND_MAX_VALUE: GhosttyProgramStatusKind = 2147483647;+pub type GhosttyProgramStatusKind = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalProgramStatus {+ pub state: GhosttyProgramStatusState,+ pub kind: GhosttyProgramStatusKind,+ pub progress: i8,+ pub id: GhosttyString,+ pub app: GhosttyString,+ pub title: GhosttyString,+ pub message: GhosttyString,+}+impl Default for GhosttyTerminalProgramStatus {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyTerminalProgramStatusFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ report: *const GhosttyTerminalProgramStatus,+ ),+>;+pub const GHOSTTY_SEMANTIC_PROMPT_INVALID: GhosttySemanticPromptKind = 0;+pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_START: GhosttySemanticPromptKind = 1;+pub const GHOSTTY_SEMANTIC_PROMPT_INPUT_START: GhosttySemanticPromptKind = 2;+pub const GHOSTTY_SEMANTIC_PROMPT_OUTPUT_START: GhosttySemanticPromptKind = 3;+pub const GHOSTTY_SEMANTIC_PROMPT_COMMAND_END: GhosttySemanticPromptKind = 4;+pub const GHOSTTY_SEMANTIC_PROMPT_MAX_VALUE: GhosttySemanticPromptKind = 2147483647;+pub type GhosttySemanticPromptKind = ::core::ffi::c_uint;+pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_PRIMARY: GhosttySemanticPromptPromptKind = 0;+pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_RIGHT: GhosttySemanticPromptPromptKind = 1;+pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_CONTINUATION: GhosttySemanticPromptPromptKind = 2;+pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_SECONDARY: GhosttySemanticPromptPromptKind = 3;+pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_MAX_VALUE: GhosttySemanticPromptPromptKind = 2147483647;+pub type GhosttySemanticPromptPromptKind = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyTerminalSemanticPrompt {+ pub kind: GhosttySemanticPromptKind,+ pub prompt_kind: GhosttySemanticPromptPromptKind,+ pub has_exit_code: bool,+ pub exit_code: i32,+ pub command: GhosttyString,+ pub error: GhosttyString,+}+impl Default for GhosttyTerminalSemanticPrompt {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyTerminalSemanticPromptFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ event: *const GhosttyTerminalSemanticPrompt,+ ),+>;+pub type GhosttyTerminalResetFn = ::core::option::Option<+ unsafe extern "C" fn(terminal: GhosttyTerminal, userdata: *mut ::core::ffi::c_void),+>;+pub const GHOSTTY_TERMINAL_RESIZE_WINDOW_GRID: GhosttyTerminalResizeWindowTag = 0;+pub const GHOSTTY_TERMINAL_RESIZE_WINDOW_MAX_VALUE: GhosttyTerminalResizeWindowTag = 2147483647;+pub type GhosttyTerminalResizeWindowTag = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyTerminalResizeWindowGrid {+ pub rows: u16,+ pub columns: u16,+}+#[repr(C)]+#[derive(Copy, Clone)]+pub union GhosttyTerminalResizeWindowValue {+ pub grid: GhosttyTerminalResizeWindowGrid,+ pub _padding: [u64; 2usize],+}+impl Default for GhosttyTerminalResizeWindowValue {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Copy, Clone)]+pub struct GhosttyTerminalResizeWindow {+ pub tag: GhosttyTerminalResizeWindowTag,+ pub value: GhosttyTerminalResizeWindowValue,+}+impl Default for GhosttyTerminalResizeWindow {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub type GhosttyTerminalResizeWindowFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ request: *const GhosttyTerminalResizeWindow,+ ),+>;+pub type GhosttyTerminalColorSchemeFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ out_scheme: *mut GhosttyColorScheme,+ ) -> bool,+>;+pub type GhosttyTerminalDeviceAttributesFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ out_attrs: *mut GhosttyDeviceAttributes,+ ) -> bool,+>;+pub type GhosttyTerminalEnquiryFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ ) -> GhosttyString,+>;+pub type GhosttyTerminalSizeFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ out_size: *mut GhosttySizeReportSize,+ ) -> bool,+>;+pub type GhosttyTerminalTitleChangedFn = ::core::option::Option<+ unsafe extern "C" fn(terminal: GhosttyTerminal, userdata: *mut ::core::ffi::c_void),+>;+pub type GhosttyTerminalRenderHoldFn = ::core::option::Option<+ unsafe extern "C" fn(terminal: GhosttyTerminal, userdata: *mut ::core::ffi::c_void, held: bool),+>;+pub type GhosttyTerminalPwdChangedFn = ::core::option::Option<+ unsafe extern "C" fn(terminal: GhosttyTerminal, userdata: *mut ::core::ffi::c_void),+>;+pub type GhosttyTerminalWritePtyFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ data: *const u8,+ len: usize,+ ),+>;+pub type GhosttyTerminalXtversionFn = ::core::option::Option<+ unsafe extern "C" fn(+ terminal: GhosttyTerminal,+ userdata: *mut ::core::ffi::c_void,+ ) -> GhosttyString,+>;+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyTerminalModeConfig {+ pub mode: GhosttyMode,+ pub value: bool,+}+pub const GHOSTTY_TERMINAL_OPT_INVALID: GhosttyTerminalOption = 0;+pub const GHOSTTY_TERMINAL_OPT_USERDATA: GhosttyTerminalOption = 1;+pub const GHOSTTY_TERMINAL_OPT_WRITE_PTY: GhosttyTerminalOption = 2;+pub const GHOSTTY_TERMINAL_OPT_BELL: GhosttyTerminalOption = 3;+pub const GHOSTTY_TERMINAL_OPT_ENQUIRY: GhosttyTerminalOption = 4;+pub const GHOSTTY_TERMINAL_OPT_XTVERSION: GhosttyTerminalOption = 5;+pub const GHOSTTY_TERMINAL_OPT_TITLE_CHANGED: GhosttyTerminalOption = 6;+pub const GHOSTTY_TERMINAL_OPT_SIZE: GhosttyTerminalOption = 7;+pub const GHOSTTY_TERMINAL_OPT_COLOR_SCHEME: GhosttyTerminalOption = 8;+pub const GHOSTTY_TERMINAL_OPT_DEVICE_ATTRIBUTES: GhosttyTerminalOption = 9;+pub const GHOSTTY_TERMINAL_OPT_TITLE: GhosttyTerminalOption = 10;+pub const GHOSTTY_TERMINAL_OPT_PWD: GhosttyTerminalOption = 11;+pub const GHOSTTY_TERMINAL_OPT_COLOR_FOREGROUND: GhosttyTerminalOption = 12;+pub const GHOSTTY_TERMINAL_OPT_COLOR_BACKGROUND: GhosttyTerminalOption = 13;+pub const GHOSTTY_TERMINAL_OPT_COLOR_CURSOR: GhosttyTerminalOption = 14;+pub const GHOSTTY_TERMINAL_OPT_COLOR_PALETTE: GhosttyTerminalOption = 15;+pub const GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_STORAGE_LIMIT: GhosttyTerminalOption = 16;+pub const GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_MEDIUM_FILE: GhosttyTerminalOption = 17;+pub const GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_MEDIUM_TEMP_FILE: GhosttyTerminalOption = 18;+pub const GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_MEDIUM_SHARED_MEM: GhosttyTerminalOption = 19;+pub const GHOSTTY_TERMINAL_OPT_APC_MAX_BYTES: GhosttyTerminalOption = 20;+pub const GHOSTTY_TERMINAL_OPT_APC_MAX_BYTES_KITTY: GhosttyTerminalOption = 21;+pub const GHOSTTY_TERMINAL_OPT_SELECTION: GhosttyTerminalOption = 22;+pub const GHOSTTY_TERMINAL_OPT_DEFAULT_CURSOR_STYLE: GhosttyTerminalOption = 23;+pub const GHOSTTY_TERMINAL_OPT_DEFAULT_CURSOR_BLINK: GhosttyTerminalOption = 24;+pub const GHOSTTY_TERMINAL_OPT_GLYPH_PROTOCOL: GhosttyTerminalOption = 25;+pub const GHOSTTY_TERMINAL_OPT_PWD_CHANGED: GhosttyTerminalOption = 26;+pub const GHOSTTY_TERMINAL_OPT_CLIPBOARD_WRITE: GhosttyTerminalOption = 27;+pub const GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_BYTES: GhosttyTerminalOption = 28;+pub const GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_LINES: GhosttyTerminalOption = 29;+pub const GHOSTTY_TERMINAL_OPT_DESKTOP_NOTIFICATION: GhosttyTerminalOption = 30;+pub const GHOSTTY_TERMINAL_OPT_PROGRESS_REPORT: GhosttyTerminalOption = 31;+pub const GHOSTTY_TERMINAL_OPT_CONTINUATION_MAX_BYTES: GhosttyTerminalOption = 32;+pub const GHOSTTY_TERMINAL_OPT_TITLE_REPORT: GhosttyTerminalOption = 33;+pub const GHOSTTY_TERMINAL_OPT_MODE_DEFAULT: GhosttyTerminalOption = 34;+pub const GHOSTTY_TERMINAL_OPT_MODE: GhosttyTerminalOption = 35;+pub const GHOSTTY_TERMINAL_OPT_UNKNOWN_SEQUENCE: GhosttyTerminalOption = 36;+pub const GHOSTTY_TERMINAL_OPT_UNKNOWN_MAX_BYTES: GhosttyTerminalOption = 37;+pub const GHOSTTY_TERMINAL_OPT_TERMINFO_NAME: GhosttyTerminalOption = 38;+pub const GHOSTTY_TERMINAL_OPT_CLIPBOARD_READ: GhosttyTerminalOption = 39;+pub const GHOSTTY_TERMINAL_OPT_CLIPBOARD_WRITE_MAX_BYTES: GhosttyTerminalOption = 40;+pub const GHOSTTY_TERMINAL_OPT_RESIZE_PULL_SCROLLBACK: GhosttyTerminalOption = 41;+pub const GHOSTTY_TERMINAL_OPT_RENDER_HOLD: GhosttyTerminalOption = 42;+pub const GHOSTTY_TERMINAL_OPT_SEMANTIC_PROMPT: GhosttyTerminalOption = 43;+pub const GHOSTTY_TERMINAL_OPT_RESET: GhosttyTerminalOption = 44;+pub const GHOSTTY_TERMINAL_OPT_XT_CHECKSUM_REPORT: GhosttyTerminalOption = 45;+pub const GHOSTTY_TERMINAL_OPT_XT_CHECKSUM_EXTENSION: GhosttyTerminalOption = 46;+pub const GHOSTTY_TERMINAL_OPT_PROGRAM_STATUS: GhosttyTerminalOption = 47;+pub const GHOSTTY_TERMINAL_OPT_RESIZE_WINDOW: GhosttyTerminalOption = 48;+pub const GHOSTTY_TERMINAL_OPT_MAX_VALUE: GhosttyTerminalOption = 2147483647;+pub type GhosttyTerminalOption = ::core::ffi::c_uint;+pub const GHOSTTY_TERMINAL_DATA_INVALID: GhosttyTerminalData = 0;+pub const GHOSTTY_TERMINAL_DATA_COLS: GhosttyTerminalData = 1;+pub const GHOSTTY_TERMINAL_DATA_ROWS: GhosttyTerminalData = 2;+pub const GHOSTTY_TERMINAL_DATA_CURSOR_X: GhosttyTerminalData = 3;+pub const GHOSTTY_TERMINAL_DATA_CURSOR_Y: GhosttyTerminalData = 4;+pub const GHOSTTY_TERMINAL_DATA_CURSOR_PENDING_WRAP: GhosttyTerminalData = 5;+pub const GHOSTTY_TERMINAL_DATA_ACTIVE_SCREEN: GhosttyTerminalData = 6;+pub const GHOSTTY_TERMINAL_DATA_CURSOR_VISIBLE: GhosttyTerminalData = 7;+pub const GHOSTTY_TERMINAL_DATA_KITTY_KEYBOARD_FLAGS: GhosttyTerminalData = 8;+pub const GHOSTTY_TERMINAL_DATA_SCROLLBAR: GhosttyTerminalData = 9;+pub const GHOSTTY_TERMINAL_DATA_CURSOR_SGR_STYLE: GhosttyTerminalData = 10;+pub const GHOSTTY_TERMINAL_DATA_MOUSE_TRACKING: GhosttyTerminalData = 11;+pub const GHOSTTY_TERMINAL_DATA_TITLE: GhosttyTerminalData = 12;+pub const GHOSTTY_TERMINAL_DATA_PWD: GhosttyTerminalData = 13;+pub const GHOSTTY_TERMINAL_DATA_TOTAL_ROWS: GhosttyTerminalData = 14;+pub const GHOSTTY_TERMINAL_DATA_SCROLLBACK_ROWS: GhosttyTerminalData = 15;+pub const GHOSTTY_TERMINAL_DATA_WIDTH_PX: GhosttyTerminalData = 16;+pub const GHOSTTY_TERMINAL_DATA_HEIGHT_PX: GhosttyTerminalData = 17;+pub const GHOSTTY_TERMINAL_DATA_COLOR_FOREGROUND: GhosttyTerminalData = 18;+pub const GHOSTTY_TERMINAL_DATA_COLOR_BACKGROUND: GhosttyTerminalData = 19;+pub const GHOSTTY_TERMINAL_DATA_COLOR_CURSOR: GhosttyTerminalData = 20;+pub const GHOSTTY_TERMINAL_DATA_COLOR_PALETTE: GhosttyTerminalData = 21;+pub const GHOSTTY_TERMINAL_DATA_COLOR_FOREGROUND_DEFAULT: GhosttyTerminalData = 22;+pub const GHOSTTY_TERMINAL_DATA_COLOR_BACKGROUND_DEFAULT: GhosttyTerminalData = 23;+pub const GHOSTTY_TERMINAL_DATA_COLOR_CURSOR_DEFAULT: GhosttyTerminalData = 24;+pub const GHOSTTY_TERMINAL_DATA_COLOR_PALETTE_DEFAULT: GhosttyTerminalData = 25;+pub const GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_STORAGE_LIMIT: GhosttyTerminalData = 26;+pub const GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_MEDIUM_FILE: GhosttyTerminalData = 27;+pub const GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_MEDIUM_TEMP_FILE: GhosttyTerminalData = 28;+pub const GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_MEDIUM_SHARED_MEM: GhosttyTerminalData = 29;+pub const GHOSTTY_TERMINAL_DATA_KITTY_GRAPHICS: GhosttyTerminalData = 30;+pub const GHOSTTY_TERMINAL_DATA_SELECTION: GhosttyTerminalData = 31;+pub const GHOSTTY_TERMINAL_DATA_VIEWPORT_ACTIVE: GhosttyTerminalData = 32;+pub const GHOSTTY_TERMINAL_DATA_VT_PROCESSING_ERROR: GhosttyTerminalData = 33;+pub const GHOSTTY_TERMINAL_DATA_SCROLLBACK_MAX_BYTES: GhosttyTerminalData = 34;+pub const GHOSTTY_TERMINAL_DATA_SCROLLBACK_MAX_LINES: GhosttyTerminalData = 35;+pub const GHOSTTY_TERMINAL_DATA_CONTINUATION_MAX_BYTES: GhosttyTerminalData = 36;+pub const GHOSTTY_TERMINAL_DATA_MODE: GhosttyTerminalData = 37;+pub const GHOSTTY_TERMINAL_DATA_VT_GROUND: GhosttyTerminalData = 38;+pub const GHOSTTY_TERMINAL_DATA_CURSOR_AT_PROMPT: GhosttyTerminalData = 39;+pub const GHOSTTY_TERMINAL_DATA_CLIPBOARD_WRITE_MAX_BYTES: GhosttyTerminalData = 40;+pub const GHOSTTY_TERMINAL_DATA_MOUSE_SHAPE: GhosttyTerminalData = 41;+pub const GHOSTTY_TERMINAL_DATA_MEMORY_USAGE: GhosttyTerminalData = 42;+pub const GHOSTTY_TERMINAL_DATA_MAX_VALUE: GhosttyTerminalData = 2147483647;+pub type GhosttyTerminalData = ::core::ffi::c_uint;+pub type GhosttyFormatterExtras = u32;+pub const GHOSTTY_FORMATTER_OPT_INVALID: GhosttyFormatterOption = 0;+pub const GHOSTTY_FORMATTER_OPT_EMIT: GhosttyFormatterOption = 1;+pub const GHOSTTY_FORMATTER_OPT_UNWRAP: GhosttyFormatterOption = 2;+pub const GHOSTTY_FORMATTER_OPT_TRIM: GhosttyFormatterOption = 3;+pub const GHOSTTY_FORMATTER_OPT_SELECTION: GhosttyFormatterOption = 4;+pub const GHOSTTY_FORMATTER_OPT_EXTRAS: GhosttyFormatterOption = 5;+pub const GHOSTTY_FORMATTER_OPT_MAX_VALUE: GhosttyFormatterOption = 2147483647;+pub type GhosttyFormatterOption = ::core::ffi::c_uint;+pub const GHOSTTY_RENDER_STATE_DIRTY_FALSE: GhosttyRenderStateDirty = 0;+pub const GHOSTTY_RENDER_STATE_DIRTY_PARTIAL: GhosttyRenderStateDirty = 1;+pub const GHOSTTY_RENDER_STATE_DIRTY_FULL: GhosttyRenderStateDirty = 2;+pub const GHOSTTY_RENDER_STATE_DIRTY_MAX_VALUE: GhosttyRenderStateDirty = 2147483647;+pub type GhosttyRenderStateDirty = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyRenderStateOverscan {+ pub above: u16,+ pub below: u16,+}+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyRenderStateRowId {+ pub bits: [u64; 2usize],+}+pub const GHOSTTY_RENDER_STATE_DATA_INVALID: GhosttyRenderStateData = 0;+pub const GHOSTTY_RENDER_STATE_DATA_COLS: GhosttyRenderStateData = 1;+pub const GHOSTTY_RENDER_STATE_DATA_ROWS: GhosttyRenderStateData = 2;+pub const GHOSTTY_RENDER_STATE_DATA_DIRTY: GhosttyRenderStateData = 3;+pub const GHOSTTY_RENDER_STATE_DATA_ROW_ITERATOR: GhosttyRenderStateData = 4;+pub const GHOSTTY_RENDER_STATE_DATA_COLOR_BACKGROUND: GhosttyRenderStateData = 5;+pub const GHOSTTY_RENDER_STATE_DATA_COLOR_FOREGROUND: GhosttyRenderStateData = 6;+pub const GHOSTTY_RENDER_STATE_DATA_COLOR_CURSOR: GhosttyRenderStateData = 7;+pub const GHOSTTY_RENDER_STATE_DATA_COLOR_CURSOR_HAS_VALUE: GhosttyRenderStateData = 8;+pub const GHOSTTY_RENDER_STATE_DATA_COLOR_PALETTE: GhosttyRenderStateData = 9;+pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VISUAL_STYLE: GhosttyRenderStateData = 10;+pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VISIBLE: GhosttyRenderStateData = 11;+pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_BLINKING: GhosttyRenderStateData = 12;+pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_PASSWORD_INPUT: GhosttyRenderStateData = 13;+pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VIEWPORT_HAS_VALUE: GhosttyRenderStateData = 14;+pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VIEWPORT_X: GhosttyRenderStateData = 15;+pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VIEWPORT_Y: GhosttyRenderStateData = 16;+pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VIEWPORT_WIDE_TAIL: GhosttyRenderStateData = 17;+pub const GHOSTTY_RENDER_STATE_DATA_CURSOR: GhosttyRenderStateData = 18;+pub const GHOSTTY_RENDER_STATE_DATA_COLORS: GhosttyRenderStateData = 19;+pub const GHOSTTY_RENDER_STATE_DATA_OVERSCAN: GhosttyRenderStateData = 20;+pub const GHOSTTY_RENDER_STATE_DATA_OVERSCAN_REQUEST: GhosttyRenderStateData = 21;+pub const GHOSTTY_RENDER_STATE_DATA_IMAGE_ITERATOR: GhosttyRenderStateData = 22;+pub const GHOSTTY_RENDER_STATE_DATA_IMAGE_PLACEMENTS_GENERATION: GhosttyRenderStateData = 23;+pub const GHOSTTY_RENDER_STATE_DATA_MAX_VALUE: GhosttyRenderStateData = 2147483647;+pub type GhosttyRenderStateData = ::core::ffi::c_uint;+pub const GHOSTTY_RENDER_STATE_OPT_INVALID: GhosttyRenderStateOption = 0;+pub const GHOSTTY_RENDER_STATE_OPT_DIRTY: GhosttyRenderStateOption = 1;+pub const GHOSTTY_RENDER_STATE_OPT_OVERSCAN: GhosttyRenderStateOption = 2;+pub const GHOSTTY_RENDER_STATE_OPT_MAX_VALUE: GhosttyRenderStateOption = 2147483647;+pub type GhosttyRenderStateOption = ::core::ffi::c_uint;+pub const GHOSTTY_IMAGE_PROTOCOL_KITTY: GhosttyImageProtocol = 0;+pub const GHOSTTY_IMAGE_PROTOCOL_MAX_VALUE: GhosttyImageProtocol = 2147483647;+pub type GhosttyImageProtocol = ::core::ffi::c_uint;+pub const GHOSTTY_RENDER_STATE_KITTY_PLACEMENT_KIND_VIRTUAL: GhosttyRenderStateKittyPlacementKind =+ 0;+pub const GHOSTTY_RENDER_STATE_KITTY_PLACEMENT_KIND_RELATIVE: GhosttyRenderStateKittyPlacementKind =+ 1;+pub const GHOSTTY_RENDER_STATE_KITTY_PLACEMENT_KIND_FIXED: GhosttyRenderStateKittyPlacementKind = 2;+pub const GHOSTTY_RENDER_STATE_KITTY_PLACEMENT_KIND_MAX_VALUE:+ GhosttyRenderStateKittyPlacementKind = 2147483647;+pub type GhosttyRenderStateKittyPlacementKind = ::core::ffi::c_uint;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_INVALID: GhosttyRenderStateImageData = 0;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_PROTOCOL: GhosttyRenderStateImageData = 1;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_IMAGE_ID: GhosttyRenderStateImageData = 2;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_IMAGE_GENERATION: GhosttyRenderStateImageData = 3;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_LAYER: GhosttyRenderStateImageData = 4;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_Z: GhosttyRenderStateImageData = 5;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_VIEWPORT_COL: GhosttyRenderStateImageData = 6;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_VIEWPORT_ROW: GhosttyRenderStateImageData = 7;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_GRID_COLS: GhosttyRenderStateImageData = 8;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_GRID_ROWS: GhosttyRenderStateImageData = 9;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_CELL_OFFSET_X: GhosttyRenderStateImageData = 10;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_CELL_OFFSET_Y: GhosttyRenderStateImageData = 11;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_PIXEL_WIDTH: GhosttyRenderStateImageData = 12;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_PIXEL_HEIGHT: GhosttyRenderStateImageData = 13;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_SOURCE_X: GhosttyRenderStateImageData = 14;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_SOURCE_Y: GhosttyRenderStateImageData = 15;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_SOURCE_WIDTH: GhosttyRenderStateImageData = 16;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_SOURCE_HEIGHT: GhosttyRenderStateImageData = 17;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_KITTY_PLACEMENT_ID: GhosttyRenderStateImageData = 18;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_KITTY_KIND: GhosttyRenderStateImageData = 19;+pub const GHOSTTY_RENDER_STATE_IMAGE_DATA_MAX_VALUE: GhosttyRenderStateImageData = 2147483647;+pub type GhosttyRenderStateImageData = ::core::ffi::c_uint;+pub const GHOSTTY_RENDER_STATE_ROW_DATA_INVALID: GhosttyRenderStateRowData = 0;+pub const GHOSTTY_RENDER_STATE_ROW_DATA_DIRTY: GhosttyRenderStateRowData = 1;+pub const GHOSTTY_RENDER_STATE_ROW_DATA_RAW: GhosttyRenderStateRowData = 2;+pub const GHOSTTY_RENDER_STATE_ROW_DATA_CELLS: GhosttyRenderStateRowData = 3;+pub const GHOSTTY_RENDER_STATE_ROW_DATA_SELECTION: GhosttyRenderStateRowData = 4;+pub const GHOSTTY_RENDER_STATE_ROW_DATA_CELLS_RAW: GhosttyRenderStateRowData = 5;+pub const GHOSTTY_RENDER_STATE_ROW_DATA_VIEWPORT_Y: GhosttyRenderStateRowData = 6;+pub const GHOSTTY_RENDER_STATE_ROW_DATA_ID: GhosttyRenderStateRowData = 7;+pub const GHOSTTY_RENDER_STATE_ROW_DATA_MAX_VALUE: GhosttyRenderStateRowData = 2147483647;+pub type GhosttyRenderStateRowData = ::core::ffi::c_uint;+pub const GHOSTTY_RENDER_STATE_ROW_OPT_INVALID: GhosttyRenderStateRowOption = 0;+pub const GHOSTTY_RENDER_STATE_ROW_OPT_DIRTY: GhosttyRenderStateRowOption = 1;+pub const GHOSTTY_RENDER_STATE_ROW_OPT_MAX_VALUE: GhosttyRenderStateRowOption = 2147483647;+pub type GhosttyRenderStateRowOption = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyRenderStateRowSelection {+ pub size: usize,+ pub start_x: u16,+ pub end_x: u16,+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyRenderStateCursor {+ pub size: usize,+ pub viewport_has_value: bool,+ pub viewport_x: u16,+ pub viewport_y: u16,+ pub wide_tail: bool,+ pub visible: bool,+ pub blinking: bool,+ pub password_input: bool,+ pub visual_style: GhosttyCursorStyle,+}+impl Default for GhosttyRenderStateCursor {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyRenderStateColors {+ pub size: usize,+ pub background: GhosttyColorRgb,+ pub foreground: GhosttyColorRgb,+ pub cursor: GhosttyColorRgb,+ pub cursor_has_value: bool,+ pub palette: [GhosttyColorRgb; 256usize],+}+impl Default for GhosttyRenderStateColors {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_INVALID: GhosttyRenderStateRowCellsData = 0;+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_RAW: GhosttyRenderStateRowCellsData = 1;+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_STYLE: GhosttyRenderStateRowCellsData = 2;+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_GRAPHEMES_LEN: GhosttyRenderStateRowCellsData = 3;+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_GRAPHEMES_BUF: GhosttyRenderStateRowCellsData = 4;+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_BG_COLOR: GhosttyRenderStateRowCellsData = 5;+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_FG_COLOR: GhosttyRenderStateRowCellsData = 6;+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_SELECTED: GhosttyRenderStateRowCellsData = 7;+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_HAS_STYLING: GhosttyRenderStateRowCellsData = 8;+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_GRAPHEMES_UTF8: GhosttyRenderStateRowCellsData = 9;+pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_MAX_VALUE: GhosttyRenderStateRowCellsData =+ 2147483647;+pub type GhosttyRenderStateRowCellsData = ::core::ffi::c_uint;+pub const GHOSTTY_SGR_ATTR_UNSET: GhosttySgrAttributeTag = 0;+pub const GHOSTTY_SGR_ATTR_UNKNOWN: GhosttySgrAttributeTag = 1;+pub const GHOSTTY_SGR_ATTR_BOLD: GhosttySgrAttributeTag = 2;+pub const GHOSTTY_SGR_ATTR_RESET_BOLD: GhosttySgrAttributeTag = 3;+pub const GHOSTTY_SGR_ATTR_ITALIC: GhosttySgrAttributeTag = 4;+pub const GHOSTTY_SGR_ATTR_RESET_ITALIC: GhosttySgrAttributeTag = 5;+pub const GHOSTTY_SGR_ATTR_FAINT: GhosttySgrAttributeTag = 6;+pub const GHOSTTY_SGR_ATTR_UNDERLINE: GhosttySgrAttributeTag = 7;+pub const GHOSTTY_SGR_ATTR_UNDERLINE_COLOR: GhosttySgrAttributeTag = 8;+pub const GHOSTTY_SGR_ATTR_UNDERLINE_COLOR_256: GhosttySgrAttributeTag = 9;+pub const GHOSTTY_SGR_ATTR_RESET_UNDERLINE_COLOR: GhosttySgrAttributeTag = 10;+pub const GHOSTTY_SGR_ATTR_OVERLINE: GhosttySgrAttributeTag = 11;+pub const GHOSTTY_SGR_ATTR_RESET_OVERLINE: GhosttySgrAttributeTag = 12;+pub const GHOSTTY_SGR_ATTR_BLINK: GhosttySgrAttributeTag = 13;+pub const GHOSTTY_SGR_ATTR_RESET_BLINK: GhosttySgrAttributeTag = 14;+pub const GHOSTTY_SGR_ATTR_INVERSE: GhosttySgrAttributeTag = 15;+pub const GHOSTTY_SGR_ATTR_RESET_INVERSE: GhosttySgrAttributeTag = 16;+pub const GHOSTTY_SGR_ATTR_INVISIBLE: GhosttySgrAttributeTag = 17;+pub const GHOSTTY_SGR_ATTR_RESET_INVISIBLE: GhosttySgrAttributeTag = 18;+pub const GHOSTTY_SGR_ATTR_STRIKETHROUGH: GhosttySgrAttributeTag = 19;+pub const GHOSTTY_SGR_ATTR_RESET_STRIKETHROUGH: GhosttySgrAttributeTag = 20;+pub const GHOSTTY_SGR_ATTR_DIRECT_COLOR_FG: GhosttySgrAttributeTag = 21;+pub const GHOSTTY_SGR_ATTR_DIRECT_COLOR_BG: GhosttySgrAttributeTag = 22;+pub const GHOSTTY_SGR_ATTR_BG_8: GhosttySgrAttributeTag = 23;+pub const GHOSTTY_SGR_ATTR_FG_8: GhosttySgrAttributeTag = 24;+pub const GHOSTTY_SGR_ATTR_RESET_FG: GhosttySgrAttributeTag = 25;+pub const GHOSTTY_SGR_ATTR_RESET_BG: GhosttySgrAttributeTag = 26;+pub const GHOSTTY_SGR_ATTR_BRIGHT_BG_8: GhosttySgrAttributeTag = 27;+pub const GHOSTTY_SGR_ATTR_BRIGHT_FG_8: GhosttySgrAttributeTag = 28;+pub const GHOSTTY_SGR_ATTR_BG_256: GhosttySgrAttributeTag = 29;+pub const GHOSTTY_SGR_ATTR_FG_256: GhosttySgrAttributeTag = 30;+pub const GHOSTTY_SGR_ATTR_MAX_VALUE: GhosttySgrAttributeTag = 2147483647;+pub type GhosttySgrAttributeTag = ::core::ffi::c_uint;+pub const GHOSTTY_SGR_UNDERLINE_NONE: GhosttySgrUnderline = 0;+pub const GHOSTTY_SGR_UNDERLINE_SINGLE: GhosttySgrUnderline = 1;+pub const GHOSTTY_SGR_UNDERLINE_DOUBLE: GhosttySgrUnderline = 2;+pub const GHOSTTY_SGR_UNDERLINE_CURLY: GhosttySgrUnderline = 3;+pub const GHOSTTY_SGR_UNDERLINE_DOTTED: GhosttySgrUnderline = 4;+pub const GHOSTTY_SGR_UNDERLINE_DASHED: GhosttySgrUnderline = 5;+pub const GHOSTTY_SGR_UNDERLINE_MAX_VALUE: GhosttySgrUnderline = 2147483647;+pub type GhosttySgrUnderline = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttySgrUnknown {+ pub full_ptr: *const u16,+ pub full_len: usize,+ pub partial_ptr: *const u16,+ pub partial_len: usize,+}+impl Default for GhosttySgrUnknown {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Copy, Clone)]+pub union GhosttySgrAttributeValue {+ pub unknown: GhosttySgrUnknown,+ pub underline: GhosttySgrUnderline,+ pub underline_color: GhosttyColorRgb,+ pub underline_color_256: GhosttyColorPaletteIndex,+ pub direct_color_fg: GhosttyColorRgb,+ pub direct_color_bg: GhosttyColorRgb,+ pub bg_8: GhosttyColorPaletteIndex,+ pub fg_8: GhosttyColorPaletteIndex,+ pub bright_bg_8: GhosttyColorPaletteIndex,+ pub bright_fg_8: GhosttyColorPaletteIndex,+ pub bg_256: GhosttyColorPaletteIndex,+ pub fg_256: GhosttyColorPaletteIndex,+ pub _padding: [u64; 8usize],+}+impl Default for GhosttySgrAttributeValue {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Copy, Clone)]+pub struct GhosttySgrAttribute {+ pub tag: GhosttySgrAttributeTag,+ pub value: GhosttySgrAttributeValue,+}+impl Default for GhosttySgrAttribute {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttySysImage {+ pub width: u32,+ pub height: u32,+ pub data: *mut u8,+ pub data_len: usize,+}+impl Default for GhosttySysImage {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub const GHOSTTY_SYS_LOG_LEVEL_ERROR: GhosttySysLogLevel = 0;+pub const GHOSTTY_SYS_LOG_LEVEL_WARNING: GhosttySysLogLevel = 1;+pub const GHOSTTY_SYS_LOG_LEVEL_INFO: GhosttySysLogLevel = 2;+pub const GHOSTTY_SYS_LOG_LEVEL_DEBUG: GhosttySysLogLevel = 3;+pub const GHOSTTY_SYS_LOG_LEVEL_MAX_VALUE: GhosttySysLogLevel = 2147483647;+pub type GhosttySysLogLevel = ::core::ffi::c_uint;+pub type GhosttySysLogFn = ::core::option::Option<+ unsafe extern "C" fn(+ userdata: *mut ::core::ffi::c_void,+ level: GhosttySysLogLevel,+ scope: *const u8,+ scope_len: usize,+ message: *const u8,+ message_len: usize,+ ),+>;+pub type GhosttySysDecodePngFn = ::core::option::Option<+ unsafe extern "C" fn(+ userdata: *mut ::core::ffi::c_void,+ allocator: *const GhosttyAllocator,+ data: *const u8,+ data_len: usize,+ out: *mut GhosttySysImage,+ ) -> bool,+>;+pub type GhosttySysRandomSecureFn = ::core::option::Option<+ unsafe extern "C" fn(userdata: *mut ::core::ffi::c_void, buf: *mut u8, len: usize) -> bool,+>;+pub const GHOSTTY_SYS_OPT_INVALID: GhosttySysOption = 0;+pub const GHOSTTY_SYS_OPT_USERDATA: GhosttySysOption = 1;+pub const GHOSTTY_SYS_OPT_DECODE_PNG: GhosttySysOption = 2;+pub const GHOSTTY_SYS_OPT_LOG: GhosttySysOption = 3;+pub const GHOSTTY_SYS_OPT_RANDOM_SECURE: GhosttySysOption = 4;+pub const GHOSTTY_SYS_OPT_MAX_VALUE: GhosttySysOption = 2147483647;+pub type GhosttySysOption = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyKeyEventImpl {+ _unused: [u8; 0],+}+pub type GhosttyKeyEvent = *mut GhosttyKeyEventImpl;+pub const GHOSTTY_KEY_ACTION_RELEASE: GhosttyKeyAction = 0;+pub const GHOSTTY_KEY_ACTION_PRESS: GhosttyKeyAction = 1;+pub const GHOSTTY_KEY_ACTION_REPEAT: GhosttyKeyAction = 2;+pub const GHOSTTY_KEY_ACTION_MAX_VALUE: GhosttyKeyAction = 2147483647;+pub type GhosttyKeyAction = ::core::ffi::c_uint;+pub type GhosttyMods = u16;+pub const GHOSTTY_KEY_UNIDENTIFIED: GhosttyKey = 0;+pub const GHOSTTY_KEY_BACKQUOTE: GhosttyKey = 1;+pub const GHOSTTY_KEY_BACKSLASH: GhosttyKey = 2;+pub const GHOSTTY_KEY_BRACKET_LEFT: GhosttyKey = 3;+pub const GHOSTTY_KEY_BRACKET_RIGHT: GhosttyKey = 4;+pub const GHOSTTY_KEY_COMMA: GhosttyKey = 5;+pub const GHOSTTY_KEY_DIGIT_0: GhosttyKey = 6;+pub const GHOSTTY_KEY_DIGIT_1: GhosttyKey = 7;+pub const GHOSTTY_KEY_DIGIT_2: GhosttyKey = 8;+pub const GHOSTTY_KEY_DIGIT_3: GhosttyKey = 9;+pub const GHOSTTY_KEY_DIGIT_4: GhosttyKey = 10;+pub const GHOSTTY_KEY_DIGIT_5: GhosttyKey = 11;+pub const GHOSTTY_KEY_DIGIT_6: GhosttyKey = 12;+pub const GHOSTTY_KEY_DIGIT_7: GhosttyKey = 13;+pub const GHOSTTY_KEY_DIGIT_8: GhosttyKey = 14;+pub const GHOSTTY_KEY_DIGIT_9: GhosttyKey = 15;+pub const GHOSTTY_KEY_EQUAL: GhosttyKey = 16;+pub const GHOSTTY_KEY_INTL_BACKSLASH: GhosttyKey = 17;+pub const GHOSTTY_KEY_INTL_RO: GhosttyKey = 18;+pub const GHOSTTY_KEY_INTL_YEN: GhosttyKey = 19;+pub const GHOSTTY_KEY_A: GhosttyKey = 20;+pub const GHOSTTY_KEY_B: GhosttyKey = 21;+pub const GHOSTTY_KEY_C: GhosttyKey = 22;+pub const GHOSTTY_KEY_D: GhosttyKey = 23;+pub const GHOSTTY_KEY_E: GhosttyKey = 24;+pub const GHOSTTY_KEY_F: GhosttyKey = 25;+pub const GHOSTTY_KEY_G: GhosttyKey = 26;+pub const GHOSTTY_KEY_H: GhosttyKey = 27;+pub const GHOSTTY_KEY_I: GhosttyKey = 28;+pub const GHOSTTY_KEY_J: GhosttyKey = 29;+pub const GHOSTTY_KEY_K: GhosttyKey = 30;+pub const GHOSTTY_KEY_L: GhosttyKey = 31;+pub const GHOSTTY_KEY_M: GhosttyKey = 32;+pub const GHOSTTY_KEY_N: GhosttyKey = 33;+pub const GHOSTTY_KEY_O: GhosttyKey = 34;+pub const GHOSTTY_KEY_P: GhosttyKey = 35;+pub const GHOSTTY_KEY_Q: GhosttyKey = 36;+pub const GHOSTTY_KEY_R: GhosttyKey = 37;+pub const GHOSTTY_KEY_S: GhosttyKey = 38;+pub const GHOSTTY_KEY_T: GhosttyKey = 39;+pub const GHOSTTY_KEY_U: GhosttyKey = 40;+pub const GHOSTTY_KEY_V: GhosttyKey = 41;+pub const GHOSTTY_KEY_W: GhosttyKey = 42;+pub const GHOSTTY_KEY_X: GhosttyKey = 43;+pub const GHOSTTY_KEY_Y: GhosttyKey = 44;+pub const GHOSTTY_KEY_Z: GhosttyKey = 45;+pub const GHOSTTY_KEY_MINUS: GhosttyKey = 46;+pub const GHOSTTY_KEY_PERIOD: GhosttyKey = 47;+pub const GHOSTTY_KEY_QUOTE: GhosttyKey = 48;+pub const GHOSTTY_KEY_SEMICOLON: GhosttyKey = 49;+pub const GHOSTTY_KEY_SLASH: GhosttyKey = 50;+pub const GHOSTTY_KEY_ALT_LEFT: GhosttyKey = 51;+pub const GHOSTTY_KEY_ALT_RIGHT: GhosttyKey = 52;+pub const GHOSTTY_KEY_BACKSPACE: GhosttyKey = 53;+pub const GHOSTTY_KEY_CAPS_LOCK: GhosttyKey = 54;+pub const GHOSTTY_KEY_CONTEXT_MENU: GhosttyKey = 55;+pub const GHOSTTY_KEY_CONTROL_LEFT: GhosttyKey = 56;+pub const GHOSTTY_KEY_CONTROL_RIGHT: GhosttyKey = 57;+pub const GHOSTTY_KEY_ENTER: GhosttyKey = 58;+pub const GHOSTTY_KEY_META_LEFT: GhosttyKey = 59;+pub const GHOSTTY_KEY_META_RIGHT: GhosttyKey = 60;+pub const GHOSTTY_KEY_SHIFT_LEFT: GhosttyKey = 61;+pub const GHOSTTY_KEY_SHIFT_RIGHT: GhosttyKey = 62;+pub const GHOSTTY_KEY_SPACE: GhosttyKey = 63;+pub const GHOSTTY_KEY_TAB: GhosttyKey = 64;+pub const GHOSTTY_KEY_CONVERT: GhosttyKey = 65;+pub const GHOSTTY_KEY_KANA_MODE: GhosttyKey = 66;+pub const GHOSTTY_KEY_NON_CONVERT: GhosttyKey = 67;+pub const GHOSTTY_KEY_DELETE: GhosttyKey = 68;+pub const GHOSTTY_KEY_END: GhosttyKey = 69;+pub const GHOSTTY_KEY_HELP: GhosttyKey = 70;+pub const GHOSTTY_KEY_HOME: GhosttyKey = 71;+pub const GHOSTTY_KEY_INSERT: GhosttyKey = 72;+pub const GHOSTTY_KEY_PAGE_DOWN: GhosttyKey = 73;+pub const GHOSTTY_KEY_PAGE_UP: GhosttyKey = 74;+pub const GHOSTTY_KEY_ARROW_DOWN: GhosttyKey = 75;+pub const GHOSTTY_KEY_ARROW_LEFT: GhosttyKey = 76;+pub const GHOSTTY_KEY_ARROW_RIGHT: GhosttyKey = 77;+pub const GHOSTTY_KEY_ARROW_UP: GhosttyKey = 78;+pub const GHOSTTY_KEY_NUM_LOCK: GhosttyKey = 79;+pub const GHOSTTY_KEY_NUMPAD_0: GhosttyKey = 80;+pub const GHOSTTY_KEY_NUMPAD_1: GhosttyKey = 81;+pub const GHOSTTY_KEY_NUMPAD_2: GhosttyKey = 82;+pub const GHOSTTY_KEY_NUMPAD_3: GhosttyKey = 83;+pub const GHOSTTY_KEY_NUMPAD_4: GhosttyKey = 84;+pub const GHOSTTY_KEY_NUMPAD_5: GhosttyKey = 85;+pub const GHOSTTY_KEY_NUMPAD_6: GhosttyKey = 86;+pub const GHOSTTY_KEY_NUMPAD_7: GhosttyKey = 87;+pub const GHOSTTY_KEY_NUMPAD_8: GhosttyKey = 88;+pub const GHOSTTY_KEY_NUMPAD_9: GhosttyKey = 89;+pub const GHOSTTY_KEY_NUMPAD_ADD: GhosttyKey = 90;+pub const GHOSTTY_KEY_NUMPAD_BACKSPACE: GhosttyKey = 91;+pub const GHOSTTY_KEY_NUMPAD_CLEAR: GhosttyKey = 92;+pub const GHOSTTY_KEY_NUMPAD_CLEAR_ENTRY: GhosttyKey = 93;+pub const GHOSTTY_KEY_NUMPAD_COMMA: GhosttyKey = 94;+pub const GHOSTTY_KEY_NUMPAD_DECIMAL: GhosttyKey = 95;+pub const GHOSTTY_KEY_NUMPAD_DIVIDE: GhosttyKey = 96;+pub const GHOSTTY_KEY_NUMPAD_ENTER: GhosttyKey = 97;+pub const GHOSTTY_KEY_NUMPAD_EQUAL: GhosttyKey = 98;+pub const GHOSTTY_KEY_NUMPAD_MEMORY_ADD: GhosttyKey = 99;+pub const GHOSTTY_KEY_NUMPAD_MEMORY_CLEAR: GhosttyKey = 100;+pub const GHOSTTY_KEY_NUMPAD_MEMORY_RECALL: GhosttyKey = 101;+pub const GHOSTTY_KEY_NUMPAD_MEMORY_STORE: GhosttyKey = 102;+pub const GHOSTTY_KEY_NUMPAD_MEMORY_SUBTRACT: GhosttyKey = 103;+pub const GHOSTTY_KEY_NUMPAD_MULTIPLY: GhosttyKey = 104;+pub const GHOSTTY_KEY_NUMPAD_PAREN_LEFT: GhosttyKey = 105;+pub const GHOSTTY_KEY_NUMPAD_PAREN_RIGHT: GhosttyKey = 106;+pub const GHOSTTY_KEY_NUMPAD_SUBTRACT: GhosttyKey = 107;+pub const GHOSTTY_KEY_NUMPAD_SEPARATOR: GhosttyKey = 108;+pub const GHOSTTY_KEY_NUMPAD_UP: GhosttyKey = 109;+pub const GHOSTTY_KEY_NUMPAD_DOWN: GhosttyKey = 110;+pub const GHOSTTY_KEY_NUMPAD_RIGHT: GhosttyKey = 111;+pub const GHOSTTY_KEY_NUMPAD_LEFT: GhosttyKey = 112;+pub const GHOSTTY_KEY_NUMPAD_BEGIN: GhosttyKey = 113;+pub const GHOSTTY_KEY_NUMPAD_HOME: GhosttyKey = 114;+pub const GHOSTTY_KEY_NUMPAD_END: GhosttyKey = 115;+pub const GHOSTTY_KEY_NUMPAD_INSERT: GhosttyKey = 116;+pub const GHOSTTY_KEY_NUMPAD_DELETE: GhosttyKey = 117;+pub const GHOSTTY_KEY_NUMPAD_PAGE_UP: GhosttyKey = 118;+pub const GHOSTTY_KEY_NUMPAD_PAGE_DOWN: GhosttyKey = 119;+pub const GHOSTTY_KEY_ESCAPE: GhosttyKey = 120;+pub const GHOSTTY_KEY_F1: GhosttyKey = 121;+pub const GHOSTTY_KEY_F2: GhosttyKey = 122;+pub const GHOSTTY_KEY_F3: GhosttyKey = 123;+pub const GHOSTTY_KEY_F4: GhosttyKey = 124;+pub const GHOSTTY_KEY_F5: GhosttyKey = 125;+pub const GHOSTTY_KEY_F6: GhosttyKey = 126;+pub const GHOSTTY_KEY_F7: GhosttyKey = 127;+pub const GHOSTTY_KEY_F8: GhosttyKey = 128;+pub const GHOSTTY_KEY_F9: GhosttyKey = 129;+pub const GHOSTTY_KEY_F10: GhosttyKey = 130;+pub const GHOSTTY_KEY_F11: GhosttyKey = 131;+pub const GHOSTTY_KEY_F12: GhosttyKey = 132;+pub const GHOSTTY_KEY_F13: GhosttyKey = 133;+pub const GHOSTTY_KEY_F14: GhosttyKey = 134;+pub const GHOSTTY_KEY_F15: GhosttyKey = 135;+pub const GHOSTTY_KEY_F16: GhosttyKey = 136;+pub const GHOSTTY_KEY_F17: GhosttyKey = 137;+pub const GHOSTTY_KEY_F18: GhosttyKey = 138;+pub const GHOSTTY_KEY_F19: GhosttyKey = 139;+pub const GHOSTTY_KEY_F20: GhosttyKey = 140;+pub const GHOSTTY_KEY_F21: GhosttyKey = 141;+pub const GHOSTTY_KEY_F22: GhosttyKey = 142;+pub const GHOSTTY_KEY_F23: GhosttyKey = 143;+pub const GHOSTTY_KEY_F24: GhosttyKey = 144;+pub const GHOSTTY_KEY_F25: GhosttyKey = 145;+pub const GHOSTTY_KEY_FN: GhosttyKey = 146;+pub const GHOSTTY_KEY_FN_LOCK: GhosttyKey = 147;+pub const GHOSTTY_KEY_PRINT_SCREEN: GhosttyKey = 148;+pub const GHOSTTY_KEY_SCROLL_LOCK: GhosttyKey = 149;+pub const GHOSTTY_KEY_PAUSE: GhosttyKey = 150;+pub const GHOSTTY_KEY_BROWSER_BACK: GhosttyKey = 151;+pub const GHOSTTY_KEY_BROWSER_FAVORITES: GhosttyKey = 152;+pub const GHOSTTY_KEY_BROWSER_FORWARD: GhosttyKey = 153;+pub const GHOSTTY_KEY_BROWSER_HOME: GhosttyKey = 154;+pub const GHOSTTY_KEY_BROWSER_REFRESH: GhosttyKey = 155;+pub const GHOSTTY_KEY_BROWSER_SEARCH: GhosttyKey = 156;+pub const GHOSTTY_KEY_BROWSER_STOP: GhosttyKey = 157;+pub const GHOSTTY_KEY_EJECT: GhosttyKey = 158;+pub const GHOSTTY_KEY_LAUNCH_APP_1: GhosttyKey = 159;+pub const GHOSTTY_KEY_LAUNCH_APP_2: GhosttyKey = 160;+pub const GHOSTTY_KEY_LAUNCH_MAIL: GhosttyKey = 161;+pub const GHOSTTY_KEY_MEDIA_PLAY_PAUSE: GhosttyKey = 162;+pub const GHOSTTY_KEY_MEDIA_SELECT: GhosttyKey = 163;+pub const GHOSTTY_KEY_MEDIA_STOP: GhosttyKey = 164;+pub const GHOSTTY_KEY_MEDIA_TRACK_NEXT: GhosttyKey = 165;+pub const GHOSTTY_KEY_MEDIA_TRACK_PREVIOUS: GhosttyKey = 166;+pub const GHOSTTY_KEY_POWER: GhosttyKey = 167;+pub const GHOSTTY_KEY_SLEEP: GhosttyKey = 168;+pub const GHOSTTY_KEY_AUDIO_VOLUME_DOWN: GhosttyKey = 169;+pub const GHOSTTY_KEY_AUDIO_VOLUME_MUTE: GhosttyKey = 170;+pub const GHOSTTY_KEY_AUDIO_VOLUME_UP: GhosttyKey = 171;+pub const GHOSTTY_KEY_WAKE_UP: GhosttyKey = 172;+pub const GHOSTTY_KEY_COPY: GhosttyKey = 173;+pub const GHOSTTY_KEY_CUT: GhosttyKey = 174;+pub const GHOSTTY_KEY_PASTE: GhosttyKey = 175;+pub const GHOSTTY_KEY_MAX_VALUE: GhosttyKey = 2147483647;+pub type GhosttyKey = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyKeyEncoderImpl {+ _unused: [u8; 0],+}+pub type GhosttyKeyEncoder = *mut GhosttyKeyEncoderImpl;+pub type GhosttyKittyKeyFlags = u8;+pub const GHOSTTY_OPTION_AS_ALT_FALSE: GhosttyOptionAsAlt = 0;+pub const GHOSTTY_OPTION_AS_ALT_TRUE: GhosttyOptionAsAlt = 1;+pub const GHOSTTY_OPTION_AS_ALT_LEFT: GhosttyOptionAsAlt = 2;+pub const GHOSTTY_OPTION_AS_ALT_RIGHT: GhosttyOptionAsAlt = 3;+pub const GHOSTTY_OPTION_AS_ALT_MAX_VALUE: GhosttyOptionAsAlt = 2147483647;+pub type GhosttyOptionAsAlt = ::core::ffi::c_uint;+pub const GHOSTTY_KEY_ENCODER_OPT_INVALID: GhosttyKeyEncoderOption = 0;+pub const GHOSTTY_KEY_ENCODER_OPT_CURSOR_KEY_APPLICATION: GhosttyKeyEncoderOption = 1;+pub const GHOSTTY_KEY_ENCODER_OPT_KEYPAD_KEY_APPLICATION: GhosttyKeyEncoderOption = 2;+pub const GHOSTTY_KEY_ENCODER_OPT_IGNORE_KEYPAD_WITH_NUMLOCK: GhosttyKeyEncoderOption = 3;+pub const GHOSTTY_KEY_ENCODER_OPT_ALT_ESC_PREFIX: GhosttyKeyEncoderOption = 4;+pub const GHOSTTY_KEY_ENCODER_OPT_MODIFY_OTHER_KEYS_STATE_2: GhosttyKeyEncoderOption = 5;+pub const GHOSTTY_KEY_ENCODER_OPT_KITTY_FLAGS: GhosttyKeyEncoderOption = 6;+pub const GHOSTTY_KEY_ENCODER_OPT_MACOS_OPTION_AS_ALT: GhosttyKeyEncoderOption = 7;+pub const GHOSTTY_KEY_ENCODER_OPT_BACKARROW_KEY_MODE: GhosttyKeyEncoderOption = 8;+pub const GHOSTTY_KEY_ENCODER_OPT_MAX_VALUE: GhosttyKeyEncoderOption = 2147483647;+pub type GhosttyKeyEncoderOption = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyMouseEventImpl {+ _unused: [u8; 0],+}+pub type GhosttyMouseEvent = *mut GhosttyMouseEventImpl;+pub const GHOSTTY_MOUSE_ACTION_PRESS: GhosttyMouseAction = 0;+pub const GHOSTTY_MOUSE_ACTION_RELEASE: GhosttyMouseAction = 1;+pub const GHOSTTY_MOUSE_ACTION_MOTION: GhosttyMouseAction = 2;+pub const GHOSTTY_MOUSE_ACTION_MAX_VALUE: GhosttyMouseAction = 2147483647;+pub type GhosttyMouseAction = ::core::ffi::c_uint;+pub const GHOSTTY_MOUSE_BUTTON_UNKNOWN: GhosttyMouseButton = 0;+pub const GHOSTTY_MOUSE_BUTTON_LEFT: GhosttyMouseButton = 1;+pub const GHOSTTY_MOUSE_BUTTON_RIGHT: GhosttyMouseButton = 2;+pub const GHOSTTY_MOUSE_BUTTON_MIDDLE: GhosttyMouseButton = 3;+pub const GHOSTTY_MOUSE_BUTTON_FOUR: GhosttyMouseButton = 4;+pub const GHOSTTY_MOUSE_BUTTON_FIVE: GhosttyMouseButton = 5;+pub const GHOSTTY_MOUSE_BUTTON_SIX: GhosttyMouseButton = 6;+pub const GHOSTTY_MOUSE_BUTTON_SEVEN: GhosttyMouseButton = 7;+pub const GHOSTTY_MOUSE_BUTTON_EIGHT: GhosttyMouseButton = 8;+pub const GHOSTTY_MOUSE_BUTTON_NINE: GhosttyMouseButton = 9;+pub const GHOSTTY_MOUSE_BUTTON_TEN: GhosttyMouseButton = 10;+pub const GHOSTTY_MOUSE_BUTTON_ELEVEN: GhosttyMouseButton = 11;+pub const GHOSTTY_MOUSE_BUTTON_MAX_VALUE: GhosttyMouseButton = 2147483647;+pub type GhosttyMouseButton = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyMousePosition {+ pub x: f32,+ pub y: f32,+}+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyMouseEncoderImpl {+ _unused: [u8; 0],+}+pub type GhosttyMouseEncoder = *mut GhosttyMouseEncoderImpl;+pub const GHOSTTY_MOUSE_TRACKING_NONE: GhosttyMouseTrackingMode = 0;+pub const GHOSTTY_MOUSE_TRACKING_X10: GhosttyMouseTrackingMode = 1;+pub const GHOSTTY_MOUSE_TRACKING_NORMAL: GhosttyMouseTrackingMode = 2;+pub const GHOSTTY_MOUSE_TRACKING_BUTTON: GhosttyMouseTrackingMode = 3;+pub const GHOSTTY_MOUSE_TRACKING_ANY: GhosttyMouseTrackingMode = 4;+pub const GHOSTTY_MOUSE_TRACKING_MAX_VALUE: GhosttyMouseTrackingMode = 2147483647;+pub type GhosttyMouseTrackingMode = ::core::ffi::c_uint;+pub const GHOSTTY_MOUSE_FORMAT_X10: GhosttyMouseFormat = 0;+pub const GHOSTTY_MOUSE_FORMAT_UTF8: GhosttyMouseFormat = 1;+pub const GHOSTTY_MOUSE_FORMAT_SGR: GhosttyMouseFormat = 2;+pub const GHOSTTY_MOUSE_FORMAT_URXVT: GhosttyMouseFormat = 3;+pub const GHOSTTY_MOUSE_FORMAT_SGR_PIXELS: GhosttyMouseFormat = 4;+pub const GHOSTTY_MOUSE_FORMAT_MAX_VALUE: GhosttyMouseFormat = 2147483647;+pub type GhosttyMouseFormat = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Default, Copy, Clone)]+pub struct GhosttyMouseEncoderSize {+ pub size: usize,+ pub screen_width: u32,+ pub screen_height: u32,+ pub cell_width: u32,+ pub cell_height: u32,+ pub padding_top: u32,+ pub padding_bottom: u32,+ pub padding_right: u32,+ pub padding_left: u32,+}+pub const GHOSTTY_MOUSE_ENCODER_OPT_INVALID: GhosttyMouseEncoderOption = 0;+pub const GHOSTTY_MOUSE_ENCODER_OPT_EVENT: GhosttyMouseEncoderOption = 1;+pub const GHOSTTY_MOUSE_ENCODER_OPT_FORMAT: GhosttyMouseEncoderOption = 2;+pub const GHOSTTY_MOUSE_ENCODER_OPT_SIZE: GhosttyMouseEncoderOption = 3;+pub const GHOSTTY_MOUSE_ENCODER_OPT_ANY_BUTTON_PRESSED: GhosttyMouseEncoderOption = 4;+pub const GHOSTTY_MOUSE_ENCODER_OPT_TRACK_LAST_CELL: GhosttyMouseEncoderOption = 5;+pub const GHOSTTY_MOUSE_ENCODER_OPT_MAX_VALUE: GhosttyMouseEncoderOption = 2147483647;+pub type GhosttyMouseEncoderOption = ::core::ffi::c_uint;+pub const GHOSTTY_MOUSE_SHAPE_DEFAULT: GhosttyMouseShape = 0;+pub const GHOSTTY_MOUSE_SHAPE_CONTEXT_MENU: GhosttyMouseShape = 1;+pub const GHOSTTY_MOUSE_SHAPE_HELP: GhosttyMouseShape = 2;+pub const GHOSTTY_MOUSE_SHAPE_POINTER: GhosttyMouseShape = 3;+pub const GHOSTTY_MOUSE_SHAPE_PROGRESS: GhosttyMouseShape = 4;+pub const GHOSTTY_MOUSE_SHAPE_WAIT: GhosttyMouseShape = 5;+pub const GHOSTTY_MOUSE_SHAPE_CELL: GhosttyMouseShape = 6;+pub const GHOSTTY_MOUSE_SHAPE_CROSSHAIR: GhosttyMouseShape = 7;+pub const GHOSTTY_MOUSE_SHAPE_TEXT: GhosttyMouseShape = 8;+pub const GHOSTTY_MOUSE_SHAPE_VERTICAL_TEXT: GhosttyMouseShape = 9;+pub const GHOSTTY_MOUSE_SHAPE_ALIAS: GhosttyMouseShape = 10;+pub const GHOSTTY_MOUSE_SHAPE_COPY: GhosttyMouseShape = 11;+pub const GHOSTTY_MOUSE_SHAPE_MOVE: GhosttyMouseShape = 12;+pub const GHOSTTY_MOUSE_SHAPE_NO_DROP: GhosttyMouseShape = 13;+pub const GHOSTTY_MOUSE_SHAPE_NOT_ALLOWED: GhosttyMouseShape = 14;+pub const GHOSTTY_MOUSE_SHAPE_GRAB: GhosttyMouseShape = 15;+pub const GHOSTTY_MOUSE_SHAPE_GRABBING: GhosttyMouseShape = 16;+pub const GHOSTTY_MOUSE_SHAPE_ALL_SCROLL: GhosttyMouseShape = 17;+pub const GHOSTTY_MOUSE_SHAPE_COL_RESIZE: GhosttyMouseShape = 18;+pub const GHOSTTY_MOUSE_SHAPE_ROW_RESIZE: GhosttyMouseShape = 19;+pub const GHOSTTY_MOUSE_SHAPE_N_RESIZE: GhosttyMouseShape = 20;+pub const GHOSTTY_MOUSE_SHAPE_E_RESIZE: GhosttyMouseShape = 21;+pub const GHOSTTY_MOUSE_SHAPE_S_RESIZE: GhosttyMouseShape = 22;+pub const GHOSTTY_MOUSE_SHAPE_W_RESIZE: GhosttyMouseShape = 23;+pub const GHOSTTY_MOUSE_SHAPE_NE_RESIZE: GhosttyMouseShape = 24;+pub const GHOSTTY_MOUSE_SHAPE_NW_RESIZE: GhosttyMouseShape = 25;+pub const GHOSTTY_MOUSE_SHAPE_SE_RESIZE: GhosttyMouseShape = 26;+pub const GHOSTTY_MOUSE_SHAPE_SW_RESIZE: GhosttyMouseShape = 27;+pub const GHOSTTY_MOUSE_SHAPE_EW_RESIZE: GhosttyMouseShape = 28;+pub const GHOSTTY_MOUSE_SHAPE_NS_RESIZE: GhosttyMouseShape = 29;+pub const GHOSTTY_MOUSE_SHAPE_NESW_RESIZE: GhosttyMouseShape = 30;+pub const GHOSTTY_MOUSE_SHAPE_NWSE_RESIZE: GhosttyMouseShape = 31;+pub const GHOSTTY_MOUSE_SHAPE_ZOOM_IN: GhosttyMouseShape = 32;+pub const GHOSTTY_MOUSE_SHAPE_ZOOM_OUT: GhosttyMouseShape = 33;+pub const GHOSTTY_MOUSE_SHAPE_MAX_VALUE: GhosttyMouseShape = 2147483647;+pub type GhosttyMouseShape = ::core::ffi::c_uint;+pub const GHOSTTY_PASTE_SOURCE_CLIPBOARD: GhosttyPasteSource = 0;+pub const GHOSTTY_PASTE_SOURCE_TEXT: GhosttyPasteSource = 1;+pub const GHOSTTY_PASTE_SOURCE_MAX_VALUE: GhosttyPasteSource = 2147483647;+pub type GhosttyPasteSource = ::core::ffi::c_uint;+#[repr(C)]+#[derive(Debug, Copy, Clone)]+pub struct GhosttyPaste {+ pub size: usize,+ pub location: GhosttyClipboardLocation,+ pub source: GhosttyPasteSource,+ pub mimes: *const GhosttyString,+ pub mimes_len: usize,+ pub reader: GhosttyMimeReader,+ pub allow_unsafe: bool,+}+impl Default for GhosttyPaste {+ fn default() -> Self {+ let mut s = ::core::mem::MaybeUninit::<Self>::uninit();+ unsafe {+ ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);+ s.assume_init()+ }+ }+}+pub const GHOSTTY_SEARCH_STATUS_RUNNING: GhosttySearchStatus = 0;+pub const GHOSTTY_SEARCH_STATUS_FEED_REQUIRED: GhosttySearchStatus = 1;+pub const GHOSTTY_SEARCH_STATUS_COMPLETE: GhosttySearchStatus = 2;+pub const GHOSTTY_SEARCH_STATUS_MAX_VALUE: GhosttySearchStatus = 2147483647;+pub type GhosttySearchStatus = ::core::ffi::c_uint;+pub const GHOSTTY_SEARCH_SCROLL_IF_NEEDED: GhosttySearchScroll = 0;+pub const GHOSTTY_SEARCH_SCROLL_NONE: GhosttySearchScroll = 1;+pub const GHOSTTY_SEARCH_SCROLL_MAX_VALUE: GhosttySearchScroll = 2147483647;+pub type GhosttySearchScroll = ::core::ffi::c_uint;+pub const GHOSTTY_SEARCH_DATA_INVALID: GhosttySearchData = 0;+pub const GHOSTTY_SEARCH_DATA_STATUS: GhosttySearchData = 1;+pub const GHOSTTY_SEARCH_DATA_NEEDLE: GhosttySearchData = 2;+pub const GHOSTTY_SEARCH_DATA_TOTAL_MATCHES: GhosttySearchData = 3;+pub const GHOSTTY_SEARCH_DATA_SELECTED_INDEX: GhosttySearchData = 4;+pub const GHOSTTY_SEARCH_DATA_SELECTED_MATCH: GhosttySearchData = 5;+pub const GHOSTTY_SEARCH_DATA_MATCHES: GhosttySearchData = 6;+pub const GHOSTTY_SEARCH_DATA_VIEWPORT_MATCHES: GhosttySearchData = 7;+pub const GHOSTTY_SEARCH_DATA_SELECT_SCROLL: GhosttySearchData = 8;+pub const GHOSTTY_SEARCH_DATA_MAX_VALUE: GhosttySearchData = 2147483647;+pub type GhosttySearchData = ::core::ffi::c_uint;+pub const GHOSTTY_SEARCH_OPT_INVALID: GhosttySearchOption = 0;+pub const GHOSTTY_SEARCH_OPT_NEEDLE: GhosttySearchOption = 1;+pub const GHOSTTY_SEARCH_OPT_SELECT_SCROLL: GhosttySearchOption = 4;+pub const GHOSTTY_SEARCH_OPT_MAX_VALUE: GhosttySearchOption = 2147483647;+pub type GhosttySearchOption = ::core::ffi::c_uint;+pub const GHOSTTY_SNAPSHOT_DECODER_OPT_INVALID: GhosttySnapshotDecoderOption = 0;+pub const GHOSTTY_SNAPSHOT_DECODER_OPT_MAX_CONTINUATION_BYTES: GhosttySnapshotDecoderOption = 1;+pub const GHOSTTY_SNAPSHOT_DECODER_OPT_RETAIN_CONTINUATION: GhosttySnapshotDecoderOption = 2;+pub const GHOSTTY_SNAPSHOT_DECODER_OPT_COMPRESS_HISTORY: GhosttySnapshotDecoderOption = 3;+pub const GHOSTTY_SNAPSHOT_DECODER_OPT_KITTY_IMAGE_STORAGE_LIMIT: GhosttySnapshotDecoderOption = 4;+pub const GHOSTTY_SNAPSHOT_DECODER_OPT_MAX_VALUE: GhosttySnapshotDecoderOption = 2147483647;+pub type GhosttySnapshotDecoderOption = ::core::ffi::c_uint;+pub const GHOSTTY_SNAPSHOT_DECODER_PROGRESS_KIND_PAGE: GhosttySnapshotDecoderProgressKind = 0;+pub const GHOSTTY_SNAPSHOT_DECODER_PROGRESS_KIND_IMAGE: GhosttySnapshotDecoderProgressKind = 1;+pub const GHOSTTY_SNAPSHOT_DECODER_PROGRESS_KIND_MAX_VALUE: GhosttySnapshotDecoderProgressKind =+ 2147483647;+pub type GhosttySnapshotDecoderProgressKind = ::core::ffi::c_uint;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_INVALID: GhosttySnapshotDecoderData = 0;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_MAX_CONTINUATION_BYTES: GhosttySnapshotDecoderData = 1;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_SOURCE_OFFSET: GhosttySnapshotDecoderData = 2;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_HISTORY_ROWS_PRIMARY: GhosttySnapshotDecoderData = 3;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_HISTORY_ROWS_ALTERNATE: GhosttySnapshotDecoderData = 4;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_SCREEN: GhosttySnapshotDecoderData = 5;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_ROWS: GhosttySnapshotDecoderData = 6;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_REMAINING: GhosttySnapshotDecoderData = 7;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_RETAIN_CONTINUATION: GhosttySnapshotDecoderData = 8;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_COMPRESS_HISTORY: GhosttySnapshotDecoderData = 9;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_KITTY_IMAGE_STORAGE_LIMIT: GhosttySnapshotDecoderData = 10;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_KIND: GhosttySnapshotDecoderData = 11;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_IMAGE_ID: GhosttySnapshotDecoderData = 12;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_IMAGE_FRAME: GhosttySnapshotDecoderData = 13;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_IMAGE_BYTES: GhosttySnapshotDecoderData = 14;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_KITTY_IMAGES_PRIMARY: GhosttySnapshotDecoderData = 15;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_KITTY_IMAGES_ALTERNATE: GhosttySnapshotDecoderData = 16;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_KITTY_PENDING_BYTES_PRIMARY: GhosttySnapshotDecoderData =+ 17;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_KITTY_PENDING_BYTES_ALTERNATE: GhosttySnapshotDecoderData =+ 18;+pub const GHOSTTY_SNAPSHOT_DECODER_DATA_MAX_VALUE: GhosttySnapshotDecoderData = 2147483647;+pub type GhosttySnapshotDecoderData = ::core::ffi::c_uint;+unsafe extern "C" {+ pub fn ghostty_sized_init(ptr: *mut ::core::ffi::c_void, size: usize);+ pub fn ghostty_type_json() -> *const ::core::ffi::c_char;+ pub fn ghostty_alloc(allocator: *const GhosttyAllocator, len: usize) -> *mut u8;+ pub fn ghostty_free(allocator: *const GhosttyAllocator, ptr: *mut u8, len: usize);+ pub fn ghostty_build_info(+ data: GhosttyBuildInfo,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_version() -> *const ::core::ffi::c_char;+ pub fn ghostty_color_rgb_get(color: *const GhosttyColorRgb, r: *mut u8, g: *mut u8, b: *mut u8);+ pub fn ghostty_color_parse_x11(+ name: *const ::core::ffi::c_char,+ len: usize,+ out: *mut GhosttyColorRgb,+ ) -> GhosttyResult;+ pub fn ghostty_color_parse(+ value: *const ::core::ffi::c_char,+ len: usize,+ out: *mut GhosttyColorRgb,+ ) -> GhosttyResult;+ pub fn ghostty_color_parse_palette_entry(+ value: *const ::core::ffi::c_char,+ len: usize,+ out_index: *mut u8,+ out_rgb: *mut GhosttyColorRgb,+ ) -> GhosttyResult;+ pub fn ghostty_color_palette_default(out: *mut GhosttyColorRgb);+ pub fn ghostty_color_palette_generate(+ base: *const GhosttyColorRgb,+ skip: *const GhosttyColorPaletteMask,+ bg: *const GhosttyColorRgb,+ fg: *const GhosttyColorRgb,+ harmonious: bool,+ out: *mut GhosttyColorRgb,+ );+ pub fn ghostty_color_luminance(color: *const GhosttyColorRgb) -> f64;+ pub fn ghostty_color_perceived_luminance(color: *const GhosttyColorRgb) -> f64;+ pub fn ghostty_color_contrast(a: *const GhosttyColorRgb, b: *const GhosttyColorRgb) -> f64;+ pub fn ghostty_color_x11_names() -> *const GhosttyColorX11Entry;+ pub fn ghostty_color_x11_name_count() -> usize;+ pub fn ghostty_color_scheme_report_encode(+ scheme: GhosttyColorScheme,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_focus_encode(+ event: GhosttyFocusEvent,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_cell_get(+ cell: GhosttyCell,+ data: GhosttyCellData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_cell_get_multi(+ cell: GhosttyCell,+ count: usize,+ keys: *const GhosttyCellData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_row_get(+ row: GhosttyRow,+ data: GhosttyRowData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_row_get_multi(+ row: GhosttyRow,+ count: usize,+ keys: *const GhosttyRowData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_style_default(style: *mut GhosttyStyle);+ pub fn ghostty_style_is_default(style: *const GhosttyStyle) -> bool;+ pub fn ghostty_grid_ref_cell(+ ref_: *const GhosttyGridRef,+ out_cell: *mut GhosttyCell,+ ) -> GhosttyResult;+ pub fn ghostty_grid_ref_row(+ ref_: *const GhosttyGridRef,+ out_row: *mut GhosttyRow,+ ) -> GhosttyResult;+ pub fn ghostty_grid_ref_graphemes(+ ref_: *const GhosttyGridRef,+ buf: *mut u32,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_grid_ref_hyperlink_uri(+ ref_: *const GhosttyGridRef,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_grid_ref_style(+ ref_: *const GhosttyGridRef,+ out_style: *mut GhosttyStyle,+ ) -> GhosttyResult;+ pub fn ghostty_selection_gesture_event_new(+ allocator: *const GhosttyAllocator,+ out_event: *mut GhosttySelectionGestureEvent,+ type_: GhosttySelectionGestureEventType,+ ) -> GhosttyResult;+ pub fn ghostty_selection_gesture_event_free(event: GhosttySelectionGestureEvent);+ pub fn ghostty_selection_gesture_event_set(+ event: GhosttySelectionGestureEvent,+ option: GhosttySelectionGestureEventOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_selection_gesture_event(+ gesture: GhosttySelectionGesture,+ terminal: GhosttyTerminal,+ event: GhosttySelectionGestureEvent,+ out_selection: *mut GhosttySelection,+ ) -> GhosttyResult;+ pub fn ghostty_selection_gesture_new(+ allocator: *const GhosttyAllocator,+ out_gesture: *mut GhosttySelectionGesture,+ ) -> GhosttyResult;+ pub fn ghostty_selection_gesture_free(+ gesture: GhosttySelectionGesture,+ terminal: GhosttyTerminal,+ );+ pub fn ghostty_selection_gesture_reset(+ gesture: GhosttySelectionGesture,+ terminal: GhosttyTerminal,+ );+ pub fn ghostty_selection_gesture_get(+ gesture: GhosttySelectionGesture,+ terminal: GhosttyTerminal,+ data: GhosttySelectionGestureData,+ value: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_selection_gesture_get_multi(+ gesture: GhosttySelectionGesture,+ terminal: GhosttyTerminal,+ count: usize,+ keys: *const GhosttySelectionGestureData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_select_word(+ terminal: GhosttyTerminal,+ options: *const GhosttyTerminalSelectWordOptions,+ out_selection: *mut GhosttySelection,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_select_word_between(+ terminal: GhosttyTerminal,+ options: *const GhosttyTerminalSelectWordBetweenOptions,+ out_selection: *mut GhosttySelection,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_select_line(+ terminal: GhosttyTerminal,+ options: *const GhosttyTerminalSelectLineOptions,+ out_selection: *mut GhosttySelection,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_select_all(+ terminal: GhosttyTerminal,+ out_selection: *mut GhosttySelection,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_select_output(+ terminal: GhosttyTerminal,+ ref_: *const GhosttyGridRef,+ out_selection: *mut GhosttySelection,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_selection_adjust(+ terminal: GhosttyTerminal,+ selection: *mut GhosttySelection,+ adjustment: GhosttySelectionAdjust,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_selection_order(+ terminal: GhosttyTerminal,+ selection: *const GhosttySelection,+ out_order: *mut GhosttySelectionOrder,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_selection_ordered(+ terminal: GhosttyTerminal,+ selection: *const GhosttySelection,+ desired: GhosttySelectionOrder,+ out_selection: *mut GhosttySelection,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_selection_contains(+ terminal: GhosttyTerminal,+ selection: *const GhosttySelection,+ point: GhosttyPoint,+ out_contains: *mut bool,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_selection_equal(+ terminal: GhosttyTerminal,+ a: *const GhosttySelection,+ b: *const GhosttySelection,+ out_equal: *mut bool,+ ) -> GhosttyResult;+ pub fn ghostty_mode_report_encode(+ mode: GhosttyMode,+ state: GhosttyModeReportState,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_osc_new(+ allocator: *const GhosttyAllocator,+ parser: *mut GhosttyOscParser,+ ) -> GhosttyResult;+ pub fn ghostty_osc_free(parser: GhosttyOscParser);+ pub fn ghostty_osc_reset(parser: GhosttyOscParser);+ pub fn ghostty_osc_set(+ parser: GhosttyOscParser,+ option: GhosttyOscOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_osc_next(parser: GhosttyOscParser, byte: u8);+ pub fn ghostty_osc_end(parser: GhosttyOscParser, terminator: u8) -> GhosttyOscCommand;+ pub fn ghostty_osc_command_type(command: GhosttyOscCommand) -> GhosttyOscCommandType;+ pub fn ghostty_osc_command_data(+ command: GhosttyOscCommand,+ data: GhosttyOscCommandData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_size_report_encode(+ style: GhosttySizeReportStyle,+ size: *const GhosttySizeReportSize,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_get(+ graphics: GhosttyKittyGraphics,+ data: GhosttyKittyGraphicsData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_animation_tick(+ graphics: GhosttyKittyGraphics,+ now_ms: u64,+ next_ms: *mut u64,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_image(+ graphics: GhosttyKittyGraphics,+ image_id: u32,+ ) -> GhosttyKittyGraphicsImage;+ pub fn ghostty_kitty_graphics_image_get(+ image: GhosttyKittyGraphicsImage,+ data: GhosttyKittyGraphicsImageData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_image_get_multi(+ image: GhosttyKittyGraphicsImage,+ count: usize,+ keys: *const GhosttyKittyGraphicsImageData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_placement_iterator_new(+ allocator: *const GhosttyAllocator,+ out_iterator: *mut GhosttyKittyGraphicsPlacementIterator,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_placement_iterator_free(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ );+ pub fn ghostty_kitty_graphics_placement_iterator_set(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ option: GhosttyKittyGraphicsPlacementIteratorOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_placement_next(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ ) -> bool;+ pub fn ghostty_kitty_graphics_placement_get(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ data: GhosttyKittyGraphicsPlacementData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_placement_get_multi(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ count: usize,+ keys: *const GhosttyKittyGraphicsPlacementData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_placement_rect(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ image: GhosttyKittyGraphicsImage,+ terminal: GhosttyTerminal,+ out_selection: *mut GhosttySelection,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_placement_pixel_size(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ image: GhosttyKittyGraphicsImage,+ terminal: GhosttyTerminal,+ out_width: *mut u32,+ out_height: *mut u32,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_placement_grid_size(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ image: GhosttyKittyGraphicsImage,+ terminal: GhosttyTerminal,+ out_cols: *mut u32,+ out_rows: *mut u32,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_placement_viewport_pos(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ image: GhosttyKittyGraphicsImage,+ terminal: GhosttyTerminal,+ out_col: *mut i32,+ out_row: *mut i32,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_placement_source_rect(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ image: GhosttyKittyGraphicsImage,+ out_x: *mut u32,+ out_y: *mut u32,+ out_width: *mut u32,+ out_height: *mut u32,+ ) -> GhosttyResult;+ pub fn ghostty_kitty_graphics_placement_render_info(+ iterator: GhosttyKittyGraphicsPlacementIterator,+ image: GhosttyKittyGraphicsImage,+ terminal: GhosttyTerminal,+ out_info: *mut GhosttyKittyGraphicsPlacementRenderInfo,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_new(+ allocator: *const GhosttyAllocator,+ terminal: *mut GhosttyTerminal,+ cols: u16,+ rows: u16,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_free(terminal: GhosttyTerminal);+ pub fn ghostty_terminal_reset(terminal: GhosttyTerminal);+ pub fn ghostty_terminal_resize(+ terminal: GhosttyTerminal,+ cols: u16,+ rows: u16,+ cell_width_px: u32,+ cell_height_px: u32,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_set(+ terminal: GhosttyTerminal,+ option: GhosttyTerminalOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_vt_write(terminal: GhosttyTerminal, data: *const u8, len: usize);+ pub fn ghostty_terminal_vt_write_until(+ terminal: GhosttyTerminal,+ data: *const u8,+ len: usize,+ boundaries: u32,+ out: *mut GhosttyTerminalWriteStop,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_continuation_write(+ terminal: GhosttyTerminal,+ writer: GhosttyWriter,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_continuation_buf(+ terminal: GhosttyTerminal,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_continuation_alloc(+ terminal: GhosttyTerminal,+ allocator: *const GhosttyAllocator,+ out_ptr: *mut *mut u8,+ out_len: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_scroll_viewport(+ terminal: GhosttyTerminal,+ behavior: GhosttyTerminalScrollViewport,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_compression_activity(+ terminal: GhosttyTerminal,+ out_activity: *mut u64,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_compress(+ terminal: GhosttyTerminal,+ mode: GhosttyTerminalCompressionMode,+ out_result: *mut GhosttyTerminalCompressionResult,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_get(+ terminal: GhosttyTerminal,+ data: GhosttyTerminalData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_get_multi(+ terminal: GhosttyTerminal,+ count: usize,+ keys: *const GhosttyTerminalData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_grid_ref(+ terminal: GhosttyTerminal,+ point: GhosttyPoint,+ out_ref: *mut GhosttyGridRef,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_grid_ref_track(+ terminal: GhosttyTerminal,+ point: GhosttyPoint,+ out_ref: *mut GhosttyTrackedGridRef,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_point_from_grid_ref(+ terminal: GhosttyTerminal,+ ref_: *const GhosttyGridRef,+ tag: GhosttyPointTag,+ out: *mut GhosttyPointCoordinate,+ ) -> GhosttyResult;+ pub fn ghostty_formatter_terminal_new(+ allocator: *const GhosttyAllocator,+ formatter: *mut GhosttyFormatter,+ terminal: GhosttyTerminal,+ ) -> GhosttyResult;+ pub fn ghostty_formatter_set(+ formatter: GhosttyFormatter,+ option: GhosttyFormatterOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_formatter_get(+ formatter: GhosttyFormatter,+ option: GhosttyFormatterOption,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_formatter_format(+ formatter: GhosttyFormatter,+ writer: GhosttyWriter,+ ) -> GhosttyResult;+ pub fn ghostty_formatter_format_buf(+ formatter: GhosttyFormatter,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_formatter_format_alloc(+ formatter: GhosttyFormatter,+ allocator: *const GhosttyAllocator,+ out_ptr: *mut *mut u8,+ out_len: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_formatter_free(formatter: GhosttyFormatter);+ pub fn ghostty_render_state_new(+ allocator: *const GhosttyAllocator,+ state: *mut GhosttyRenderState,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_free(state: GhosttyRenderState);+ pub fn ghostty_render_state_update(+ state: GhosttyRenderState,+ terminal: GhosttyTerminal,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_begin_update(+ state: GhosttyRenderState,+ terminal: GhosttyTerminal,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_end_update(state: GhosttyRenderState) -> GhosttyResult;+ pub fn ghostty_render_state_clean(state: GhosttyRenderState) -> GhosttyResult;+ pub fn ghostty_render_state_get(+ state: GhosttyRenderState,+ data: GhosttyRenderStateData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_get_multi(+ state: GhosttyRenderState,+ count: usize,+ keys: *const GhosttyRenderStateData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_set(+ state: GhosttyRenderState,+ option: GhosttyRenderStateOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_row_iterator_new(+ allocator: *const GhosttyAllocator,+ out_iterator: *mut GhosttyRenderStateRowIterator,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_row_iterator_free(iterator: GhosttyRenderStateRowIterator);+ pub fn ghostty_render_state_row_iterator_next(iterator: GhosttyRenderStateRowIterator) -> bool;+ pub fn ghostty_render_state_row_iterator_next_dirty(+ iterator: GhosttyRenderStateRowIterator,+ out_y: *mut u16,+ ) -> bool;+ pub fn ghostty_render_state_row_get(+ iterator: GhosttyRenderStateRowIterator,+ data: GhosttyRenderStateRowData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_row_get_multi(+ iterator: GhosttyRenderStateRowIterator,+ count: usize,+ keys: *const GhosttyRenderStateRowData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_row_set(+ iterator: GhosttyRenderStateRowIterator,+ option: GhosttyRenderStateRowOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_row_cells_new(+ allocator: *const GhosttyAllocator,+ out_cells: *mut GhosttyRenderStateRowCells,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_row_cells_next(cells: GhosttyRenderStateRowCells) -> bool;+ pub fn ghostty_render_state_row_cells_select(+ cells: GhosttyRenderStateRowCells,+ x: u16,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_row_cells_get(+ cells: GhosttyRenderStateRowCells,+ data: GhosttyRenderStateRowCellsData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_row_cells_get_multi(+ cells: GhosttyRenderStateRowCells,+ count: usize,+ keys: *const GhosttyRenderStateRowCellsData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_row_cells_free(cells: GhosttyRenderStateRowCells);+ pub fn ghostty_render_state_image_iterator_new(+ allocator: *const GhosttyAllocator,+ out_iterator: *mut GhosttyRenderStateImageIterator,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_image_iterator_free(iterator: GhosttyRenderStateImageIterator);+ pub fn ghostty_render_state_image_iterator_next(+ iterator: GhosttyRenderStateImageIterator,+ ) -> bool;+ pub fn ghostty_render_state_image_get(+ iterator: GhosttyRenderStateImageIterator,+ data: GhosttyRenderStateImageData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_render_state_image_get_multi(+ iterator: GhosttyRenderStateImageIterator,+ count: usize,+ keys: *const GhosttyRenderStateImageData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_tracked_grid_ref_free(ref_: GhosttyTrackedGridRef);+ pub fn ghostty_tracked_grid_ref_has_value(ref_: GhosttyTrackedGridRef) -> bool;+ pub fn ghostty_tracked_grid_ref_point(+ ref_: GhosttyTrackedGridRef,+ tag: GhosttyPointTag,+ out_point: *mut GhosttyPointCoordinate,+ ) -> GhosttyResult;+ pub fn ghostty_tracked_grid_ref_set(+ ref_: GhosttyTrackedGridRef,+ terminal: GhosttyTerminal,+ point: GhosttyPoint,+ ) -> GhosttyResult;+ pub fn ghostty_tracked_grid_ref_snapshot(+ ref_: GhosttyTrackedGridRef,+ out_ref: *mut GhosttyGridRef,+ ) -> GhosttyResult;+ pub fn ghostty_sgr_new(+ allocator: *const GhosttyAllocator,+ parser: *mut GhosttySgrParser,+ ) -> GhosttyResult;+ pub fn ghostty_sgr_free(parser: GhosttySgrParser);+ pub fn ghostty_sgr_reset(parser: GhosttySgrParser);+ pub fn ghostty_sgr_set_params(+ parser: GhosttySgrParser,+ params: *const u16,+ separators: *const ::core::ffi::c_char,+ len: usize,+ ) -> GhosttyResult;+ pub fn ghostty_sgr_next(parser: GhosttySgrParser, attr: *mut GhosttySgrAttribute) -> bool;+ pub fn ghostty_sgr_unknown_full(unknown: GhosttySgrUnknown, ptr: *mut *const u16) -> usize;+ pub fn ghostty_sgr_unknown_partial(unknown: GhosttySgrUnknown, ptr: *mut *const u16) -> usize;+ pub fn ghostty_sgr_attribute_tag(attr: *const GhosttySgrAttribute) -> GhosttySgrAttributeTag;+ pub fn ghostty_sgr_attribute_value(+ attr: *mut GhosttySgrAttribute,+ ) -> *mut GhosttySgrAttributeValue;+ pub fn ghostty_sys_set(+ option: GhosttySysOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_sys_log_stderr(+ userdata: *mut ::core::ffi::c_void,+ level: GhosttySysLogLevel,+ scope: *const u8,+ scope_len: usize,+ message: *const u8,+ message_len: usize,+ );+ pub fn ghostty_key_event_new(+ allocator: *const GhosttyAllocator,+ event: *mut GhosttyKeyEvent,+ ) -> GhosttyResult;+ pub fn ghostty_key_event_free(event: GhosttyKeyEvent);+ pub fn ghostty_key_event_set_action(+ event: GhosttyKeyEvent,+ action: GhosttyKeyAction,+ ) -> GhosttyResult;+ pub fn ghostty_key_event_get_action(event: GhosttyKeyEvent) -> GhosttyKeyAction;+ pub fn ghostty_key_event_set_key(event: GhosttyKeyEvent, key: GhosttyKey) -> GhosttyResult;+ pub fn ghostty_key_event_get_key(event: GhosttyKeyEvent) -> GhosttyKey;+ pub fn ghostty_key_event_set_mods(event: GhosttyKeyEvent, mods: GhosttyMods) -> GhosttyResult;+ pub fn ghostty_key_event_get_mods(event: GhosttyKeyEvent) -> GhosttyMods;+ pub fn ghostty_key_event_set_consumed_mods(+ event: GhosttyKeyEvent,+ consumed_mods: GhosttyMods,+ ) -> GhosttyResult;+ pub fn ghostty_key_event_get_consumed_mods(event: GhosttyKeyEvent) -> GhosttyMods;+ pub fn ghostty_key_event_set_composing(+ event: GhosttyKeyEvent,+ composing: bool,+ ) -> GhosttyResult;+ pub fn ghostty_key_event_get_composing(event: GhosttyKeyEvent) -> bool;+ pub fn ghostty_key_event_set_utf8(event: GhosttyKeyEvent, utf8: GhosttyString)+ -> GhosttyResult;+ pub fn ghostty_key_event_get_utf8(event: GhosttyKeyEvent) -> GhosttyString;+ pub fn ghostty_key_event_set_unshifted_codepoint(+ event: GhosttyKeyEvent,+ codepoint: u32,+ ) -> GhosttyResult;+ pub fn ghostty_key_event_get_unshifted_codepoint(event: GhosttyKeyEvent) -> u32;+ pub fn ghostty_key_encoder_new(+ allocator: *const GhosttyAllocator,+ encoder: *mut GhosttyKeyEncoder,+ ) -> GhosttyResult;+ pub fn ghostty_key_encoder_free(encoder: GhosttyKeyEncoder);+ pub fn ghostty_key_encoder_set(+ encoder: GhosttyKeyEncoder,+ option: GhosttyKeyEncoderOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_key_encoder_set_from_terminal(+ encoder: GhosttyKeyEncoder,+ terminal: GhosttyTerminal,+ ) -> GhosttyResult;+ pub fn ghostty_key_encoder_encode(+ encoder: GhosttyKeyEncoder,+ event: GhosttyKeyEvent,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_mouse_event_new(+ allocator: *const GhosttyAllocator,+ event: *mut GhosttyMouseEvent,+ ) -> GhosttyResult;+ pub fn ghostty_mouse_event_free(event: GhosttyMouseEvent);+ pub fn ghostty_mouse_event_set_action(+ event: GhosttyMouseEvent,+ action: GhosttyMouseAction,+ ) -> GhosttyResult;+ pub fn ghostty_mouse_event_get_action(event: GhosttyMouseEvent) -> GhosttyMouseAction;+ pub fn ghostty_mouse_event_set_button(+ event: GhosttyMouseEvent,+ button: GhosttyMouseButton,+ ) -> GhosttyResult;+ pub fn ghostty_mouse_event_clear_button(event: GhosttyMouseEvent) -> GhosttyResult;+ pub fn ghostty_mouse_event_get_button(+ event: GhosttyMouseEvent,+ out_button: *mut GhosttyMouseButton,+ ) -> GhosttyResult;+ pub fn ghostty_mouse_event_set_mods(+ event: GhosttyMouseEvent,+ mods: GhosttyMods,+ ) -> GhosttyResult;+ pub fn ghostty_mouse_event_get_mods(event: GhosttyMouseEvent) -> GhosttyMods;+ pub fn ghostty_mouse_event_set_position(+ event: GhosttyMouseEvent,+ position: GhosttyMousePosition,+ ) -> GhosttyResult;+ pub fn ghostty_mouse_event_get_position(event: GhosttyMouseEvent) -> GhosttyMousePosition;+ pub fn ghostty_mouse_encoder_new(+ allocator: *const GhosttyAllocator,+ encoder: *mut GhosttyMouseEncoder,+ ) -> GhosttyResult;+ pub fn ghostty_mouse_encoder_free(encoder: GhosttyMouseEncoder);+ pub fn ghostty_mouse_encoder_set(+ encoder: GhosttyMouseEncoder,+ option: GhosttyMouseEncoderOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_mouse_encoder_set_from_terminal(+ encoder: GhosttyMouseEncoder,+ terminal: GhosttyTerminal,+ ) -> GhosttyResult;+ pub fn ghostty_mouse_encoder_reset(encoder: GhosttyMouseEncoder) -> GhosttyResult;+ pub fn ghostty_mouse_encoder_encode(+ encoder: GhosttyMouseEncoder,+ event: GhosttyMouseEvent,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_terminal_paste(+ terminal: GhosttyTerminal,+ paste: *const GhosttyPaste,+ out_pasted: *mut bool,+ ) -> GhosttyResult;+ pub fn ghostty_paste_is_safe(data: *const ::core::ffi::c_char, len: usize) -> bool;+ pub fn ghostty_paste_encode(+ data: *mut ::core::ffi::c_char,+ data_len: usize,+ bracketed: bool,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_search_new(+ allocator: *const GhosttyAllocator,+ out_search: *mut GhosttySearch,+ terminal: GhosttyTerminal,+ ) -> GhosttyResult;+ pub fn ghostty_search_free(search: GhosttySearch);+ pub fn ghostty_search_tick(+ search: GhosttySearch,+ out_status: *mut GhosttySearchStatus,+ ) -> GhosttyResult;+ pub fn ghostty_search_feed(search: GhosttySearch) -> GhosttyResult;+ pub fn ghostty_search_run(search: GhosttySearch) -> GhosttyResult;+ pub fn ghostty_search_select_next(search: GhosttySearch) -> GhosttyResult;+ pub fn ghostty_search_select_prev(search: GhosttySearch) -> GhosttyResult;+ pub fn ghostty_search_set(+ search: GhosttySearch,+ option: GhosttySearchOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_search_get(+ search: GhosttySearch,+ data: GhosttySearchData,+ value: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_search_get_multi(+ search: GhosttySearch,+ count: usize,+ keys: *const GhosttySearchData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_snapshot_encode(+ terminal: GhosttyTerminal,+ writer: GhosttyWriter,+ ) -> GhosttyResult;+ pub fn ghostty_snapshot_encode_buf(+ terminal: GhosttyTerminal,+ buf: *mut u8,+ buf_len: usize,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_snapshot_encode_alloc(+ terminal: GhosttyTerminal,+ allocator: *const GhosttyAllocator,+ out_ptr: *mut *mut u8,+ out_len: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_snapshot_decoder_new(+ allocator: *const GhosttyAllocator,+ decoder: *mut GhosttySnapshotDecoder,+ reader: GhosttyReader,+ ) -> GhosttyResult;+ pub fn ghostty_snapshot_decoder_new_buf(+ allocator: *const GhosttyAllocator,+ decoder: *mut GhosttySnapshotDecoder,+ ptr: *const u8,+ len: usize,+ ) -> GhosttyResult;+ pub fn ghostty_snapshot_decoder_free(decoder: GhosttySnapshotDecoder);+ pub fn ghostty_snapshot_decoder_set(+ decoder: GhosttySnapshotDecoder,+ option: GhosttySnapshotDecoderOption,+ value: *const ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_snapshot_decoder_ready(+ decoder: GhosttySnapshotDecoder,+ terminal: *mut GhosttyTerminal,+ ) -> GhosttyResult;+ pub fn ghostty_snapshot_decoder_next(decoder: GhosttySnapshotDecoder) -> GhosttyResult;+ pub fn ghostty_snapshot_decoder_decode(+ decoder: GhosttySnapshotDecoder,+ terminal: *mut GhosttyTerminal,+ ) -> GhosttyResult;+ pub fn ghostty_snapshot_decoder_get(+ decoder: GhosttySnapshotDecoder,+ data: GhosttySnapshotDecoderData,+ out: *mut ::core::ffi::c_void,+ ) -> GhosttyResult;+ pub fn ghostty_snapshot_decoder_get_multi(+ decoder: GhosttySnapshotDecoder,+ count: usize,+ keys: *const GhosttySnapshotDecoderData,+ values: *mut *mut ::core::ffi::c_void,+ out_written: *mut usize,+ ) -> GhosttyResult;+ pub fn ghostty_unicode_codepoint_width(cp: u32) -> u8;+ pub fn ghostty_unicode_grapheme_width(cps: *const u32, len: usize, width: *mut u8) -> usize;+}diff --git a/native/crates/ghostty_vt/src/tests.rs b/native/crates/ghostty_vt/src/tests.rsnew file mode 100644index 00000000000..e58f2841e5e--- /dev/null+++ b/native/crates/ghostty_vt/src/tests.rs@@ -0,0 +1,119 @@+use super::*;++fn term(cols: u16, rows: u16) -> Term {+ Term::new(cols, rows, Config::default())+}++fn text(term: &Term, line: i32) -> String {+ term.row(Line(line)).iter().map(|cell| cell.c).collect::<String>().trim_end().to_owned()+}++#[test]+fn printed_text_and_sgr_reach_the_cells() {+ let mut term = term(10, 3);+ term.advance(b"a\x1b[1;31;48;2;1;2;3mb\x1b[4:3;58;5;9mc\x1b[0m");+ assert_eq!(text(&term, 0), "abc");+ let b = term.cell(Point::new(Line(0), Column(1)));+ assert_eq!((b.fg, b.bg), (Color::Indexed(1), Color::Spec(Rgb { r: 1, g: 2, b: 3 })));+ assert!(b.flags.contains(Flags::BOLD));+ let c = term.cell(Point::new(Line(0), Column(2)));+ assert!(c.flags.contains(Flags::UNDERCURL));+ assert_eq!(c.underline_color, Some(Color::Indexed(9)));+ let blank = term.cell(Point::new(Line(0), Column(5)));+ assert_eq!(blank, Cell::default());+}++#[test]+fn wide_characters_and_combining_marks_keep_their_cells() {+ let mut term = term(10, 2);+ term.advance("界e\u{301}".as_bytes());+ let row = term.row(Line(0));+ assert!(row[Column(0)].flags.contains(Flags::WIDE_CHAR));+ assert!(row[Column(1)].flags.contains(Flags::WIDE_CHAR_SPACER));+ assert_eq!((row[Column(2)].c, row[Column(2)].zerowidth.as_slice()), ('e', &['\u{301}'][..]));+}++#[test]+fn a_variation_selector_stays_with_its_emoji() {+ let mut term = term(10, 2);+ term.advance("✌\u{fe0f}👍".as_bytes());+ let row = term.row(Line(0));+ assert_eq!((row[Column(0)].c, row[Column(0)].zerowidth.as_slice(), row[Column(0)].flags), ('✌', &['\u{fe0f}'][..], Flags::empty()));+ assert_eq!(row[Column(1)].c, '👍');+}++#[test]+fn a_soft_wrap_marks_the_last_column_and_scrollback_keeps_lines() {+ let mut term = term(4, 2);+ term.advance(b"abcdef\r\n1\r\n2");+ assert_eq!(term.history_size(), 2);+ assert_eq!(text(&term, -2), "abcd");+ assert!(term.wraps(Line(-2)));+ assert!(term.cell(Point::new(Line(-2), Column(3))).flags.contains(Flags::WRAPLINE));+ assert!(!term.wraps(Line(-1)));+ assert_eq!(term.row(Line(-2)).line_length(), Column(4));+}++#[test]+fn the_scrollback_limit_hides_older_lines() {+ let mut term = Term::new(4, 2, Config { scrolling_history: 3, ..Config::default() });+ for line in 0..20 {+ term.advance(format!("{line}\r\n").as_bytes());+ }+ assert_eq!(term.history_size(), 3);+ assert_eq!(text(&term, -3), "16");+ term.scroll_display(Scroll::Top);+ assert_eq!(term.display_offset(), 3);+ term.scroll_display(Scroll::Delta(100));+ assert_eq!(term.display_offset(), 3);+ term.scroll_display(Scroll::Bottom);+ assert_eq!(term.display_offset(), 0);+}++#[test]+fn queries_get_xterm_js_replies() {+ let mut term = term(80, 24);+ term.set_cell_size(8, 16);+ term.advance(b"\x1b[c\x1b[>c\x1b[>q\x1b[6n\x1b[14t");+ let reply = String::from_utf8(term.take_effects().pty_write).unwrap();+ assert_eq!(reply, "\x1b[?1;2c\x1b[>0;276;0c\x1bP>|xterm.js(6.1.0-beta.337)\x1b\\\x1b[1;1R\x1b[4;384;640t");+}++#[test]+fn bell_title_and_modes_are_reported() {+ let mut term = term(10, 2);+ term.advance(b"\x07\x1b]0;hi\x07\x1b[?1h\x1b[?2004h\x1b[?1049h");+ let effects = term.take_effects();+ assert!(effects.bell);+ assert_eq!(effects.title.as_deref(), Some("hi"));+ let mode = term.mode();+ assert!(mode.contains(TermMode::APP_CURSOR | TermMode::BRACKETED_PASTE | TermMode::ALT_SCREEN));+ assert!(!mode.intersects(TermMode::MOUSE_MODE));+}++#[test]+fn a_selection_reads_text_and_follows_scrolled_output() {+ let mut term = term(5, 2);+ term.advance(b"ab cd\r\nef");+ term.start_selection(SelectionType::Simple, Point::new(Line(0), Column(0)), Side::Left);+ term.update_selection(Point::new(Line(1), Column(1)), Side::Right);+ assert_eq!(term.selection_to_string().as_deref(), Some("ab cd\nef"));+ term.advance(b"\r\n\r\n");+ assert_eq!(term.selection_range().map(|range| range.start.line), Some(Line(-2)));+ term.start_selection(SelectionType::Semantic, Point::new(Line(-2), Column(4)), Side::Left);+ assert_eq!(term.selection_to_string().as_deref(), Some("cd"));+ term.resize(6, 2);+ assert!(!term.has_selection());+}++#[test]+fn osc_colors_override_the_defaults() {+ let mut term = term(5, 2);+ let colors = DefaultColors { palette: [Rgb::default(); 256], foreground: Rgb { r: 1, g: 1, b: 1 }, background: Rgb::default(), cursor: Rgb::default() };+ term.set_default_colors(colors);+ term.advance(b"\x1b]4;1;rgb:ff/00/00\x07\x1b]10;?\x07");+ let overrides = term.color_overrides();+ assert_eq!(overrides[1], Some(Rgb { r: 255, g: 0, b: 0 }));+ assert_eq!(overrides[256], None);+ assert!(String::from_utf8(term.take_effects().pty_write).unwrap().starts_with("\x1b]10;rgb:0101/0101/0101"));+}