From 19db2e2755c9abb4946fbb2dbadea85516703138 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Sun, 25 May 2025 22:25:23 -0600 Subject: [PATCH 1/5] CircBuf: non-allocating rotateToZero We can call `std.mem.rotate` for this. --- src/datastruct/circ_buf.zig | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/datastruct/circ_buf.zig b/src/datastruct/circ_buf.zig index 065bf6a1d..646a00940 100644 --- a/src/datastruct/circ_buf.zig +++ b/src/datastruct/circ_buf.zig @@ -152,7 +152,7 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { /// If larger, new values will be set to the default value. pub fn resize(self: *Self, alloc: Allocator, size: usize) Allocator.Error!void { // Rotate to zero so it is aligned. - try self.rotateToZero(alloc); + try self.rotateToZero(); // Reallocate, this adds to the end so we're ready to go. const prev_len = self.len(); @@ -173,29 +173,16 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { } /// Rotate the data so that it is zero-aligned. - fn rotateToZero(self: *Self, alloc: Allocator) Allocator.Error!void { - // TODO: this does this in the worst possible way by allocating. - // rewrite to not allocate, its possible, I'm just lazy right now. - + fn rotateToZero(self: *Self) Allocator.Error!void { // If we're already at zero then do nothing. if (self.tail == 0) return; - var buf = try alloc.alloc(T, self.storage.len); - defer { - self.head = if (self.full) 0 else self.len(); - self.tail = 0; - alloc.free(self.storage); - self.storage = buf; - } + // We use std.mem.rotate to rotate our storage in-place. + std.mem.rotate(T, self.storage, self.tail); - if (!self.full and self.head >= self.tail) { - fastmem.copy(T, buf, self.storage[self.tail..self.head]); - return; - } - - const middle = self.storage.len - self.tail; - fastmem.copy(T, buf, self.storage[self.tail..]); - fastmem.copy(T, buf[middle..], self.storage[0..self.head]); + // Then fix up our head and tail. + self.head = self.len() % self.storage.len; + self.tail = 0; } /// Returns if the buffer is currently empty. To check if its @@ -589,7 +576,7 @@ test "CircBuf rotateToZero" { defer buf.deinit(alloc); _ = buf.getPtrSlice(0, 11); - try buf.rotateToZero(alloc); + try buf.rotateToZero(); } test "CircBuf rotateToZero offset" { @@ -611,7 +598,7 @@ test "CircBuf rotateToZero offset" { try testing.expect(buf.tail > 0 and buf.head >= buf.tail); // Rotate to zero - try buf.rotateToZero(alloc); + try buf.rotateToZero(); try testing.expectEqual(@as(usize, 0), buf.tail); try testing.expectEqual(@as(usize, 1), buf.head); } @@ -645,7 +632,7 @@ test "CircBuf rotateToZero wraps" { } // Rotate to zero - try buf.rotateToZero(alloc); + try buf.rotateToZero(); try testing.expectEqual(@as(usize, 0), buf.tail); try testing.expectEqual(@as(usize, 3), buf.head); { @@ -681,7 +668,7 @@ test "CircBuf rotateToZero full no wrap" { } // Rotate to zero - try buf.rotateToZero(alloc); + try buf.rotateToZero(); try testing.expect(buf.full); try testing.expectEqual(@as(usize, 0), buf.tail); try testing.expectEqual(@as(usize, 0), buf.head); From 25a708ed9831083db9555da16137df7d98c38de3 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Sun, 25 May 2025 22:51:14 -0600 Subject: [PATCH 2/5] terminal/style: compare packed styles directly, no cast needed Woohoo, Zig 0.14! --- src/terminal/style.zig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/terminal/style.zig b/src/terminal/style.zig index 7f176561b..34b07772a 100644 --- a/src/terminal/style.zig +++ b/src/terminal/style.zig @@ -87,10 +87,9 @@ pub const Style = struct { /// True if the style is equal to another style. pub fn eql(self: Style, other: Style) bool { - const packed_self = PackedStyle.fromStyle(self); - const packed_other = PackedStyle.fromStyle(other); - // TODO: in Zig 0.14, equating packed structs is allowed. Remove this work around. - return @as(u128, @bitCast(packed_self)) == @as(u128, @bitCast(packed_other)); + // We convert the styles to packed structs and compare as integers + // because this is much faster than comparing each field separately. + return PackedStyle.fromStyle(self) == PackedStyle.fromStyle(other); } /// Returns the bg color for a cell with this style given the cell From 2905b4727980b8d1109f333e0d78db7674eb0e48 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Mon, 26 May 2025 19:39:39 -0600 Subject: [PATCH 3/5] font: use labeled switch continue pattern for feature string parser In this case it does result in a little repeated code for reading bytes, but I find the control flow easier to follow, so it's worth it IMO. --- src/font/shaper/feature.zig | 300 ++++++++++++++++-------------------- 1 file changed, 133 insertions(+), 167 deletions(-) diff --git a/src/font/shaper/feature.zig b/src/font/shaper/feature.zig index 8e70d51da..c2d49234d 100644 --- a/src/font/shaper/feature.zig +++ b/src/font/shaper/feature.zig @@ -35,190 +35,156 @@ pub const Feature = struct { /// /// Ref: https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-feature-from-string pub fn fromReader(reader: anytype) ?Feature { - var tag: [4]u8 = undefined; + var tag_buf: [4]u8 = undefined; + var tag: []u8 = tag_buf[0..0]; var value: ?u32 = null; - // TODO: when we move to Zig 0.14 this can be replaced with a - // labeled switch continue pattern rather than this loop. - var state: union(enum) { + state: switch ((enum { /// Initial state. - start: void, - /// Parsing the tag, data is index. - tag: u2, + start, + /// Parsing the tag. + tag, /// In the space between the tag and the value. - space: void, + space, /// Parsing an integer parameter directly in to `value`. - int: void, + int, /// Parsing a boolean keyword parameter ("on"/"off"). - bool: void, + bool, /// Encountered an unrecoverable syntax error, advancing to boundary. - err: void, - /// Done parsing feature. - done: void, - } = .start; - while (true) { - // If we hit the end of the stream we just pretend it's a comma. - const byte = reader.readByte() catch ','; - switch (state) { - // If we're done then we skip whitespace until we see a ','. - .done => switch (byte) { - ' ', '\t' => continue, - ',' => break, - // If we see something other than whitespace or a ',' - // then this is an error since the intent is unclear. - else => { - state = .err; - continue; - }, + err, + /// Done parsing feature, skip whitespace until end. + done, + }).start) { + // If we're done then we skip whitespace until we see a ','. + .done => while (true) switch (reader.readByte() catch ',') { + ' ', '\t' => continue, + ',' => break, + // If we see something other than whitespace or a ',' + // then this is an error since the intent is unclear. + else => continue :state .err, + }, + + // If we're fast-forwarding from an error we just wanna + // stop at the first boundary and ignore all other bytes. + .err => { + reader.skipUntilDelimiterOrEof(',') catch {}; + return null; + }, + + .start => while (true) switch (reader.readByte() catch ',') { + // Ignore leading whitespace. + ' ', '\t' => continue, + // Empty feature string. + ',' => return null, + // '+' prefix to explicitly enable feature. + '+' => { + value = 1; + continue :state .tag; }, + // '-' prefix to explicitly disable feature. + '-' => { + value = 0; + continue :state .tag; + }, + // Quote mark introducing a tag. + '"', '\'' => { + continue :state .tag; + }, + // First letter of tag. + else => |byte| { + tag.len = 1; + tag[0] = byte; + continue :state .tag; + }, + }, - // If we're fast-forwarding from an error we just wanna - // stop at the first boundary and ignore all other bytes. - .err => if (byte == ',') return null, + .tag => while (true) switch (reader.readByte() catch ',') { + // If the tag is interrupted by a comma it's invalid. + ',' => return null, + // Ignore quote marks. This does technically ignore cases like + // "'k'e'r'n' = 0", but it's unambiguous so if someone really + // wants to do that in their config then... sure why not. + '"', '\'' => continue, + // In all other cases we add the byte to our tag. + else => |byte| { + tag.len += 1; + tag[tag.len - 1] = byte; + if (tag.len == 4) continue :state .space; + }, + }, - .start => switch (byte) { - // Ignore leading whitespace. - ' ', '\t' => continue, - // Empty feature string. - ',' => return null, - // '+' prefix to explicitly enable feature. - '+' => { - value = 1; - state = .{ .tag = 0 }; - continue; - }, - // '-' prefix to explicitly disable feature. - '-' => { + .space => while (true) switch (reader.readByte() catch ',') { + ' ', '\t' => continue, + // Ignore quote marks since we might have a + // closing quote from the tag still ahead. + '"', '\'' => continue, + // Allow an '=' (which we can safely ignore) + // only if we don't already have a value due + // to a '+' or '-' prefix. + '=' => if (value != null) continue :state .err, + ',' => { + // Specifying only a tag turns a feature on. + if (value == null) value = 1; + break; + }, + '0'...'9' => |byte| { + // If we already have value because of a + // '+' or '-' prefix then this is an error. + if (value != null) continue :state .err; + value = byte - '0'; + continue :state .int; + }, + 'o', 'O' => { + // If we already have value because of a + // '+' or '-' prefix then this is an error. + if (value != null) continue :state .err; + continue :state .bool; + }, + else => continue :state .err, + }, + + .int => while (true) switch (reader.readByte() catch ',') { + ',' => break, + '0'...'9' => |byte| { + // If our value gets too big while + // parsing we consider it an error. + value = std.math.mul(u32, value.?, 10) catch { + continue :state .err; + }; + value.? += byte - '0'; + }, + else => continue :state .err, + }, + + .bool => while (true) switch (reader.readByte() catch ',') { + ',' => return null, + 'n', 'N' => { + // "ofn" + if (value != null) { + assert(value == 0); + continue :state .err; + } + value = 1; + continue :state .done; + }, + 'f', 'F' => { + // To make sure we consume two 'f's. + if (value == null) { value = 0; - state = .{ .tag = 0 }; - continue; - }, - // Quote mark introducing a tag. - '"', '\'' => { - state = .{ .tag = 0 }; - continue; - }, - // First letter of tag. - else => { - tag[0] = byte; - state = .{ .tag = 1 }; - continue; - }, + } else { + assert(value == 0); + continue :state .done; + } }, - - .tag => |*i| switch (byte) { - // If the tag is interrupted by a comma it's invalid. - ',' => return null, - // Ignore quote marks. - '"', '\'' => continue, - // A prefix of '+' or '-' - // In all other cases we add the byte to our tag. - else => { - tag[i.*] = byte; - if (i.* == 3) { - state = .space; - continue; - } - i.* += 1; - }, - }, - - .space => switch (byte) { - ' ', '\t' => continue, - // Ignore quote marks since we might have a - // closing quote from the tag still ahead. - '"', '\'' => continue, - // Allow an '=' (which we can safely ignore) - // only if we don't already have a value due - // to a '+' or '-' prefix. - '=' => if (value != null) { - state = .err; - continue; - }, - ',' => { - // Specifying only a tag turns a feature on. - if (value == null) value = 1; - break; - }, - '0'...'9' => { - // If we already have value because of a - // '+' or '-' prefix then this is an error. - if (value != null) { - state = .err; - continue; - } - value = byte - '0'; - state = .int; - continue; - }, - 'o', 'O' => { - // If we already have value because of a - // '+' or '-' prefix then this is an error. - if (value != null) { - state = .err; - continue; - } - state = .bool; - continue; - }, - else => { - state = .err; - continue; - }, - }, - - .int => switch (byte) { - ',' => break, - '0'...'9' => { - // If our value gets too big while - // parsing we consider it an error. - value = std.math.mul(u32, value.?, 10) catch { - state = .err; - continue; - }; - value.? += byte - '0'; - }, - else => { - state = .err; - continue; - }, - }, - - .bool => switch (byte) { - ',' => return null, - 'n', 'N' => { - // "ofn" - if (value != null) { - assert(value == 0); - state = .err; - continue; - } - value = 1; - state = .done; - continue; - }, - 'f', 'F' => { - // To make sure we consume two 'f's. - if (value == null) { - value = 0; - } else { - assert(value == 0); - state = .done; - continue; - } - }, - else => { - state = .err; - continue; - }, - }, - } + else => continue :state .err, + }, } assert(value != null); + assert(tag.len == 4); return .{ - .tag = tag, + .tag = tag_buf, .value = value.?, }; } From 2fe2ccdbde58557f17ba1787551dfb0666b6a147 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Mon, 26 May 2025 19:56:35 -0600 Subject: [PATCH 4/5] font/sprite: use decl literals in box drawing code Cleaner and less visual noise, easy change to make, there are many other areas in the code which would benefit from decl literals as well, but this is an area that benefits a lot from them and is self-contained. --- src/font/sprite/Box.zig | 310 ++++++++++++++++++++-------------------- 1 file changed, 155 insertions(+), 155 deletions(-) diff --git a/src/font/sprite/Box.zig b/src/font/sprite/Box.zig index 68acdabe5..b1ebfe3a9 100644 --- a/src/font/sprite/Box.zig +++ b/src/font/sprite/Box.zig @@ -516,40 +516,40 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void 0x257f => self.draw_lines(canvas, .{ .up = .heavy, .down = .light }), // '▀' UPPER HALF BLOCK - 0x2580 => self.draw_block(canvas, Alignment.upper, 1, half), + 0x2580 => self.draw_block(canvas, .upper, 1, half), // '▁' LOWER ONE EIGHTH BLOCK - 0x2581 => self.draw_block(canvas, Alignment.lower, 1, one_eighth), + 0x2581 => self.draw_block(canvas, .lower, 1, one_eighth), // '▂' LOWER ONE QUARTER BLOCK - 0x2582 => self.draw_block(canvas, Alignment.lower, 1, one_quarter), + 0x2582 => self.draw_block(canvas, .lower, 1, one_quarter), // '▃' LOWER THREE EIGHTHS BLOCK - 0x2583 => self.draw_block(canvas, Alignment.lower, 1, three_eighths), + 0x2583 => self.draw_block(canvas, .lower, 1, three_eighths), // '▄' LOWER HALF BLOCK - 0x2584 => self.draw_block(canvas, Alignment.lower, 1, half), + 0x2584 => self.draw_block(canvas, .lower, 1, half), // '▅' LOWER FIVE EIGHTHS BLOCK - 0x2585 => self.draw_block(canvas, Alignment.lower, 1, five_eighths), + 0x2585 => self.draw_block(canvas, .lower, 1, five_eighths), // '▆' LOWER THREE QUARTERS BLOCK - 0x2586 => self.draw_block(canvas, Alignment.lower, 1, three_quarters), + 0x2586 => self.draw_block(canvas, .lower, 1, three_quarters), // '▇' LOWER SEVEN EIGHTHS BLOCK - 0x2587 => self.draw_block(canvas, Alignment.lower, 1, seven_eighths), + 0x2587 => self.draw_block(canvas, .lower, 1, seven_eighths), // '█' FULL BLOCK 0x2588 => self.draw_full_block(canvas), // '▉' LEFT SEVEN EIGHTHS BLOCK - 0x2589 => self.draw_block(canvas, Alignment.left, seven_eighths, 1), + 0x2589 => self.draw_block(canvas, .left, seven_eighths, 1), // '▊' LEFT THREE QUARTERS BLOCK - 0x258a => self.draw_block(canvas, Alignment.left, three_quarters, 1), + 0x258a => self.draw_block(canvas, .left, three_quarters, 1), // '▋' LEFT FIVE EIGHTHS BLOCK - 0x258b => self.draw_block(canvas, Alignment.left, five_eighths, 1), + 0x258b => self.draw_block(canvas, .left, five_eighths, 1), // '▌' LEFT HALF BLOCK - 0x258c => self.draw_block(canvas, Alignment.left, half, 1), + 0x258c => self.draw_block(canvas, .left, half, 1), // '▍' LEFT THREE EIGHTHS BLOCK - 0x258d => self.draw_block(canvas, Alignment.left, three_eighths, 1), + 0x258d => self.draw_block(canvas, .left, three_eighths, 1), // '▎' LEFT ONE QUARTER BLOCK - 0x258e => self.draw_block(canvas, Alignment.left, one_quarter, 1), + 0x258e => self.draw_block(canvas, .left, one_quarter, 1), // '▏' LEFT ONE EIGHTH BLOCK - 0x258f => self.draw_block(canvas, Alignment.left, one_eighth, 1), + 0x258f => self.draw_block(canvas, .left, one_eighth, 1), // '▐' RIGHT HALF BLOCK - 0x2590 => self.draw_block(canvas, Alignment.right, half, 1), + 0x2590 => self.draw_block(canvas, .right, half, 1), // '░' 0x2591 => self.draw_light_shade(canvas), // '▒' @@ -557,9 +557,9 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void // '▓' 0x2593 => self.draw_dark_shade(canvas), // '▔' UPPER ONE EIGHTH BLOCK - 0x2594 => self.draw_block(canvas, Alignment.upper, 1, one_eighth), + 0x2594 => self.draw_block(canvas, .upper, 1, one_eighth), // '▕' RIGHT ONE EIGHTH BLOCK - 0x2595 => self.draw_block(canvas, Alignment.right, one_eighth, 1), + 0x2595 => self.draw_block(canvas, .right, one_eighth, 1), // '▖' 0x2596 => self.draw_quadrant(canvas, .{ .bl = true }), // '▗' @@ -588,35 +588,35 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void octant_min...octant_max => self.draw_octant(canvas, cp), // '🬼' - 0x1fb3c => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb3c => try self.draw_smooth_mosaic(canvas, .from( \\... \\... \\#.. \\##. )), // '🬽' - 0x1fb3d => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb3d => try self.draw_smooth_mosaic(canvas, .from( \\... \\... \\#\. \\### )), // '🬾' - 0x1fb3e => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb3e => try self.draw_smooth_mosaic(canvas, .from( \\... \\#.. \\#\. \\##. )), // '🬿' - 0x1fb3f => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb3f => try self.draw_smooth_mosaic(canvas, .from( \\... \\#.. \\##. \\### )), // '🭀' - 0x1fb40 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb40 => try self.draw_smooth_mosaic(canvas, .from( \\#.. \\#.. \\##. @@ -624,42 +624,42 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void )), // '🭁' - 0x1fb41 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb41 => try self.draw_smooth_mosaic(canvas, .from( \\/## \\### \\### \\### )), // '🭂' - 0x1fb42 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb42 => try self.draw_smooth_mosaic(canvas, .from( \\./# \\### \\### \\### )), // '🭃' - 0x1fb43 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb43 => try self.draw_smooth_mosaic(canvas, .from( \\.## \\.## \\### \\### )), // '🭄' - 0x1fb44 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb44 => try self.draw_smooth_mosaic(canvas, .from( \\..# \\.## \\### \\### )), // '🭅' - 0x1fb45 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb45 => try self.draw_smooth_mosaic(canvas, .from( \\.## \\.## \\.## \\### )), // '🭆' - 0x1fb46 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb46 => try self.draw_smooth_mosaic(canvas, .from( \\... \\./# \\### @@ -667,35 +667,35 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void )), // '🭇' - 0x1fb47 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb47 => try self.draw_smooth_mosaic(canvas, .from( \\... \\... \\..# \\.## )), // '🭈' - 0x1fb48 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb48 => try self.draw_smooth_mosaic(canvas, .from( \\... \\... \\./# \\### )), // '🭉' - 0x1fb49 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb49 => try self.draw_smooth_mosaic(canvas, .from( \\... \\..# \\./# \\.## )), // '🭊' - 0x1fb4a => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb4a => try self.draw_smooth_mosaic(canvas, .from( \\... \\..# \\.## \\### )), // '🭋' - 0x1fb4b => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb4b => try self.draw_smooth_mosaic(canvas, .from( \\..# \\..# \\.## @@ -703,42 +703,42 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void )), // '🭌' - 0x1fb4c => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb4c => try self.draw_smooth_mosaic(canvas, .from( \\##\ \\### \\### \\### )), // '🭍' - 0x1fb4d => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb4d => try self.draw_smooth_mosaic(canvas, .from( \\#\. \\### \\### \\### )), // '🭎' - 0x1fb4e => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb4e => try self.draw_smooth_mosaic(canvas, .from( \\##. \\##. \\### \\### )), // '🭏' - 0x1fb4f => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb4f => try self.draw_smooth_mosaic(canvas, .from( \\#.. \\##. \\### \\### )), // '🭐' - 0x1fb50 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb50 => try self.draw_smooth_mosaic(canvas, .from( \\##. \\##. \\##. \\### )), // '🭑' - 0x1fb51 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb51 => try self.draw_smooth_mosaic(canvas, .from( \\... \\#\. \\### @@ -746,35 +746,35 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void )), // '🭒' - 0x1fb52 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb52 => try self.draw_smooth_mosaic(canvas, .from( \\### \\### \\### \\\## )), // '🭓' - 0x1fb53 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb53 => try self.draw_smooth_mosaic(canvas, .from( \\### \\### \\### \\.\# )), // '🭔' - 0x1fb54 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb54 => try self.draw_smooth_mosaic(canvas, .from( \\### \\### \\.## \\.## )), // '🭕' - 0x1fb55 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb55 => try self.draw_smooth_mosaic(canvas, .from( \\### \\### \\.## \\..# )), // '🭖' - 0x1fb56 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb56 => try self.draw_smooth_mosaic(canvas, .from( \\### \\.## \\.## @@ -782,35 +782,35 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void )), // '🭗' - 0x1fb57 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb57 => try self.draw_smooth_mosaic(canvas, .from( \\##. \\#.. \\... \\... )), // '🭘' - 0x1fb58 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb58 => try self.draw_smooth_mosaic(canvas, .from( \\### \\#/. \\... \\... )), // '🭙' - 0x1fb59 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb59 => try self.draw_smooth_mosaic(canvas, .from( \\##. \\#/. \\#.. \\... )), // '🭚' - 0x1fb5a => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb5a => try self.draw_smooth_mosaic(canvas, .from( \\### \\##. \\#.. \\... )), // '🭛' - 0x1fb5b => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb5b => try self.draw_smooth_mosaic(canvas, .from( \\##. \\##. \\#.. @@ -818,42 +818,42 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void )), // '🭜' - 0x1fb5c => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb5c => try self.draw_smooth_mosaic(canvas, .from( \\### \\### \\#/. \\... )), // '🭝' - 0x1fb5d => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb5d => try self.draw_smooth_mosaic(canvas, .from( \\### \\### \\### \\##/ )), // '🭞' - 0x1fb5e => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb5e => try self.draw_smooth_mosaic(canvas, .from( \\### \\### \\### \\#/. )), // '🭟' - 0x1fb5f => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb5f => try self.draw_smooth_mosaic(canvas, .from( \\### \\### \\##. \\##. )), // '🭠' - 0x1fb60 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb60 => try self.draw_smooth_mosaic(canvas, .from( \\### \\### \\##. \\#.. )), // '🭡' - 0x1fb61 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb61 => try self.draw_smooth_mosaic(canvas, .from( \\### \\##. \\##. @@ -861,42 +861,42 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void )), // '🭢' - 0x1fb62 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb62 => try self.draw_smooth_mosaic(canvas, .from( \\.## \\..# \\... \\... )), // '🭣' - 0x1fb63 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb63 => try self.draw_smooth_mosaic(canvas, .from( \\### \\.\# \\... \\... )), // '🭤' - 0x1fb64 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb64 => try self.draw_smooth_mosaic(canvas, .from( \\.## \\.\# \\..# \\... )), // '🭥' - 0x1fb65 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb65 => try self.draw_smooth_mosaic(canvas, .from( \\### \\.## \\..# \\... )), // '🭦' - 0x1fb66 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb66 => try self.draw_smooth_mosaic(canvas, .from( \\.## \\.## \\..# \\..# )), // '🭧' - 0x1fb67 => try self.draw_smooth_mosaic(canvas, SmoothMosaic.from( + 0x1fb67 => try self.draw_smooth_mosaic(canvas, .from( \\### \\### \\.\# @@ -959,79 +959,79 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void 0x1fb7b => self.draw_horizontal_one_eighth_block_n(canvas, 6), // '🮂' UPPER ONE QUARTER BLOCK - 0x1fb82 => self.draw_block(canvas, Alignment.upper, 1, one_quarter), + 0x1fb82 => self.draw_block(canvas, .upper, 1, one_quarter), // '🮃' UPPER THREE EIGHTHS BLOCK - 0x1fb83 => self.draw_block(canvas, Alignment.upper, 1, three_eighths), + 0x1fb83 => self.draw_block(canvas, .upper, 1, three_eighths), // '🮄' UPPER FIVE EIGHTHS BLOCK - 0x1fb84 => self.draw_block(canvas, Alignment.upper, 1, five_eighths), + 0x1fb84 => self.draw_block(canvas, .upper, 1, five_eighths), // '🮅' UPPER THREE QUARTERS BLOCK - 0x1fb85 => self.draw_block(canvas, Alignment.upper, 1, three_quarters), + 0x1fb85 => self.draw_block(canvas, .upper, 1, three_quarters), // '🮆' UPPER SEVEN EIGHTHS BLOCK - 0x1fb86 => self.draw_block(canvas, Alignment.upper, 1, seven_eighths), + 0x1fb86 => self.draw_block(canvas, .upper, 1, seven_eighths), // '🭼' LEFT AND LOWER ONE EIGHTH BLOCK 0x1fb7c => { - self.draw_block(canvas, Alignment.left, one_eighth, 1); - self.draw_block(canvas, Alignment.lower, 1, one_eighth); + self.draw_block(canvas, .left, one_eighth, 1); + self.draw_block(canvas, .lower, 1, one_eighth); }, // '🭽' LEFT AND UPPER ONE EIGHTH BLOCK 0x1fb7d => { - self.draw_block(canvas, Alignment.left, one_eighth, 1); - self.draw_block(canvas, Alignment.upper, 1, one_eighth); + self.draw_block(canvas, .left, one_eighth, 1); + self.draw_block(canvas, .upper, 1, one_eighth); }, // '🭾' RIGHT AND UPPER ONE EIGHTH BLOCK 0x1fb7e => { - self.draw_block(canvas, Alignment.right, one_eighth, 1); - self.draw_block(canvas, Alignment.upper, 1, one_eighth); + self.draw_block(canvas, .right, one_eighth, 1); + self.draw_block(canvas, .upper, 1, one_eighth); }, // '🭿' RIGHT AND LOWER ONE EIGHTH BLOCK 0x1fb7f => { - self.draw_block(canvas, Alignment.right, one_eighth, 1); - self.draw_block(canvas, Alignment.lower, 1, one_eighth); + self.draw_block(canvas, .right, one_eighth, 1); + self.draw_block(canvas, .lower, 1, one_eighth); }, // '🮀' UPPER AND LOWER ONE EIGHTH BLOCK 0x1fb80 => { - self.draw_block(canvas, Alignment.upper, 1, one_eighth); - self.draw_block(canvas, Alignment.lower, 1, one_eighth); + self.draw_block(canvas, .upper, 1, one_eighth); + self.draw_block(canvas, .lower, 1, one_eighth); }, // '🮁' 0x1fb81 => self.draw_horizontal_one_eighth_1358_block(canvas), // '🮇' RIGHT ONE QUARTER BLOCK - 0x1fb87 => self.draw_block(canvas, Alignment.right, one_quarter, 1), + 0x1fb87 => self.draw_block(canvas, .right, one_quarter, 1), // '🮈' RIGHT THREE EIGHTHS BLOCK - 0x1fb88 => self.draw_block(canvas, Alignment.right, three_eighths, 1), + 0x1fb88 => self.draw_block(canvas, .right, three_eighths, 1), // '🮉' RIGHT FIVE EIGHTHS BLOCK - 0x1fb89 => self.draw_block(canvas, Alignment.right, five_eighths, 1), + 0x1fb89 => self.draw_block(canvas, .right, five_eighths, 1), // '🮊' RIGHT THREE QUARTERS BLOCK - 0x1fb8a => self.draw_block(canvas, Alignment.right, three_quarters, 1), + 0x1fb8a => self.draw_block(canvas, .right, three_quarters, 1), // '🮋' RIGHT SEVEN EIGHTHS BLOCK - 0x1fb8b => self.draw_block(canvas, Alignment.right, seven_eighths, 1), + 0x1fb8b => self.draw_block(canvas, .right, seven_eighths, 1), // '🮌' - 0x1fb8c => self.draw_block_shade(canvas, Alignment.left, half, 1, .medium), + 0x1fb8c => self.draw_block_shade(canvas, .left, half, 1, .medium), // '🮍' - 0x1fb8d => self.draw_block_shade(canvas, Alignment.right, half, 1, .medium), + 0x1fb8d => self.draw_block_shade(canvas, .right, half, 1, .medium), // '🮎' - 0x1fb8e => self.draw_block_shade(canvas, Alignment.upper, 1, half, .medium), + 0x1fb8e => self.draw_block_shade(canvas, .upper, 1, half, .medium), // '🮏' - 0x1fb8f => self.draw_block_shade(canvas, Alignment.lower, 1, half, .medium), + 0x1fb8f => self.draw_block_shade(canvas, .lower, 1, half, .medium), // '🮐' 0x1fb90 => self.draw_medium_shade(canvas), // '🮑' 0x1fb91 => { self.draw_medium_shade(canvas); - self.draw_block(canvas, Alignment.upper, 1, half); + self.draw_block(canvas, .upper, 1, half); }, // '🮒' 0x1fb92 => { self.draw_medium_shade(canvas); - self.draw_block(canvas, Alignment.lower, 1, half); + self.draw_block(canvas, .lower, 1, half); }, // '🮔' 0x1fb94 => { self.draw_medium_shade(canvas); - self.draw_block(canvas, Alignment.right, half, 1); + self.draw_block(canvas, .right, half, 1); }, // '🮕' 0x1fb95 => self.draw_checkerboard_fill(canvas, 0), @@ -1117,194 +1117,194 @@ fn draw(self: Box, alloc: Allocator, canvas: *font.sprite.Canvas, cp: u32) !void }, // '🯎' - 0x1fbce => self.draw_block(canvas, Alignment.left, two_thirds, 1), + 0x1fbce => self.draw_block(canvas, .left, two_thirds, 1), // '🯏' - 0x1fbcf => self.draw_block(canvas, Alignment.left, one_third, 1), + 0x1fbcf => self.draw_block(canvas, .left, one_third, 1), // '🯐' 0x1fbd0 => self.draw_cell_diagonal( canvas, - Alignment.middle_right, - Alignment.lower_left, + .middle_right, + .lower_left, ), // '🯑' 0x1fbd1 => self.draw_cell_diagonal( canvas, - Alignment.upper_right, - Alignment.middle_left, + .upper_right, + .middle_left, ), // '🯒' 0x1fbd2 => self.draw_cell_diagonal( canvas, - Alignment.upper_left, - Alignment.middle_right, + .upper_left, + .middle_right, ), // '🯓' 0x1fbd3 => self.draw_cell_diagonal( canvas, - Alignment.middle_left, - Alignment.lower_right, + .middle_left, + .lower_right, ), // '🯔' 0x1fbd4 => self.draw_cell_diagonal( canvas, - Alignment.upper_left, - Alignment.lower_center, + .upper_left, + .lower_center, ), // '🯕' 0x1fbd5 => self.draw_cell_diagonal( canvas, - Alignment.upper_center, - Alignment.lower_right, + .upper_center, + .lower_right, ), // '🯖' 0x1fbd6 => self.draw_cell_diagonal( canvas, - Alignment.upper_right, - Alignment.lower_center, + .upper_right, + .lower_center, ), // '🯗' 0x1fbd7 => self.draw_cell_diagonal( canvas, - Alignment.upper_center, - Alignment.lower_left, + .upper_center, + .lower_left, ), // '🯘' 0x1fbd8 => { self.draw_cell_diagonal( canvas, - Alignment.upper_left, - Alignment.middle_center, + .upper_left, + .middle_center, ); self.draw_cell_diagonal( canvas, - Alignment.middle_center, - Alignment.upper_right, + .middle_center, + .upper_right, ); }, // '🯙' 0x1fbd9 => { self.draw_cell_diagonal( canvas, - Alignment.upper_right, - Alignment.middle_center, + .upper_right, + .middle_center, ); self.draw_cell_diagonal( canvas, - Alignment.middle_center, - Alignment.lower_right, + .middle_center, + .lower_right, ); }, // '🯚' 0x1fbda => { self.draw_cell_diagonal( canvas, - Alignment.lower_left, - Alignment.middle_center, + .lower_left, + .middle_center, ); self.draw_cell_diagonal( canvas, - Alignment.middle_center, - Alignment.lower_right, + .middle_center, + .lower_right, ); }, // '🯛' 0x1fbdb => { self.draw_cell_diagonal( canvas, - Alignment.upper_left, - Alignment.middle_center, + .upper_left, + .middle_center, ); self.draw_cell_diagonal( canvas, - Alignment.middle_center, - Alignment.lower_left, + .middle_center, + .lower_left, ); }, // '🯜' 0x1fbdc => { self.draw_cell_diagonal( canvas, - Alignment.upper_left, - Alignment.lower_center, + .upper_left, + .lower_center, ); self.draw_cell_diagonal( canvas, - Alignment.lower_center, - Alignment.upper_right, + .lower_center, + .upper_right, ); }, // '🯝' 0x1fbdd => { self.draw_cell_diagonal( canvas, - Alignment.upper_right, - Alignment.middle_left, + .upper_right, + .middle_left, ); self.draw_cell_diagonal( canvas, - Alignment.middle_left, - Alignment.lower_right, + .middle_left, + .lower_right, ); }, // '🯞' 0x1fbde => { self.draw_cell_diagonal( canvas, - Alignment.lower_left, - Alignment.upper_center, + .lower_left, + .upper_center, ); self.draw_cell_diagonal( canvas, - Alignment.upper_center, - Alignment.lower_right, + .upper_center, + .lower_right, ); }, // '🯟' 0x1fbdf => { self.draw_cell_diagonal( canvas, - Alignment.upper_left, - Alignment.middle_right, + .upper_left, + .middle_right, ); self.draw_cell_diagonal( canvas, - Alignment.middle_right, - Alignment.lower_left, + .middle_right, + .lower_left, ); }, // '🯠' - 0x1fbe0 => self.draw_circle(canvas, Alignment.top, false), + 0x1fbe0 => self.draw_circle(canvas, .top, false), // '🯡' - 0x1fbe1 => self.draw_circle(canvas, Alignment.right, false), + 0x1fbe1 => self.draw_circle(canvas, .right, false), // '🯢' - 0x1fbe2 => self.draw_circle(canvas, Alignment.bottom, false), + 0x1fbe2 => self.draw_circle(canvas, .bottom, false), // '🯣' - 0x1fbe3 => self.draw_circle(canvas, Alignment.left, false), + 0x1fbe3 => self.draw_circle(canvas, .left, false), // '🯤' - 0x1fbe4 => self.draw_block(canvas, Alignment.upper_center, 0.5, 0.5), + 0x1fbe4 => self.draw_block(canvas, .upper_center, 0.5, 0.5), // '🯥' - 0x1fbe5 => self.draw_block(canvas, Alignment.lower_center, 0.5, 0.5), + 0x1fbe5 => self.draw_block(canvas, .lower_center, 0.5, 0.5), // '🯦' - 0x1fbe6 => self.draw_block(canvas, Alignment.middle_left, 0.5, 0.5), + 0x1fbe6 => self.draw_block(canvas, .middle_left, 0.5, 0.5), // '🯧' - 0x1fbe7 => self.draw_block(canvas, Alignment.middle_right, 0.5, 0.5), + 0x1fbe7 => self.draw_block(canvas, .middle_right, 0.5, 0.5), // '🯨' - 0x1fbe8 => self.draw_circle(canvas, Alignment.top, true), + 0x1fbe8 => self.draw_circle(canvas, .top, true), // '🯩' - 0x1fbe9 => self.draw_circle(canvas, Alignment.right, true), + 0x1fbe9 => self.draw_circle(canvas, .right, true), // '🯪' - 0x1fbea => self.draw_circle(canvas, Alignment.bottom, true), + 0x1fbea => self.draw_circle(canvas, .bottom, true), // '🯫' - 0x1fbeb => self.draw_circle(canvas, Alignment.left, true), + 0x1fbeb => self.draw_circle(canvas, .left, true), // '🯬' - 0x1fbec => self.draw_circle(canvas, Alignment.top_right, true), + 0x1fbec => self.draw_circle(canvas, .top_right, true), // '🯭' - 0x1fbed => self.draw_circle(canvas, Alignment.bottom_left, true), + 0x1fbed => self.draw_circle(canvas, .bottom_left, true), // '🯮' - 0x1fbee => self.draw_circle(canvas, Alignment.bottom_right, true), + 0x1fbee => self.draw_circle(canvas, .bottom_right, true), // '🯯' - 0x1fbef => self.draw_circle(canvas, Alignment.top_left, true), + 0x1fbef => self.draw_circle(canvas, .top_left, true), // (Below:) // Branch drawing character set, used for drawing git-like From 2384bd69cc25db7228dcb2e90ea1d296bbf0ba84 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Mon, 26 May 2025 21:39:15 -0600 Subject: [PATCH 5/5] style: use decl literals This commit changes a LOT of areas of the code to use decl literals instead of redundantly referring to the type. These changes were mostly driven by some regex searches and then manual adjustment on a case-by-case basis. I almost certainly missed quite a few places where decl literals could be used, but this is a good first step in converting things, and other instances can be addressed when they're discovered. I tested GLFW+Metal and building the framework on macOS and tested a GTK build on Linux, so I'm 99% sure I didn't introduce any syntax errors or other problems with this. (fingers crossed) --- pkg/fontconfig/pattern.zig | 4 +- pkg/glfw/Monitor.zig | 2 +- pkg/glfw/opengl.zig | 2 +- src/Command.zig | 2 +- src/Surface.zig | 2 +- src/apprt/embedded.zig | 12 +++--- src/apprt/gtk/ClipboardConfirmationWindow.zig | 14 +++---- src/apprt/gtk/ConfigErrorsDialog.zig | 6 +-- src/apprt/gtk/ResizeOverlay.zig | 4 +- src/apprt/gtk/Split.zig | 2 +- src/apprt/gtk/Surface.zig | 2 +- src/apprt/gtk/Window.zig | 8 ++-- src/apprt/gtk/inspector.zig | 2 +- src/apprt/gtk/winproto/x11.zig | 2 +- src/build/SharedDeps.zig | 8 ++-- src/cli/args.zig | 4 +- src/config/Config.zig | 8 ++-- src/config/formatter.zig | 2 +- src/crash/sentry_envelope.zig | 2 +- src/font/CodepointResolver.zig | 16 +++---- src/font/Collection.zig | 18 ++++---- src/font/DeferredFace.zig | 2 +- src/font/SharedGrid.zig | 2 +- src/font/SharedGridSet.zig | 16 +++---- src/font/face/coretext.zig | 2 +- src/font/face/freetype_convert.zig | 2 +- src/font/shaper/coretext.zig | 10 ++--- src/font/shaper/feature.zig | 2 +- src/font/shaper/harfbuzz.zig | 8 ++-- src/font/sprite/canvas.zig | 2 +- src/global.zig | 2 +- src/input/Binding.zig | 4 +- src/input/KeyEncoder.zig | 2 +- src/inspector/termio.zig | 2 +- src/os/args.zig | 2 +- src/renderer/Thread.zig | 2 +- src/renderer/cursor.zig | 2 +- src/renderer/link.zig | 2 +- src/renderer/metal/cell.zig | 2 +- src/renderer/size.zig | 4 +- src/terminal/PageList.zig | 12 +++--- src/terminal/Parser.zig | 4 +- src/terminal/Screen.zig | 12 +++--- src/terminal/Selection.zig | 8 ++-- src/terminal/StringMap.zig | 2 +- src/terminal/Terminal.zig | 10 ++--- src/terminal/bitmap_allocator.zig | 8 ++-- src/terminal/hash_map.zig | 42 +++++++++---------- src/terminal/kitty/graphics_command.zig | 18 ++++---- src/terminal/kitty/graphics_exec.zig | 2 +- src/terminal/osc.zig | 4 +- src/terminal/page.zig | 20 ++++----- src/terminal/search.zig | 4 +- src/terminal/sgr.zig | 4 +- src/terminal/style.zig | 8 ++-- src/terminal/x11_color.zig | 2 +- src/unicode/props.zig | 2 +- 57 files changed, 177 insertions(+), 177 deletions(-) diff --git a/pkg/fontconfig/pattern.zig b/pkg/fontconfig/pattern.zig index e0ec27a69..3a623e223 100644 --- a/pkg/fontconfig/pattern.zig +++ b/pkg/fontconfig/pattern.zig @@ -44,7 +44,7 @@ pub const Pattern = opaque { &val, ))).toError(); - return Value.init(&val); + return .init(&val); } pub fn delete(self: *Pattern, prop: Property) bool { @@ -138,7 +138,7 @@ pub const Pattern = opaque { return Entry{ .result = @enumFromInt(result), .binding = @enumFromInt(binding), - .value = Value.init(&value), + .value = .init(&value), }; } }; diff --git a/pkg/glfw/Monitor.zig b/pkg/glfw/Monitor.zig index 4accb23cd..3b194965a 100644 --- a/pkg/glfw/Monitor.zig +++ b/pkg/glfw/Monitor.zig @@ -281,7 +281,7 @@ pub inline fn setGamma(self: Monitor, gamma: f32) void { /// see also: monitor_gamma pub inline fn getGammaRamp(self: Monitor) ?GammaRamp { internal_debug.assertInitialized(); - if (c.glfwGetGammaRamp(self.handle)) |ramp| return GammaRamp.fromC(ramp.*); + if (c.glfwGetGammaRamp(self.handle)) |ramp| return .fromC(ramp.*); return null; } diff --git a/pkg/glfw/opengl.zig b/pkg/glfw/opengl.zig index 04bc3a65c..8fe2efbed 100644 --- a/pkg/glfw/opengl.zig +++ b/pkg/glfw/opengl.zig @@ -47,7 +47,7 @@ pub inline fn makeContextCurrent(window: ?Window) void { /// see also: context_current, glfwMakeContextCurrent pub inline fn getCurrentContext() ?Window { internal_debug.assertInitialized(); - if (c.glfwGetCurrentContext()) |handle| return Window.from(handle); + if (c.glfwGetCurrentContext()) |handle| return .from(handle); return null; } diff --git a/src/Command.zig b/src/Command.zig index e17c1b370..281dcce40 100644 --- a/src/Command.zig +++ b/src/Command.zig @@ -370,7 +370,7 @@ pub fn wait(self: Command, block: bool) !Exit { } }; - return Exit.init(res.status); + return .init(res.status); } /// Sets command->data to data. diff --git a/src/Surface.zig b/src/Surface.zig index f9e232340..32f7487d3 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -463,7 +463,7 @@ pub fn init( // Create our terminal grid with the initial size const app_mailbox: App.Mailbox = .{ .rt_app = rt_app, .mailbox = &app.mailbox }; var renderer_impl = try Renderer.init(alloc, .{ - .config = try Renderer.DerivedConfig.init(alloc, config), + .config = try .init(alloc, config), .font_grid = font_grid, .size = size, .surface_mailbox = .{ .surface = self, .app = app_mailbox }, diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index 7bc84bcad..97466e9b5 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -423,7 +423,7 @@ pub const Surface = struct { pub fn init(self: *Surface, app: *App, opts: Options) !void { self.* = .{ .app = app, - .platform = try Platform.init(opts.platform_tag, opts.platform), + .platform = try .init(opts.platform_tag, opts.platform), .userdata = opts.userdata, .core_surface = undefined, .content_scale = .{ @@ -522,7 +522,7 @@ pub const Surface = struct { const alloc = self.app.core_app.alloc; const inspector = try alloc.create(Inspector); errdefer alloc.destroy(inspector); - inspector.* = try Inspector.init(self); + inspector.* = try .init(self); self.inspector = inspector; return inspector; } @@ -1180,7 +1180,7 @@ pub const CAPI = struct { // Create our runtime app var app = try global.alloc.create(App); errdefer global.alloc.destroy(app); - app.* = try App.init(core_app, config, opts.*); + app.* = try .init(core_app, config, opts.*); errdefer app.terminate(); return app; @@ -1949,7 +1949,7 @@ pub const CAPI = struct { } export fn ghostty_inspector_metal_init(ptr: *Inspector, device: objc.c.id) bool { - return ptr.initMetal(objc.Object.fromId(device)); + return ptr.initMetal(.fromId(device)); } export fn ghostty_inspector_metal_render( @@ -1958,8 +1958,8 @@ pub const CAPI = struct { descriptor: objc.c.id, ) void { return ptr.renderMetal( - objc.Object.fromId(command_buffer), - objc.Object.fromId(descriptor), + .fromId(command_buffer), + .fromId(descriptor), ) catch |err| { log.err("error rendering inspector err={}", .{err}); return; diff --git a/src/apprt/gtk/ClipboardConfirmationWindow.zig b/src/apprt/gtk/ClipboardConfirmationWindow.zig index f10fc79ac..fab1aa893 100644 --- a/src/apprt/gtk/ClipboardConfirmationWindow.zig +++ b/src/apprt/gtk/ClipboardConfirmationWindow.zig @@ -69,16 +69,16 @@ fn init( request: apprt.ClipboardRequest, is_secure_input: bool, ) !void { - var builder = switch (DialogType) { + var builder: Builder = switch (DialogType) { adw.AlertDialog => switch (request) { - .osc_52_read => Builder.init("ccw-osc-52-read", 1, 5), - .osc_52_write => Builder.init("ccw-osc-52-write", 1, 5), - .paste => Builder.init("ccw-paste", 1, 5), + .osc_52_read => .init("ccw-osc-52-read", 1, 5), + .osc_52_write => .init("ccw-osc-52-write", 1, 5), + .paste => .init("ccw-paste", 1, 5), }, adw.MessageDialog => switch (request) { - .osc_52_read => Builder.init("ccw-osc-52-read", 1, 2), - .osc_52_write => Builder.init("ccw-osc-52-write", 1, 2), - .paste => Builder.init("ccw-paste", 1, 2), + .osc_52_read => .init("ccw-osc-52-read", 1, 2), + .osc_52_write => .init("ccw-osc-52-write", 1, 2), + .paste => .init("ccw-paste", 1, 2), }, else => unreachable, }; diff --git a/src/apprt/gtk/ConfigErrorsDialog.zig b/src/apprt/gtk/ConfigErrorsDialog.zig index ccc5599ad..da70ccce1 100644 --- a/src/apprt/gtk/ConfigErrorsDialog.zig +++ b/src/apprt/gtk/ConfigErrorsDialog.zig @@ -32,9 +32,9 @@ pub fn maybePresent(app: *App, window: ?*Window) void { const config_errors_dialog = config_errors_dialog: { if (app.config_errors_dialog) |config_errors_dialog| break :config_errors_dialog config_errors_dialog; - var builder = switch (DialogType) { - adw.AlertDialog => Builder.init("config-errors-dialog", 1, 5), - adw.MessageDialog => Builder.init("config-errors-dialog", 1, 2), + var builder: Builder = switch (DialogType) { + adw.AlertDialog => .init("config-errors-dialog", 1, 5), + adw.MessageDialog => .init("config-errors-dialog", 1, 2), else => unreachable, }; diff --git a/src/apprt/gtk/ResizeOverlay.zig b/src/apprt/gtk/ResizeOverlay.zig index 767cf097d..2ab59624a 100644 --- a/src/apprt/gtk/ResizeOverlay.zig +++ b/src/apprt/gtk/ResizeOverlay.zig @@ -50,12 +50,12 @@ first: bool = true, pub fn init(self: *ResizeOverlay, surface: *Surface, config: *const configpkg.Config) void { self.* = .{ .surface = surface, - .config = DerivedConfig.init(config), + .config = .init(config), }; } pub fn updateConfig(self: *ResizeOverlay, config: *const configpkg.Config) void { - self.config = DerivedConfig.init(config); + self.config = .init(config); } /// De-initialize the ResizeOverlay. This removes any pending idlers/timers that diff --git a/src/apprt/gtk/Split.zig b/src/apprt/gtk/Split.zig index 9caa9ab56..fb719c3c9 100644 --- a/src/apprt/gtk/Split.zig +++ b/src/apprt/gtk/Split.zig @@ -138,7 +138,7 @@ pub fn init( .container = container, .top_left = .{ .surface = tl }, .bottom_right = .{ .surface = br }, - .orientation = Orientation.fromDirection(direction), + .orientation = .fromDirection(direction), }; // Replace the previous containers element with our split. This allows a diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index bcb78e087..30a3d28f7 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -1191,7 +1191,7 @@ pub fn mouseOverLink(self: *Surface, uri_: ?[]const u8) void { return; } - self.url_widget = URLWidget.init(self.overlay, uriZ); + self.url_widget = .init(self.overlay, uriZ); } pub fn supportsClipboard( diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index 4a5926a97..aa1f0a4b1 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -136,7 +136,7 @@ pub fn init(self: *Window, app: *App) !void { self.* = .{ .app = app, .last_config = @intFromPtr(&app.config), - .config = DerivedConfig.init(&app.config), + .config = .init(&app.config), .window = undefined, .headerbar = undefined, .tab_overview = null, @@ -148,7 +148,7 @@ pub fn init(self: *Window, app: *App) !void { }; // Create the window - self.window = adw.ApplicationWindow.new(app.app.as(gtk.Application)); + self.window = .new(app.app.as(gtk.Application)); const gtk_window = self.window.as(gtk.Window); const gtk_widget = self.window.as(gtk.Widget); errdefer gtk_window.destroy(); @@ -333,7 +333,7 @@ pub fn init(self: *Window, app: *App) !void { } // Setup our toast overlay if we have one - self.toast_overlay = adw.ToastOverlay.new(); + self.toast_overlay = .new(); self.toast_overlay.setChild(self.notebook.asWidget()); box.append(self.toast_overlay.as(gtk.Widget)); @@ -463,7 +463,7 @@ pub fn updateConfig( if (self.last_config == this_config) return; self.last_config = this_config; - self.config = DerivedConfig.init(config); + self.config = .init(config); // We always resync our appearance whenever the config changes. try self.syncAppearance(); diff --git a/src/apprt/gtk/inspector.zig b/src/apprt/gtk/inspector.zig index e3e61e258..3adeb9711 100644 --- a/src/apprt/gtk/inspector.zig +++ b/src/apprt/gtk/inspector.zig @@ -138,7 +138,7 @@ const Window = struct { }; // Create the window - self.window = gtk.ApplicationWindow.new(inspector.surface.app.app.as(gtk.Application)); + self.window = .new(inspector.surface.app.app.as(gtk.Application)); errdefer self.window.as(gtk.Window).destroy(); self.window.as(gtk.Window).setTitle(i18n._("Ghostty: Terminal Inspector")); diff --git a/src/apprt/gtk/winproto/x11.zig b/src/apprt/gtk/winproto/x11.zig index c2b6bf416..387905b18 100644 --- a/src/apprt/gtk/winproto/x11.zig +++ b/src/apprt/gtk/winproto/x11.zig @@ -109,7 +109,7 @@ pub const App = struct { return .{ .display = xlib_display, .base_event_code = base_event_code, - .atoms = Atoms.init(gdk_x11_display), + .atoms = .init(gdk_x11_display), }; } diff --git a/src/build/SharedDeps.zig b/src/build/SharedDeps.zig index 0df261600..512975ac0 100644 --- a/src/build/SharedDeps.zig +++ b/src/build/SharedDeps.zig @@ -24,9 +24,9 @@ pub const LazyPathList = std.ArrayList(std.Build.LazyPath); pub fn init(b: *std.Build, cfg: *const Config) !SharedDeps { var result: SharedDeps = .{ .config = cfg, - .help_strings = try HelpStrings.init(b, cfg), - .unicode_tables = try UnicodeTables.init(b), - .framedata = try GhosttyFrameData.init(b), + .help_strings = try .init(b, cfg), + .unicode_tables = try .init(b), + .framedata = try .init(b), // Setup by retarget .options = undefined, @@ -72,7 +72,7 @@ fn initTarget( target: std.Build.ResolvedTarget, ) !void { // Update our metallib - self.metallib = MetallibStep.create(b, .{ + self.metallib = .create(b, .{ .name = "Ghostty", .target = target, .sources = &.{b.path("src/renderer/shaders/cell.metal")}, diff --git a/src/cli/args.zig b/src/cli/args.zig index 4860cdd74..68972a622 100644 --- a/src/cli/args.zig +++ b/src/cli/args.zig @@ -84,7 +84,7 @@ pub fn parse( // If the arena is unset, we create it. We mark that we own it // only so that we can clean it up on error. if (dst._arena == null) { - dst._arena = ArenaAllocator.init(alloc); + dst._arena = .init(alloc); arena_owned = true; } @@ -481,7 +481,7 @@ pub fn parseAutoStruct(comptime T: type, alloc: Allocator, v: []const u8) !T { // Keep track of which fields were set so we can error if a required // field was not set. const FieldSet = std.StaticBitSet(info.fields.len); - var fields_set: FieldSet = FieldSet.initEmpty(); + var fields_set: FieldSet = .initEmpty(); // We split each value by "," var iter = std.mem.splitSequence(u8, v, ","); diff --git a/src/config/Config.zig b/src/config/Config.zig index 6f1e89d41..8d08113bc 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -2531,7 +2531,7 @@ pub fn load(alloc_gpa: Allocator) !Config { pub fn default(alloc_gpa: Allocator) Allocator.Error!Config { // Build up our basic config var result: Config = .{ - ._arena = ArenaAllocator.init(alloc_gpa), + ._arena = .init(alloc_gpa), }; errdefer result.deinit(); const alloc = result._arena.?.allocator(); @@ -3332,7 +3332,7 @@ pub fn parseManuallyHook( /// be deallocated while shallow clones exist. pub fn shallowClone(self: *const Config, alloc_gpa: Allocator) Config { var result = self.*; - result._arena = ArenaAllocator.init(alloc_gpa); + result._arena = .init(alloc_gpa); return result; } @@ -5975,7 +5975,7 @@ pub const QuickTerminalSize = struct { it.next() orelse return error.ValueRequired, cli.args.whitespace, ); - self.primary = try Size.parse(primary); + self.primary = try .parse(primary); self.secondary = secondary: { const secondary = std.mem.trim( @@ -5983,7 +5983,7 @@ pub const QuickTerminalSize = struct { it.next() orelse break :secondary null, cli.args.whitespace, ); - break :secondary try Size.parse(secondary); + break :secondary try .parse(secondary); }; if (it.next()) |_| return error.TooManyArguments; diff --git a/src/config/formatter.zig b/src/config/formatter.zig index ca3da1d91..cabf80953 100644 --- a/src/config/formatter.zig +++ b/src/config/formatter.zig @@ -153,7 +153,7 @@ pub const FileFormatter = struct { // If we're change-tracking then we need the default config to // compare against. var default: ?Config = if (self.changed) - try Config.default(self.alloc) + try .default(self.alloc) else null; defer if (default) |*v| v.deinit(); diff --git a/src/crash/sentry_envelope.zig b/src/crash/sentry_envelope.zig index 70eb99f51..6b675554c 100644 --- a/src/crash/sentry_envelope.zig +++ b/src/crash/sentry_envelope.zig @@ -331,7 +331,7 @@ pub const Item = union(enum) { // Decode the item. self.* = switch (encoded.type) { - .attachment => .{ .attachment = try Attachment.decode( + .attachment => .{ .attachment = try .decode( alloc, encoded, ) }, diff --git a/src/font/CodepointResolver.zig b/src/font/CodepointResolver.zig index 37093b59a..16536300c 100644 --- a/src/font/CodepointResolver.zig +++ b/src/font/CodepointResolver.zig @@ -37,7 +37,7 @@ collection: Collection, /// The set of statuses and whether they're enabled or not. This defaults /// to true. This can be changed at runtime with no ill effect. -styles: StyleStatus = StyleStatus.initFill(true), +styles: StyleStatus = .initFill(true), /// If discovery is available, we'll look up fonts where we can't find /// the codepoint. This can be set after initialization. @@ -140,7 +140,7 @@ pub fn getIndex( // handle this. if (self.sprite) |sprite| { if (sprite.hasCodepoint(cp, p)) { - return Collection.Index.initSpecial(.sprite); + return .initSpecial(.sprite); } } @@ -388,7 +388,7 @@ test getIndex { { errdefer c.deinit(alloc); - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, @@ -398,7 +398,7 @@ test getIndex { _ = try c.add( alloc, .regular, - .{ .loaded = try Face.init( + .{ .loaded = try .init( lib, testEmoji, .{ .size = .{ .points = 12 } }, @@ -408,7 +408,7 @@ test getIndex { _ = try c.add( alloc, .regular, - .{ .loaded = try Face.init( + .{ .loaded = try .init( lib, testEmojiText, .{ .size = .{ .points = 12 } }, @@ -467,17 +467,17 @@ test "getIndex disabled font style" { var c = Collection.init(); c.load_options = .{ .library = lib }; - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, ) }); - _ = try c.add(alloc, .bold, .{ .loaded = try Face.init( + _ = try c.add(alloc, .bold, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, ) }); - _ = try c.add(alloc, .italic, .{ .loaded = try Face.init( + _ = try c.add(alloc, .italic, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, diff --git a/src/font/Collection.zig b/src/font/Collection.zig index 59f89d402..8533331bc 100644 --- a/src/font/Collection.zig +++ b/src/font/Collection.zig @@ -55,7 +55,7 @@ load_options: ?LoadOptions = null, pub fn init() Collection { // Initialize our styles array, preallocating some space that is // likely to be used. - return .{ .faces = StyleArray.initFill(.{}) }; + return .{ .faces = .initFill(.{}) }; } pub fn deinit(self: *Collection, alloc: Allocator) void { @@ -707,7 +707,7 @@ test "add full" { defer c.deinit(alloc); for (0..Index.Special.start - 1) |_| { - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12 } }, @@ -755,7 +755,7 @@ test getFace { var c = init(); defer c.deinit(alloc); - const idx = try c.add(alloc, .regular, .{ .loaded = try Face.init( + const idx = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, @@ -779,7 +779,7 @@ test getIndex { var c = init(); defer c.deinit(alloc); - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, @@ -811,7 +811,7 @@ test completeStyles { defer c.deinit(alloc); c.load_options = .{ .library = lib }; - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, @@ -838,7 +838,7 @@ test setSize { defer c.deinit(alloc); c.load_options = .{ .library = lib }; - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, @@ -861,7 +861,7 @@ test hasCodepoint { defer c.deinit(alloc); c.load_options = .{ .library = lib }; - const idx = try c.add(alloc, .regular, .{ .loaded = try Face.init( + const idx = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, @@ -885,7 +885,7 @@ test "hasCodepoint emoji default graphical" { defer c.deinit(alloc); c.load_options = .{ .library = lib }; - const idx = try c.add(alloc, .regular, .{ .loaded = try Face.init( + const idx = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testEmoji, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, @@ -908,7 +908,7 @@ test "metrics" { defer c.deinit(alloc); c.load_options = .{ .library = lib }; - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, diff --git a/src/font/DeferredFace.zig b/src/font/DeferredFace.zig index 8794ccea9..f9ce0bff5 100644 --- a/src/font/DeferredFace.zig +++ b/src/font/DeferredFace.zig @@ -254,7 +254,7 @@ fn loadWebCanvas( opts: font.face.Options, ) !Face { const wc = self.wc.?; - return try Face.initNamed(wc.alloc, wc.font_str, opts, wc.presentation); + return try .initNamed(wc.alloc, wc.font_str, opts, wc.presentation); } /// Returns true if this face can satisfy the given codepoint and diff --git a/src/font/SharedGrid.zig b/src/font/SharedGrid.zig index 72e97fad8..35770f920 100644 --- a/src/font/SharedGrid.zig +++ b/src/font/SharedGrid.zig @@ -319,7 +319,7 @@ fn testGrid(mode: TestMode, alloc: Allocator, lib: Library) !SharedGrid { switch (mode) { .normal => { - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, diff --git a/src/font/SharedGridSet.zig b/src/font/SharedGridSet.zig index 8ad30629e..858d7930f 100644 --- a/src/font/SharedGridSet.zig +++ b/src/font/SharedGridSet.zig @@ -126,7 +126,7 @@ pub fn ref( .ref = 1, }; - grid.* = try SharedGrid.init(self.alloc, resolver: { + grid.* = try .init(self.alloc, resolver: { // Build our collection. This is the expensive operation that // involves finding fonts, loading them (maybe, some are deferred), // etc. @@ -258,7 +258,7 @@ fn collection( _ = try c.add( self.alloc, .regular, - .{ .fallback_loaded = try Face.init( + .{ .fallback_loaded = try .init( self.font_lib, font.embedded.regular, load_options.faceOptions(), @@ -267,7 +267,7 @@ fn collection( _ = try c.add( self.alloc, .bold, - .{ .fallback_loaded = try Face.init( + .{ .fallback_loaded = try .init( self.font_lib, font.embedded.bold, load_options.faceOptions(), @@ -276,7 +276,7 @@ fn collection( _ = try c.add( self.alloc, .italic, - .{ .fallback_loaded = try Face.init( + .{ .fallback_loaded = try .init( self.font_lib, font.embedded.italic, load_options.faceOptions(), @@ -285,7 +285,7 @@ fn collection( _ = try c.add( self.alloc, .bold_italic, - .{ .fallback_loaded = try Face.init( + .{ .fallback_loaded = try .init( self.font_lib, font.embedded.bold_italic, load_options.faceOptions(), @@ -318,7 +318,7 @@ fn collection( _ = try c.add( self.alloc, .regular, - .{ .fallback_loaded = try Face.init( + .{ .fallback_loaded = try .init( self.font_lib, font.embedded.emoji, load_options.faceOptions(), @@ -327,7 +327,7 @@ fn collection( _ = try c.add( self.alloc, .regular, - .{ .fallback_loaded = try Face.init( + .{ .fallback_loaded = try .init( self.font_lib, font.embedded.emoji_text, load_options.faceOptions(), @@ -391,7 +391,7 @@ fn discover(self: *SharedGridSet) !?*Discover { // If we initialized, use it if (self.font_discover) |*v| return v; - self.font_discover = Discover.init(); + self.font_discover = .init(); return &self.font_discover.?; } diff --git a/src/font/face/coretext.zig b/src/font/face/coretext.zig index 639eae43c..06bba661f 100644 --- a/src/font/face/coretext.zig +++ b/src/font/face/coretext.zig @@ -97,7 +97,7 @@ pub const Face = struct { errdefer if (comptime harfbuzz_shaper) hb_font.destroy(); const color: ?ColorState = if (traits.color_glyphs) - try ColorState.init(ct_font) + try .init(ct_font) else null; errdefer if (color) |v| v.deinit(); diff --git a/src/font/face/freetype_convert.zig b/src/font/face/freetype_convert.zig index 6df350bfa..3a7cf8c98 100644 --- a/src/font/face/freetype_convert.zig +++ b/src/font/face/freetype_convert.zig @@ -30,7 +30,7 @@ fn genMap() Map { // Initialize to no converter var i: usize = 0; while (i < freetype.c.FT_PIXEL_MODE_MAX) : (i += 1) { - result[i] = AtlasArray.initFill(null); + result[i] = .initFill(null); } // Map our converters diff --git a/src/font/shaper/coretext.zig b/src/font/shaper/coretext.zig index f2ac5b85d..8e2c45c69 100644 --- a/src/font/shaper/coretext.zig +++ b/src/font/shaper/coretext.zig @@ -191,7 +191,7 @@ pub const Shaper = struct { // Create the CF release thread. var cf_release_thread = try alloc.create(CFReleaseThread); errdefer alloc.destroy(cf_release_thread); - cf_release_thread.* = try CFReleaseThread.init(alloc); + cf_release_thread.* = try .init(alloc); errdefer cf_release_thread.deinit(); // Start the CF release thread. @@ -1768,7 +1768,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper { c.load_options = .{ .library = lib }; // Setup group - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12 } }, @@ -1776,7 +1776,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper { if (font.options.backend != .coretext) { // Coretext doesn't support Noto's format - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testEmoji, .{ .size = .{ .points = 12 } }, @@ -1795,7 +1795,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper { errdefer face.deinit(); _ = try c.add(alloc, .regular, .{ .deferred = face }); } - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testEmojiText, .{ .size = .{ .points = 12 } }, @@ -1803,7 +1803,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper { const grid_ptr = try alloc.create(SharedGrid); errdefer alloc.destroy(grid_ptr); - grid_ptr.* = try SharedGrid.init(alloc, .{ .collection = c }); + grid_ptr.* = try .init(alloc, .{ .collection = c }); errdefer grid_ptr.*.deinit(alloc); var shaper = try Shaper.init(alloc, .{}); diff --git a/src/font/shaper/feature.zig b/src/font/shaper/feature.zig index c2d49234d..66d0cb1f7 100644 --- a/src/font/shaper/feature.zig +++ b/src/font/shaper/feature.zig @@ -21,7 +21,7 @@ pub const Feature = struct { pub fn fromString(str: []const u8) ?Feature { var fbs = std.io.fixedBufferStream(str); const reader = fbs.reader(); - return Feature.fromReader(reader); + return .fromReader(reader); } /// Parse a single font feature setting from a std.io.Reader, with a version diff --git a/src/font/shaper/harfbuzz.zig b/src/font/shaper/harfbuzz.zig index eb8130f79..361cbbe93 100644 --- a/src/font/shaper/harfbuzz.zig +++ b/src/font/shaper/harfbuzz.zig @@ -1227,7 +1227,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper { c.load_options = .{ .library = lib }; // Setup group - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testFont, .{ .size = .{ .points = 12 } }, @@ -1235,7 +1235,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper { if (comptime !font.options.backend.hasCoretext()) { // Coretext doesn't support Noto's format - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testEmoji, .{ .size = .{ .points = 12 } }, @@ -1254,7 +1254,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper { errdefer face.deinit(); _ = try c.add(alloc, .regular, .{ .deferred = face }); } - _ = try c.add(alloc, .regular, .{ .loaded = try Face.init( + _ = try c.add(alloc, .regular, .{ .loaded = try .init( lib, testEmojiText, .{ .size = .{ .points = 12 } }, @@ -1262,7 +1262,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper { const grid_ptr = try alloc.create(SharedGrid); errdefer alloc.destroy(grid_ptr); - grid_ptr.* = try SharedGrid.init(alloc, .{ .collection = c }); + grid_ptr.* = try .init(alloc, .{ .collection = c }); errdefer grid_ptr.*.deinit(alloc); var shaper = try Shaper.init(alloc, .{}); diff --git a/src/font/sprite/canvas.zig b/src/font/sprite/canvas.zig index ed00aef12..a5ca7b290 100644 --- a/src/font/sprite/canvas.zig +++ b/src/font/sprite/canvas.zig @@ -150,7 +150,7 @@ pub const Canvas = struct { /// Acquires a z2d drawing context, caller MUST deinit context. pub fn getContext(self: *Canvas) z2d.Context { - return z2d.Context.init(self.alloc, &self.sfc); + return .init(self.alloc, &self.sfc); } /// Draw and fill a single pixel diff --git a/src/global.zig b/src/global.zig index 375c10538..d11dd775b 100644 --- a/src/global.zig +++ b/src/global.zig @@ -139,7 +139,7 @@ pub const GlobalState = struct { std.log.info("libxev default backend={s}", .{@tagName(xev.backend)}); // As early as possible, initialize our resource limits. - self.rlimits = ResourceLimits.init(); + self.rlimits = .init(); // Initialize our crash reporting. crash.init(self.alloc) catch |err| { diff --git a/src/input/Binding.zig b/src/input/Binding.zig index 59adc7149..3818d99a6 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -71,7 +71,7 @@ pub const Parser = struct { // parse the action now. return .{ .trigger_it = .{ .input = input[0..eql_idx] }, - .action = try Action.parse(input[eql_idx + 1 ..]), + .action = try .parse(input[eql_idx + 1 ..]), .flags = flags, }; } @@ -158,7 +158,7 @@ const SequenceIterator = struct { const rem = self.input[self.i..]; const idx = std.mem.indexOf(u8, rem, ">") orelse rem.len; defer self.i += idx + 1; - return try Trigger.parse(rem[0..idx]); + return try .parse(rem[0..idx]); } /// Returns true if there are no more triggers to parse. diff --git a/src/input/KeyEncoder.zig b/src/input/KeyEncoder.zig index 41634f2f1..b5f18b5a2 100644 --- a/src/input/KeyEncoder.zig +++ b/src/input/KeyEncoder.zig @@ -164,7 +164,7 @@ fn kitty( var seq: KittySequence = .{ .key = entry.code, .final = entry.final, - .mods = KittyMods.fromInput( + .mods = .fromInput( self.event.action, self.event.key, all_mods, diff --git a/src/inspector/termio.zig b/src/inspector/termio.zig index 6aa6628ab..5ab9d3cd4 100644 --- a/src/inspector/termio.zig +++ b/src/inspector/termio.zig @@ -308,7 +308,7 @@ pub const VTHandler = struct { current_seq: usize = 1, /// Exclude certain actions by tag. - filter_exclude: ActionTagSet = ActionTagSet.initMany(&.{.print}), + filter_exclude: ActionTagSet = .initMany(&.{.print}), filter_text: *cimgui.c.ImGuiTextFilter, const ActionTagSet = std.EnumSet(terminal.Parser.Action.Tag); diff --git a/src/os/args.zig b/src/os/args.zig index 9f7401c94..a531a418b 100644 --- a/src/os/args.zig +++ b/src/os/args.zig @@ -12,7 +12,7 @@ const macos = @import("macos"); /// but handles macOS using NSProcessInfo instead of libc argc/argv. pub fn iterator(allocator: Allocator) ArgIterator.InitError!ArgIterator { //if (true) return try std.process.argsWithAllocator(allocator); - return ArgIterator.initWithAllocator(allocator); + return .initWithAllocator(allocator); } /// Duck-typed to std.process.ArgIterator diff --git a/src/renderer/Thread.zig b/src/renderer/Thread.zig index 46ef8609b..1e9c29b26 100644 --- a/src/renderer/Thread.zig +++ b/src/renderer/Thread.zig @@ -155,7 +155,7 @@ pub fn init( return .{ .alloc = alloc, - .config = DerivedConfig.init(config), + .config = .init(config), .loop = loop, .wakeup = wakeup_h, .stop = stop_h, diff --git a/src/renderer/cursor.zig b/src/renderer/cursor.zig index d8769d9e2..287b83450 100644 --- a/src/renderer/cursor.zig +++ b/src/renderer/cursor.zig @@ -62,7 +62,7 @@ pub fn style( } // Otherwise, we use whatever style the terminal wants. - return Style.fromTerminal(state.terminal.screen.cursor.cursor_style); + return .fromTerminal(state.terminal.screen.cursor.cursor_style); } test "cursor: default uses configured style" { diff --git a/src/renderer/link.zig b/src/renderer/link.zig index 994190ec8..410fb8632 100644 --- a/src/renderer/link.zig +++ b/src/renderer/link.zig @@ -179,7 +179,7 @@ pub const Set = struct { if (current) |*sel| { sel.endPtr().* = cell_pin; } else { - current = terminal.Selection.init( + current = .init( cell_pin, cell_pin, false, diff --git a/src/renderer/metal/cell.zig b/src/renderer/metal/cell.zig index 61b8887fd..e1bcb7b9f 100644 --- a/src/renderer/metal/cell.zig +++ b/src/renderer/metal/cell.zig @@ -44,7 +44,7 @@ fn ArrayListPool(comptime T: type) type { }; for (self.lists) |*list| { - list.* = try ArrayListT.initCapacity(alloc, initial_capacity); + list.* = try .initCapacity(alloc, initial_capacity); } return self; diff --git a/src/renderer/size.zig b/src/renderer/size.zig index 83e921a26..b26c1581e 100644 --- a/src/renderer/size.zig +++ b/src/renderer/size.zig @@ -22,7 +22,7 @@ pub const Size = struct { /// taking the screen size, removing padding, and dividing by the cell /// dimensions. pub fn grid(self: Size) GridSize { - return GridSize.init(self.screen.subPadding(self.padding), self.cell); + return .init(self.screen.subPadding(self.padding), self.cell); } /// The size of the terminal. This is the same as the screen without @@ -39,7 +39,7 @@ pub const Size = struct { self.padding = explicit; // Now we can calculate the balanced padding - self.padding = Padding.balanced( + self.padding = .balanced( self.screen, self.grid(), self.cell, diff --git a/src/terminal/PageList.zig b/src/terminal/PageList.zig index 95519fe99..300af8e13 100644 --- a/src/terminal/PageList.zig +++ b/src/terminal/PageList.zig @@ -287,8 +287,8 @@ fn initPages( // Initialize the first set of pages to contain our viewport so that // the top of the first page is always the active area. node.* = .{ - .data = Page.initBuf( - OffsetBuf.init(page_buf), + .data = .initBuf( + .init(page_buf), Page.layout(cap), ), }; @@ -472,7 +472,7 @@ pub fn clone( }; // Setup our pools - break :alloc try MemoryPool.init( + break :alloc try .init( alloc, std.heap.page_allocator, page_count, @@ -1201,7 +1201,7 @@ const ReflowCursor = struct { node.data.size.rows = 1; list.pages.insertAfter(self.node, node); - self.* = ReflowCursor.init(node); + self.* = .init(node); self.new_rows = new_rows; } @@ -1817,7 +1817,7 @@ pub fn grow(self: *PageList) !?*List.Node { @memset(buf, 0); // Initialize our new page and reinsert it as the last - first.data = Page.initBuf(OffsetBuf.init(buf), layout); + first.data = .initBuf(.init(buf), layout); first.data.size.rows = 1; self.pages.insertAfter(last, first); @@ -1989,7 +1989,7 @@ fn createPageExt( // to undefined, 0xAA. if (comptime std.debug.runtime_safety) @memset(page_buf, 0); - page.* = .{ .data = Page.initBuf(OffsetBuf.init(page_buf), layout) }; + page.* = .{ .data = .initBuf(.init(page_buf), layout) }; page.data.size.rows = 0; if (total_size) |v| { diff --git a/src/terminal/Parser.zig b/src/terminal/Parser.zig index 4e74f04ba..14ed6d6df 100644 --- a/src/terminal/Parser.zig +++ b/src/terminal/Parser.zig @@ -217,7 +217,7 @@ intermediates_idx: u8 = 0, /// Param tracking, building params: [MAX_PARAMS]u16 = undefined, -params_sep: Action.CSI.SepList = Action.CSI.SepList.initEmpty(), +params_sep: Action.CSI.SepList = .initEmpty(), params_idx: u8 = 0, param_acc: u16 = 0, param_acc_idx: u8 = 0, @@ -395,7 +395,7 @@ fn doAction(self: *Parser, action: TransitionAction, c: u8) ?Action { pub fn clear(self: *Parser) void { self.intermediates_idx = 0; self.params_idx = 0; - self.params_sep = Action.CSI.SepList.initEmpty(); + self.params_sep = .initEmpty(); self.param_acc = 0; self.param_acc_idx = 0; } diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 9ab4b23e2..2688b03a7 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -171,7 +171,7 @@ pub const SavedCursor = struct { /// State required for all charset operations. pub const CharsetState = struct { /// The list of graphical charsets by slot - charsets: CharsetArray = CharsetArray.initFill(charsets.Charset.utf8), + charsets: CharsetArray = .initFill(charsets.Charset.utf8), /// GL is the slot to use when using a 7-bit printable char (up to 127) /// GR used for 8-bit printable chars. @@ -2433,7 +2433,7 @@ pub fn selectLine(self: *const Screen, opts: SelectLine) ?Selection { return null; }; - return Selection.init(start, end, false); + return .init(start, end, false); } /// Return the selection for all contents on the screen. Surrounding @@ -2489,7 +2489,7 @@ pub fn selectAll(self: *Screen) ?Selection { return null; }; - return Selection.init(start, end, false); + return .init(start, end, false); } /// Select the nearest word to start point that is between start_pt and @@ -2624,7 +2624,7 @@ pub fn selectWord(self: *Screen, pin: Pin) ?Selection { break :start prev; }; - return Selection.init(start, end, false); + return .init(start, end, false); } /// Select the command output under the given point. The limits of the output @@ -2724,7 +2724,7 @@ pub fn selectOutput(self: *Screen, pin: Pin) ?Selection { break :boundary it_prev; }; - return Selection.init(start, end, false); + return .init(start, end, false); } /// Returns the selection bounds for the prompt at the given point. If the @@ -2805,7 +2805,7 @@ pub fn selectPrompt(self: *Screen, pin: Pin) ?Selection { break :end it_prev; }; - return Selection.init(start, end, false); + return .init(start, end, false); } pub const LineIterator = struct { diff --git a/src/terminal/Selection.zig b/src/terminal/Selection.zig index a90595d20..267f223d5 100644 --- a/src/terminal/Selection.zig +++ b/src/terminal/Selection.zig @@ -228,7 +228,7 @@ pub fn order(self: Selection, s: *const Screen) Order { /// Note that only forward and reverse are useful desired orders for this /// function. All other orders act as if forward order was desired. pub fn ordered(self: Selection, s: *const Screen, desired: Order) Selection { - if (self.order(s) == desired) return Selection.init( + if (self.order(s) == desired) return .init( self.start(), self.end(), self.rectangle, @@ -237,9 +237,9 @@ pub fn ordered(self: Selection, s: *const Screen, desired: Order) Selection { const tl = self.topLeft(s); const br = self.bottomRight(s); return switch (desired) { - .forward => Selection.init(tl, br, self.rectangle), - .reverse => Selection.init(br, tl, self.rectangle), - else => Selection.init(tl, br, self.rectangle), + .forward => .init(tl, br, self.rectangle), + .reverse => .init(br, tl, self.rectangle), + else => .init(tl, br, self.rectangle), }; } diff --git a/src/terminal/StringMap.zig b/src/terminal/StringMap.zig index 9892c13df..dde69d25e 100644 --- a/src/terminal/StringMap.zig +++ b/src/terminal/StringMap.zig @@ -80,7 +80,7 @@ pub const Match = struct { const end_idx: usize = @intCast(self.region.ends()[0] - 1); const start_pt = self.map.map[self.offset + start_idx]; const end_pt = self.map.map[self.offset + end_idx]; - return Selection.init(start_pt, end_pt, false); + return .init(start_pt, end_pt, false); } }; diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index efb9684eb..595fee1ba 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -79,7 +79,7 @@ default_palette: color.Palette = color.default, color_palette: struct { const Mask = std.StaticBitSet(@typeInfo(color.Palette).array.len); colors: color.Palette = color.default, - mask: Mask = Mask.initEmpty(), + mask: Mask = .initEmpty(), } = .{}, /// The previous printed character. This is used for the repeat previous @@ -210,9 +210,9 @@ pub fn init( .cols = cols, .rows = rows, .active_screen = .primary, - .screen = try Screen.init(alloc, cols, rows, opts.max_scrollback), - .secondary_screen = try Screen.init(alloc, cols, rows, 0), - .tabstops = try Tabstops.init(alloc, cols, TABSTOP_INTERVAL), + .screen = try .init(alloc, cols, rows, opts.max_scrollback), + .secondary_screen = try .init(alloc, cols, rows, 0), + .tabstops = try .init(alloc, cols, TABSTOP_INTERVAL), .scrolling_region = .{ .top = 0, .bottom = rows - 1, @@ -2454,7 +2454,7 @@ pub fn resize( // Resize our tabstops if (self.cols != cols) { self.tabstops.deinit(alloc); - self.tabstops = try Tabstops.init(alloc, cols, 8); + self.tabstops = try .init(alloc, cols, 8); } // If we're making the screen smaller, dealloc the unused items. diff --git a/src/terminal/bitmap_allocator.zig b/src/terminal/bitmap_allocator.zig index f96d39831..68d968768 100644 --- a/src/terminal/bitmap_allocator.zig +++ b/src/terminal/bitmap_allocator.zig @@ -403,7 +403,7 @@ test "BitmapAllocator alloc sequentially" { const buf = try alloc.alignedAlloc(u8, Alloc.base_align, layout.total_size); defer alloc.free(buf); - var bm = Alloc.init(OffsetBuf.init(buf), layout); + var bm = Alloc.init(.init(buf), layout); const ptr = try bm.alloc(u8, buf, 1); ptr[0] = 'A'; @@ -429,7 +429,7 @@ test "BitmapAllocator alloc non-byte" { const buf = try alloc.alignedAlloc(u8, Alloc.base_align, layout.total_size); defer alloc.free(buf); - var bm = Alloc.init(OffsetBuf.init(buf), layout); + var bm = Alloc.init(.init(buf), layout); const ptr = try bm.alloc(u21, buf, 1); ptr[0] = 'A'; @@ -453,7 +453,7 @@ test "BitmapAllocator alloc non-byte multi-chunk" { const buf = try alloc.alignedAlloc(u8, Alloc.base_align, layout.total_size); defer alloc.free(buf); - var bm = Alloc.init(OffsetBuf.init(buf), layout); + var bm = Alloc.init(.init(buf), layout); const ptr = try bm.alloc(u21, buf, 6); try testing.expectEqual(@as(usize, 6), ptr.len); for (ptr) |*v| v.* = 'A'; @@ -478,7 +478,7 @@ test "BitmapAllocator alloc large" { const buf = try alloc.alignedAlloc(u8, Alloc.base_align, layout.total_size); defer alloc.free(buf); - var bm = Alloc.init(OffsetBuf.init(buf), layout); + var bm = Alloc.init(.init(buf), layout); const ptr = try bm.alloc(u8, buf, 129); ptr[0] = 'A'; bm.free(buf, ptr); diff --git a/src/terminal/hash_map.zig b/src/terminal/hash_map.zig index 0cc17a747..9a16be3b2 100644 --- a/src/terminal/hash_map.zig +++ b/src/terminal/hash_map.zig @@ -893,7 +893,7 @@ test "HashMap basic usage" { const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); const count = 5; var i: u32 = 0; @@ -927,7 +927,7 @@ test "HashMap ensureTotalCapacity" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); const initial_capacity = map.capacity(); try testing.expect(initial_capacity >= 20); @@ -947,7 +947,7 @@ test "HashMap ensureUnusedCapacity with tombstones" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); var i: i32 = 0; while (i < 100) : (i += 1) { @@ -965,7 +965,7 @@ test "HashMap clearRetainingCapacity" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); map.clearRetainingCapacity(); @@ -996,7 +996,7 @@ test "HashMap ensureTotalCapacity with existing elements" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); try map.put(0, 0); try expectEqual(map.count(), 1); @@ -1015,7 +1015,7 @@ test "HashMap remove" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); var i: u32 = 0; while (i < 16) : (i += 1) { @@ -1053,7 +1053,7 @@ test "HashMap reverse removes" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); var i: u32 = 0; while (i < 16) : (i += 1) { @@ -1081,7 +1081,7 @@ test "HashMap multiple removes on same metadata" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); var i: u32 = 0; while (i < 16) : (i += 1) { @@ -1124,7 +1124,7 @@ test "HashMap put and remove loop in random order" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); var keys = std.ArrayList(u32).init(alloc); defer keys.deinit(); @@ -1162,7 +1162,7 @@ test "HashMap put" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); var i: u32 = 0; while (i < 16) : (i += 1) { @@ -1193,7 +1193,7 @@ test "HashMap put full load" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); for (0..cap) |i| try map.put(i, i); for (0..cap) |i| try expectEqual(map.get(i).?, i); @@ -1209,7 +1209,7 @@ test "HashMap putAssumeCapacity" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); var i: u32 = 0; while (i < 20) : (i += 1) { @@ -1244,7 +1244,7 @@ test "HashMap repeat putAssumeCapacity/remove" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); const limit = cap; @@ -1280,7 +1280,7 @@ test "HashMap getOrPut" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); var i: u32 = 0; while (i < 10) : (i += 1) { @@ -1309,7 +1309,7 @@ test "HashMap basic hash map usage" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); try testing.expect((try map.fetchPut(1, 11)) == null); try testing.expect((try map.fetchPut(2, 22)) == null); @@ -1360,7 +1360,7 @@ test "HashMap ensureUnusedCapacity" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); try map.ensureUnusedCapacity(32); try testing.expectError(error.OutOfMemory, map.ensureUnusedCapacity(cap + 1)); @@ -1374,7 +1374,7 @@ test "HashMap removeByPtr" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); var i: i32 = undefined; i = 0; @@ -1405,7 +1405,7 @@ test "HashMap removeByPtr 0 sized key" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); try map.put(0, 0); @@ -1429,7 +1429,7 @@ test "HashMap repeat fetchRemove" { const layout = Map.layoutForCapacity(cap); const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size); defer alloc.free(buf); - var map = Map.init(OffsetBuf.init(buf), layout); + var map = Map.init(.init(buf), layout); map.putAssumeCapacity(0, {}); map.putAssumeCapacity(1, {}); @@ -1457,7 +1457,7 @@ test "OffsetHashMap basic usage" { const layout = OffsetMap.layout(cap); const buf = try alloc.alignedAlloc(u8, OffsetMap.base_align, layout.total_size); defer alloc.free(buf); - var offset_map = OffsetMap.init(OffsetBuf.init(buf), layout); + var offset_map = OffsetMap.init(.init(buf), layout); var map = offset_map.map(buf.ptr); const count = 5; @@ -1492,7 +1492,7 @@ test "OffsetHashMap remake map" { const layout = OffsetMap.layout(cap); const buf = try alloc.alignedAlloc(u8, OffsetMap.base_align, layout.total_size); defer alloc.free(buf); - var offset_map = OffsetMap.init(OffsetBuf.init(buf), layout); + var offset_map = OffsetMap.init(.init(buf), layout); { var map = offset_map.map(buf.ptr); diff --git a/src/terminal/kitty/graphics_command.zig b/src/terminal/kitty/graphics_command.zig index 61ba33a4d..adc6edafe 100644 --- a/src/terminal/kitty/graphics_command.zig +++ b/src/terminal/kitty/graphics_command.zig @@ -155,17 +155,17 @@ pub const Parser = struct { break :action c; }; const control: Command.Control = switch (action) { - 'q' => .{ .query = try Transmission.parse(self.kv) }, - 't' => .{ .transmit = try Transmission.parse(self.kv) }, + 'q' => .{ .query = try .parse(self.kv) }, + 't' => .{ .transmit = try .parse(self.kv) }, 'T' => .{ .transmit_and_display = .{ - .transmission = try Transmission.parse(self.kv), - .display = try Display.parse(self.kv), + .transmission = try .parse(self.kv), + .display = try .parse(self.kv), } }, - 'p' => .{ .display = try Display.parse(self.kv) }, - 'd' => .{ .delete = try Delete.parse(self.kv) }, - 'f' => .{ .transmit_animation_frame = try AnimationFrameLoading.parse(self.kv) }, - 'a' => .{ .control_animation = try AnimationControl.parse(self.kv) }, - 'c' => .{ .compose_animation = try AnimationFrameComposition.parse(self.kv) }, + 'p' => .{ .display = try .parse(self.kv) }, + 'd' => .{ .delete = try .parse(self.kv) }, + 'f' => .{ .transmit_animation_frame = try .parse(self.kv) }, + 'a' => .{ .control_animation = try .parse(self.kv) }, + 'c' => .{ .compose_animation = try .parse(self.kv) }, else => return error.InvalidFormat, }; diff --git a/src/terminal/kitty/graphics_exec.zig b/src/terminal/kitty/graphics_exec.zig index 25c819b10..f917c104a 100644 --- a/src/terminal/kitty/graphics_exec.zig +++ b/src/terminal/kitty/graphics_exec.zig @@ -324,7 +324,7 @@ fn loadAndAddImage( } break :loading loading.*; - } else try LoadingImage.init(alloc, cmd); + } else try .init(alloc, cmd); // We only want to deinit on error. If we're chunking, then we don't // want to deinit at all. If we're not chunking, then we'll deinit diff --git a/src/terminal/osc.zig b/src/terminal/osc.zig index ce7afdf64..932964137 100644 --- a/src/terminal/osc.zig +++ b/src/terminal/osc.zig @@ -1354,8 +1354,8 @@ pub const Parser = struct { } switch (self.command) { - .report_color => |*c| c.terminator = Terminator.init(terminator_ch), - .kitty_color_protocol => |*c| c.terminator = Terminator.init(terminator_ch), + .report_color => |*c| c.terminator = .init(terminator_ch), + .kitty_color_protocol => |*c| c.terminator = .init(terminator_ch), else => {}, } diff --git a/src/terminal/page.zig b/src/terminal/page.zig index acb757592..d7f252af1 100644 --- a/src/terminal/page.zig +++ b/src/terminal/page.zig @@ -241,23 +241,23 @@ pub const Page = struct { l.styles_layout, .{}, ), - .string_alloc = StringAlloc.init( + .string_alloc = .init( buf.add(l.string_alloc_start), l.string_alloc_layout, ), - .grapheme_alloc = GraphemeAlloc.init( + .grapheme_alloc = .init( buf.add(l.grapheme_alloc_start), l.grapheme_alloc_layout, ), - .grapheme_map = GraphemeMap.init( + .grapheme_map = .init( buf.add(l.grapheme_map_start), l.grapheme_map_layout, ), - .hyperlink_map = hyperlink.Map.init( + .hyperlink_map = .init( buf.add(l.hyperlink_map_start), l.hyperlink_map_layout, ), - .hyperlink_set = hyperlink.Set.init( + .hyperlink_set = .init( buf.add(l.hyperlink_set_start), l.hyperlink_set_layout, .{}, @@ -280,7 +280,7 @@ pub const Page = struct { // We zero the page memory as u64 instead of u8 because // we can and it's empirically quite a bit faster. @memset(@as([*]u64, @ptrCast(self.memory))[0 .. self.memory.len / 8], 0); - self.* = initBuf(OffsetBuf.init(self.memory), layout(self.capacity)); + self.* = initBuf(.init(self.memory), layout(self.capacity)); } pub const IntegrityError = error{ @@ -2260,7 +2260,7 @@ test "Page appendGrapheme small" { defer page.deinit(); const rac = page.getRowAndCell(0, 0); - rac.cell.* = Cell.init(0x09); + rac.cell.* = .init(0x09); // One try page.appendGrapheme(rac.row, rac.cell, 0x0A); @@ -2289,7 +2289,7 @@ test "Page appendGrapheme larger than chunk" { defer page.deinit(); const rac = page.getRowAndCell(0, 0); - rac.cell.* = Cell.init(0x09); + rac.cell.* = .init(0x09); const count = grapheme_chunk_len * 10; for (0..count) |i| { @@ -2312,11 +2312,11 @@ test "Page clearGrapheme not all cells" { defer page.deinit(); const rac = page.getRowAndCell(0, 0); - rac.cell.* = Cell.init(0x09); + rac.cell.* = .init(0x09); try page.appendGrapheme(rac.row, rac.cell, 0x0A); const rac2 = page.getRowAndCell(1, 0); - rac2.cell.* = Cell.init(0x09); + rac2.cell.* = .init(0x09); try page.appendGrapheme(rac2.row, rac2.cell, 0x0A); // Clear it diff --git a/src/terminal/search.zig b/src/terminal/search.zig index 56b181c48..2f87f894b 100644 --- a/src/terminal/search.zig +++ b/src/terminal/search.zig @@ -365,7 +365,7 @@ const SlidingWindow = struct { } self.assertIntegrity(); - return Selection.init(tl, br, false); + return .init(tl, br, false); } /// Convert a data index into a pin. @@ -417,7 +417,7 @@ const SlidingWindow = struct { // Initialize our metadata for the node. var meta: Meta = .{ .node = node, - .cell_map = Page.CellMap.init(alloc), + .cell_map = .init(alloc), }; errdefer meta.deinit(); diff --git a/src/terminal/sgr.zig b/src/terminal/sgr.zig index 2bc32c5f9..e4b85fbdd 100644 --- a/src/terminal/sgr.zig +++ b/src/terminal/sgr.zig @@ -98,7 +98,7 @@ pub const Attribute = union(enum) { /// Parser parses the attributes from a list of SGR parameters. pub const Parser = struct { params: []const u16, - params_sep: SepList = SepList.initEmpty(), + params_sep: SepList = .initEmpty(), idx: usize = 0, /// Next returns the next attribute or null if there are no more attributes. @@ -376,7 +376,7 @@ fn testParse(params: []const u16) Attribute { } fn testParseColon(params: []const u16) Attribute { - var p: Parser = .{ .params = params, .params_sep = SepList.initFull() }; + var p: Parser = .{ .params = params, .params_sep = .initFull() }; return p.next().?; } diff --git a/src/terminal/style.zig b/src/terminal/style.zig index 34b07772a..f35a4e1f7 100644 --- a/src/terminal/style.zig +++ b/src/terminal/style.zig @@ -302,9 +302,9 @@ pub const Style = struct { .underline = std.meta.activeTag(style.underline_color), }, .data = .{ - .fg = Data.fromColor(style.fg_color), - .bg = Data.fromColor(style.bg_color), - .underline = Data.fromColor(style.underline_color), + .fg = .fromColor(style.fg_color), + .bg = .fromColor(style.bg_color), + .underline = .fromColor(style.underline_color), }, .flags = style.flags, }; @@ -349,7 +349,7 @@ test "Set basic usage" { const style: Style = .{ .flags = .{ .bold = true } }; const style2: Style = .{ .flags = .{ .italic = true } }; - var set = Set.init(OffsetBuf.init(buf), layout, .{}); + var set = Set.init(.init(buf), layout, .{}); // Add style const id = try set.add(buf, style); diff --git a/src/terminal/x11_color.zig b/src/terminal/x11_color.zig index 88bc30f09..977cd4538 100644 --- a/src/terminal/x11_color.zig +++ b/src/terminal/x11_color.zig @@ -33,7 +33,7 @@ fn colorMap() !ColorMap { } assert(i == len); - return ColorMap.initComptime(kvs); + return .initComptime(kvs); } /// This is the rgb.txt file from the X11 project. This was last sourced diff --git a/src/unicode/props.zig b/src/unicode/props.zig index 8c7621b79..99c57aa0a 100644 --- a/src/unicode/props.zig +++ b/src/unicode/props.zig @@ -125,7 +125,7 @@ pub fn get(cp: u21) Properties { return .{ .width = @intCast(@min(2, @max(0, zg_width))), - .grapheme_boundary_class = GraphemeBoundaryClass.init(cp), + .grapheme_boundary_class = .init(cp), }; }