add: signal handling WINCH, user input thread with waiting blocking
This commit is contained in:
@@ -1,26 +1,27 @@
|
||||
const std = @import("std");
|
||||
const lib_event = @import("../event.zig");
|
||||
const widget = @import("../widget.zig");
|
||||
const isTaggedUnion = @import("../event.zig").isTaggedUnion;
|
||||
const Error = @import("../event.zig").Error;
|
||||
|
||||
pub fn Layout(comptime Event: type) type {
|
||||
if (!lib_event.isTaggedUnion(Event)) {
|
||||
if (!isTaggedUnion(Event)) {
|
||||
@compileError("Provided user event `Event` for `Layout(comptime Event: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
const Widget = @import("../widget.zig").Widget(Event);
|
||||
return struct {
|
||||
w: widget.Widget(Event) = undefined,
|
||||
widget: Widget = undefined,
|
||||
events: std.ArrayList(Event) = undefined,
|
||||
c: std.ArrayList(u8) = undefined,
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator, w: widget.Widget(Event)) @This() {
|
||||
pub fn init(allocator: std.mem.Allocator, widget: Widget) @This() {
|
||||
return .{
|
||||
.w = w,
|
||||
.widget = widget,
|
||||
.events = std.ArrayList(Event).init(allocator),
|
||||
.c = std.ArrayList(u8).init(allocator),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn deinit(this: *@This()) void {
|
||||
this.w.deinit();
|
||||
this.widget.deinit();
|
||||
this.events.deinit();
|
||||
this.c.deinit();
|
||||
this.* = undefined;
|
||||
@@ -28,14 +29,14 @@ pub fn Layout(comptime Event: type) type {
|
||||
|
||||
pub fn handle(this: *@This(), event: Event) !*std.ArrayList(Event) {
|
||||
this.events.clearRetainingCapacity();
|
||||
if (this.w.handle(event)) |e| {
|
||||
if (this.widget.handle(event)) |e| {
|
||||
try this.events.append(e);
|
||||
}
|
||||
return &this.events;
|
||||
}
|
||||
|
||||
pub fn content(this: *@This()) !*std.ArrayList(u8) {
|
||||
const widget_content = try this.w.content();
|
||||
const widget_content = try this.widget.content();
|
||||
this.c.clearRetainingCapacity();
|
||||
try this.c.appendSlice(widget_content.items);
|
||||
return &this.c;
|
||||
|
||||
Reference in New Issue
Block a user