diff --git a/src/macos.zig b/src/macos.zig index b451716..68bbfe7 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -34,7 +34,7 @@ pub fn macos_version(allocator: std.mem.Allocator) ![]const u8 { const koko = info.msgSend(NSOperatingSystemVersion, "operatingSystemVersion", .{}); - 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 }); + const buf = try std.fmt.allocPrint(allocator, " OS: macOS {s} {d}.{d}.{d}\n", .{ version_to_name(koko), koko.major, koko.minor, koko.patch }); return buf; } @@ -49,7 +49,7 @@ pub fn macos_kernel_version(allocator: std.mem.Allocator) ![]const u8 { 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, "\t\t\tKernel: {s} {s}\n", .{ sysname, version }); + const buf = try std.fmt.allocPrint(allocator, " Kernel: {s} {s}\n", .{ sysname, version }); return buf; } diff --git a/src/main.zig b/src/main.zig index 0dac812..1fba685 100644 --- a/src/main.zig +++ b/src/main.zig @@ -36,20 +36,31 @@ pub fn main() !void { const kernel = try macos.macos_kernel_version(allocator); defer allocator.free(kernel); - try tty.anyWriter().writeAll("\x1bc"); + // try tty.anyWriter().writeAll("\x1bc"); + // try tty.anyWriter().writeAll("\x1b[1;1H"); try tty.anyWriter().writeAll(vaxis.ctlseqs.unicode_set); defer vx.queryTerminalSend(tty.anyWriter()) catch {}; defer tty.anyWriter().writeAll(vaxis.ctlseqs.unicode_reset) catch {}; var buf_writer = tty.bufferedWriter(); const writer = buf_writer.writer().any(); - const winsize: vaxis.Winsize = try vaxis.Tty.getWinsize(tty.fd); try vx.resize(allocator, tty.anyWriter(), winsize); const win = vx.window(); - win.clear(); + const koko = try vx.loadImage(allocator, writer, .{ .path = "/Users/kc/Sync/Images/apple-white.png" }); + + const dims = try koko.cellSize(win); + + // const cursor_row = vx.state.cursor.row; + const logo_win = win.child(.{ .y_off = 0, .x_off = 0, .width = .{ .limit = dims.cols + 1 }, .height = .{ .limit = dims.rows + 1 }, .border = .{ .where = .right, .glyphs = .single_rounded, .style = .{ .fg = .{ .index = 15 } } } }); + // const logo_win = win.child(.{ .y_off = 0, .x_off = 0 }); + const info_win = win.child(.{ .y_off = 0, .x_off = dims.cols + 1, .width = .{ .limit = 40 }, .height = .{ .limit = 20 } }); + + logo_win.clear(); + info_win.clear(); + var result: vaxis.Window.PrintResult = .{ .col = 0, .row = 0, .overflow = false }; // try tty.anyWriter().writeAll(vaxis.ctlseqs.kitty_graphics_query); // var img1 = try vaxis.zigimg.Image.fromFilePath(allocator, "/Users/kc/Sync/Images/apple-white.png"); @@ -61,20 +72,21 @@ pub fn main() !void { const system_info = [_]vaxis.Cell.Segment{ .{ .text = os }, .{ .text = kernel }, - .{ .text = "\t\t\tKernel: lalal\n" }, - .{ .text = "\t\t\tKernel: lalal\n" }, - .{ .text = "\t\t\tKernel: lalal\n" }, - .{ .text = "\t\t\tKernel: lalal\n" }, - .{ .text = "\t\t\tKernel: lalal\n" }, - .{ .text = "\t\t\tKernel: lalal\n" }, - .{ .text = "\t\t\tKernel: lalal\n" }, - .{ .text = "\t\t\tKernel: lalal\n" }, + // .{ .text = " Kernel: lalal\n" }, + // .{ .text = " Kernel: lalal\n" }, + // .{ .text = " Kernel: lalal\n" }, + // .{ .text = " Kernel: lalal\n" }, + // .{ .text = " Kernel: lalal\n" }, + // .{ .text = " Kernel: lalal\n" }, + // .{ .text = "Kernel: lalal\n" }, + // .{ .text = "Kernel: lalal\n" }, }; - try root.kitty_image_inline_copy(allocator, tty.anyWriter(), "/Users/kc/Sync/Images/apple-dark.png"); + try koko.draw(logo_win, .{}); + // try root.kitty_image_inline_copy(allocator, tty.anyWriter(), "/Users/kc/Sync/Images/apple-dark.png"); - result = try win.print(&system_info, .{ .wrap = .word }); + result = try info_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().print("\x1b[{d}A\x1b[9999999D", .{winsize.rows}); // try tty.anyWriter().writeAll("\x1b[1J"); try vx.prettyPrint(writer); @@ -86,12 +98,12 @@ pub fn main() !void { // try image.draw(win, .{}); // try vx.render(tty.anyWriter()); + win.clear(); try buf_writer.flush(); // try vx.queryTerminalSend(tty.anyWriter()); // Clear from cursor to beginning of the screen // Move cursor to the upper left corner of the screen - // try stdout.writeAll("\x1b[1;1H"); // try stdout_file.writeAll("\x1b[9B"); // try vx.enterAltScreen(tty.anyWriter()); @@ -108,10 +120,6 @@ pub fn main() !void { // win.hideCursor(); // const dims = try image[0].cellSize(win); - // const logo_win = win.child(.{ .y_off = 0, .x_off = 0, .width = .{ .limit = dims.cols }, .height = .{ .limit = dims.rows } }); - // const logo_win = win.child(.{ .y_off = 0, .x_off = 0 }); - // const os_info = win.child(.{ .y_off = 0, .x_off = dims.cols, .width = .{ .limit = 30 }, .height = .{ .limit = 10 } }); - // try vx.render(writer); // try stdout.print("\n\n\n\n\n\n\n\n\n", .{});