add more defaults and make it more presentable

This commit is contained in:
Jeeves 2024-04-05 18:23:58 -06:00
parent 9f0c0d4afb
commit 1d59e48a4f
2 changed files with 34 additions and 3 deletions

View file

@ -14,16 +14,22 @@ pub fn main() !void {
var term = try Terminal.init(allocator); var term = try Terminal.init(allocator);
defer term.deinit(); defer term.deinit();
try term.print("poopoo", .{}); try term.clearScreen();
try term.print("fooboo", .{});
try term.cursorLeft(); try term.cursorLeft();
try term.cursorLeft(); try term.cursorLeft();
try term.print("ee", .{}); try term.print("ar", .{});
// try term.cursorSet(12, 3); // try term.cursorSet(12, 3);
try term.blinkOn();
try term.boldOn(); try term.boldOn();
try term.underlineOn(); try term.underlineOn();
try term.print("AAAAAAAAAAAAAAAAAAA", .{}); try term.italicsOn();
try term.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ", .{});
try term.blinkOff();
try term.boldOff(); try term.boldOff();
try term.underlineOff(); try term.underlineOff();
try term.italicsOff();
try term.print("eeheeveehee\n", .{});
} }
pub const Terminal = struct { pub const Terminal = struct {
@ -138,6 +144,10 @@ pub const Terminal = struct {
try self.info.writeString(.exit_underline_mode, self.tty.writer(), &[_]u32{}); try self.info.writeString(.exit_underline_mode, self.tty.writer(), &[_]u32{});
} }
pub fn clearScreen(self: *Terminal) !void {
try self.info.writeString(.clear_screen, self.tty.writer(), &[_]u32{});
}
pub const Info = @import("terminfo.zig"); pub const Info = @import("terminfo.zig");
pub const SpecialKey = enum(u16) { pub const SpecialKey = enum(u16) {

View file

@ -413,13 +413,17 @@ pub const String = enum {
exit_am_mode, exit_am_mode,
exit_attribute_mode, exit_attribute_mode,
exit_ca_mode, exit_ca_mode,
exit_blink_mode,
exit_bold_mode, exit_bold_mode,
exit_dim_mode,
exit_delete_mode, exit_delete_mode,
exit_doublewide_mode, exit_doublewide_mode,
exit_insert_mode, exit_insert_mode,
exit_italics_mode, exit_italics_mode,
exit_leftward_mode, exit_leftward_mode,
exit_micro_mode, exit_micro_mode,
exit_reverse_mode,
exit_secure_mode,
exit_shadow_mode, exit_shadow_mode,
exit_standout_mode, exit_standout_mode,
exit_subscript_mode, exit_subscript_mode,
@ -607,13 +611,17 @@ pub const String = enum {
.exit_am_mode => "rmam", .exit_am_mode => "rmam",
.exit_attribute_mode => "sgr0", .exit_attribute_mode => "sgr0",
.exit_ca_mode => "rmcup", .exit_ca_mode => "rmcup",
.exit_blink_mode => null,
.exit_bold_mode => null, .exit_bold_mode => null,
.exit_dim_mode => null,
.exit_delete_mode => "rmdc", .exit_delete_mode => "rmdc",
.exit_doublewide_mode => "rwidm", .exit_doublewide_mode => "rwidm",
.exit_insert_mode => "rmir", .exit_insert_mode => "rmir",
.exit_italics_mode => "ritm", .exit_italics_mode => "ritm",
.exit_leftward_mode => "rlm", .exit_leftward_mode => "rlm",
.exit_micro_mode => "rmicm", .exit_micro_mode => "rmicm",
.exit_reverse_mode => null,
.exit_secure_mode => null,
.exit_shadow_mode => "rshm", .exit_shadow_mode => "rshm",
.exit_standout_mode => "rmso", .exit_standout_mode => "rmso",
.exit_subscript_mode => "rsubm", .exit_subscript_mode => "rsubm",
@ -735,7 +743,20 @@ pub const String = enum {
pub fn default(self: String) ?[]const u8 { pub fn default(self: String) ?[]const u8 {
return switch (self) { return switch (self) {
.enter_bold_mode => "\x1b[1m",
.enter_dim_mode => "\x1b[2m",
.enter_italics_mode => "\x1b[3m",
.enter_underline_mode => "\x1b[4m",
.enter_blink_mode => "\x1b[5m",
.enter_reverse_mode => "\x1b[7m",
.enter_secure_mode => "\x1b[8m",
.exit_bold_mode => "\x1b[22m", .exit_bold_mode => "\x1b[22m",
.exit_dim_mode => "\x1b[22m",
.exit_italics_mode => "\x1b[23m",
.exit_underline_mode => "\x1b[24m",
.exit_blink_mode => "\x1b[25m",
.exit_reverse_mode => "\x1b[27m",
.exit_secure_mode => "\x1b[28m",
else => null, else => null,
}; };
} }