add some terminal helpers
This commit is contained in:
parent
8b8dcce24e
commit
5b6395e864
1 changed files with 34 additions and 0 deletions
|
@ -188,10 +188,44 @@ bools: std.StringHashMap(bool),
|
||||||
ints: std.StringHashMap(u32),
|
ints: std.StringHashMap(u32),
|
||||||
strings: std.StringHashMap([]const u8),
|
strings: std.StringHashMap([]const u8),
|
||||||
|
|
||||||
|
// TODO: move these to a single function taking a tuple for the args
|
||||||
|
|
||||||
|
pub fn clearScreen(self: *Self, writer: anytype) !void {
|
||||||
|
try writer.writeAll(self.strings.get("clear") orelse "\x1b[H\x1b[2J");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clearToLineBegin(self: *Self, writer: anytype) !void {
|
||||||
|
try writer.writeAll(self.strings.get("el1") orelse "\x1b[1K");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clearToLineEnd(self: *Self, writer: anytype) !void {
|
||||||
|
try writer.writeAll(self.strings.get("el") orelse "\x1b[K");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clearToScreenEnd(self: *Self, writer: anytype) !void {
|
||||||
|
try writer.writeAll(self.strings.get("ed") orelse "\x1b[J");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cursorHome(self: *Self, writer: anytype) !void {
|
||||||
|
try writer.writeAll(self.strings.get("home") orelse "\x1b[H");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cursorDown(self: *Self, writer: anytype) !void {
|
||||||
|
try writer.writeAll(self.strings.get("cud1") orelse "\n");
|
||||||
|
}
|
||||||
|
|
||||||
pub fn cursorLeft(self: *Self, writer: anytype) !void {
|
pub fn cursorLeft(self: *Self, writer: anytype) !void {
|
||||||
try writer.writeAll(self.strings.get("cub1") orelse "\x08");
|
try writer.writeAll(self.strings.get("cub1") orelse "\x08");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cursorRight(self: *Self, writer: anytype) !void {
|
||||||
|
try writer.writeAll(self.strings.get("cuf1") orelse "\x1b[C");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cursorUp(self: *Self, writer: anytype) !void {
|
||||||
|
try writer.writeAll(self.strings.get("cuu1") orelse "\x1b[A");
|
||||||
|
}
|
||||||
|
|
||||||
// pub const Sequence = struct {
|
// pub const Sequence = struct {
|
||||||
// info: *Self,
|
// info: *Self,
|
||||||
// bytes: std.ArrayList(u8),
|
// bytes: std.ArrayList(u8),
|
||||||
|
|
Loading…
Add table
Reference in a new issue