refactor: use {t} format specifiers
This commit is contained in:
parent
76f23b0824
commit
090d27d890
8 changed files with 19 additions and 21 deletions
|
|
@ -484,7 +484,7 @@ pub fn build_exe(
|
||||||
break :blk mod;
|
break :blk mod;
|
||||||
},
|
},
|
||||||
else => |tag| {
|
else => |tag| {
|
||||||
std.log.err("OS '{s}' does not support -Dgui mode", .{@tagName(tag)});
|
std.log.err("OS '{t}' does not support -Dgui mode", .{tag});
|
||||||
std.process.exit(0xff);
|
std.process.exit(0xff);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -814,8 +814,8 @@ fn gen_version_info(
|
||||||
else
|
else
|
||||||
try writer.print("branch: {s} at {s}\n", .{ branch, remote });
|
try writer.print("branch: {s} at {s}\n", .{ branch, remote });
|
||||||
|
|
||||||
try writer.print("built-with: zig {s} ({s})\n", .{ builtin.zig_version_string, @tagName(builtin.zig_backend) });
|
try writer.print("built-with: zig {s} ({t})\n", .{ builtin.zig_version_string, builtin.zig_backend });
|
||||||
try writer.print("build-mode: {s}\n", .{@tagName(optimize)});
|
try writer.print("build-mode: {t}\n", .{optimize});
|
||||||
|
|
||||||
if (log.len > 0)
|
if (log.len > 0)
|
||||||
try writer.print("\nwith the following diverging commits:\n{s}\n", .{log});
|
try writer.print("\nwith the following diverging commits:\n{s}\n", .{log});
|
||||||
|
|
|
||||||
|
|
@ -1971,7 +1971,7 @@ fn show_or_log_message(self: *Self, operation: enum { show, log }, params_cb: []
|
||||||
if (type_ <= 2)
|
if (type_ <= 2)
|
||||||
self.logger_lsp.err_msg("lsp", msg)
|
self.logger_lsp.err_msg("lsp", msg)
|
||||||
else
|
else
|
||||||
self.logger_lsp.print("{s}: {s}", .{ @tagName(operation), msg });
|
self.logger_lsp.print("{t}: {s}", .{ operation, msg });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_notification(self: *Self, method: []const u8, params_cb: []const u8) !void {
|
pub fn show_notification(self: *Self, method: []const u8, params_cb: []const u8) !void {
|
||||||
|
|
|
||||||
|
|
@ -743,7 +743,7 @@ fn write_config_value_description(T: type, field_type: type, writer: *std.Io.Wri
|
||||||
try writer.print("one of ", .{});
|
try writer.print("one of ", .{});
|
||||||
for (std.meta.tags(field_type)) |tag| {
|
for (std.meta.tags(field_type)) |tag| {
|
||||||
if (first) first = false else try writer.print(", ", .{});
|
if (first) first = false else try writer.print(", ", .{});
|
||||||
try writer.print("\"{s}\"", .{@tagName(tag)});
|
try writer.print("\"{t}\"", .{tag});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.optional => |info| switch (@typeInfo(info.child)) {
|
.optional => |info| switch (@typeInfo(info.child)) {
|
||||||
|
|
@ -1180,7 +1180,7 @@ fn restart_manual() noreturn {
|
||||||
fn restart_failed(ret: c_int) noreturn {
|
fn restart_failed(ret: c_int) noreturn {
|
||||||
var stderr_buffer: [1024]u8 = undefined;
|
var stderr_buffer: [1024]u8 = undefined;
|
||||||
var stderr_writer = std.fs.File.stderr().writer(&stderr_buffer);
|
var stderr_writer = std.fs.File.stderr().writer(&stderr_buffer);
|
||||||
stderr_writer.interface.print("\nrestart failed: {s}", .{@tagName(std.posix.errno(ret))}) catch {};
|
stderr_writer.interface.print("\nrestart failed: {t}", .{std.posix.errno(ret)}) catch {};
|
||||||
stderr_writer.interface.flush() catch {};
|
stderr_writer.interface.flush() catch {};
|
||||||
exit(234);
|
exit(234);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,7 @@ pub fn FullPanic(comptime panicFn: fn ([]const u8, ?usize) noreturn) type {
|
||||||
}
|
}
|
||||||
pub fn inactiveUnionField(active: anytype, accessed: @TypeOf(active)) noreturn {
|
pub fn inactiveUnionField(active: anytype, accessed: @TypeOf(active)) noreturn {
|
||||||
@branchHint(.cold);
|
@branchHint(.cold);
|
||||||
std.debug.panicExtra(@returnAddress(), "access of union field '{s}' while field '{s}' is active", .{
|
std.debug.panicExtra(@returnAddress(), "access of union field '{t}' while field '{t}' is active", .{ accessed, active });
|
||||||
@tagName(accessed), @tagName(active),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
pub fn sliceCastLenRemainder(src_len: usize) noreturn {
|
pub fn sliceCastLenRemainder(src_len: usize) noreturn {
|
||||||
@branchHint(.cold);
|
@branchHint(.cold);
|
||||||
|
|
|
||||||
|
|
@ -5010,7 +5010,7 @@ pub const Editor = struct {
|
||||||
const update_time = end_time - start_time;
|
const update_time = end_time - start_time;
|
||||||
self.syntax_incremental_reparse = end_time - start_time > syntax_full_reparse_time_limit;
|
self.syntax_incremental_reparse = end_time - start_time > syntax_full_reparse_time_limit;
|
||||||
if (self.syntax_report_timing)
|
if (self.syntax_report_timing)
|
||||||
self.logger.print("syntax update {s} time: {d}ms ({d} edits)", .{ @tagName(kind), update_time, edit_count });
|
self.logger.print("syntax update {t} time: {d}ms ({d} edits)", .{ kind, update_time, edit_count });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@ pub fn load_entries(palette: *Type) !usize {
|
||||||
for (p.meta.arguments) |arg| {
|
for (p.meta.arguments) |arg| {
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
try writer.print("{s}", .{@tagName(arg)});
|
try writer.print("{t}", .{arg});
|
||||||
} else {
|
} else {
|
||||||
try writer.print(", {s}", .{@tagName(arg)});
|
try writer.print(", {t}", .{arg});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try writer.writeAll("}");
|
try writer.writeAll("}");
|
||||||
|
|
|
||||||
|
|
@ -909,14 +909,14 @@ fn force_color_scheme(self: *Self, color_scheme: @TypeOf(self.color_scheme)) voi
|
||||||
self.color_scheme = color_scheme;
|
self.color_scheme = color_scheme;
|
||||||
self.color_scheme_locked = true;
|
self.color_scheme_locked = true;
|
||||||
self.set_terminal_style(self.current_theme());
|
self.set_terminal_style(self.current_theme());
|
||||||
self.logger.print("color scheme: {s} ({s})", .{ @tagName(self.color_scheme), self.current_theme().name });
|
self.logger.print("color scheme: {t} ({s})", .{ self.color_scheme, self.current_theme().name });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_color_scheme(self: *Self, color_scheme: @TypeOf(self.color_scheme)) void {
|
fn set_color_scheme(self: *Self, color_scheme: @TypeOf(self.color_scheme)) void {
|
||||||
if (self.color_scheme_locked) return;
|
if (self.color_scheme_locked) return;
|
||||||
self.color_scheme = color_scheme;
|
self.color_scheme = color_scheme;
|
||||||
self.set_terminal_style(self.current_theme());
|
self.set_terminal_style(self.current_theme());
|
||||||
self.logger.print("color scheme: {s} ({s})", .{ @tagName(self.color_scheme), self.current_theme().name });
|
self.logger.print("color scheme: {t} ({s})", .{ self.color_scheme, self.current_theme().name });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn current_theme(self: *const Self) *const Widget.Theme {
|
fn current_theme(self: *const Self) *const Widget.Theme {
|
||||||
|
|
@ -1031,7 +1031,7 @@ const cmds = struct {
|
||||||
var buf: [32]u8 = undefined;
|
var buf: [32]u8 = undefined;
|
||||||
const m = try tp.message.fmtbuf(&buf, .{ "whitespace_mode", self.config_.whitespace_mode });
|
const m = try tp.message.fmtbuf(&buf, .{ "whitespace_mode", self.config_.whitespace_mode });
|
||||||
_ = try self.send_widgets(tp.self_pid(), m);
|
_ = try self.send_widgets(tp.self_pid(), m);
|
||||||
self.logger.print("whitespace rendering {s}", .{@tagName(self.config_.whitespace_mode)});
|
self.logger.print("whitespace rendering {t}", .{self.config_.whitespace_mode});
|
||||||
}
|
}
|
||||||
pub const toggle_whitespace_mode_meta: Meta = .{ .description = "Next whitespace mode" };
|
pub const toggle_whitespace_mode_meta: Meta = .{ .description = "Next whitespace mode" };
|
||||||
|
|
||||||
|
|
@ -2094,7 +2094,7 @@ pub fn set_next_style(widget_type: WidgetType) void {
|
||||||
const ref = widget_type_config_variable(widget_type);
|
const ref = widget_type_config_variable(widget_type);
|
||||||
ref.* = next_widget_style(ref.*);
|
ref.* = next_widget_style(ref.*);
|
||||||
const self = current();
|
const self = current();
|
||||||
self.logger.print("{s} style {s}", .{ @tagName(widget_type), @tagName(ref.*) });
|
self.logger.print("{t} style {t}", .{ widget_type, ref.* });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_widget_style(tag: ConfigWidgetStyle) ConfigWidgetStyle {
|
fn next_widget_style(tag: ConfigWidgetStyle) ConfigWidgetStyle {
|
||||||
|
|
|
||||||
|
|
@ -416,7 +416,7 @@ const D3d = struct {
|
||||||
&context,
|
&context,
|
||||||
);
|
);
|
||||||
if (last_hr >= 0) {
|
if (last_hr >= 0) {
|
||||||
std.log.info("d3d11: {s} debug={}", .{ @tagName(config.driver), config.debug });
|
std.log.info("d3d11: {t} debug={}", .{ config.driver, config.debug });
|
||||||
return .{
|
return .{
|
||||||
.{
|
.{
|
||||||
.device = device,
|
.device = device,
|
||||||
|
|
@ -427,8 +427,8 @@ const D3d = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
std.log.info(
|
std.log.info(
|
||||||
"D3D11 {s} Driver (with{s} debug) error, hresult=0x{x}",
|
"D3D11 {t} Driver (with{s} debug) error, hresult=0x{x}",
|
||||||
.{ @tagName(config.driver), if (config.debug) "" else "out", @as(u32, @bitCast(last_hr)) },
|
.{ config.driver, if (config.debug) "" else "out", @as(u32, @bitCast(last_hr)) },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
std.debug.panic("failed to initialize Direct3D11, hresult=0x{x}", .{@as(u32, @bitCast(last_hr))});
|
std.debug.panic("failed to initialize Direct3D11, hresult=0x{x}", .{@as(u32, @bitCast(last_hr))});
|
||||||
|
|
@ -624,8 +624,8 @@ fn reportShaderError(kind: enum { vertex, pixel }, maybe_error_blob: ?*win32.ID3
|
||||||
defer _ = err.IUnknown.Release();
|
defer _ = err.IUnknown.Release();
|
||||||
const ptr: [*]const u8 = @ptrCast(err.GetBufferPointer() orelse return);
|
const ptr: [*]const u8 = @ptrCast(err.GetBufferPointer() orelse return);
|
||||||
const str = ptr[0..err.GetBufferSize()];
|
const str = ptr[0..err.GetBufferSize()];
|
||||||
log.err("{s} shader error:\n{s}\n", .{ @tagName(kind), str });
|
log.err("{t} shader error:\n{s}\n", .{ kind, str });
|
||||||
std.debug.panic("{s} shader error:\n{s}\n", .{ @tagName(kind), str });
|
std.debug.panic("{t} shader error:\n{s}\n", .{ kind, str });
|
||||||
}
|
}
|
||||||
|
|
||||||
const ShaderCells = struct {
|
const ShaderCells = struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue