diff --git a/src/terminfo.zig b/src/terminfo.zig index b1b5025..cd52da4 100644 --- a/src/terminfo.zig +++ b/src/terminfo.zig @@ -188,10 +188,44 @@ bools: std.StringHashMap(bool), ints: std.StringHashMap(u32), 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 { 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 { // info: *Self, // bytes: std.ArrayList(u8),