WIP make example interactive

Handle inputs as per usual (which however is a bit weak, is it goes through
key by key and not the entire line), batch all events such that all events
are handled before the next frame is rendered. For this the `App.start`
function needs to become configurable, such that it changes the termios as
configured (hence it is currently all commented out for testing).
This commit is contained in:
2026-01-20 11:54:28 +01:00
parent 4a3bec3edc
commit c29c60bd89
2 changed files with 65 additions and 14 deletions

View File

@@ -71,21 +71,21 @@ pub fn App(comptime M: type, comptime E: type) type {
this.quit_event.reset();
this.thread = try Thread.spawn(.{}, @This().run, .{this});
var termios: posix.termios = undefined;
try terminal.enableRawMode(&termios);
if (this.termios) |_| {} else this.termios = termios;
//var termios: posix.termios = undefined;
//try terminal.enableRawMode(&termios);
//if (this.termios) |_| {} else this.termios = termios;
try terminal.enterAltScreen();
try terminal.saveScreen();
try terminal.hideCursor();
try terminal.enableMouseSupport();
//try terminal.enterAltScreen();
//try terminal.saveScreen();
//try terminal.hideCursor();
//try terminal.enableMouseSupport();
}
pub fn interrupt(this: *@This()) !void {
this.quit_event.set();
try terminal.disableMouseSupport();
try terminal.restoreScreen();
try terminal.exitAltScreen();
//try terminal.disableMouseSupport();
//try terminal.restoreScreen();
//try terminal.exitAltScreen();
if (this.thread) |*thread| {
thread.join();
this.thread = null;