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)
This commit is contained in:
Qwerasd
2025-05-26 21:39:15 -06:00
parent 2fe2ccdbde
commit 2384bd69cc
57 changed files with 177 additions and 177 deletions

View File

@@ -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),
};
}
};

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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.

View File

@@ -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 },

View File

@@ -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;

View File

@@ -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,
};

View File

@@ -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,
};

View File

@@ -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

View File

@@ -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

View File

@@ -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(

View File

@@ -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();

View File

@@ -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"));

View File

@@ -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),
};
}

View File

@@ -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")},

View File

@@ -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, ",");

View File

@@ -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;

View File

@@ -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();

View File

@@ -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,
) },

View File

@@ -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 } },

View File

@@ -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 } },

View File

@@ -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

View File

@@ -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 } },

View File

@@ -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.?;
}

View File

@@ -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();

View File

@@ -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

View File

@@ -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, .{});

View File

@@ -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

View File

@@ -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, .{});

View File

@@ -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

View File

@@ -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| {

View File

@@ -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.

View File

@@ -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,

View File

@@ -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);

View File

@@ -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

View File

@@ -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,

View File

@@ -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" {

View File

@@ -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,

View File

@@ -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;

View File

@@ -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,

View File

@@ -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| {

View File

@@ -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;
}

View File

@@ -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 {

View File

@@ -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),
};
}

View File

@@ -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);
}
};

View File

@@ -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.

View File

@@ -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);

View File

@@ -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);

View File

@@ -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,
};

View File

@@ -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

View File

@@ -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 => {},
}

View File

@@ -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

View File

@@ -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();

View File

@@ -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().?;
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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),
};
}