From e0f55486d2f4f7a2bda2fe543cd3549fef7ce78b Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 22 Mar 2024 20:53:33 +0100 Subject: [PATCH] feat: add editor_widget colors --- src/compile.zig | 31 +++++++++++++++++++++++++++++++ src/theme.zig | 2 ++ 2 files changed, 33 insertions(+) diff --git a/src/compile.zig b/src/compile.zig index 46896fc..0588162 100644 --- a/src/compile.zig +++ b/src/compile.zig @@ -67,6 +67,8 @@ fn load_json(theme_: *theme_file) theme { .editor_gutter_modified = derive_style.editor_gutter_modified(type_idx, cb), .editor_gutter_added = derive_style.editor_gutter_added(type_idx, cb), .editor_gutter_deleted = derive_style.editor_gutter_deleted(type_idx, cb), + .editor_widget = derive_style.editor_widget(type_idx, cb), + .editor_widget_border = derive_style.editor_widget_border(type_idx, cb), .statusbar = derive_style.statusbar(type_idx, cb), .statusbar_hover = derive_style.statusbar_hover(type_idx, cb), .scrollbar = derive_style.scrollbar(type_idx, cb), @@ -458,6 +460,20 @@ const derive_style = struct { }; } + fn editor_widget(type_idx: usize, cb: []const u8) Style { + return .{ + .fg = if (find_color("editorWidget.foreground", cb)) |col| col else defaults.@"editorWidget.foreground"(type_idx, cb), + .bg = if (find_color("editorWidget.background", cb)) |col| col else defaults.@"editorWidget.background"(type_idx, cb), + }; + } + + fn editor_widget_border(type_idx: usize, cb: []const u8) Style { + return .{ + .fg = if (find_color("editorWidget.foreground", cb)) |col| col else defaults.@"editorWidget.foreground"(type_idx, cb), + .bg = if (find_color("editorWidget.border", cb)) |col| col else defaults.@"editorWidget.border"(type_idx, cb), + }; + } + fn statusbar(type_idx: usize, cb: []const u8) Style { return .{ .fg = if (find_color("statusBar.foreground", cb)) |col| col else defaults.@"statusBar.foreground"(type_idx, cb), @@ -657,6 +673,21 @@ const defaults = struct { fn @"editorGutter.deletedBackground"(type_idx: usize, cb: []const u8) ?Color { return @"editorError.foreground"(type_idx, cb); } + + // registerColor('editorWidget.foreground', { dark: foreground, light: foreground, hcDark: foreground, hcLight: foreground }, nls.localize('editorWidgetForeground', 'Foreground color of editor widgets, such as find/replace.')); + fn @"editorWidget.foreground"(type_idx: usize, cb: []const u8) ?Color { + return derive_style.editor(type_idx, cb).fg; + } + + // registerColor('editorWidget.background', { dark: '#252526', light: '#F3F3F3', hcDark: '#0C141F', hcLight: Color.white }, nls.localize('editorWidgetBackground', 'Background color of editor widgets, such as find/replace.')); + fn @"editorWidget.background"(type_idx: usize, _: []const u8) ?Color { + return ([2]Color{ 0x252526, 0xF3F3F3 })[type_idx]; + } + + // registerColor('editorWidget.border', { dark: '#454545', light: '#C8C8C8', hcDark: contrastBorder, hcLight: contrastBorder }, nls.localize('editorWidgetBorder', 'Border color of editor widgets. The color is only used if the widget chooses to have a border and if the color is not overridden by a widget.')); + fn @"editorWidget.border"(type_idx: usize, _: []const u8) ?Color { + return ([2]Color{ 0x454545, 0xC8C8C8 })[type_idx]; + } }; const Writer = std.fs.File.Writer; diff --git a/src/theme.zig b/src/theme.zig index c88fb41..864a1a2 100644 --- a/src/theme.zig +++ b/src/theme.zig @@ -15,6 +15,8 @@ editor_gutter_active: Style, editor_gutter_modified: Style, editor_gutter_added: Style, editor_gutter_deleted: Style, +editor_widget: Style, +editor_widget_border: Style, statusbar: Style, statusbar_hover: Style, scrollbar: Style,