mod(app): remove interupt method, merged with stop
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m13s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m13s
This commit is contained in:
@@ -147,8 +147,8 @@ pub fn main() !void {
|
||||
if (key.eql(.{ .cp = 'c', .mod = .{ .ctrl = true } })) app.quit();
|
||||
|
||||
if (key.eql(.{ .cp = 'n', .mod = .{ .ctrl = true } })) {
|
||||
try app.interrupt();
|
||||
renderer.size = .{}; // reset size, such that next resize will cause a full re-draw!
|
||||
try app.stop();
|
||||
defer renderer.clear() catch @panic("could not clear the screen");
|
||||
defer app.start(.full) catch @panic("could not start app event loop");
|
||||
var child = std.process.Child.init(&.{"vim"}, allocator);
|
||||
_ = child.spawnAndWait() catch |err| app.postEvent(.{
|
||||
@@ -157,7 +157,6 @@ pub fn main() !void {
|
||||
.msg = "Spawning $EDITOR failed",
|
||||
},
|
||||
});
|
||||
continue;
|
||||
}
|
||||
},
|
||||
// NOTE errors could be displayed in another container in case one was received, etc. to provide the user with feedback
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const QuitText = struct {
|
||||
const text = "Press ctrl+c to quit.";
|
||||
const text = "Press ctrl+c or ctrl+d to quit.";
|
||||
|
||||
pub fn element(this: *@This()) App.Element {
|
||||
return .{
|
||||
@@ -142,13 +142,16 @@ pub fn main() !void {
|
||||
|
||||
// handle events
|
||||
for (0..len) |_| {
|
||||
const event = app.queue.pop();
|
||||
const event = app.queue.drain().?;
|
||||
log.debug("received event: {s}", .{@tagName(event)});
|
||||
|
||||
// pre event handling
|
||||
switch (event) {
|
||||
// NOTE draw the character with the ctrl indication and a newline to make sure the rendering stays consistent
|
||||
.cancel => try renderer.writeCtrlDWithNewline(),
|
||||
.cancel => {
|
||||
app.quit();
|
||||
break :event;
|
||||
},
|
||||
.line => |line| {
|
||||
defer gpa.free(line);
|
||||
log.debug("{s}", .{line});
|
||||
@@ -165,15 +168,7 @@ pub fn main() !void {
|
||||
.msg = "Container Event handling failed",
|
||||
},
|
||||
});
|
||||
|
||||
// post event handling
|
||||
switch (event) {
|
||||
.quit => break :event,
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
// if there are more events to process continue handling them otherwise I can render the next frame
|
||||
if (app.queue.len() > 0) continue :event;
|
||||
|
||||
container.resize(&app.model, try renderer.resize());
|
||||
container.reposition(&app.model, .{});
|
||||
|
||||
Reference in New Issue
Block a user