config: add text-blink option to opt out of text blinking

This commit is contained in:
Leah Amelia Chen
2024-09-02 22:22:29 +02:00
parent 7d150b050c
commit 789cec1b8b
2 changed files with 11 additions and 2 deletions

View File

@ -346,6 +346,13 @@ foreground: Color = .{ .r = 0xFF, .g = 0xFF, .b = 0xFF },
/// This value does not apply to Emoji or images. /// This value does not apply to Emoji or images.
@"minimum-contrast": f64 = 1, @"minimum-contrast": f64 = 1,
/// Whether to enable blinking text.
/// Text can be made to blink via a SGR sequence, which is synchronized with
/// cursor blinking when that is enabled. Text blinking and cursor blinking
/// can be independently toggled on or off without interfering with each other:
/// to adjust cursor blinking settings, see `cursor-style-blink`.
@"text-blink": bool = true,
/// Color palette for the 256 color form that many terminal applications use. /// Color palette for the 256 color form that many terminal applications use.
/// The syntax of this configuration is `N=HEXCODE` where `N` is 0 to 255 (for /// The syntax of this configuration is `N=HEXCODE` where `N` is 0 to 255 (for
/// the 256 colors in the terminal color table) and `HEXCODE` is a typical RGB /// the 256 colors in the terminal color table) and `HEXCODE` is a typical RGB

View File

@ -93,7 +93,7 @@ flags: packed struct {
/// This is true when blinking text should be visible and false /// This is true when blinking text should be visible and false
/// when it should not be visible. This is toggled on a timer by the /// when it should not be visible. This is toggled on a timer by the
/// thread automatically. /// thread automatically.
blink_visible: bool = false, blink_visible: bool = true,
/// Whether the cursor should be forced into staying visible regardless /// Whether the cursor should be forced into staying visible regardless
/// of blinking. Used when the user is typing. /// of blinking. Used when the user is typing.
@ -109,10 +109,12 @@ flags: packed struct {
pub const DerivedConfig = struct { pub const DerivedConfig = struct {
custom_shader_animation: configpkg.CustomShaderAnimation, custom_shader_animation: configpkg.CustomShaderAnimation,
text_blink: bool,
pub fn init(config: *const configpkg.Config) DerivedConfig { pub fn init(config: *const configpkg.Config) DerivedConfig {
return .{ return .{
.custom_shader_animation = config.@"custom-shader-animation", .custom_shader_animation = config.@"custom-shader-animation",
.text_blink = config.@"text-blink",
}; };
} }
}; };
@ -547,7 +549,7 @@ fn renderCallback(
t.renderer.updateFrame( t.renderer.updateFrame(
t.surface, t.surface,
t.state, t.state,
t.flags.blink_visible, !t.config.text_blink or t.flags.blink_visible,
t.flags.cursor_always_visible or t.flags.blink_visible, t.flags.cursor_always_visible or t.flags.blink_visible,
) catch |err| ) catch |err|
log.warn("error rendering err={}", .{err}); log.warn("error rendering err={}", .{err});