wip: Apparently we need to clear before printing to get text aligned with image
This commit is contained in:
parent
e85a085e41
commit
4368ac677e
3 changed files with 10 additions and 12 deletions
|
@ -34,7 +34,7 @@ pub fn macos_version(allocator: std.mem.Allocator) ![]const u8 {
|
||||||
|
|
||||||
const koko = info.msgSend(NSOperatingSystemVersion, "operatingSystemVersion", .{});
|
const koko = info.msgSend(NSOperatingSystemVersion, "operatingSystemVersion", .{});
|
||||||
|
|
||||||
const buf = try std.fmt.allocPrint(allocator, "\n\t\t\tOS: {s} {d}.{d}.{d}", .{ version_to_name(koko), koko.major, koko.minor, koko.patch });
|
const buf = try std.fmt.allocPrint(allocator, "\t\t\tOS: {s} {d}.{d}.{d}\n", .{ version_to_name(koko), koko.major, koko.minor, koko.patch });
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,10 @@ pub fn macos_kernel_version(allocator: std.mem.Allocator) ![]const u8 {
|
||||||
return error.UnameFailed;
|
return error.UnameFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
const kaka = std.mem.span(@ptrCast(name.sysname));
|
const sysname = std.mem.sliceTo(name.sysname[0..], 0);
|
||||||
|
const version = std.mem.sliceTo(name.release[0..], 0);
|
||||||
|
|
||||||
const buf = try std.fmt.allocPrint(allocator, "\n\t\t\tKernel: {s} {s}", .{ kaka, name.version });
|
const buf = try std.fmt.allocPrint(allocator, "\t\t\tKernel: {s} {s}\n", .{ sysname, version });
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
13
src/main.zig
13
src/main.zig
|
@ -36,7 +36,7 @@ pub fn main() !void {
|
||||||
const kernel = try macos.macos_kernel_version(allocator);
|
const kernel = try macos.macos_kernel_version(allocator);
|
||||||
defer allocator.free(kernel);
|
defer allocator.free(kernel);
|
||||||
|
|
||||||
// try tty.anyWriter().writeAll(vaxis.ctlseqs.kitty_graphics_clear);
|
try tty.anyWriter().writeAll("\x1bc");
|
||||||
try tty.anyWriter().writeAll(vaxis.ctlseqs.unicode_set);
|
try tty.anyWriter().writeAll(vaxis.ctlseqs.unicode_set);
|
||||||
defer vx.queryTerminalSend(tty.anyWriter()) catch {};
|
defer vx.queryTerminalSend(tty.anyWriter()) catch {};
|
||||||
defer tty.anyWriter().writeAll(vaxis.ctlseqs.unicode_reset) catch {};
|
defer tty.anyWriter().writeAll(vaxis.ctlseqs.unicode_reset) catch {};
|
||||||
|
@ -57,6 +57,7 @@ pub fn main() !void {
|
||||||
// const koko = try vx.transmitImage(allocator, tty.anyWriter(), &img1, .png);
|
// const koko = try vx.transmitImage(allocator, tty.anyWriter(), &img1, .png);
|
||||||
// win.hideCursor();
|
// win.hideCursor();
|
||||||
// win.showCursor(10, 1);
|
// win.showCursor(10, 1);
|
||||||
|
|
||||||
const system_info = [_]vaxis.Cell.Segment{
|
const system_info = [_]vaxis.Cell.Segment{
|
||||||
.{ .text = os },
|
.{ .text = os },
|
||||||
.{ .text = kernel },
|
.{ .text = kernel },
|
||||||
|
@ -70,14 +71,11 @@ pub fn main() !void {
|
||||||
.{ .text = "\t\t\tKernel: lalal\n" },
|
.{ .text = "\t\t\tKernel: lalal\n" },
|
||||||
};
|
};
|
||||||
try root.kitty_image_inline_copy(allocator, tty.anyWriter(), "/Users/kc/Sync/Images/apple-dark.png");
|
try root.kitty_image_inline_copy(allocator, tty.anyWriter(), "/Users/kc/Sync/Images/apple-dark.png");
|
||||||
try tty.anyWriter().print("\x1b[10;1H", .{});
|
|
||||||
try tty.anyWriter().print("\r\t\tTEST: testest\n", .{});
|
|
||||||
try tty.anyWriter().print("\r\t\tTEST: testest\n", .{});
|
|
||||||
try tty.anyWriter().print("\r\t\tTEST: testest\n", .{});
|
|
||||||
try tty.anyWriter().print("\r\t\tTEST: testest\n", .{});
|
|
||||||
try tty.anyWriter().print("\r\t\tTEST: testest\n", .{});
|
|
||||||
|
|
||||||
result = try win.print(&system_info, .{ .wrap = .word });
|
result = try win.print(&system_info, .{ .wrap = .word });
|
||||||
|
// printf '\e[%sA\e[9999999D' "${lines:-0}"
|
||||||
|
try tty.anyWriter().print("\x1b[{d}A\x1b[9999999D", .{winsize.rows});
|
||||||
|
// try tty.anyWriter().writeAll("\x1b[1J");
|
||||||
|
|
||||||
try vx.prettyPrint(writer);
|
try vx.prettyPrint(writer);
|
||||||
// const dimensions = try koko.cellSize(win);
|
// const dimensions = try koko.cellSize(win);
|
||||||
|
@ -92,7 +90,6 @@ pub fn main() !void {
|
||||||
// try vx.queryTerminalSend(tty.anyWriter());
|
// try vx.queryTerminalSend(tty.anyWriter());
|
||||||
|
|
||||||
// Clear from cursor to beginning of the screen
|
// Clear from cursor to beginning of the screen
|
||||||
// try stdout.writeAll("\x1b[1J");
|
|
||||||
// Move cursor to the upper left corner of the screen
|
// Move cursor to the upper left corner of the screen
|
||||||
// try stdout.writeAll("\x1b[1;1H");
|
// try stdout.writeAll("\x1b[1;1H");
|
||||||
// try stdout_file.writeAll("\x1b[9B");
|
// try stdout_file.writeAll("\x1b[9B");
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub fn kitty_image_inline_copy(allocator: std.mem.Allocator, tty: std.io.AnyWrit
|
||||||
const encoded = base64Encoder.encode(b64_buf, path);
|
const encoded = base64Encoder.encode(b64_buf, path);
|
||||||
|
|
||||||
try tty.print("\x1b_Ga=T,q=2,f=100,t=f,p=0,s=267,v=314;{s}\x1b\\", .{encoded});
|
try tty.print("\x1b_Ga=T,q=2,f=100,t=f,p=0,s=267,v=314;{s}\x1b\\", .{encoded});
|
||||||
try tty.print("\x1b\\", .{});
|
// try tty.print("\x1b\\", .{});
|
||||||
|
|
||||||
// if (encoded.len <= 4096) {
|
// if (encoded.len <= 4096) {
|
||||||
// try tty.print("\x1b_Ga=T,q=2,f=100,t=f,s=267,v=314,m=1;{s}\x1b\\", .{encoded});
|
// try tty.print("\x1b_Ga=T,q=2,f=100,t=f,s=267,v=314,m=1;{s}\x1b\\", .{encoded});
|
||||||
|
|
Loading…
Reference in a new issue