mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 08:16:13 +03:00
config: add cursor-opacity
This commit is contained in:
@ -174,6 +174,13 @@ palette: Palette = .{},
|
||||
/// The color of the cursor. If this is not set, a default will be chosen.
|
||||
@"cursor-color": ?Color = null,
|
||||
|
||||
/// The opacity level (opposite of transparency) of the cursor.
|
||||
/// A value of 1 is fully opaque and a value of 0 is fully transparent.
|
||||
/// A value less than 0 or greater than 1 will be clamped to the nearest
|
||||
/// valid value. Note that a sufficiently small value such as 0.3 may be
|
||||
/// effectively invisible and may make it difficult to find the cursor.
|
||||
@"cursor-opacity": f64 = 1.0,
|
||||
|
||||
/// The style of the cursor. This sets the default style. A running
|
||||
/// programn can still request an explicit cursor style using escape
|
||||
/// sequences (such as CSI q). Shell configurations will often request
|
||||
|
@ -104,6 +104,7 @@ pub const DerivedConfig = struct {
|
||||
font_features: std.ArrayList([]const u8),
|
||||
font_styles: font.Group.StyleStatus,
|
||||
cursor_color: ?terminal.color.RGB,
|
||||
cursor_opacity: f64,
|
||||
cursor_text: ?terminal.color.RGB,
|
||||
background: terminal.color.RGB,
|
||||
background_opacity: f64,
|
||||
@ -144,6 +145,8 @@ pub const DerivedConfig = struct {
|
||||
else
|
||||
null,
|
||||
|
||||
.cursor_opacity = @max(0, @min(1, config.@"cursor-opacity")),
|
||||
|
||||
.background = config.background.toTerminalRGB(),
|
||||
.foreground = config.foreground.toTerminalRGB(),
|
||||
|
||||
@ -1419,6 +1422,10 @@ fn addCursor(
|
||||
};
|
||||
|
||||
const color = self.config.cursor_color orelse self.config.foreground;
|
||||
const alpha: u8 = alpha: {
|
||||
const alpha = 255 * self.config.cursor_opacity;
|
||||
break :alpha @intFromFloat(@ceil(alpha));
|
||||
};
|
||||
|
||||
const sprite: font.Sprite = switch (cursor_style) {
|
||||
.block => .cursor_rect,
|
||||
@ -1444,7 +1451,7 @@ fn addCursor(
|
||||
@as(f32, @floatFromInt(screen.cursor.y)),
|
||||
},
|
||||
.cell_width = if (cell.attrs.wide) 2 else 1,
|
||||
.color = .{ color.r, color.g, color.b, 0xFF },
|
||||
.color = .{ color.r, color.g, color.b, alpha },
|
||||
.glyph_pos = .{ glyph.atlas_x, glyph.atlas_y },
|
||||
.glyph_size = .{ glyph.width, glyph.height },
|
||||
.glyph_offset = .{ glyph.offset_x, glyph.offset_y },
|
||||
|
@ -219,6 +219,7 @@ pub const DerivedConfig = struct {
|
||||
font_styles: font.Group.StyleStatus,
|
||||
cursor_color: ?terminal.color.RGB,
|
||||
cursor_text: ?terminal.color.RGB,
|
||||
cursor_opacity: f64,
|
||||
background: terminal.color.RGB,
|
||||
background_opacity: f64,
|
||||
foreground: terminal.color.RGB,
|
||||
@ -258,6 +259,8 @@ pub const DerivedConfig = struct {
|
||||
else
|
||||
null,
|
||||
|
||||
.cursor_opacity = @max(0, @min(1, config.@"cursor-opacity")),
|
||||
|
||||
.background = config.background.toTerminalRGB(),
|
||||
.foreground = config.foreground.toTerminalRGB(),
|
||||
|
||||
@ -870,6 +873,10 @@ fn addCursor(
|
||||
};
|
||||
|
||||
const color = self.config.cursor_color orelse self.config.foreground;
|
||||
const alpha: u8 = alpha: {
|
||||
const alpha = 255 * self.config.cursor_opacity;
|
||||
break :alpha @intFromFloat(@ceil(alpha));
|
||||
};
|
||||
|
||||
const sprite: font.Sprite = switch (cursor_style) {
|
||||
.block => .cursor_rect,
|
||||
@ -896,7 +903,7 @@ fn addCursor(
|
||||
.fg_r = color.r,
|
||||
.fg_g = color.g,
|
||||
.fg_b = color.b,
|
||||
.fg_a = 255,
|
||||
.fg_a = alpha,
|
||||
.bg_r = 0,
|
||||
.bg_g = 0,
|
||||
.bg_b = 0,
|
||||
|
Reference in New Issue
Block a user