ref(ctlseqs): use control sequence file; rename key names
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 46s

This commit is contained in:
2025-02-17 23:08:47 +01:00
parent a9f48bfb6a
commit c2080ab40f
4 changed files with 87 additions and 75 deletions

View File

@@ -1,5 +1,6 @@
const std = @import("std");
pub const code_point = @import("code_point");
const ctlseqs = @import("ctlseqs.zig");
const Key = @import("key.zig").Key;
const Position = @import("size.zig").Position;
@@ -25,35 +26,43 @@ pub fn getTerminalSize() Size {
}
pub fn saveScreen() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[?47h");
_ = try std.posix.write(std.posix.STDIN_FILENO, ctlseqs.save_screen);
}
pub fn restoreScreen() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[?47l");
_ = try std.posix.write(std.posix.STDIN_FILENO, ctlseqs.restore_screen);
}
pub fn enterAltScreen() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[?1049h");
_ = try std.posix.write(std.posix.STDIN_FILENO, ctlseqs.smcup);
}
pub fn exitAltScreen() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[?1049l");
_ = try std.posix.write(std.posix.STDIN_FILENO, ctlseqs.rmcup);
}
pub fn clearScreen() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[2J");
_ = try std.posix.write(std.posix.STDIN_FILENO, ctlseqs.clear_screen);
}
pub fn hideCursor() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[?25l");
_ = try std.posix.write(std.posix.STDIN_FILENO, ctlseqs.hide_cursor);
}
pub fn showCursor() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[?25h");
_ = try std.posix.write(std.posix.STDIN_FILENO, ctlseqs.show_cursor);
}
pub fn setCursorPositionHome() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, "\x1b[H");
_ = try std.posix.write(std.posix.STDIN_FILENO, ctlseqs.home);
}
pub fn enableMouseSupport() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, ctlseqs.mouse_set);
}
pub fn disableMouseSupport() !void {
_ = try std.posix.write(std.posix.STDIN_FILENO, ctlseqs.mouse_reset);
}
pub fn read(buf: []u8) !usize {