fix: windows build with zig 0.14.0-dev.3039

This commit is contained in:
CJ van den Berg 2025-02-04 23:32:40 +01:00
parent 53045123c6
commit d503f3c197
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
5 changed files with 44 additions and 10 deletions

View file

@ -18,8 +18,8 @@
.hash = "1220220dbc7fe91c1c54438193ca765cebbcb7d58f35cdcaee404a9d2245a42a4362",
},
.thespian = .{
.url = "https://github.com/neurocyte/thespian/archive/063c441c30aafd212b4d8e97555590594855a082.tar.gz",
.hash = "1220d04b3ac1fd1584796d8047a24cccca834592bb2ee7175e1692a1fc6d6d791fb1",
.url = "https://github.com/neurocyte/thespian/archive/eb9b8a3dcfbd15e95195951fab0505c337927f39.tar.gz",
.hash = "1220caa6ad6a0fa724c5ee13b45add9e87c57d44fd91c7731f659470f88359e1cb64",
},
.themes = .{
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-618a7801d3383049adfe18cc09f5f5086c66995f/flow-themes.tar.gz",

View file

@ -32,7 +32,11 @@ pub const std_options: std.Options = .{
const renderer = @import("renderer");
pub const panic = if (@hasDecl(renderer, "panic")) renderer.panic else std.builtin.default_panic;
pub const panic = if (@hasDecl(renderer, "panic")) renderer.panic else default_panic;
fn default_panic(msg: []const u8, _: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
return std.debug.defaultPanic(msg, ret_addr);
}
pub fn main() anyerror!void {
if (builtin.os.tag == .linux) {

View file

@ -18,8 +18,38 @@ pub const StyleBits = @import("tuirenderer").style;
const gui = @import("gui");
const DropWriter = gui.DropWriter;
pub const style = StyleBits;
pub const styles = @import("tuirenderer").styles;
pub const panic = win32.messageBoxThenPanic(.{ .title = "Flow Panic" });
pub const panic = messageBoxThenPanic(.{ .title = "Flow Panic" });
threadlocal var thread_is_panicing = false;
fn messageBoxThenPanic(
opt: struct {
title: [:0]const u8,
style: win32.MESSAGEBOX_STYLE = .{ .ICONASTERISK = 1 },
// TODO: add option/logic to include the stacktrace in the messagebox
},
) std.builtin.PanicFn {
return struct {
pub fn panic(
msg: []const u8,
_: ?*std.builtin.StackTrace,
ret_addr: ?usize,
) noreturn {
if (!thread_is_panicing) {
thread_is_panicing = true;
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const msg_z: [:0]const u8 = if (std.fmt.allocPrintZ(
arena.allocator(),
"{s}",
.{msg},
)) |msg_z| msg_z else |_| "failed allocate error message";
_ = win32.MessageBoxA(null, msg_z, opt.title, opt.style);
}
std.debug.defaultPanic(msg, ret_addr);
}
}.panic;
}
allocator: std.mem.Allocator,
vx: vaxis.Vaxis,
@ -35,7 +65,7 @@ thread: ?std.Thread = null,
hwnd: ?win32.HWND = null,
title_buf: std.ArrayList(u16),
style: ?Style = null,
style_: ?Style = null,
const global = struct {
var init_called: bool = false;
@ -344,12 +374,12 @@ fn update_window_title(self: *Self) void {
}
pub fn set_terminal_style(self: *Self, style_: Style) void {
self.style = style_;
self.style_ = style_;
self.update_window_style();
}
fn update_window_style(self: *Self) void {
const hwnd = self.hwnd orelse return;
if (self.style) |style_| {
if (self.style_) |style_| {
if (style_.bg) |color| gui.set_window_background(hwnd, @intCast(color.color));
}
}

View file

@ -41,12 +41,12 @@ pub const Font = struct {
);
if (hr < 0) std.debug.panic(
"CreateTextFormat '{}' height {d} failed, hresult=0x{x}",
.{ std.unicode.fmtUtf16le(face.slice()), size, @as(u32, @bitCast(hr)) },
.{ std.unicode.fmtUtf16Le(face.slice()), size, @as(u32, @bitCast(hr)) },
);
}
errdefer _ = text_format.IUnknown.Release();
const cell_size = blk: {
const cell_size: XY(u16) = blk: {
var text_layout: *win32.IDWriteTextLayout = undefined;
{
const hr = global.dwrite_factory.CreateTextLayout(

View file

@ -145,7 +145,7 @@ fn getConfig() *gui_config {
}
fn getFieldDefault(field: std.builtin.Type.StructField) ?*const field.type {
return @alignCast(@ptrCast(field.default_value orelse return null));
return @alignCast(@ptrCast(field.default_value_ptr orelse return null));
}
fn getDefaultFontFace() FontFace {