feat(event): introduce .bell system event
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 16m37s
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 16m37s
This commit is contained in:
@@ -915,6 +915,11 @@ pub fn Container(Model: type, Event: type) type {
|
|||||||
relative_mouse.y -= this.origin.y;
|
relative_mouse.y -= this.origin.y;
|
||||||
try this.element.handle(model, .{ .mouse = relative_mouse });
|
try this.element.handle(model, .{ .mouse = relative_mouse });
|
||||||
},
|
},
|
||||||
|
.bell => {
|
||||||
|
// ring the terminal bell and do not propagate the event any further
|
||||||
|
_ = try terminal.ringBell();
|
||||||
|
return;
|
||||||
|
},
|
||||||
else => try this.element.handle(model, event),
|
else => try this.element.handle(model, event),
|
||||||
}
|
}
|
||||||
for (this.elements.items) |*element| try element.handle(model, event);
|
for (this.elements.items) |*element| try element.handle(model, event);
|
||||||
@@ -961,6 +966,7 @@ const assert = std.debug.assert;
|
|||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const build_options = @import("build_options");
|
const build_options = @import("build_options");
|
||||||
const input = @import("input.zig");
|
const input = @import("input.zig");
|
||||||
|
const terminal = @import("terminal.zig");
|
||||||
const isTaggedUnion = @import("event.zig").isTaggedUnion;
|
const isTaggedUnion = @import("event.zig").isTaggedUnion;
|
||||||
const Cell = @import("cell.zig");
|
const Cell = @import("cell.zig");
|
||||||
const Color = @import("color.zig").Color;
|
const Color = @import("color.zig").Color;
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ pub const SystemEvent = union(enum) {
|
|||||||
/// Usually no `Container` nor `Element` should act on that event, as it
|
/// Usually no `Container` nor `Element` should act on that event, as it
|
||||||
/// only serves for event based loops to force a re-draw with a new `Event`.
|
/// only serves for event based loops to force a re-draw with a new `Event`.
|
||||||
resize,
|
resize,
|
||||||
|
/// Ring the terminal bell to notify the user. This `Event` is handled by
|
||||||
|
/// every `Container` and will not be passed through the container tree.
|
||||||
|
bell,
|
||||||
/// Error event to notify other containers about a recoverable error
|
/// Error event to notify other containers about a recoverable error
|
||||||
err: struct {
|
err: struct {
|
||||||
/// actual error
|
/// actual error
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ pub fn disableMouseSupport() !void {
|
|||||||
_ = try posix.write(posix.STDIN_FILENO, ctlseqs.mouse_reset);
|
_ = try posix.write(posix.STDIN_FILENO, ctlseqs.mouse_reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ringBell() !void {
|
||||||
|
_ = try posix.write(posix.STDIN_FILENO, &.{7});
|
||||||
|
}
|
||||||
|
|
||||||
pub fn read(buf: []u8) !usize {
|
pub fn read(buf: []u8) !usize {
|
||||||
return try posix.read(posix.STDIN_FILENO, buf);
|
return try posix.read(posix.STDIN_FILENO, buf);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user