feat(app): event line provides entire line contents as a single event; add(event): .cancel event
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m5s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m5s
Introduce `.cancel` event that is fired when the user sends EOF in *non raw mode* renderings. The event `.line` now sends the entire line (even if larger than the internal buffer) but requires now an `Allocator`.
This commit is contained in:
@@ -77,7 +77,7 @@ pub fn main() !void {
|
||||
|
||||
const gpa = allocator.allocator();
|
||||
|
||||
var app: App = .init(.{}, .{});
|
||||
var app: App = .init(gpa, .{}, .{});
|
||||
var renderer = zterm.Renderer.Direct.init(gpa);
|
||||
defer renderer.deinit();
|
||||
|
||||
@@ -147,9 +147,10 @@ pub fn main() !void {
|
||||
|
||||
// pre event handling
|
||||
switch (event) {
|
||||
// NOTE maybe I want to decouple the `key`s from the user input too? i.e. this only makes sense if the output is not echoed!
|
||||
// otherwise just use gnu's `readline`?
|
||||
// NOTE draw the character with the ctrl indication and a newline to make sure the rendering stays consistent
|
||||
.cancel => try renderer.writeCtrlDWithNewline(),
|
||||
.line => |line| {
|
||||
defer gpa.free(line);
|
||||
log.debug("{s}", .{line});
|
||||
},
|
||||
// NOTE errors could be displayed in another container in case one was received, etc. to provide the user with feedback
|
||||
|
||||
Reference in New Issue
Block a user