fix: release mode undefined usage (for optionals); bump to 0.14.dev
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 54s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 54s
This commit is contained in:
@@ -69,7 +69,7 @@ pub fn App(comptime E: type, comptime R: fn (comptime bool) type, comptime fulls
|
||||
.mask = std.posix.empty_sigset,
|
||||
.flags = 0,
|
||||
};
|
||||
std.posix.sigaction(std.posix.SIG.WINCH, &winch_act, null) catch @panic("could not attach signal WINCH");
|
||||
std.posix.sigaction(std.posix.SIG.WINCH, &winch_act, null);
|
||||
|
||||
try registerWinch(.{
|
||||
.context = this,
|
||||
|
||||
@@ -23,12 +23,12 @@ pub fn mergeTaggedUnions(comptime A: type, comptime B: type) type {
|
||||
if (!isTaggedUnion(A) or !isTaggedUnion(B)) {
|
||||
@compileError("Both types for merging tagged unions need to be of type `union(enum)`.");
|
||||
}
|
||||
const a_fields = @typeInfo(A).Union.fields;
|
||||
const a_fields_tag = @typeInfo(A).Union.tag_type.?;
|
||||
const a_enum_fields = @typeInfo(a_fields_tag).Enum.fields;
|
||||
const b_fields = @typeInfo(B).Union.fields;
|
||||
const b_fields_tag = @typeInfo(B).Union.tag_type.?;
|
||||
const b_enum_fields = @typeInfo(b_fields_tag).Enum.fields;
|
||||
const a_fields = @typeInfo(A).@"union".fields;
|
||||
const a_fields_tag = @typeInfo(A).@"union".tag_type.?;
|
||||
const a_enum_fields = @typeInfo(a_fields_tag).@"enum".fields;
|
||||
const b_fields = @typeInfo(B).@"union".fields;
|
||||
const b_fields_tag = @typeInfo(B).@"union".tag_type.?;
|
||||
const b_enum_fields = @typeInfo(b_fields_tag).@"enum".fields;
|
||||
var fields: [a_fields.len + b_fields.len]std.builtin.Type.UnionField = undefined;
|
||||
var enum_fields: [a_fields.len + b_fields.len]std.builtin.Type.EnumField = undefined;
|
||||
var i: usize = 0;
|
||||
@@ -49,19 +49,19 @@ pub fn mergeTaggedUnions(comptime A: type, comptime B: type) type {
|
||||
|
||||
const log2_i = @bitSizeOf(@TypeOf(i)) - @clz(i);
|
||||
|
||||
const EventType = @Type(.{ .Int = .{
|
||||
const EventType = @Type(.{ .int = .{
|
||||
.signedness = .unsigned,
|
||||
.bits = log2_i,
|
||||
} });
|
||||
|
||||
const Event = @Type(.{ .Enum = .{
|
||||
const Event = @Type(.{ .@"enum" = .{
|
||||
.tag_type = EventType,
|
||||
.fields = enum_fields[0..],
|
||||
.decls = &.{},
|
||||
.is_exhaustive = true,
|
||||
} });
|
||||
|
||||
return @Type(.{ .Union = .{
|
||||
return @Type(.{ .@"union" = .{
|
||||
.layout = .auto,
|
||||
.tag_type = Event,
|
||||
.fields = fields[0..],
|
||||
@@ -72,7 +72,7 @@ pub fn mergeTaggedUnions(comptime A: type, comptime B: type) type {
|
||||
// Determine at `comptime` whether the provided type `E` is an `union(enum)`.
|
||||
pub fn isTaggedUnion(comptime E: type) bool {
|
||||
switch (@typeInfo(E)) {
|
||||
.Union => |u| {
|
||||
.@"union" => |u| {
|
||||
if (u.tag_type) |_| {} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
if (!isTaggedUnion(Element)) {
|
||||
@compileError("Provided type `Element` for `Layout(comptime Event: type, comptime Element: type, comptime Renderer: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[0].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[0].name);
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[1].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[1].name);
|
||||
}
|
||||
const Events = std.ArrayList(Event);
|
||||
return struct {
|
||||
|
||||
@@ -20,19 +20,19 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
if (!isTaggedUnion(Element)) {
|
||||
@compileError("Provided type `Element` for `Layout(comptime Event: type, comptime Element: type, comptime Renderer: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[0].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[0].name);
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[1].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[1].name);
|
||||
}
|
||||
const Container = struct {
|
||||
element: Element,
|
||||
container_size: u8, // 0 - 100 %
|
||||
};
|
||||
const Containers = std.ArrayList(Container);
|
||||
const LayoutType = @typeInfo(Element).Union.fields[0].type;
|
||||
const WidgetType = @typeInfo(Element).Union.fields[1].type;
|
||||
const LayoutType = @typeInfo(Element).@"union".fields[0].type;
|
||||
const WidgetType = @typeInfo(Element).@"union".fields[1].type;
|
||||
const Events = std.ArrayList(Event);
|
||||
return struct {
|
||||
// TODO: current focused `Element`?
|
||||
@@ -43,20 +43,20 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
pub fn init(allocator: std.mem.Allocator, children: anytype) @This() {
|
||||
const ArgsType = @TypeOf(children);
|
||||
const args_type_info = @typeInfo(ArgsType);
|
||||
if (args_type_info != .Struct) {
|
||||
if (args_type_info != .@"struct") {
|
||||
@compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));
|
||||
}
|
||||
comptime var total_size = 0;
|
||||
const fields_info = args_type_info.Struct.fields;
|
||||
var containers = Containers.initCapacity(allocator, fields_info.len) catch @panic("OOM");
|
||||
const fields_info = args_type_info.@"struct".fields;
|
||||
var containers = Containers.initCapacity(allocator, fields_info.len) catch @panic("HContainer.zig: out of memory");
|
||||
inline for (comptime fields_info) |field| {
|
||||
const child = @field(children, field.name);
|
||||
const ChildType = @TypeOf(child);
|
||||
const child_type_info = @typeInfo(ChildType);
|
||||
if (child_type_info != .Struct) {
|
||||
if (child_type_info != .@"struct") {
|
||||
@compileError("expected tuple or struct as child type, found " ++ @typeName(ChildType));
|
||||
}
|
||||
const child_fields = child_type_info.Struct.fields;
|
||||
const child_fields = child_type_info.@"struct".fields;
|
||||
if (child_fields.len != 2) {
|
||||
@compileError("expected nested tuple or struct to have exactly 2 fields, but found " ++ child_fields.len);
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
if (!isTaggedUnion(Element)) {
|
||||
@compileError("Provided type `Element` for `Layout(comptime Event: type, comptime Element: type, comptime Renderer: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[0].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[0].name);
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[1].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[1].name);
|
||||
}
|
||||
const Elements = std.ArrayList(Element);
|
||||
const LayoutType = @typeInfo(Element).Union.fields[0].type;
|
||||
const WidgetType = @typeInfo(Element).Union.fields[1].type;
|
||||
const LayoutType = @typeInfo(Element).@"union".fields[0].type;
|
||||
const WidgetType = @typeInfo(Element).@"union".fields[1].type;
|
||||
const Events = std.ArrayList(Event);
|
||||
return struct {
|
||||
// TODO: current focused `Element`?
|
||||
@@ -37,11 +37,11 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
pub fn init(allocator: std.mem.Allocator, children: anytype) @This() {
|
||||
const ArgsType = @TypeOf(children);
|
||||
const args_type_info = @typeInfo(ArgsType);
|
||||
if (args_type_info != .Struct) {
|
||||
if (args_type_info != .@"struct") {
|
||||
@compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));
|
||||
}
|
||||
const fields_info = args_type_info.Struct.fields;
|
||||
var elements = Elements.initCapacity(allocator, fields_info.len) catch @panic("OOM");
|
||||
const fields_info = args_type_info.@"struct".fields;
|
||||
var elements = Elements.initCapacity(allocator, fields_info.len) catch @panic("HStack.zig: out of memory");
|
||||
inline for (comptime fields_info) |field| {
|
||||
const child = @field(children, field.name);
|
||||
const ChildType = @TypeOf(child);
|
||||
|
||||
@@ -18,11 +18,11 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
if (!isTaggedUnion(Element)) {
|
||||
@compileError("Provided type `Element` for `Layout(comptime Event: type, comptime Element: type, comptime Renderer: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[0].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[0].name);
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[1].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[1].name);
|
||||
}
|
||||
const Events = std.ArrayList(Event);
|
||||
return struct {
|
||||
@@ -33,7 +33,7 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
config: Config = undefined,
|
||||
|
||||
const Config = struct {
|
||||
margin: ?u8 = undefined,
|
||||
margin: ?u8 = null,
|
||||
left: u8 = 0,
|
||||
right: u8 = 0,
|
||||
top: u8 = 0,
|
||||
|
||||
@@ -18,11 +18,11 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
if (!isTaggedUnion(Element)) {
|
||||
@compileError("Provided type `Element` for `Layout(comptime Event: type, comptime Element: type, comptime Renderer: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[0].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[0].name);
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[1].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[1].name);
|
||||
}
|
||||
const Events = std.ArrayList(Event);
|
||||
return struct {
|
||||
@@ -33,7 +33,7 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
config: Config = undefined,
|
||||
|
||||
const Config = struct {
|
||||
padding: ?u16 = undefined,
|
||||
padding: ?u16 = null,
|
||||
left: u16 = 0,
|
||||
right: u16 = 0,
|
||||
top: u16 = 0,
|
||||
|
||||
@@ -20,19 +20,19 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
if (!isTaggedUnion(Element)) {
|
||||
@compileError("Provided type `Element` for `Layout(comptime Event: type, comptime Element: type, comptime Renderer: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[0].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[0].name);
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[1].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[1].name);
|
||||
}
|
||||
const Container = struct {
|
||||
element: Element,
|
||||
container_size: u8, // 0 - 100 %
|
||||
};
|
||||
const Containers = std.ArrayList(Container);
|
||||
const LayoutType = @typeInfo(Element).Union.fields[0].type;
|
||||
const WidgetType = @typeInfo(Element).Union.fields[1].type;
|
||||
const LayoutType = @typeInfo(Element).@"union".fields[0].type;
|
||||
const WidgetType = @typeInfo(Element).@"union".fields[1].type;
|
||||
const Events = std.ArrayList(Event);
|
||||
return struct {
|
||||
// TODO: current focused `Element`?
|
||||
@@ -43,20 +43,20 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
pub fn init(allocator: std.mem.Allocator, children: anytype) @This() {
|
||||
const ArgsType = @TypeOf(children);
|
||||
const args_type_info = @typeInfo(ArgsType);
|
||||
if (args_type_info != .Struct) {
|
||||
if (args_type_info != .@"struct") {
|
||||
@compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));
|
||||
}
|
||||
comptime var total_size = 0;
|
||||
const fields_info = args_type_info.Struct.fields;
|
||||
var containers = Containers.initCapacity(allocator, fields_info.len) catch @panic("OOM");
|
||||
const fields_info = args_type_info.@"struct".fields;
|
||||
var containers = Containers.initCapacity(allocator, fields_info.len) catch @panic("VContainer.zig: out of memory");
|
||||
inline for (comptime fields_info) |field| {
|
||||
const child = @field(children, field.name);
|
||||
const ChildType = @TypeOf(child);
|
||||
const child_type_info = @typeInfo(ChildType);
|
||||
if (child_type_info != .Struct) {
|
||||
if (child_type_info != .@"struct") {
|
||||
@compileError("expected tuple or struct as child type, found " ++ @typeName(ChildType));
|
||||
}
|
||||
const child_fields = child_type_info.Struct.fields;
|
||||
const child_fields = child_type_info.@"struct".fields;
|
||||
if (child_fields.len != 2) {
|
||||
@compileError("expected nested tuple or struct to have exactly 2 fields, but found " ++ child_fields.len);
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
if (!isTaggedUnion(Element)) {
|
||||
@compileError("Provided type `Element` for `Layout(comptime Event: type, comptime Element: type, comptime Renderer: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[0].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[0].name, "layout")) {
|
||||
@compileError("Expected `layout: Layout` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[0].name);
|
||||
}
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).Union.fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).Union.fields[1].name);
|
||||
if (!std.mem.eql(u8, @typeInfo(Element).@"union".fields[1].name, "widget")) {
|
||||
@compileError("Expected `widget: Widget` to be the first union element, but has name: " ++ @typeInfo(Element).@"union".fields[1].name);
|
||||
}
|
||||
const Elements = std.ArrayList(Element);
|
||||
const LayoutType = @typeInfo(Element).Union.fields[0].type;
|
||||
const WidgetType = @typeInfo(Element).Union.fields[1].type;
|
||||
const LayoutType = @typeInfo(Element).@"union".fields[0].type;
|
||||
const WidgetType = @typeInfo(Element).@"union".fields[1].type;
|
||||
const Events = std.ArrayList(Event);
|
||||
return struct {
|
||||
// TODO: current focused `Element`?
|
||||
@@ -37,11 +37,11 @@ pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: t
|
||||
pub fn init(allocator: std.mem.Allocator, children: anytype) @This() {
|
||||
const ArgsType = @TypeOf(children);
|
||||
const args_type_info = @typeInfo(ArgsType);
|
||||
if (args_type_info != .Struct) {
|
||||
if (args_type_info != .@"struct") {
|
||||
@compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));
|
||||
}
|
||||
const fields_info = args_type_info.Struct.fields;
|
||||
var elements = Elements.initCapacity(allocator, fields_info.len) catch @panic("OOM");
|
||||
const fields_info = args_type_info.@"struct".fields;
|
||||
var elements = Elements.initCapacity(allocator, fields_info.len) catch @panic("VStack.zig out of memory");
|
||||
inline for (comptime fields_info) |field| {
|
||||
const child = @field(children, field.name);
|
||||
const ChildType = @TypeOf(child);
|
||||
|
||||
@@ -20,7 +20,7 @@ pub const ReportMode = enum {
|
||||
pub fn getTerminalSize() Size {
|
||||
var ws: std.posix.winsize = undefined;
|
||||
_ = std.posix.system.ioctl(std.posix.STDIN_FILENO, std.posix.T.IOCGWINSZ, @intFromPtr(&ws));
|
||||
return .{ .cols = ws.ws_col, .rows = ws.ws_row };
|
||||
return .{ .cols = ws.col, .rows = ws.row };
|
||||
}
|
||||
|
||||
pub fn saveScreen() !void {
|
||||
|
||||
Reference in New Issue
Block a user