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:
20
src/app.zig
20
src/app.zig
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user