0.13 conversions

This commit is contained in:
Mitchell Hashimoto
2024-06-08 20:21:00 -07:00
parent eadd2dc5b0
commit 53423f1071
5 changed files with 20 additions and 13 deletions

View File

@ -1485,7 +1485,7 @@ fn root() []const u8 {
}
/// ANSI escape codes for colored log output
const color_map = std.ComptimeStringMap([]const u8, .{
const color_map = std.StaticStringMap([]const u8).initComptime(.{
&.{ "black", "30m" },
&.{ "blue", "34m" },
&.{ "b", "1m" },

View File

@ -622,7 +622,10 @@ test "image load: rgb, not compressed, temporary file" {
var tmp_dir = try internal_os.TempDir.init();
defer tmp_dir.deinit();
const data = @embedFile("testdata/image-rgb-none-20x15-2147483647-raw.data");
try tmp_dir.dir.writeFile("image.data", data);
try tmp_dir.dir.writeFile(.{
.sub_path = "image.data",
.data = data,
});
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const path = try tmp_dir.dir.realpath("image.data", &buf);
@ -656,7 +659,10 @@ test "image load: rgb, not compressed, regular file" {
var tmp_dir = try internal_os.TempDir.init();
defer tmp_dir.deinit();
const data = @embedFile("testdata/image-rgb-none-20x15-2147483647-raw.data");
try tmp_dir.dir.writeFile("image.data", data);
try tmp_dir.dir.writeFile(.{
.sub_path = "image.data",
.data = data,
});
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const path = try tmp_dir.dir.realpath("image.data", &buf);
@ -688,7 +694,10 @@ test "image load: png, not compressed, regular file" {
var tmp_dir = try internal_os.TempDir.init();
defer tmp_dir.deinit();
const data = @embedFile("testdata/image-png-none-50x76-2147483647-raw.data");
try tmp_dir.dir.writeFile("image.data", data);
try tmp_dir.dir.writeFile(.{
.sub_path = "image.data",
.data = data,
});
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const path = try tmp_dir.dir.realpath("image.data", &buf);

View File

@ -47,7 +47,7 @@ pub const MouseShape = enum(c_int) {
}
};
const string_map = std.ComptimeStringMap(MouseShape, .{
const string_map = std.StaticStringMap(MouseShape).initComptime(.{
// W3C
.{ "default", .default },
.{ "context-menu", .context_menu },

View File

@ -5,7 +5,9 @@ const RGB = @import("color.zig").RGB;
/// The map of all available X11 colors.
pub const map = colorMap() catch @compileError("failed to parse rgb.txt");
fn colorMap() !type {
pub const ColorMap = std.StaticStringMapWithEql(RGB, std.static_string_map.eqlAsciiIgnoreCase);
fn colorMap() !ColorMap {
@setEvalBranchQuota(100_000);
const KV = struct { []const u8, RGB };
@ -31,11 +33,7 @@ fn colorMap() !type {
}
assert(i == len);
return std.ComptimeStringMapWithEql(
RGB,
kvs,
std.comptime_string_map.eqlAsciiIgnoreCase,
);
return ColorMap.initComptime(kvs);
}
/// This is the rgb.txt file from the X11 project. This was last sourced

View File

@ -68,7 +68,7 @@ pub fn encode(self: Source, writer: anytype) !void {
/// Returns a ComptimeStringMap for all of the capabilities in this terminfo.
/// The value is the value that should be sent as a response to XTGETTCAP.
/// Important: the value is the FULL response included the escape sequences.
pub fn xtgettcapMap(comptime self: Source) type {
pub fn xtgettcapMap(comptime self: Source) std.StaticStringMap([]const u8) {
const KV = struct { []const u8, []const u8 };
// We have all of our capabilities plus To, TN, and RGB which aren't
@ -145,7 +145,7 @@ pub fn xtgettcapMap(comptime self: Source) type {
}
const kvs_final = kvs;
return std.ComptimeStringMap([]const u8, &kvs_final);
return std.StaticStringMap([]const u8).initComptime(&kvs_final);
}
fn hexencode(comptime input: []const u8) []const u8 {