aboutsummaryrefslogtreecommitdiff
path: root/src/ghostty
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-25 22:08:11 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-25 22:08:11 +0300
commit292a98a91e35662fd65993956278787ee0ca9840 (patch)
treeab14f0f075a5c92dab32373678a4e213c95bb2b0 /src/ghostty
parentdb1ef28d64279b290b882eea9a7a655dd78d08c9 (diff)
fix: answer osc 12 cursor color queries
refs #806
Diffstat (limited to 'src/ghostty')
-rw-r--r--src/ghostty/mod.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ghostty/mod.rs b/src/ghostty/mod.rs
index 2b45e3d8..3800ab49 100644
--- a/src/ghostty/mod.rs
+++ b/src/ghostty/mod.rs
@@ -162,6 +162,10 @@ pub const MODE_MOUSE_SGR_PIXELS: u16 = 1016;
pub const MODE_BRACKETED_PASTE: u16 = 2004;
pub const MODE_SYNCHRONIZED_OUTPUT: u16 = 2026;
pub const MODE_GRAPHEME_CLUSTER: u16 = 2027;
+// These are documented in vendor/libghostty-vt/include/ghostty/vt/terminal.h,
+// but the generated bindings do not currently expose named constants for them.
+const TERMINAL_DATA_COLOR_FOREGROUND: ffi::GhosttyTerminalData = 18;
+const TERMINAL_DATA_COLOR_CURSOR: ffi::GhosttyTerminalData = 20;
const KITTY_IMAGE_STORAGE_LIMIT_BYTES: u64 = 64 * 1024 * 1024;
const APC_MAX_BYTES: usize = 16 * 1024 * 1024;
@@ -1006,6 +1010,14 @@ impl Terminal {
self.get_u16(ffi::GhosttyTerminalData_GHOSTTY_TERMINAL_DATA_ROWS)
}
+ pub fn effective_foreground_color(&self) -> Result<Option<RgbColor>, Error> {
+ self.get_optional_rgb_color(TERMINAL_DATA_COLOR_FOREGROUND)
+ }
+
+ pub fn effective_cursor_color(&self) -> Result<Option<RgbColor>, Error> {
+ self.get_optional_rgb_color(TERMINAL_DATA_COLOR_CURSOR)
+ }
+
fn width_px(&self) -> Result<u32, Error> {
self.get_u32(ffi::GhosttyTerminalData_GHOSTTY_TERMINAL_DATA_WIDTH_PX)
}
@@ -1052,6 +1064,25 @@ impl Terminal {
Ok(out)
}
+ fn get_optional_rgb_color(
+ &self,
+ data: ffi::GhosttyTerminalData,
+ ) -> Result<Option<RgbColor>, Error> {
+ let mut out = ffi::GhosttyColorRgb::default();
+ let result = unsafe {
+ ffi::ghostty_terminal_get(
+ self.raw,
+ data,
+ (&mut out as *mut ffi::GhosttyColorRgb).cast(),
+ )
+ };
+ match result {
+ ffi::GhosttyResult_GHOSTTY_SUCCESS => Ok(Some(out.into())),
+ ffi::GhosttyResult_GHOSTTY_NO_VALUE => Ok(None),
+ other => Err(Error(other)),
+ }
+ }
+
pub fn kitty_image_placements(&self) -> Result<Vec<KittyImagePlacement>, Error> {
self.kitty_image_placements_with_data_filter(|_| true)
}