mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
rename config
This commit is contained in:
@@ -784,14 +784,29 @@ foreground: Color = .{ .r = 0xFF, .g = 0xFF, .b = 0xFF },
|
||||
///
|
||||
/// For definitions on the color indices and what they canonically map to,
|
||||
/// [see this cheat sheet](https://www.ditig.com/256-colors-cheat-sheet).
|
||||
///
|
||||
/// For most themes, you only need to set the first 16 colors (0–15) since the
|
||||
/// rest of the palette (16–255) will be automatically generated by
|
||||
/// default (see `palette-generate` for more details).
|
||||
palette: Palette = .{},
|
||||
|
||||
/// Whether to generate the extended 256 palette from your base16 colors.
|
||||
/// This option is true by default but will not replace manually defined colors.
|
||||
/// Whether to automatically generate the extended 256 color palette
|
||||
/// (indices 16–255) from the base 16 ANSI colors.
|
||||
///
|
||||
/// For more information
|
||||
/// [see here](https://gist.github.com/jake-stewart/0a8ea46159a7da2c808e5be2177e1783).
|
||||
@"generate-256-palette": bool = true,
|
||||
/// This lets theme authors specify only the base 16 colors and have the
|
||||
/// rest of the palette be automatically generated in a consistent and
|
||||
/// aesthetic way.
|
||||
///
|
||||
/// When enabled, the 6×6×6 color cube and 24-step grayscale ramp are
|
||||
/// derived from interpolations of the base palette, giving a more cohesive
|
||||
/// look. Colors that have been explicitly set via `palette` are never
|
||||
/// overwritten.
|
||||
///
|
||||
/// For more information on how the generation works, see here:
|
||||
/// https://gist.github.com/jake-stewart/0a8ea46159a7da2c808e5be2177e1783
|
||||
///
|
||||
/// Available since: 1.3.0
|
||||
@"palette-generate": bool = true,
|
||||
|
||||
/// The color of the cursor. If this is not set, a default will be chosen.
|
||||
///
|
||||
@@ -5537,8 +5552,7 @@ pub const ColorList = struct {
|
||||
}
|
||||
};
|
||||
|
||||
/// Palette is the 256 color palette for 256-color mode. This is still
|
||||
/// used by many terminal applications.
|
||||
/// Palette is the 256 color palette for 256-color mode.
|
||||
pub const Palette = struct {
|
||||
const Self = @This();
|
||||
|
||||
@@ -5546,9 +5560,7 @@ pub const Palette = struct {
|
||||
value: terminal.color.Palette = terminal.color.default,
|
||||
|
||||
/// Keep track of which indexes were manually set by the user.
|
||||
mask: Mask = .initEmpty(),
|
||||
|
||||
const Mask = std.StaticBitSet(@typeInfo(terminal.color.Palette).array.len);
|
||||
mask: terminal.color.PaletteMask = .initEmpty(),
|
||||
|
||||
/// ghostty_config_palette_s
|
||||
pub const C = extern struct {
|
||||
@@ -5622,6 +5634,8 @@ pub const Palette = struct {
|
||||
try testing.expect(p.value[0].r == 0xAA);
|
||||
try testing.expect(p.value[0].g == 0xBB);
|
||||
try testing.expect(p.value[0].b == 0xCC);
|
||||
try testing.expect(p.mask.isSet(0));
|
||||
try testing.expect(!p.mask.isSet(1));
|
||||
}
|
||||
|
||||
test "parseCLI base" {
|
||||
@@ -5644,6 +5658,12 @@ pub const Palette = struct {
|
||||
try testing.expect(p.value[0xF].r == 0xAB);
|
||||
try testing.expect(p.value[0xF].g == 0xCD);
|
||||
try testing.expect(p.value[0xF].b == 0xEF);
|
||||
|
||||
try testing.expect(p.mask.isSet(0b1));
|
||||
try testing.expect(p.mask.isSet(0o7));
|
||||
try testing.expect(p.mask.isSet(0xF));
|
||||
try testing.expect(!p.mask.isSet(0));
|
||||
try testing.expect(!p.mask.isSet(2));
|
||||
}
|
||||
|
||||
test "parseCLI overflow" {
|
||||
@@ -5651,6 +5671,8 @@ pub const Palette = struct {
|
||||
|
||||
var p: Self = .{};
|
||||
try testing.expectError(error.Overflow, p.parseCLI("256=#AABBCC"));
|
||||
// Mask should remain empty since parsing failed.
|
||||
try testing.expectEqual(@as(usize, 0), p.mask.count());
|
||||
}
|
||||
|
||||
test "formatConfig" {
|
||||
@@ -5682,6 +5704,11 @@ pub const Palette = struct {
|
||||
try testing.expect(p.value[2].r == 0x12);
|
||||
try testing.expect(p.value[2].g == 0x34);
|
||||
try testing.expect(p.value[2].b == 0x56);
|
||||
|
||||
try testing.expect(p.mask.isSet(0));
|
||||
try testing.expect(p.mask.isSet(1));
|
||||
try testing.expect(p.mask.isSet(2));
|
||||
try testing.expect(!p.mask.isSet(3));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -167,9 +167,7 @@ pub const DynamicPalette = struct {
|
||||
|
||||
/// A bitset where each bit represents whether the corresponding
|
||||
/// palette index has been modified from its default value.
|
||||
mask: Mask,
|
||||
|
||||
const Mask = std.StaticBitSet(@typeInfo(Palette).array.len);
|
||||
mask: PaletteMask,
|
||||
|
||||
pub const default: DynamicPalette = .init(colorpkg.default);
|
||||
|
||||
|
||||
@@ -175,8 +175,13 @@ pub const DerivedConfig = struct {
|
||||
errdefer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
|
||||
const palette = if (config.@"generate-256-palette")
|
||||
terminalpkg.color.generate_256_palette(config.palette.value, config.palette.mask, config.background.toTerminalRGB(), config.foreground.toTerminalRGB())
|
||||
const palette: terminalpkg.color.Palette = if (config.@"palette-generate")
|
||||
terminalpkg.color.generate256Color(
|
||||
config.palette.value,
|
||||
config.palette.mask,
|
||||
config.background.toTerminalRGB(),
|
||||
config.foreground.toTerminalRGB(),
|
||||
)
|
||||
else
|
||||
config.palette.value;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user