mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
ability to customize cursor color
This commit is contained in:
@ -52,6 +52,9 @@ pub const Config = struct {
|
||||
/// https://www.ditig.com/256-colors-cheat-sheet
|
||||
palette: Palette = .{},
|
||||
|
||||
/// The color of the cursor. If this is not set, a default will be chosen.
|
||||
@"cursor-color": ?Color = null,
|
||||
|
||||
/// The command to run, usually a shell. If this is not an absolute path,
|
||||
/// it'll be looked up in the PATH. If this is not set, a default will
|
||||
/// be looked up from your system. The rules for the default lookup are:
|
||||
|
@ -47,6 +47,7 @@ focused: bool,
|
||||
/// blinking.
|
||||
cursor_visible: bool,
|
||||
cursor_style: renderer.CursorStyle,
|
||||
cursor_color: ?terminal.color.RGB,
|
||||
|
||||
/// Default foreground color
|
||||
foreground: terminal.color.RGB,
|
||||
@ -240,6 +241,7 @@ pub fn init(alloc: Allocator, options: renderer.Options) !Metal {
|
||||
.focused = true,
|
||||
.cursor_visible = true,
|
||||
.cursor_style = .box,
|
||||
.cursor_color = if (options.config.@"cursor-color") |col| col.toTerminalRGB() else null,
|
||||
.background = options.config.background.toTerminalRGB(),
|
||||
.foreground = options.config.foreground.toTerminalRGB(),
|
||||
.selection_background = if (options.config.@"selection-background") |bg|
|
||||
@ -921,6 +923,12 @@ fn addCursor(self: *Metal, screen: *terminal.Screen) void {
|
||||
screen.cursor.x,
|
||||
);
|
||||
|
||||
const color = self.cursor_color orelse terminal.color.RGB{
|
||||
.r = 0xFF,
|
||||
.g = 0xFF,
|
||||
.b = 0xFF,
|
||||
};
|
||||
|
||||
self.cells.appendAssumeCapacity(.{
|
||||
.mode = GPUCellMode.fromCursor(self.cursor_style),
|
||||
.grid_pos = .{
|
||||
@ -928,7 +936,7 @@ fn addCursor(self: *Metal, screen: *terminal.Screen) void {
|
||||
@intToFloat(f32, screen.cursor.y),
|
||||
},
|
||||
.cell_width = if (cell.attrs.wide) 2 else 1,
|
||||
.color = .{ 0xFF, 0xFF, 0xFF, 0xFF },
|
||||
.color = .{ color.r, color.g, color.b, 0xFF },
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ font_shaper: font.Shaper,
|
||||
/// blinking.
|
||||
cursor_visible: bool,
|
||||
cursor_style: renderer.CursorStyle,
|
||||
cursor_color: ?terminal.color.RGB,
|
||||
|
||||
/// Default foreground color
|
||||
foreground: terminal.color.RGB,
|
||||
@ -300,6 +301,7 @@ pub fn init(alloc: Allocator, options: renderer.Options) !OpenGL {
|
||||
.font_shaper = shaper,
|
||||
.cursor_visible = true,
|
||||
.cursor_style = .box,
|
||||
.cursor_color = if (options.config.@"cursor-color") |col| col.toTerminalRGB() else null,
|
||||
.background = options.config.background.toTerminalRGB(),
|
||||
.foreground = options.config.foreground.toTerminalRGB(),
|
||||
.selection_background = if (options.config.@"selection-background") |bg|
|
||||
@ -821,6 +823,12 @@ fn addCursor(self: *OpenGL, screen: *terminal.Screen) void {
|
||||
screen.cursor.x,
|
||||
);
|
||||
|
||||
const color = self.cursor_color orelse terminal.color.RGB{
|
||||
.r = 0xFF,
|
||||
.g = 0xFF,
|
||||
.b = 0xFF,
|
||||
};
|
||||
|
||||
self.cells.appendAssumeCapacity(.{
|
||||
.mode = GPUCellMode.fromCursor(self.cursor_style),
|
||||
.grid_col = @intCast(u16, screen.cursor.x),
|
||||
@ -830,9 +838,9 @@ fn addCursor(self: *OpenGL, screen: *terminal.Screen) void {
|
||||
.fg_g = 0,
|
||||
.fg_b = 0,
|
||||
.fg_a = 0,
|
||||
.bg_r = 0xFF,
|
||||
.bg_g = 0xFF,
|
||||
.bg_b = 0xFF,
|
||||
.bg_r = color.r,
|
||||
.bg_g = color.g,
|
||||
.bg_b = color.b,
|
||||
.bg_a = 255,
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user