fix: windows build with zig 0.14.0-dev.3039
This commit is contained in:
parent
53045123c6
commit
d503f3c197
5 changed files with 44 additions and 10 deletions
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue