mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 06:47:33 +03:00
Merge pull request #1281 from jcollie/sort-list-colors
sort output from +list-colors
This commit is contained in:
@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const inputpkg = @import("../input.zig");
|
|
||||||
const args = @import("args.zig");
|
const args = @import("args.zig");
|
||||||
const x11_color = @import("../terminal/main.zig").x11_color;
|
const x11_color = @import("../terminal/main.zig").x11_color;
|
||||||
|
|
||||||
@ -23,10 +22,24 @@ pub fn run(alloc: std.mem.Allocator) !u8 {
|
|||||||
|
|
||||||
const stdout = std.io.getStdOut().writer();
|
const stdout = std.io.getStdOut().writer();
|
||||||
|
|
||||||
inline for (x11_color.map.kvs) |kv| {
|
var keys = std.ArrayList([]const u8).init(alloc);
|
||||||
const name = kv.key;
|
defer keys.deinit();
|
||||||
const rgb = kv.value;
|
for (x11_color.map.kvs) |kv| try keys.append(kv.key);
|
||||||
try stdout.print("{s} = #{x:0>2}{x:0>2}{x:0>2}\n", .{ name, rgb.r, rgb.g, rgb.b });
|
|
||||||
|
std.mem.sortUnstable([]const u8, keys.items, {}, struct {
|
||||||
|
fn lessThan(_: void, lhs: []const u8, rhs: []const u8) bool {
|
||||||
|
return std.ascii.orderIgnoreCase(lhs, rhs) == .lt;
|
||||||
|
}
|
||||||
|
}.lessThan);
|
||||||
|
|
||||||
|
for (keys.items) |name| {
|
||||||
|
const rgb = x11_color.map.get(name).?;
|
||||||
|
try stdout.print("{s} = #{x:0>2}{x:0>2}{x:0>2}\n", .{
|
||||||
|
name,
|
||||||
|
rgb.r,
|
||||||
|
rgb.g,
|
||||||
|
rgb.b,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user