diff --git a/include/ghostty/vt/render.h b/include/ghostty/vt/render.h index e268c54eb..3823d56f5 100644 --- a/include/ghostty/vt/render.h +++ b/include/ghostty/vt/render.h @@ -126,6 +126,23 @@ typedef enum { * It is unsafe to use row data after updating the render state. * */ GHOSTTY_RENDER_STATE_DATA_ROW_ITERATOR = 4, + + /** Default/current background color (GhosttyColorRgb). */ + GHOSTTY_RENDER_STATE_DATA_COLOR_BACKGROUND = 5, + + /** Default/current foreground color (GhosttyColorRgb). */ + GHOSTTY_RENDER_STATE_DATA_COLOR_FOREGROUND = 6, + + /** Cursor color when explicitly set by terminal state (GhosttyColorRgb). + * Returns GHOSTTY_INVALID_VALUE if no explicit cursor color is set; + * use COLOR_CURSOR_HAS_VALUE to check first. */ + GHOSTTY_RENDER_STATE_DATA_COLOR_CURSOR = 7, + + /** Whether an explicit cursor color is set (bool). */ + GHOSTTY_RENDER_STATE_DATA_COLOR_CURSOR_HAS_VALUE = 8, + + /** The active 256-color palette (GhosttyColorRgb[256]). */ + GHOSTTY_RENDER_STATE_DATA_COLOR_PALETTE = 9, } GhosttyRenderStateData; /** diff --git a/src/terminal/c/render.zig b/src/terminal/c/render.zig index f097eba28..75a02b114 100644 --- a/src/terminal/c/render.zig +++ b/src/terminal/c/render.zig @@ -60,6 +60,11 @@ pub const Data = enum(c_int) { rows = 2, dirty = 3, row_iterator = 4, + color_background = 5, + color_foreground = 6, + color_cursor = 7, + color_cursor_has_value = 8, + color_palette = 9, /// Output type expected for querying the data of the given kind. pub fn OutType(comptime self: Data) type { @@ -68,6 +73,9 @@ pub const Data = enum(c_int) { .cols, .rows => size.CellCountInt, .dirty => Dirty, .row_iterator => RowIterator, + .color_background, .color_foreground, .color_cursor => colorpkg.RGB.C, + .color_cursor_has_value => bool, + .color_palette => [256]colorpkg.RGB.C, }; } }; @@ -177,6 +185,18 @@ fn getTyped( .dirty = row_data.items(.dirty), }; }, + .color_background => out.* = state.state.colors.background.cval(), + .color_foreground => out.* = state.state.colors.foreground.cval(), + .color_cursor => { + const cursor = state.state.colors.cursor orelse return .invalid_value; + out.* = cursor.cval(); + }, + .color_cursor_has_value => out.* = state.state.colors.cursor != null, + .color_palette => { + for (&out.*, state.state.colors.palette) |*dst, src| { + dst.* = src.cval(); + } + }, } return .success;