mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-01 23:48:35 +00:00
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:
@@ -44,7 +44,7 @@ pub const Pattern = opaque {
|
|||||||
&val,
|
&val,
|
||||||
))).toError();
|
))).toError();
|
||||||
|
|
||||||
return Value.init(&val);
|
return .init(&val);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete(self: *Pattern, prop: Property) bool {
|
pub fn delete(self: *Pattern, prop: Property) bool {
|
||||||
@@ -138,7 +138,7 @@ pub const Pattern = opaque {
|
|||||||
return Entry{
|
return Entry{
|
||||||
.result = @enumFromInt(result),
|
.result = @enumFromInt(result),
|
||||||
.binding = @enumFromInt(binding),
|
.binding = @enumFromInt(binding),
|
||||||
.value = Value.init(&value),
|
.value = .init(&value),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -281,7 +281,7 @@ pub inline fn setGamma(self: Monitor, gamma: f32) void {
|
|||||||
/// see also: monitor_gamma
|
/// see also: monitor_gamma
|
||||||
pub inline fn getGammaRamp(self: Monitor) ?GammaRamp {
|
pub inline fn getGammaRamp(self: Monitor) ?GammaRamp {
|
||||||
internal_debug.assertInitialized();
|
internal_debug.assertInitialized();
|
||||||
if (c.glfwGetGammaRamp(self.handle)) |ramp| return GammaRamp.fromC(ramp.*);
|
if (c.glfwGetGammaRamp(self.handle)) |ramp| return .fromC(ramp.*);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ pub inline fn makeContextCurrent(window: ?Window) void {
|
|||||||
/// see also: context_current, glfwMakeContextCurrent
|
/// see also: context_current, glfwMakeContextCurrent
|
||||||
pub inline fn getCurrentContext() ?Window {
|
pub inline fn getCurrentContext() ?Window {
|
||||||
internal_debug.assertInitialized();
|
internal_debug.assertInitialized();
|
||||||
if (c.glfwGetCurrentContext()) |handle| return Window.from(handle);
|
if (c.glfwGetCurrentContext()) |handle| return .from(handle);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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.
|
/// Sets command->data to data.
|
||||||
|
@@ -463,7 +463,7 @@ pub fn init(
|
|||||||
// Create our terminal grid with the initial size
|
// Create our terminal grid with the initial size
|
||||||
const app_mailbox: App.Mailbox = .{ .rt_app = rt_app, .mailbox = &app.mailbox };
|
const app_mailbox: App.Mailbox = .{ .rt_app = rt_app, .mailbox = &app.mailbox };
|
||||||
var renderer_impl = try Renderer.init(alloc, .{
|
var renderer_impl = try Renderer.init(alloc, .{
|
||||||
.config = try Renderer.DerivedConfig.init(alloc, config),
|
.config = try .init(alloc, config),
|
||||||
.font_grid = font_grid,
|
.font_grid = font_grid,
|
||||||
.size = size,
|
.size = size,
|
||||||
.surface_mailbox = .{ .surface = self, .app = app_mailbox },
|
.surface_mailbox = .{ .surface = self, .app = app_mailbox },
|
||||||
|
@@ -423,7 +423,7 @@ pub const Surface = struct {
|
|||||||
pub fn init(self: *Surface, app: *App, opts: Options) !void {
|
pub fn init(self: *Surface, app: *App, opts: Options) !void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.app = app,
|
.app = app,
|
||||||
.platform = try Platform.init(opts.platform_tag, opts.platform),
|
.platform = try .init(opts.platform_tag, opts.platform),
|
||||||
.userdata = opts.userdata,
|
.userdata = opts.userdata,
|
||||||
.core_surface = undefined,
|
.core_surface = undefined,
|
||||||
.content_scale = .{
|
.content_scale = .{
|
||||||
@@ -522,7 +522,7 @@ pub const Surface = struct {
|
|||||||
const alloc = self.app.core_app.alloc;
|
const alloc = self.app.core_app.alloc;
|
||||||
const inspector = try alloc.create(Inspector);
|
const inspector = try alloc.create(Inspector);
|
||||||
errdefer alloc.destroy(inspector);
|
errdefer alloc.destroy(inspector);
|
||||||
inspector.* = try Inspector.init(self);
|
inspector.* = try .init(self);
|
||||||
self.inspector = inspector;
|
self.inspector = inspector;
|
||||||
return inspector;
|
return inspector;
|
||||||
}
|
}
|
||||||
@@ -1180,7 +1180,7 @@ pub const CAPI = struct {
|
|||||||
// Create our runtime app
|
// Create our runtime app
|
||||||
var app = try global.alloc.create(App);
|
var app = try global.alloc.create(App);
|
||||||
errdefer global.alloc.destroy(app);
|
errdefer global.alloc.destroy(app);
|
||||||
app.* = try App.init(core_app, config, opts.*);
|
app.* = try .init(core_app, config, opts.*);
|
||||||
errdefer app.terminate();
|
errdefer app.terminate();
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
@@ -1949,7 +1949,7 @@ pub const CAPI = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export fn ghostty_inspector_metal_init(ptr: *Inspector, device: objc.c.id) bool {
|
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(
|
export fn ghostty_inspector_metal_render(
|
||||||
@@ -1958,8 +1958,8 @@ pub const CAPI = struct {
|
|||||||
descriptor: objc.c.id,
|
descriptor: objc.c.id,
|
||||||
) void {
|
) void {
|
||||||
return ptr.renderMetal(
|
return ptr.renderMetal(
|
||||||
objc.Object.fromId(command_buffer),
|
.fromId(command_buffer),
|
||||||
objc.Object.fromId(descriptor),
|
.fromId(descriptor),
|
||||||
) catch |err| {
|
) catch |err| {
|
||||||
log.err("error rendering inspector err={}", .{err});
|
log.err("error rendering inspector err={}", .{err});
|
||||||
return;
|
return;
|
||||||
|
@@ -69,16 +69,16 @@ fn init(
|
|||||||
request: apprt.ClipboardRequest,
|
request: apprt.ClipboardRequest,
|
||||||
is_secure_input: bool,
|
is_secure_input: bool,
|
||||||
) !void {
|
) !void {
|
||||||
var builder = switch (DialogType) {
|
var builder: Builder = switch (DialogType) {
|
||||||
adw.AlertDialog => switch (request) {
|
adw.AlertDialog => switch (request) {
|
||||||
.osc_52_read => Builder.init("ccw-osc-52-read", 1, 5),
|
.osc_52_read => .init("ccw-osc-52-read", 1, 5),
|
||||||
.osc_52_write => Builder.init("ccw-osc-52-write", 1, 5),
|
.osc_52_write => .init("ccw-osc-52-write", 1, 5),
|
||||||
.paste => Builder.init("ccw-paste", 1, 5),
|
.paste => .init("ccw-paste", 1, 5),
|
||||||
},
|
},
|
||||||
adw.MessageDialog => switch (request) {
|
adw.MessageDialog => switch (request) {
|
||||||
.osc_52_read => Builder.init("ccw-osc-52-read", 1, 2),
|
.osc_52_read => .init("ccw-osc-52-read", 1, 2),
|
||||||
.osc_52_write => Builder.init("ccw-osc-52-write", 1, 2),
|
.osc_52_write => .init("ccw-osc-52-write", 1, 2),
|
||||||
.paste => Builder.init("ccw-paste", 1, 2),
|
.paste => .init("ccw-paste", 1, 2),
|
||||||
},
|
},
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
|
@@ -32,9 +32,9 @@ pub fn maybePresent(app: *App, window: ?*Window) void {
|
|||||||
const config_errors_dialog = config_errors_dialog: {
|
const config_errors_dialog = config_errors_dialog: {
|
||||||
if (app.config_errors_dialog) |config_errors_dialog| break :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) {
|
var builder: Builder = switch (DialogType) {
|
||||||
adw.AlertDialog => Builder.init("config-errors-dialog", 1, 5),
|
adw.AlertDialog => .init("config-errors-dialog", 1, 5),
|
||||||
adw.MessageDialog => Builder.init("config-errors-dialog", 1, 2),
|
adw.MessageDialog => .init("config-errors-dialog", 1, 2),
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -50,12 +50,12 @@ first: bool = true,
|
|||||||
pub fn init(self: *ResizeOverlay, surface: *Surface, config: *const configpkg.Config) void {
|
pub fn init(self: *ResizeOverlay, surface: *Surface, config: *const configpkg.Config) void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.surface = surface,
|
.surface = surface,
|
||||||
.config = DerivedConfig.init(config),
|
.config = .init(config),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn updateConfig(self: *ResizeOverlay, config: *const configpkg.Config) void {
|
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
|
/// De-initialize the ResizeOverlay. This removes any pending idlers/timers that
|
||||||
|
@@ -138,7 +138,7 @@ pub fn init(
|
|||||||
.container = container,
|
.container = container,
|
||||||
.top_left = .{ .surface = tl },
|
.top_left = .{ .surface = tl },
|
||||||
.bottom_right = .{ .surface = br },
|
.bottom_right = .{ .surface = br },
|
||||||
.orientation = Orientation.fromDirection(direction),
|
.orientation = .fromDirection(direction),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Replace the previous containers element with our split. This allows a
|
// Replace the previous containers element with our split. This allows a
|
||||||
|
@@ -1191,7 +1191,7 @@ pub fn mouseOverLink(self: *Surface, uri_: ?[]const u8) void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.url_widget = URLWidget.init(self.overlay, uriZ);
|
self.url_widget = .init(self.overlay, uriZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn supportsClipboard(
|
pub fn supportsClipboard(
|
||||||
|
@@ -136,7 +136,7 @@ pub fn init(self: *Window, app: *App) !void {
|
|||||||
self.* = .{
|
self.* = .{
|
||||||
.app = app,
|
.app = app,
|
||||||
.last_config = @intFromPtr(&app.config),
|
.last_config = @intFromPtr(&app.config),
|
||||||
.config = DerivedConfig.init(&app.config),
|
.config = .init(&app.config),
|
||||||
.window = undefined,
|
.window = undefined,
|
||||||
.headerbar = undefined,
|
.headerbar = undefined,
|
||||||
.tab_overview = null,
|
.tab_overview = null,
|
||||||
@@ -148,7 +148,7 @@ pub fn init(self: *Window, app: *App) !void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create the window
|
// 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_window = self.window.as(gtk.Window);
|
||||||
const gtk_widget = self.window.as(gtk.Widget);
|
const gtk_widget = self.window.as(gtk.Widget);
|
||||||
errdefer gtk_window.destroy();
|
errdefer gtk_window.destroy();
|
||||||
@@ -333,7 +333,7 @@ pub fn init(self: *Window, app: *App) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup our toast overlay if we have one
|
// 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());
|
self.toast_overlay.setChild(self.notebook.asWidget());
|
||||||
box.append(self.toast_overlay.as(gtk.Widget));
|
box.append(self.toast_overlay.as(gtk.Widget));
|
||||||
|
|
||||||
@@ -463,7 +463,7 @@ pub fn updateConfig(
|
|||||||
if (self.last_config == this_config) return;
|
if (self.last_config == this_config) return;
|
||||||
self.last_config = this_config;
|
self.last_config = this_config;
|
||||||
|
|
||||||
self.config = DerivedConfig.init(config);
|
self.config = .init(config);
|
||||||
|
|
||||||
// We always resync our appearance whenever the config changes.
|
// We always resync our appearance whenever the config changes.
|
||||||
try self.syncAppearance();
|
try self.syncAppearance();
|
||||||
|
@@ -138,7 +138,7 @@ const Window = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create the window
|
// 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();
|
errdefer self.window.as(gtk.Window).destroy();
|
||||||
|
|
||||||
self.window.as(gtk.Window).setTitle(i18n._("Ghostty: Terminal Inspector"));
|
self.window.as(gtk.Window).setTitle(i18n._("Ghostty: Terminal Inspector"));
|
||||||
|
@@ -109,7 +109,7 @@ pub const App = struct {
|
|||||||
return .{
|
return .{
|
||||||
.display = xlib_display,
|
.display = xlib_display,
|
||||||
.base_event_code = base_event_code,
|
.base_event_code = base_event_code,
|
||||||
.atoms = Atoms.init(gdk_x11_display),
|
.atoms = .init(gdk_x11_display),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,9 +24,9 @@ pub const LazyPathList = std.ArrayList(std.Build.LazyPath);
|
|||||||
pub fn init(b: *std.Build, cfg: *const Config) !SharedDeps {
|
pub fn init(b: *std.Build, cfg: *const Config) !SharedDeps {
|
||||||
var result: SharedDeps = .{
|
var result: SharedDeps = .{
|
||||||
.config = cfg,
|
.config = cfg,
|
||||||
.help_strings = try HelpStrings.init(b, cfg),
|
.help_strings = try .init(b, cfg),
|
||||||
.unicode_tables = try UnicodeTables.init(b),
|
.unicode_tables = try .init(b),
|
||||||
.framedata = try GhosttyFrameData.init(b),
|
.framedata = try .init(b),
|
||||||
|
|
||||||
// Setup by retarget
|
// Setup by retarget
|
||||||
.options = undefined,
|
.options = undefined,
|
||||||
@@ -72,7 +72,7 @@ fn initTarget(
|
|||||||
target: std.Build.ResolvedTarget,
|
target: std.Build.ResolvedTarget,
|
||||||
) !void {
|
) !void {
|
||||||
// Update our metallib
|
// Update our metallib
|
||||||
self.metallib = MetallibStep.create(b, .{
|
self.metallib = .create(b, .{
|
||||||
.name = "Ghostty",
|
.name = "Ghostty",
|
||||||
.target = target,
|
.target = target,
|
||||||
.sources = &.{b.path("src/renderer/shaders/cell.metal")},
|
.sources = &.{b.path("src/renderer/shaders/cell.metal")},
|
||||||
|
@@ -84,7 +84,7 @@ pub fn parse(
|
|||||||
// If the arena is unset, we create it. We mark that we own it
|
// If the arena is unset, we create it. We mark that we own it
|
||||||
// only so that we can clean it up on error.
|
// only so that we can clean it up on error.
|
||||||
if (dst._arena == null) {
|
if (dst._arena == null) {
|
||||||
dst._arena = ArenaAllocator.init(alloc);
|
dst._arena = .init(alloc);
|
||||||
arena_owned = true;
|
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
|
// Keep track of which fields were set so we can error if a required
|
||||||
// field was not set.
|
// field was not set.
|
||||||
const FieldSet = std.StaticBitSet(info.fields.len);
|
const FieldSet = std.StaticBitSet(info.fields.len);
|
||||||
var fields_set: FieldSet = FieldSet.initEmpty();
|
var fields_set: FieldSet = .initEmpty();
|
||||||
|
|
||||||
// We split each value by ","
|
// We split each value by ","
|
||||||
var iter = std.mem.splitSequence(u8, v, ",");
|
var iter = std.mem.splitSequence(u8, v, ",");
|
||||||
|
@@ -2531,7 +2531,7 @@ pub fn load(alloc_gpa: Allocator) !Config {
|
|||||||
pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
|
pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
|
||||||
// Build up our basic config
|
// Build up our basic config
|
||||||
var result: Config = .{
|
var result: Config = .{
|
||||||
._arena = ArenaAllocator.init(alloc_gpa),
|
._arena = .init(alloc_gpa),
|
||||||
};
|
};
|
||||||
errdefer result.deinit();
|
errdefer result.deinit();
|
||||||
const alloc = result._arena.?.allocator();
|
const alloc = result._arena.?.allocator();
|
||||||
@@ -3332,7 +3332,7 @@ pub fn parseManuallyHook(
|
|||||||
/// be deallocated while shallow clones exist.
|
/// be deallocated while shallow clones exist.
|
||||||
pub fn shallowClone(self: *const Config, alloc_gpa: Allocator) Config {
|
pub fn shallowClone(self: *const Config, alloc_gpa: Allocator) Config {
|
||||||
var result = self.*;
|
var result = self.*;
|
||||||
result._arena = ArenaAllocator.init(alloc_gpa);
|
result._arena = .init(alloc_gpa);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5975,7 +5975,7 @@ pub const QuickTerminalSize = struct {
|
|||||||
it.next() orelse return error.ValueRequired,
|
it.next() orelse return error.ValueRequired,
|
||||||
cli.args.whitespace,
|
cli.args.whitespace,
|
||||||
);
|
);
|
||||||
self.primary = try Size.parse(primary);
|
self.primary = try .parse(primary);
|
||||||
|
|
||||||
self.secondary = secondary: {
|
self.secondary = secondary: {
|
||||||
const secondary = std.mem.trim(
|
const secondary = std.mem.trim(
|
||||||
@@ -5983,7 +5983,7 @@ pub const QuickTerminalSize = struct {
|
|||||||
it.next() orelse break :secondary null,
|
it.next() orelse break :secondary null,
|
||||||
cli.args.whitespace,
|
cli.args.whitespace,
|
||||||
);
|
);
|
||||||
break :secondary try Size.parse(secondary);
|
break :secondary try .parse(secondary);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (it.next()) |_| return error.TooManyArguments;
|
if (it.next()) |_| return error.TooManyArguments;
|
||||||
|
@@ -153,7 +153,7 @@ pub const FileFormatter = struct {
|
|||||||
// If we're change-tracking then we need the default config to
|
// If we're change-tracking then we need the default config to
|
||||||
// compare against.
|
// compare against.
|
||||||
var default: ?Config = if (self.changed)
|
var default: ?Config = if (self.changed)
|
||||||
try Config.default(self.alloc)
|
try .default(self.alloc)
|
||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
defer if (default) |*v| v.deinit();
|
defer if (default) |*v| v.deinit();
|
||||||
|
@@ -331,7 +331,7 @@ pub const Item = union(enum) {
|
|||||||
|
|
||||||
// Decode the item.
|
// Decode the item.
|
||||||
self.* = switch (encoded.type) {
|
self.* = switch (encoded.type) {
|
||||||
.attachment => .{ .attachment = try Attachment.decode(
|
.attachment => .{ .attachment = try .decode(
|
||||||
alloc,
|
alloc,
|
||||||
encoded,
|
encoded,
|
||||||
) },
|
) },
|
||||||
|
@@ -37,7 +37,7 @@ collection: Collection,
|
|||||||
|
|
||||||
/// The set of statuses and whether they're enabled or not. This defaults
|
/// 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.
|
/// 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
|
/// If discovery is available, we'll look up fonts where we can't find
|
||||||
/// the codepoint. This can be set after initialization.
|
/// the codepoint. This can be set after initialization.
|
||||||
@@ -140,7 +140,7 @@ pub fn getIndex(
|
|||||||
// handle this.
|
// handle this.
|
||||||
if (self.sprite) |sprite| {
|
if (self.sprite) |sprite| {
|
||||||
if (sprite.hasCodepoint(cp, p)) {
|
if (sprite.hasCodepoint(cp, p)) {
|
||||||
return Collection.Index.initSpecial(.sprite);
|
return .initSpecial(.sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,7 +388,7 @@ test getIndex {
|
|||||||
|
|
||||||
{
|
{
|
||||||
errdefer c.deinit(alloc);
|
errdefer c.deinit(alloc);
|
||||||
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
|
_ = try c.add(alloc, .regular, .{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
||||||
@@ -398,7 +398,7 @@ test getIndex {
|
|||||||
_ = try c.add(
|
_ = try c.add(
|
||||||
alloc,
|
alloc,
|
||||||
.regular,
|
.regular,
|
||||||
.{ .loaded = try Face.init(
|
.{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testEmoji,
|
testEmoji,
|
||||||
.{ .size = .{ .points = 12 } },
|
.{ .size = .{ .points = 12 } },
|
||||||
@@ -408,7 +408,7 @@ test getIndex {
|
|||||||
_ = try c.add(
|
_ = try c.add(
|
||||||
alloc,
|
alloc,
|
||||||
.regular,
|
.regular,
|
||||||
.{ .loaded = try Face.init(
|
.{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testEmojiText,
|
testEmojiText,
|
||||||
.{ .size = .{ .points = 12 } },
|
.{ .size = .{ .points = 12 } },
|
||||||
@@ -467,17 +467,17 @@ test "getIndex disabled font style" {
|
|||||||
var c = Collection.init();
|
var c = Collection.init();
|
||||||
c.load_options = .{ .library = lib };
|
c.load_options = .{ .library = lib };
|
||||||
|
|
||||||
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
|
_ = try c.add(alloc, .regular, .{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .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,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .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,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
||||||
|
@@ -55,7 +55,7 @@ load_options: ?LoadOptions = null,
|
|||||||
pub fn init() Collection {
|
pub fn init() Collection {
|
||||||
// Initialize our styles array, preallocating some space that is
|
// Initialize our styles array, preallocating some space that is
|
||||||
// likely to be used.
|
// likely to be used.
|
||||||
return .{ .faces = StyleArray.initFill(.{}) };
|
return .{ .faces = .initFill(.{}) };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Collection, alloc: Allocator) void {
|
pub fn deinit(self: *Collection, alloc: Allocator) void {
|
||||||
@@ -707,7 +707,7 @@ test "add full" {
|
|||||||
defer c.deinit(alloc);
|
defer c.deinit(alloc);
|
||||||
|
|
||||||
for (0..Index.Special.start - 1) |_| {
|
for (0..Index.Special.start - 1) |_| {
|
||||||
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
|
_ = try c.add(alloc, .regular, .{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12 } },
|
.{ .size = .{ .points = 12 } },
|
||||||
@@ -755,7 +755,7 @@ test getFace {
|
|||||||
var c = init();
|
var c = init();
|
||||||
defer c.deinit(alloc);
|
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,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
||||||
@@ -779,7 +779,7 @@ test getIndex {
|
|||||||
var c = init();
|
var c = init();
|
||||||
defer c.deinit(alloc);
|
defer c.deinit(alloc);
|
||||||
|
|
||||||
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
|
_ = try c.add(alloc, .regular, .{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
||||||
@@ -811,7 +811,7 @@ test completeStyles {
|
|||||||
defer c.deinit(alloc);
|
defer c.deinit(alloc);
|
||||||
c.load_options = .{ .library = lib };
|
c.load_options = .{ .library = lib };
|
||||||
|
|
||||||
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
|
_ = try c.add(alloc, .regular, .{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
||||||
@@ -838,7 +838,7 @@ test setSize {
|
|||||||
defer c.deinit(alloc);
|
defer c.deinit(alloc);
|
||||||
c.load_options = .{ .library = lib };
|
c.load_options = .{ .library = lib };
|
||||||
|
|
||||||
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
|
_ = try c.add(alloc, .regular, .{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
||||||
@@ -861,7 +861,7 @@ test hasCodepoint {
|
|||||||
defer c.deinit(alloc);
|
defer c.deinit(alloc);
|
||||||
c.load_options = .{ .library = lib };
|
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,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
||||||
@@ -885,7 +885,7 @@ test "hasCodepoint emoji default graphical" {
|
|||||||
defer c.deinit(alloc);
|
defer c.deinit(alloc);
|
||||||
c.load_options = .{ .library = lib };
|
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,
|
lib,
|
||||||
testEmoji,
|
testEmoji,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
||||||
@@ -908,7 +908,7 @@ test "metrics" {
|
|||||||
defer c.deinit(alloc);
|
defer c.deinit(alloc);
|
||||||
c.load_options = .{ .library = lib };
|
c.load_options = .{ .library = lib };
|
||||||
|
|
||||||
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
|
_ = try c.add(alloc, .regular, .{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
||||||
|
@@ -254,7 +254,7 @@ fn loadWebCanvas(
|
|||||||
opts: font.face.Options,
|
opts: font.face.Options,
|
||||||
) !Face {
|
) !Face {
|
||||||
const wc = self.wc.?;
|
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
|
/// Returns true if this face can satisfy the given codepoint and
|
||||||
|
@@ -319,7 +319,7 @@ fn testGrid(mode: TestMode, alloc: Allocator, lib: Library) !SharedGrid {
|
|||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
.normal => {
|
.normal => {
|
||||||
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
|
_ = try c.add(alloc, .regular, .{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
|
||||||
|
@@ -126,7 +126,7 @@ pub fn ref(
|
|||||||
.ref = 1,
|
.ref = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
grid.* = try SharedGrid.init(self.alloc, resolver: {
|
grid.* = try .init(self.alloc, resolver: {
|
||||||
// Build our collection. This is the expensive operation that
|
// Build our collection. This is the expensive operation that
|
||||||
// involves finding fonts, loading them (maybe, some are deferred),
|
// involves finding fonts, loading them (maybe, some are deferred),
|
||||||
// etc.
|
// etc.
|
||||||
@@ -258,7 +258,7 @@ fn collection(
|
|||||||
_ = try c.add(
|
_ = try c.add(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
.regular,
|
.regular,
|
||||||
.{ .fallback_loaded = try Face.init(
|
.{ .fallback_loaded = try .init(
|
||||||
self.font_lib,
|
self.font_lib,
|
||||||
font.embedded.regular,
|
font.embedded.regular,
|
||||||
load_options.faceOptions(),
|
load_options.faceOptions(),
|
||||||
@@ -267,7 +267,7 @@ fn collection(
|
|||||||
_ = try c.add(
|
_ = try c.add(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
.bold,
|
.bold,
|
||||||
.{ .fallback_loaded = try Face.init(
|
.{ .fallback_loaded = try .init(
|
||||||
self.font_lib,
|
self.font_lib,
|
||||||
font.embedded.bold,
|
font.embedded.bold,
|
||||||
load_options.faceOptions(),
|
load_options.faceOptions(),
|
||||||
@@ -276,7 +276,7 @@ fn collection(
|
|||||||
_ = try c.add(
|
_ = try c.add(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
.italic,
|
.italic,
|
||||||
.{ .fallback_loaded = try Face.init(
|
.{ .fallback_loaded = try .init(
|
||||||
self.font_lib,
|
self.font_lib,
|
||||||
font.embedded.italic,
|
font.embedded.italic,
|
||||||
load_options.faceOptions(),
|
load_options.faceOptions(),
|
||||||
@@ -285,7 +285,7 @@ fn collection(
|
|||||||
_ = try c.add(
|
_ = try c.add(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
.bold_italic,
|
.bold_italic,
|
||||||
.{ .fallback_loaded = try Face.init(
|
.{ .fallback_loaded = try .init(
|
||||||
self.font_lib,
|
self.font_lib,
|
||||||
font.embedded.bold_italic,
|
font.embedded.bold_italic,
|
||||||
load_options.faceOptions(),
|
load_options.faceOptions(),
|
||||||
@@ -318,7 +318,7 @@ fn collection(
|
|||||||
_ = try c.add(
|
_ = try c.add(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
.regular,
|
.regular,
|
||||||
.{ .fallback_loaded = try Face.init(
|
.{ .fallback_loaded = try .init(
|
||||||
self.font_lib,
|
self.font_lib,
|
||||||
font.embedded.emoji,
|
font.embedded.emoji,
|
||||||
load_options.faceOptions(),
|
load_options.faceOptions(),
|
||||||
@@ -327,7 +327,7 @@ fn collection(
|
|||||||
_ = try c.add(
|
_ = try c.add(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
.regular,
|
.regular,
|
||||||
.{ .fallback_loaded = try Face.init(
|
.{ .fallback_loaded = try .init(
|
||||||
self.font_lib,
|
self.font_lib,
|
||||||
font.embedded.emoji_text,
|
font.embedded.emoji_text,
|
||||||
load_options.faceOptions(),
|
load_options.faceOptions(),
|
||||||
@@ -391,7 +391,7 @@ fn discover(self: *SharedGridSet) !?*Discover {
|
|||||||
// If we initialized, use it
|
// If we initialized, use it
|
||||||
if (self.font_discover) |*v| return v;
|
if (self.font_discover) |*v| return v;
|
||||||
|
|
||||||
self.font_discover = Discover.init();
|
self.font_discover = .init();
|
||||||
return &self.font_discover.?;
|
return &self.font_discover.?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -97,7 +97,7 @@ pub const Face = struct {
|
|||||||
errdefer if (comptime harfbuzz_shaper) hb_font.destroy();
|
errdefer if (comptime harfbuzz_shaper) hb_font.destroy();
|
||||||
|
|
||||||
const color: ?ColorState = if (traits.color_glyphs)
|
const color: ?ColorState = if (traits.color_glyphs)
|
||||||
try ColorState.init(ct_font)
|
try .init(ct_font)
|
||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
errdefer if (color) |v| v.deinit();
|
errdefer if (color) |v| v.deinit();
|
||||||
|
@@ -30,7 +30,7 @@ fn genMap() Map {
|
|||||||
// Initialize to no converter
|
// Initialize to no converter
|
||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
while (i < freetype.c.FT_PIXEL_MODE_MAX) : (i += 1) {
|
while (i < freetype.c.FT_PIXEL_MODE_MAX) : (i += 1) {
|
||||||
result[i] = AtlasArray.initFill(null);
|
result[i] = .initFill(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map our converters
|
// Map our converters
|
||||||
|
@@ -191,7 +191,7 @@ pub const Shaper = struct {
|
|||||||
// Create the CF release thread.
|
// Create the CF release thread.
|
||||||
var cf_release_thread = try alloc.create(CFReleaseThread);
|
var cf_release_thread = try alloc.create(CFReleaseThread);
|
||||||
errdefer alloc.destroy(cf_release_thread);
|
errdefer alloc.destroy(cf_release_thread);
|
||||||
cf_release_thread.* = try CFReleaseThread.init(alloc);
|
cf_release_thread.* = try .init(alloc);
|
||||||
errdefer cf_release_thread.deinit();
|
errdefer cf_release_thread.deinit();
|
||||||
|
|
||||||
// Start the CF release thread.
|
// Start the CF release thread.
|
||||||
@@ -1768,7 +1768,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper {
|
|||||||
c.load_options = .{ .library = lib };
|
c.load_options = .{ .library = lib };
|
||||||
|
|
||||||
// Setup group
|
// Setup group
|
||||||
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
|
_ = try c.add(alloc, .regular, .{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12 } },
|
.{ .size = .{ .points = 12 } },
|
||||||
@@ -1776,7 +1776,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper {
|
|||||||
|
|
||||||
if (font.options.backend != .coretext) {
|
if (font.options.backend != .coretext) {
|
||||||
// Coretext doesn't support Noto's format
|
// 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,
|
lib,
|
||||||
testEmoji,
|
testEmoji,
|
||||||
.{ .size = .{ .points = 12 } },
|
.{ .size = .{ .points = 12 } },
|
||||||
@@ -1795,7 +1795,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper {
|
|||||||
errdefer face.deinit();
|
errdefer face.deinit();
|
||||||
_ = try c.add(alloc, .regular, .{ .deferred = face });
|
_ = 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,
|
lib,
|
||||||
testEmojiText,
|
testEmojiText,
|
||||||
.{ .size = .{ .points = 12 } },
|
.{ .size = .{ .points = 12 } },
|
||||||
@@ -1803,7 +1803,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper {
|
|||||||
|
|
||||||
const grid_ptr = try alloc.create(SharedGrid);
|
const grid_ptr = try alloc.create(SharedGrid);
|
||||||
errdefer alloc.destroy(grid_ptr);
|
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);
|
errdefer grid_ptr.*.deinit(alloc);
|
||||||
|
|
||||||
var shaper = try Shaper.init(alloc, .{});
|
var shaper = try Shaper.init(alloc, .{});
|
||||||
|
@@ -21,7 +21,7 @@ pub const Feature = struct {
|
|||||||
pub fn fromString(str: []const u8) ?Feature {
|
pub fn fromString(str: []const u8) ?Feature {
|
||||||
var fbs = std.io.fixedBufferStream(str);
|
var fbs = std.io.fixedBufferStream(str);
|
||||||
const reader = fbs.reader();
|
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
|
/// Parse a single font feature setting from a std.io.Reader, with a version
|
||||||
|
@@ -1227,7 +1227,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper {
|
|||||||
c.load_options = .{ .library = lib };
|
c.load_options = .{ .library = lib };
|
||||||
|
|
||||||
// Setup group
|
// Setup group
|
||||||
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
|
_ = try c.add(alloc, .regular, .{ .loaded = try .init(
|
||||||
lib,
|
lib,
|
||||||
testFont,
|
testFont,
|
||||||
.{ .size = .{ .points = 12 } },
|
.{ .size = .{ .points = 12 } },
|
||||||
@@ -1235,7 +1235,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper {
|
|||||||
|
|
||||||
if (comptime !font.options.backend.hasCoretext()) {
|
if (comptime !font.options.backend.hasCoretext()) {
|
||||||
// Coretext doesn't support Noto's format
|
// 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,
|
lib,
|
||||||
testEmoji,
|
testEmoji,
|
||||||
.{ .size = .{ .points = 12 } },
|
.{ .size = .{ .points = 12 } },
|
||||||
@@ -1254,7 +1254,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper {
|
|||||||
errdefer face.deinit();
|
errdefer face.deinit();
|
||||||
_ = try c.add(alloc, .regular, .{ .deferred = face });
|
_ = 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,
|
lib,
|
||||||
testEmojiText,
|
testEmojiText,
|
||||||
.{ .size = .{ .points = 12 } },
|
.{ .size = .{ .points = 12 } },
|
||||||
@@ -1262,7 +1262,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper {
|
|||||||
|
|
||||||
const grid_ptr = try alloc.create(SharedGrid);
|
const grid_ptr = try alloc.create(SharedGrid);
|
||||||
errdefer alloc.destroy(grid_ptr);
|
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);
|
errdefer grid_ptr.*.deinit(alloc);
|
||||||
|
|
||||||
var shaper = try Shaper.init(alloc, .{});
|
var shaper = try Shaper.init(alloc, .{});
|
||||||
|
@@ -150,7 +150,7 @@ pub const Canvas = struct {
|
|||||||
|
|
||||||
/// Acquires a z2d drawing context, caller MUST deinit context.
|
/// Acquires a z2d drawing context, caller MUST deinit context.
|
||||||
pub fn getContext(self: *Canvas) z2d.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
|
/// Draw and fill a single pixel
|
||||||
|
@@ -139,7 +139,7 @@ pub const GlobalState = struct {
|
|||||||
std.log.info("libxev default backend={s}", .{@tagName(xev.backend)});
|
std.log.info("libxev default backend={s}", .{@tagName(xev.backend)});
|
||||||
|
|
||||||
// As early as possible, initialize our resource limits.
|
// As early as possible, initialize our resource limits.
|
||||||
self.rlimits = ResourceLimits.init();
|
self.rlimits = .init();
|
||||||
|
|
||||||
// Initialize our crash reporting.
|
// Initialize our crash reporting.
|
||||||
crash.init(self.alloc) catch |err| {
|
crash.init(self.alloc) catch |err| {
|
||||||
|
@@ -71,7 +71,7 @@ pub const Parser = struct {
|
|||||||
// parse the action now.
|
// parse the action now.
|
||||||
return .{
|
return .{
|
||||||
.trigger_it = .{ .input = input[0..eql_idx] },
|
.trigger_it = .{ .input = input[0..eql_idx] },
|
||||||
.action = try Action.parse(input[eql_idx + 1 ..]),
|
.action = try .parse(input[eql_idx + 1 ..]),
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ const SequenceIterator = struct {
|
|||||||
const rem = self.input[self.i..];
|
const rem = self.input[self.i..];
|
||||||
const idx = std.mem.indexOf(u8, rem, ">") orelse rem.len;
|
const idx = std.mem.indexOf(u8, rem, ">") orelse rem.len;
|
||||||
defer self.i += idx + 1;
|
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.
|
/// Returns true if there are no more triggers to parse.
|
||||||
|
@@ -164,7 +164,7 @@ fn kitty(
|
|||||||
var seq: KittySequence = .{
|
var seq: KittySequence = .{
|
||||||
.key = entry.code,
|
.key = entry.code,
|
||||||
.final = entry.final,
|
.final = entry.final,
|
||||||
.mods = KittyMods.fromInput(
|
.mods = .fromInput(
|
||||||
self.event.action,
|
self.event.action,
|
||||||
self.event.key,
|
self.event.key,
|
||||||
all_mods,
|
all_mods,
|
||||||
|
@@ -308,7 +308,7 @@ pub const VTHandler = struct {
|
|||||||
current_seq: usize = 1,
|
current_seq: usize = 1,
|
||||||
|
|
||||||
/// Exclude certain actions by tag.
|
/// Exclude certain actions by tag.
|
||||||
filter_exclude: ActionTagSet = ActionTagSet.initMany(&.{.print}),
|
filter_exclude: ActionTagSet = .initMany(&.{.print}),
|
||||||
filter_text: *cimgui.c.ImGuiTextFilter,
|
filter_text: *cimgui.c.ImGuiTextFilter,
|
||||||
|
|
||||||
const ActionTagSet = std.EnumSet(terminal.Parser.Action.Tag);
|
const ActionTagSet = std.EnumSet(terminal.Parser.Action.Tag);
|
||||||
|
@@ -12,7 +12,7 @@ const macos = @import("macos");
|
|||||||
/// but handles macOS using NSProcessInfo instead of libc argc/argv.
|
/// but handles macOS using NSProcessInfo instead of libc argc/argv.
|
||||||
pub fn iterator(allocator: Allocator) ArgIterator.InitError!ArgIterator {
|
pub fn iterator(allocator: Allocator) ArgIterator.InitError!ArgIterator {
|
||||||
//if (true) return try std.process.argsWithAllocator(allocator);
|
//if (true) return try std.process.argsWithAllocator(allocator);
|
||||||
return ArgIterator.initWithAllocator(allocator);
|
return .initWithAllocator(allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Duck-typed to std.process.ArgIterator
|
/// Duck-typed to std.process.ArgIterator
|
||||||
|
@@ -155,7 +155,7 @@ pub fn init(
|
|||||||
|
|
||||||
return .{
|
return .{
|
||||||
.alloc = alloc,
|
.alloc = alloc,
|
||||||
.config = DerivedConfig.init(config),
|
.config = .init(config),
|
||||||
.loop = loop,
|
.loop = loop,
|
||||||
.wakeup = wakeup_h,
|
.wakeup = wakeup_h,
|
||||||
.stop = stop_h,
|
.stop = stop_h,
|
||||||
|
@@ -62,7 +62,7 @@ pub fn style(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, we use whatever style the terminal wants.
|
// 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" {
|
test "cursor: default uses configured style" {
|
||||||
|
@@ -179,7 +179,7 @@ pub const Set = struct {
|
|||||||
if (current) |*sel| {
|
if (current) |*sel| {
|
||||||
sel.endPtr().* = cell_pin;
|
sel.endPtr().* = cell_pin;
|
||||||
} else {
|
} else {
|
||||||
current = terminal.Selection.init(
|
current = .init(
|
||||||
cell_pin,
|
cell_pin,
|
||||||
cell_pin,
|
cell_pin,
|
||||||
false,
|
false,
|
||||||
|
@@ -44,7 +44,7 @@ fn ArrayListPool(comptime T: type) type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (self.lists) |*list| {
|
for (self.lists) |*list| {
|
||||||
list.* = try ArrayListT.initCapacity(alloc, initial_capacity);
|
list.* = try .initCapacity(alloc, initial_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@@ -22,7 +22,7 @@ pub const Size = struct {
|
|||||||
/// taking the screen size, removing padding, and dividing by the cell
|
/// taking the screen size, removing padding, and dividing by the cell
|
||||||
/// dimensions.
|
/// dimensions.
|
||||||
pub fn grid(self: Size) GridSize {
|
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
|
/// The size of the terminal. This is the same as the screen without
|
||||||
@@ -39,7 +39,7 @@ pub const Size = struct {
|
|||||||
self.padding = explicit;
|
self.padding = explicit;
|
||||||
|
|
||||||
// Now we can calculate the balanced padding
|
// Now we can calculate the balanced padding
|
||||||
self.padding = Padding.balanced(
|
self.padding = .balanced(
|
||||||
self.screen,
|
self.screen,
|
||||||
self.grid(),
|
self.grid(),
|
||||||
self.cell,
|
self.cell,
|
||||||
|
@@ -287,8 +287,8 @@ fn initPages(
|
|||||||
// Initialize the first set of pages to contain our viewport so that
|
// Initialize the first set of pages to contain our viewport so that
|
||||||
// the top of the first page is always the active area.
|
// the top of the first page is always the active area.
|
||||||
node.* = .{
|
node.* = .{
|
||||||
.data = Page.initBuf(
|
.data = .initBuf(
|
||||||
OffsetBuf.init(page_buf),
|
.init(page_buf),
|
||||||
Page.layout(cap),
|
Page.layout(cap),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@@ -472,7 +472,7 @@ pub fn clone(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Setup our pools
|
// Setup our pools
|
||||||
break :alloc try MemoryPool.init(
|
break :alloc try .init(
|
||||||
alloc,
|
alloc,
|
||||||
std.heap.page_allocator,
|
std.heap.page_allocator,
|
||||||
page_count,
|
page_count,
|
||||||
@@ -1201,7 +1201,7 @@ const ReflowCursor = struct {
|
|||||||
node.data.size.rows = 1;
|
node.data.size.rows = 1;
|
||||||
list.pages.insertAfter(self.node, node);
|
list.pages.insertAfter(self.node, node);
|
||||||
|
|
||||||
self.* = ReflowCursor.init(node);
|
self.* = .init(node);
|
||||||
|
|
||||||
self.new_rows = new_rows;
|
self.new_rows = new_rows;
|
||||||
}
|
}
|
||||||
@@ -1817,7 +1817,7 @@ pub fn grow(self: *PageList) !?*List.Node {
|
|||||||
@memset(buf, 0);
|
@memset(buf, 0);
|
||||||
|
|
||||||
// Initialize our new page and reinsert it as the last
|
// 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;
|
first.data.size.rows = 1;
|
||||||
self.pages.insertAfter(last, first);
|
self.pages.insertAfter(last, first);
|
||||||
|
|
||||||
@@ -1989,7 +1989,7 @@ fn createPageExt(
|
|||||||
// to undefined, 0xAA.
|
// to undefined, 0xAA.
|
||||||
if (comptime std.debug.runtime_safety) @memset(page_buf, 0);
|
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;
|
page.data.size.rows = 0;
|
||||||
|
|
||||||
if (total_size) |v| {
|
if (total_size) |v| {
|
||||||
|
@@ -217,7 +217,7 @@ intermediates_idx: u8 = 0,
|
|||||||
|
|
||||||
/// Param tracking, building
|
/// Param tracking, building
|
||||||
params: [MAX_PARAMS]u16 = undefined,
|
params: [MAX_PARAMS]u16 = undefined,
|
||||||
params_sep: Action.CSI.SepList = Action.CSI.SepList.initEmpty(),
|
params_sep: Action.CSI.SepList = .initEmpty(),
|
||||||
params_idx: u8 = 0,
|
params_idx: u8 = 0,
|
||||||
param_acc: u16 = 0,
|
param_acc: u16 = 0,
|
||||||
param_acc_idx: u8 = 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 {
|
pub fn clear(self: *Parser) void {
|
||||||
self.intermediates_idx = 0;
|
self.intermediates_idx = 0;
|
||||||
self.params_idx = 0;
|
self.params_idx = 0;
|
||||||
self.params_sep = Action.CSI.SepList.initEmpty();
|
self.params_sep = .initEmpty();
|
||||||
self.param_acc = 0;
|
self.param_acc = 0;
|
||||||
self.param_acc_idx = 0;
|
self.param_acc_idx = 0;
|
||||||
}
|
}
|
||||||
|
@@ -171,7 +171,7 @@ pub const SavedCursor = struct {
|
|||||||
/// State required for all charset operations.
|
/// State required for all charset operations.
|
||||||
pub const CharsetState = struct {
|
pub const CharsetState = struct {
|
||||||
/// The list of graphical charsets by slot
|
/// 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)
|
/// GL is the slot to use when using a 7-bit printable char (up to 127)
|
||||||
/// GR used for 8-bit printable chars.
|
/// GR used for 8-bit printable chars.
|
||||||
@@ -2433,7 +2433,7 @@ pub fn selectLine(self: *const Screen, opts: SelectLine) ?Selection {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Selection.init(start, end, false);
|
return .init(start, end, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the selection for all contents on the screen. Surrounding
|
/// Return the selection for all contents on the screen. Surrounding
|
||||||
@@ -2489,7 +2489,7 @@ pub fn selectAll(self: *Screen) ?Selection {
|
|||||||
return null;
|
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
|
/// 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;
|
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
|
/// 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;
|
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
|
/// 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;
|
break :end it_prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Selection.init(start, end, false);
|
return .init(start, end, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const LineIterator = struct {
|
pub const LineIterator = struct {
|
||||||
|
@@ -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
|
/// Note that only forward and reverse are useful desired orders for this
|
||||||
/// function. All other orders act as if forward order was desired.
|
/// function. All other orders act as if forward order was desired.
|
||||||
pub fn ordered(self: Selection, s: *const Screen, desired: Order) Selection {
|
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.start(),
|
||||||
self.end(),
|
self.end(),
|
||||||
self.rectangle,
|
self.rectangle,
|
||||||
@@ -237,9 +237,9 @@ pub fn ordered(self: Selection, s: *const Screen, desired: Order) Selection {
|
|||||||
const tl = self.topLeft(s);
|
const tl = self.topLeft(s);
|
||||||
const br = self.bottomRight(s);
|
const br = self.bottomRight(s);
|
||||||
return switch (desired) {
|
return switch (desired) {
|
||||||
.forward => Selection.init(tl, br, self.rectangle),
|
.forward => .init(tl, br, self.rectangle),
|
||||||
.reverse => Selection.init(br, tl, self.rectangle),
|
.reverse => .init(br, tl, self.rectangle),
|
||||||
else => Selection.init(tl, br, self.rectangle),
|
else => .init(tl, br, self.rectangle),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -80,7 +80,7 @@ pub const Match = struct {
|
|||||||
const end_idx: usize = @intCast(self.region.ends()[0] - 1);
|
const end_idx: usize = @intCast(self.region.ends()[0] - 1);
|
||||||
const start_pt = self.map.map[self.offset + start_idx];
|
const start_pt = self.map.map[self.offset + start_idx];
|
||||||
const end_pt = self.map.map[self.offset + end_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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -79,7 +79,7 @@ default_palette: color.Palette = color.default,
|
|||||||
color_palette: struct {
|
color_palette: struct {
|
||||||
const Mask = std.StaticBitSet(@typeInfo(color.Palette).array.len);
|
const Mask = std.StaticBitSet(@typeInfo(color.Palette).array.len);
|
||||||
colors: color.Palette = color.default,
|
colors: color.Palette = color.default,
|
||||||
mask: Mask = Mask.initEmpty(),
|
mask: Mask = .initEmpty(),
|
||||||
} = .{},
|
} = .{},
|
||||||
|
|
||||||
/// The previous printed character. This is used for the repeat previous
|
/// The previous printed character. This is used for the repeat previous
|
||||||
@@ -210,9 +210,9 @@ pub fn init(
|
|||||||
.cols = cols,
|
.cols = cols,
|
||||||
.rows = rows,
|
.rows = rows,
|
||||||
.active_screen = .primary,
|
.active_screen = .primary,
|
||||||
.screen = try Screen.init(alloc, cols, rows, opts.max_scrollback),
|
.screen = try .init(alloc, cols, rows, opts.max_scrollback),
|
||||||
.secondary_screen = try Screen.init(alloc, cols, rows, 0),
|
.secondary_screen = try .init(alloc, cols, rows, 0),
|
||||||
.tabstops = try Tabstops.init(alloc, cols, TABSTOP_INTERVAL),
|
.tabstops = try .init(alloc, cols, TABSTOP_INTERVAL),
|
||||||
.scrolling_region = .{
|
.scrolling_region = .{
|
||||||
.top = 0,
|
.top = 0,
|
||||||
.bottom = rows - 1,
|
.bottom = rows - 1,
|
||||||
@@ -2454,7 +2454,7 @@ pub fn resize(
|
|||||||
// Resize our tabstops
|
// Resize our tabstops
|
||||||
if (self.cols != cols) {
|
if (self.cols != cols) {
|
||||||
self.tabstops.deinit(alloc);
|
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.
|
// If we're making the screen smaller, dealloc the unused items.
|
||||||
|
@@ -403,7 +403,7 @@ test "BitmapAllocator alloc sequentially" {
|
|||||||
const buf = try alloc.alignedAlloc(u8, Alloc.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Alloc.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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);
|
const ptr = try bm.alloc(u8, buf, 1);
|
||||||
ptr[0] = 'A';
|
ptr[0] = 'A';
|
||||||
|
|
||||||
@@ -429,7 +429,7 @@ test "BitmapAllocator alloc non-byte" {
|
|||||||
const buf = try alloc.alignedAlloc(u8, Alloc.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Alloc.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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);
|
const ptr = try bm.alloc(u21, buf, 1);
|
||||||
ptr[0] = 'A';
|
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);
|
const buf = try alloc.alignedAlloc(u8, Alloc.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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);
|
const ptr = try bm.alloc(u21, buf, 6);
|
||||||
try testing.expectEqual(@as(usize, 6), ptr.len);
|
try testing.expectEqual(@as(usize, 6), ptr.len);
|
||||||
for (ptr) |*v| v.* = 'A';
|
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);
|
const buf = try alloc.alignedAlloc(u8, Alloc.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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);
|
const ptr = try bm.alloc(u8, buf, 129);
|
||||||
ptr[0] = 'A';
|
ptr[0] = 'A';
|
||||||
bm.free(buf, ptr);
|
bm.free(buf, ptr);
|
||||||
|
@@ -893,7 +893,7 @@ test "HashMap basic usage" {
|
|||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
|
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
const count = 5;
|
const count = 5;
|
||||||
var i: u32 = 0;
|
var i: u32 = 0;
|
||||||
@@ -927,7 +927,7 @@ test "HashMap ensureTotalCapacity" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
const initial_capacity = map.capacity();
|
const initial_capacity = map.capacity();
|
||||||
try testing.expect(initial_capacity >= 20);
|
try testing.expect(initial_capacity >= 20);
|
||||||
@@ -947,7 +947,7 @@ test "HashMap ensureUnusedCapacity with tombstones" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
var i: i32 = 0;
|
var i: i32 = 0;
|
||||||
while (i < 100) : (i += 1) {
|
while (i < 100) : (i += 1) {
|
||||||
@@ -965,7 +965,7 @@ test "HashMap clearRetainingCapacity" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
map.clearRetainingCapacity();
|
map.clearRetainingCapacity();
|
||||||
|
|
||||||
@@ -996,7 +996,7 @@ test "HashMap ensureTotalCapacity with existing elements" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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 map.put(0, 0);
|
||||||
try expectEqual(map.count(), 1);
|
try expectEqual(map.count(), 1);
|
||||||
@@ -1015,7 +1015,7 @@ test "HashMap remove" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
var i: u32 = 0;
|
var i: u32 = 0;
|
||||||
while (i < 16) : (i += 1) {
|
while (i < 16) : (i += 1) {
|
||||||
@@ -1053,7 +1053,7 @@ test "HashMap reverse removes" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
var i: u32 = 0;
|
var i: u32 = 0;
|
||||||
while (i < 16) : (i += 1) {
|
while (i < 16) : (i += 1) {
|
||||||
@@ -1081,7 +1081,7 @@ test "HashMap multiple removes on same metadata" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
var i: u32 = 0;
|
var i: u32 = 0;
|
||||||
while (i < 16) : (i += 1) {
|
while (i < 16) : (i += 1) {
|
||||||
@@ -1124,7 +1124,7 @@ test "HashMap put and remove loop in random order" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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);
|
var keys = std.ArrayList(u32).init(alloc);
|
||||||
defer keys.deinit();
|
defer keys.deinit();
|
||||||
@@ -1162,7 +1162,7 @@ test "HashMap put" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
var i: u32 = 0;
|
var i: u32 = 0;
|
||||||
while (i < 16) : (i += 1) {
|
while (i < 16) : (i += 1) {
|
||||||
@@ -1193,7 +1193,7 @@ test "HashMap put full load" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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 map.put(i, i);
|
||||||
for (0..cap) |i| try expectEqual(map.get(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 layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
var i: u32 = 0;
|
var i: u32 = 0;
|
||||||
while (i < 20) : (i += 1) {
|
while (i < 20) : (i += 1) {
|
||||||
@@ -1244,7 +1244,7 @@ test "HashMap repeat putAssumeCapacity/remove" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
const limit = cap;
|
const limit = cap;
|
||||||
|
|
||||||
@@ -1280,7 +1280,7 @@ test "HashMap getOrPut" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
var i: u32 = 0;
|
var i: u32 = 0;
|
||||||
while (i < 10) : (i += 1) {
|
while (i < 10) : (i += 1) {
|
||||||
@@ -1309,7 +1309,7 @@ test "HashMap basic hash map usage" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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(1, 11)) == null);
|
||||||
try testing.expect((try map.fetchPut(2, 22)) == null);
|
try testing.expect((try map.fetchPut(2, 22)) == null);
|
||||||
@@ -1360,7 +1360,7 @@ test "HashMap ensureUnusedCapacity" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
try map.ensureUnusedCapacity(32);
|
try map.ensureUnusedCapacity(32);
|
||||||
try testing.expectError(error.OutOfMemory, map.ensureUnusedCapacity(cap + 1));
|
try testing.expectError(error.OutOfMemory, map.ensureUnusedCapacity(cap + 1));
|
||||||
@@ -1374,7 +1374,7 @@ test "HashMap removeByPtr" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
var i: i32 = undefined;
|
var i: i32 = undefined;
|
||||||
i = 0;
|
i = 0;
|
||||||
@@ -1405,7 +1405,7 @@ test "HashMap removeByPtr 0 sized key" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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 map.put(0, 0);
|
||||||
|
|
||||||
@@ -1429,7 +1429,7 @@ test "HashMap repeat fetchRemove" {
|
|||||||
const layout = Map.layoutForCapacity(cap);
|
const layout = Map.layoutForCapacity(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, Map.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
var map = Map.init(OffsetBuf.init(buf), layout);
|
var map = Map.init(.init(buf), layout);
|
||||||
|
|
||||||
map.putAssumeCapacity(0, {});
|
map.putAssumeCapacity(0, {});
|
||||||
map.putAssumeCapacity(1, {});
|
map.putAssumeCapacity(1, {});
|
||||||
@@ -1457,7 +1457,7 @@ test "OffsetHashMap basic usage" {
|
|||||||
const layout = OffsetMap.layout(cap);
|
const layout = OffsetMap.layout(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, OffsetMap.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, OffsetMap.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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);
|
var map = offset_map.map(buf.ptr);
|
||||||
|
|
||||||
const count = 5;
|
const count = 5;
|
||||||
@@ -1492,7 +1492,7 @@ test "OffsetHashMap remake map" {
|
|||||||
const layout = OffsetMap.layout(cap);
|
const layout = OffsetMap.layout(cap);
|
||||||
const buf = try alloc.alignedAlloc(u8, OffsetMap.base_align, layout.total_size);
|
const buf = try alloc.alignedAlloc(u8, OffsetMap.base_align, layout.total_size);
|
||||||
defer alloc.free(buf);
|
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);
|
var map = offset_map.map(buf.ptr);
|
||||||
|
@@ -155,17 +155,17 @@ pub const Parser = struct {
|
|||||||
break :action c;
|
break :action c;
|
||||||
};
|
};
|
||||||
const control: Command.Control = switch (action) {
|
const control: Command.Control = switch (action) {
|
||||||
'q' => .{ .query = try Transmission.parse(self.kv) },
|
'q' => .{ .query = try .parse(self.kv) },
|
||||||
't' => .{ .transmit = try Transmission.parse(self.kv) },
|
't' => .{ .transmit = try .parse(self.kv) },
|
||||||
'T' => .{ .transmit_and_display = .{
|
'T' => .{ .transmit_and_display = .{
|
||||||
.transmission = try Transmission.parse(self.kv),
|
.transmission = try .parse(self.kv),
|
||||||
.display = try Display.parse(self.kv),
|
.display = try .parse(self.kv),
|
||||||
} },
|
} },
|
||||||
'p' => .{ .display = try Display.parse(self.kv) },
|
'p' => .{ .display = try .parse(self.kv) },
|
||||||
'd' => .{ .delete = try Delete.parse(self.kv) },
|
'd' => .{ .delete = try .parse(self.kv) },
|
||||||
'f' => .{ .transmit_animation_frame = try AnimationFrameLoading.parse(self.kv) },
|
'f' => .{ .transmit_animation_frame = try .parse(self.kv) },
|
||||||
'a' => .{ .control_animation = try AnimationControl.parse(self.kv) },
|
'a' => .{ .control_animation = try .parse(self.kv) },
|
||||||
'c' => .{ .compose_animation = try AnimationFrameComposition.parse(self.kv) },
|
'c' => .{ .compose_animation = try .parse(self.kv) },
|
||||||
else => return error.InvalidFormat,
|
else => return error.InvalidFormat,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -324,7 +324,7 @@ fn loadAndAddImage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
break :loading loading.*;
|
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
|
// 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
|
// want to deinit at all. If we're not chunking, then we'll deinit
|
||||||
|
@@ -1354,8 +1354,8 @@ pub const Parser = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (self.command) {
|
switch (self.command) {
|
||||||
.report_color => |*c| c.terminator = Terminator.init(terminator_ch),
|
.report_color => |*c| c.terminator = .init(terminator_ch),
|
||||||
.kitty_color_protocol => |*c| c.terminator = Terminator.init(terminator_ch),
|
.kitty_color_protocol => |*c| c.terminator = .init(terminator_ch),
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -241,23 +241,23 @@ pub const Page = struct {
|
|||||||
l.styles_layout,
|
l.styles_layout,
|
||||||
.{},
|
.{},
|
||||||
),
|
),
|
||||||
.string_alloc = StringAlloc.init(
|
.string_alloc = .init(
|
||||||
buf.add(l.string_alloc_start),
|
buf.add(l.string_alloc_start),
|
||||||
l.string_alloc_layout,
|
l.string_alloc_layout,
|
||||||
),
|
),
|
||||||
.grapheme_alloc = GraphemeAlloc.init(
|
.grapheme_alloc = .init(
|
||||||
buf.add(l.grapheme_alloc_start),
|
buf.add(l.grapheme_alloc_start),
|
||||||
l.grapheme_alloc_layout,
|
l.grapheme_alloc_layout,
|
||||||
),
|
),
|
||||||
.grapheme_map = GraphemeMap.init(
|
.grapheme_map = .init(
|
||||||
buf.add(l.grapheme_map_start),
|
buf.add(l.grapheme_map_start),
|
||||||
l.grapheme_map_layout,
|
l.grapheme_map_layout,
|
||||||
),
|
),
|
||||||
.hyperlink_map = hyperlink.Map.init(
|
.hyperlink_map = .init(
|
||||||
buf.add(l.hyperlink_map_start),
|
buf.add(l.hyperlink_map_start),
|
||||||
l.hyperlink_map_layout,
|
l.hyperlink_map_layout,
|
||||||
),
|
),
|
||||||
.hyperlink_set = hyperlink.Set.init(
|
.hyperlink_set = .init(
|
||||||
buf.add(l.hyperlink_set_start),
|
buf.add(l.hyperlink_set_start),
|
||||||
l.hyperlink_set_layout,
|
l.hyperlink_set_layout,
|
||||||
.{},
|
.{},
|
||||||
@@ -280,7 +280,7 @@ pub const Page = struct {
|
|||||||
// We zero the page memory as u64 instead of u8 because
|
// We zero the page memory as u64 instead of u8 because
|
||||||
// we can and it's empirically quite a bit faster.
|
// we can and it's empirically quite a bit faster.
|
||||||
@memset(@as([*]u64, @ptrCast(self.memory))[0 .. self.memory.len / 8], 0);
|
@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{
|
pub const IntegrityError = error{
|
||||||
@@ -2260,7 +2260,7 @@ test "Page appendGrapheme small" {
|
|||||||
defer page.deinit();
|
defer page.deinit();
|
||||||
|
|
||||||
const rac = page.getRowAndCell(0, 0);
|
const rac = page.getRowAndCell(0, 0);
|
||||||
rac.cell.* = Cell.init(0x09);
|
rac.cell.* = .init(0x09);
|
||||||
|
|
||||||
// One
|
// One
|
||||||
try page.appendGrapheme(rac.row, rac.cell, 0x0A);
|
try page.appendGrapheme(rac.row, rac.cell, 0x0A);
|
||||||
@@ -2289,7 +2289,7 @@ test "Page appendGrapheme larger than chunk" {
|
|||||||
defer page.deinit();
|
defer page.deinit();
|
||||||
|
|
||||||
const rac = page.getRowAndCell(0, 0);
|
const rac = page.getRowAndCell(0, 0);
|
||||||
rac.cell.* = Cell.init(0x09);
|
rac.cell.* = .init(0x09);
|
||||||
|
|
||||||
const count = grapheme_chunk_len * 10;
|
const count = grapheme_chunk_len * 10;
|
||||||
for (0..count) |i| {
|
for (0..count) |i| {
|
||||||
@@ -2312,11 +2312,11 @@ test "Page clearGrapheme not all cells" {
|
|||||||
defer page.deinit();
|
defer page.deinit();
|
||||||
|
|
||||||
const rac = page.getRowAndCell(0, 0);
|
const rac = page.getRowAndCell(0, 0);
|
||||||
rac.cell.* = Cell.init(0x09);
|
rac.cell.* = .init(0x09);
|
||||||
try page.appendGrapheme(rac.row, rac.cell, 0x0A);
|
try page.appendGrapheme(rac.row, rac.cell, 0x0A);
|
||||||
|
|
||||||
const rac2 = page.getRowAndCell(1, 0);
|
const rac2 = page.getRowAndCell(1, 0);
|
||||||
rac2.cell.* = Cell.init(0x09);
|
rac2.cell.* = .init(0x09);
|
||||||
try page.appendGrapheme(rac2.row, rac2.cell, 0x0A);
|
try page.appendGrapheme(rac2.row, rac2.cell, 0x0A);
|
||||||
|
|
||||||
// Clear it
|
// Clear it
|
||||||
|
@@ -365,7 +365,7 @@ const SlidingWindow = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.assertIntegrity();
|
self.assertIntegrity();
|
||||||
return Selection.init(tl, br, false);
|
return .init(tl, br, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a data index into a pin.
|
/// Convert a data index into a pin.
|
||||||
@@ -417,7 +417,7 @@ const SlidingWindow = struct {
|
|||||||
// Initialize our metadata for the node.
|
// Initialize our metadata for the node.
|
||||||
var meta: Meta = .{
|
var meta: Meta = .{
|
||||||
.node = node,
|
.node = node,
|
||||||
.cell_map = Page.CellMap.init(alloc),
|
.cell_map = .init(alloc),
|
||||||
};
|
};
|
||||||
errdefer meta.deinit();
|
errdefer meta.deinit();
|
||||||
|
|
||||||
|
@@ -98,7 +98,7 @@ pub const Attribute = union(enum) {
|
|||||||
/// Parser parses the attributes from a list of SGR parameters.
|
/// Parser parses the attributes from a list of SGR parameters.
|
||||||
pub const Parser = struct {
|
pub const Parser = struct {
|
||||||
params: []const u16,
|
params: []const u16,
|
||||||
params_sep: SepList = SepList.initEmpty(),
|
params_sep: SepList = .initEmpty(),
|
||||||
idx: usize = 0,
|
idx: usize = 0,
|
||||||
|
|
||||||
/// Next returns the next attribute or null if there are no more attributes.
|
/// 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 {
|
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().?;
|
return p.next().?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -302,9 +302,9 @@ pub const Style = struct {
|
|||||||
.underline = std.meta.activeTag(style.underline_color),
|
.underline = std.meta.activeTag(style.underline_color),
|
||||||
},
|
},
|
||||||
.data = .{
|
.data = .{
|
||||||
.fg = Data.fromColor(style.fg_color),
|
.fg = .fromColor(style.fg_color),
|
||||||
.bg = Data.fromColor(style.bg_color),
|
.bg = .fromColor(style.bg_color),
|
||||||
.underline = Data.fromColor(style.underline_color),
|
.underline = .fromColor(style.underline_color),
|
||||||
},
|
},
|
||||||
.flags = style.flags,
|
.flags = style.flags,
|
||||||
};
|
};
|
||||||
@@ -349,7 +349,7 @@ test "Set basic usage" {
|
|||||||
const style: Style = .{ .flags = .{ .bold = true } };
|
const style: Style = .{ .flags = .{ .bold = true } };
|
||||||
const style2: Style = .{ .flags = .{ .italic = true } };
|
const style2: Style = .{ .flags = .{ .italic = true } };
|
||||||
|
|
||||||
var set = Set.init(OffsetBuf.init(buf), layout, .{});
|
var set = Set.init(.init(buf), layout, .{});
|
||||||
|
|
||||||
// Add style
|
// Add style
|
||||||
const id = try set.add(buf, style);
|
const id = try set.add(buf, style);
|
||||||
|
@@ -33,7 +33,7 @@ fn colorMap() !ColorMap {
|
|||||||
}
|
}
|
||||||
assert(i == len);
|
assert(i == len);
|
||||||
|
|
||||||
return ColorMap.initComptime(kvs);
|
return .initComptime(kvs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is the rgb.txt file from the X11 project. This was last sourced
|
/// This is the rgb.txt file from the X11 project. This was last sourced
|
||||||
|
@@ -125,7 +125,7 @@ pub fn get(cp: u21) Properties {
|
|||||||
|
|
||||||
return .{
|
return .{
|
||||||
.width = @intCast(@min(2, @max(0, zg_width))),
|
.width = @intCast(@min(2, @max(0, zg_width))),
|
||||||
.grapheme_boundary_class = GraphemeBoundaryClass.init(cp),
|
.grapheme_boundary_class = .init(cp),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user