authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-09 15:21:23 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-09 15:21:23 -07:00
log09bc7a7c9ed9b42e2fd245c084ecd5323c479081
tree67dca0c152e8e315cfe89047b72c5557f27ba8e1
parent25039cacc478cea1f2613bf69d079dad134e45f7

enforce that params need to be comptime known for make_csi_sequence


1 files changed, 15 insertions(+), 15 deletions(-)

src/lib.zig+15-15
......@@ -52,7 +52,7 @@ pub const escape = struct {
5252 pub const RIS = ascii.ESC.s() ++ "c";
5353};
5454
55fn make_csi_sequence(comptime c: []const u8, x: anytype) []const u8 {
55fn make_csi_sequence(comptime c: []const u8, comptime x: anytype) []const u8 {
5656 return escape.CSI ++ _join(";", arr_i_to_s(x)) ++ c;
5757}
5858
......@@ -65,20 +65,20 @@ fn arr_i_to_s(x: anytype) [][]const u8 {
6565}
6666
6767pub const csi = struct {
68 pub fn CursorUp(n: i32) []const u8 { return make_csi_sequence("A", .{n}); }
69 pub fn CursorDown(n: i32) []const u8 { return make_csi_sequence("B", .{n}); }
70 pub fn CursorForward(n: i32) []const u8 { return make_csi_sequence("C", .{n}); }
71 pub fn CursorBack(n: i32) []const u8 { return make_csi_sequence("D", .{n}); }
72 pub fn CursorNextLine(n: i32) []const u8 { return make_csi_sequence("E", .{n}); }
73 pub fn CursorPrevLine(n: i32) []const u8 { return make_csi_sequence("F", .{n}); }
74 pub fn CursorHorzAbs(n: i32) []const u8 { return make_csi_sequence("G", .{n}); }
75 pub fn CursorPos(n: i32, m: i32) []const u8 { return make_csi_sequence("H", .{n, m}); }
76 pub fn EraseInDisplay(n: i32) []const u8 { return make_csi_sequence("J", .{n}); }
77 pub fn EraseInLine(n: i32) []const u8 { return make_csi_sequence("K", .{n}); }
78 pub fn ScrollUp(n: i32) []const u8 { return make_csi_sequence("S", .{n}); }
79 pub fn ScrollDown(n: i32) []const u8 { return make_csi_sequence("T", .{n}); }
80 pub fn HorzVertPos(n: i32, m: i32) []const u8 { return make_csi_sequence("f", .{n, m}); }
81 pub fn SGR(ns: anytype) []const u8 { return make_csi_sequence("m", ns); }
68 pub fn CursorUp(comptime n: i32) []const u8 { return make_csi_sequence("A", .{n}); }
69 pub fn CursorDown(comptime n: i32) []const u8 { return make_csi_sequence("B", .{n}); }
70 pub fn CursorForward(comptime n: i32) []const u8 { return make_csi_sequence("C", .{n}); }
71 pub fn CursorBack(comptime n: i32) []const u8 { return make_csi_sequence("D", .{n}); }
72 pub fn CursorNextLine(comptime n: i32) []const u8 { return make_csi_sequence("E", .{n}); }
73 pub fn CursorPrevLine(comptime n: i32) []const u8 { return make_csi_sequence("F", .{n}); }
74 pub fn CursorHorzAbs(comptime n: i32) []const u8 { return make_csi_sequence("G", .{n}); }
75 pub fn CursorPos(comptime n: i32, m: i32) []const u8 { return make_csi_sequence("H", .{n, m}); }
76 pub fn EraseInDisplay(comptime n: i32) []const u8 { return make_csi_sequence("J", .{n}); }
77 pub fn EraseInLine(comptime n: i32) []const u8 { return make_csi_sequence("K", .{n}); }
78 pub fn ScrollUp(comptime n: i32) []const u8 { return make_csi_sequence("S", .{n}); }
79 pub fn ScrollDown(comptime n: i32) []const u8 { return make_csi_sequence("T", .{n}); }
80 pub fn HorzVertPos(comptime n: i32, m: i32) []const u8 { return make_csi_sequence("f", .{n, m}); }
81 pub fn SGR(comptime ns: anytype) []const u8 { return make_csi_sequence("m", ns); }
8282};
8383
8484pub const style = struct {