From 6833b39ffe311f0f1e39b6669b946d712d7dcd93 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 16 Jun 2026 23:04:59 -0300 Subject: ghostty setup --- main.zig | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'main.zig') diff --git a/main.zig b/main.zig index e591b7d0..a55ad637 100644 --- a/main.zig +++ b/main.zig @@ -1,5 +1,6 @@ const std = @import("std"); const vaxis = @import("vaxis"); +const ghostty_vt = @import("ghostty-vt"); // basic file navigation // basic shell io @@ -40,6 +41,15 @@ pub fn main(init: std.process.Init) !void { const io = init.io; const gpa = init.gpa; + var t: ghostty_vt.Terminal = try .init(gpa, .{ + .cols = 6, + .rows = 40, + }); + defer t.deinit(gpa); + + try t.printString("hello there!\nhowdy!"); + const str = try t.plainString(gpa); + var tty_buf: [0x10000]u8 = undefined; var lines: [0x1000][0x1000]u8 = undefined; @@ -78,17 +88,8 @@ pub fn main(init: std.process.Init) !void { while (true) { const event = try loop.nextEvent(); const win = vx.window(); - - for (0..MAX_FILES) |i| { - if (i > MAX_FILES) break; - - // const str: [:0]u8 = std.mem.absorbSentinel(&line); - const len = std.mem.findSentinel(u8, 0, @ptrCast(&lines[i])); - _ = win.printSegment(.{ .text = lines[i][0..len] }, .{ - .row_offset = @intCast(i), - .wrap = .none, - }); - } + const win_child = win.child(.{ .border = .{ .where = .all }, .height = 8, .width = 42 }); + _ = win_child.printSegment(.{ .text = "hey" }, .{}); switch (event) { .key_press => |key| { @@ -97,20 +98,22 @@ pub fn main(init: std.process.Init) !void { } }, .mouse => |m| { + _ = win.printSegment(.{ .text = str }, .{ .col_offset = 1, .row_offset = 1 }); + if (m.type == .press) { // const txt = try std.fmt.allocPrint(gpa, "col={} row={} xo={} yo={}", .{ m.col, m.row, m.xoffset, m.yoffset }); - const len = std.mem.findSentinel(u8, 0, @ptrCast(&lines[@intCast(m.row)])); - _ = win.printSegment( - .{ - .text = lines[@intCast(m.row)][0..len], - .style = .{ .fg = .{ .rgb = .{ 0x00, 0xd0, 0xaa } } }, - }, - .{ - .col_offset = @as(u16, @intCast(m.col)), - .row_offset = @as(u16, @intCast(m.row)), - .wrap = .none, - }, - ); + // constlen = std.mem.findSentinel(u8, 0, @ptrCast(&lines[@intCast(m.row)])); + // _ = win.printSegment( + // .{ + // .text = lines[@intCast(m.row)][0..len], + // .style = .{ .fg = .{ .rgb = .{ 0x00, 0xd0, 0xaa } } }, + // }, + // .{ + // .col_offset = @as(u16, @intCast(m.col)), + // .row_offset = @as(u16, @intCast(m.row)), + // .wrap = .none, + // }, + // ); } }, .winsize => |ws| try vx.resize(gpa, tty.writer(), ws), -- cgit v1.3