mod(app): automatically hide cursor when running fullscreen tui's
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 37s

This commit is contained in:
2024-11-11 13:32:39 +01:00
parent 1544a4d2ff
commit 8b3f863404
2 changed files with 10 additions and 0 deletions

View File

@@ -89,6 +89,7 @@ pub fn App(comptime E: type, comptime R: fn (comptime bool) type, comptime fulls
if (fullscreen) {
try terminal.saveScreen();
try terminal.enterAltScreen();
try terminal.hideCursor();
}
}
@@ -109,6 +110,7 @@ pub fn App(comptime E: type, comptime R: fn (comptime bool) type, comptime fulls
if (this.termios) |*termios| {
try terminal.disableRawMode(termios);
if (fullscreen) {
try terminal.showCursor();
try terminal.existAltScreen();
try terminal.restoreScreen();
}

View File

@@ -43,6 +43,14 @@ pub fn clearScreen() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[2J");
}
pub fn hideCursor() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[?25l");
}
pub fn showCursor() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[?25h");
}
pub fn setCursorPositionHome() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[H");
}