╭ changed ────────╮ │src/ui/widget.zig│ ╰─────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │1290 38, 48 => { │ │1291 // truecolor form: 38;2;r;g;b — anything else is ignored│ │1292 if (i + 4 < n and nums[i + 1] == 2) { │ │1293 - const c = Grid.Color{ │ │1293 + const c = Grid.Color{ .rgb = .{ │ │1294 .r = @truncate(nums[i + 2]), │ │1295 .g = @truncate(nums[i + 3]), │ │1296 .b = @truncate(nums[i + 4]), │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │1297 - }; │ │1297 + } }; │ │1298 if (nums[i] == 38) style.fg = c else style.bg = c;│ │1299 i += 4; │ │1300 } │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │1389 // stays legible over it │ │1390 const art_brightness = 35; // percent │ │1391 │ │1392 + // only truecolor can be dimmed; palette colors pass through │ │1393 fn dimColor(color: ?Grid.Color) ?Grid.Color { │ │1394 const c = color orelse return null; │ │1394 - return .{ │ │1395 - .r = @intCast(@as(u16, c.r) * art_brightness / 100), │ │1396 - .g = @intCast(@as(u16, c.g) * art_brightness / 100), │ │1397 - .b = @intCast(@as(u16, c.b) * art_brightness / 100), │ │1395 + return switch (c) { │ │1396 + .rgb => |v| .{ .rgb = .{ │ │1397 + .r = @intCast(@as(u16, v.r) * art_brightness / 100),│ │1398 + .g = @intCast(@as(u16, v.g) * art_brightness / 100),│ │1399 + .b = @intCast(@as(u16, v.b) * art_brightness / 100),│ │1400 + } }, │ │1401 + else => c, │ │1402 }; │ │1403 } │ │1404 │ ╰──────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │1428 return if (v >= 1 and v <= 9) 10 else v; │ │1429 } │ │1430 }.f; │ │1427 - return .{ .r = snap(c.r), .g = snap(c.g), .b = snap(c.b) }; │ │1431 + return switch (c) { │ │1432 + .rgb => |v| .{ .rgb = .{ .r = snap(v.r), .g = snap(v.g), .b = snap(v.b) } },│ │1433 + else => c, │ │1434 + }; │ │1435 } │ │1436 │ │1437 fn applyArtBackground(dst: *Grid.Cell, src: Grid.Cell) void { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────╮ │1439 dst.style.bg = background_maybe; │ │1440 // change unstyled text to contrast with the art behind it │ │1441 if (dst.style.fg == null) { │ │1435 - if (background_maybe) |background| { │ │1442 + // the art is parsed as truecolor, so a palette bg never occurs │ │1443 + const background: ?Grid.Color.Rgb = if (background_maybe) |b| switch (b) {│ │1444 + .rgb => |v| v, │ │1445 + else => null, │ │1446 + } else null; │ │1447 + if (background) |v| { │ │1448 // use near-black and near-white, which is easier on the eyes │ │1449 // while retaining high contrast │ │1438 - const luminance = (@as(u32, background.r) * 299 + │ │1439 - @as(u32, background.g) * 587 + │ │1440 - @as(u32, background.b) * 114) / 1000; │ │1450 + const luminance = (@as(u32, v.r) * 299 + │ │1451 + @as(u32, v.g) * 587 + │ │1452 + @as(u32, v.b) * 114) / 1000; │ │1453 dst.style.fg = if (luminance >= 128) │ │1442 - .{ .r = 16, .g = 16, .b = 16 } │ │1454 + .{ .rgb = .{ .r = 16, .g = 16, .b = 16 } } │ │1455 else │ │1444 - .{ .r = 240, .g = 240, .b = 240 }; │ │1456 + .{ .rgb = .{ .r = 240, .g = 240, .b = 240 } }; │ │1457 } │ │1458 } │ │1459 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │1608 (if (focused) .double else .single) │ │1609 else │ │1610 .hidden; │ │1611 + self.selector(i).options.inverted = i == self.selected;│ │1612 } │ │1613 } │ │1614 self.textInput().options.border_style = .single; │ ╰─────────────────────────────────────────────────────────────────────────────╯