fix examples, update readme features

This commit is contained in:
Tim Culverhouse 2024-05-22 14:06:26 -05:00
parent d7bc2c451b
commit 1b957ec84e
10 changed files with 27 additions and 33 deletions

View file

@ -25,7 +25,7 @@ Vaxis uses zig `0.12.0`.
| Kitty Keyboard | ✅ | ✅ | ✅ |
| Styled Underlines | ✅ | ✅ | ✅ |
| Mouse Shapes (OSC 22) | ✅ | ✅ | ❌ |
| System Clipboard (OSC 52) | ✅ | planned | ❌ |
| System Clipboard (OSC 52) | ✅ | | ❌ |
| System Notifications (OSC 9) | ✅ | ✅ | ❌ |
| System Notifications (OSC 777) | ✅ | ✅ | ❌ |
| Synchronized Output (DEC 2026) | ✅ | ✅ | ✅ |
@ -35,7 +35,7 @@ Vaxis uses zig `0.12.0`.
| Images (half block) | ✅ | planned | ✅ |
| Images (quadrant) | ✅ | planned | ✅ |
| Images (sextant) | ❌ | ❌ | ✅ |
| Images (sixel) | ✅ | debating | ✅ |
| Images (sixel) | ✅ | | ✅ |
| Images (kitty) | ✅ | ✅ | ✅ |
| Images (iterm2) | ❌ | ❌ | ✅ |
| Video | ❌ | ❌ | ✅ |

View file

@ -19,7 +19,7 @@ pub fn main() !void {
var loop: vaxis.Loop(Event) = .{ .vaxis = &vx };
try loop.run(alloc);
try loop.run();
defer loop.stop();
try vx.queryTerminal();

View file

@ -23,7 +23,7 @@ pub fn main() !void {
var loop: vaxis.Loop(Event) = .{ .vaxis = &vx };
try loop.run(alloc);
try loop.run();
defer loop.stop();
try vx.enterAltScreen();

View file

@ -22,7 +22,7 @@ pub fn main() !void {
// Start the read loop. This puts the terminal in raw mode and begins
// reading user input
try loop.run(alloc);
try loop.run();
defer loop.stop();
// Optionally enter the alternate screen

View file

@ -29,7 +29,7 @@ pub fn main() !void {
var loop: vaxis.Loop(Event) = .{ .vaxis = &vx };
try loop.run(alloc);
try loop.run();
defer loop.stop();
// Optionally enter the alternate screen

View file

@ -16,7 +16,7 @@ pub fn main() !void {
var loop: vaxis.Loop(Event) = .{ .vaxis = &vx };
try loop.run(alloc);
try loop.run();
defer loop.stop();
try vx.enterAltScreen();
try vx.queryTerminal();

View file

@ -19,7 +19,7 @@ pub fn main() !void {
var loop: vaxis.Loop(Event) = .{ .vaxis = &vx };
try loop.run(alloc);
try loop.run();
defer loop.stop();
try vx.queryTerminal();

View file

@ -32,7 +32,7 @@ pub fn main() !void {
winsize: vaxis.Winsize,
}) = .{ .vaxis = &vx };
try loop.run(alloc);
try loop.run();
defer loop.stop();
try vx.enterAltScreen();
try vx.queryTerminal();
@ -94,10 +94,9 @@ pub fn main() !void {
break :keyEvt;
}
// Command State
if (
active != .btm and
key.matchesAny(&.{ ':', '/', 'g', 'G' }, .{})
) {
if (active != .btm and
key.matchesAny(&.{ ':', '/', 'g', 'G' }, .{}))
{
active = .btm;
for (0..cmd_input.buf.items.len) |_| _ = cmd_input.buf.orderedRemove(0);
try cmd_input.update(.{ .key_press = key });
@ -127,11 +126,9 @@ pub fn main() !void {
// Run Command and Clear Command Bar
else if (key.matchExact(vaxis.Key.enter, .{})) {
const cmd = cmd_input.buf.items;
if (
mem.eql(u8, ":q", cmd) or
if (mem.eql(u8, ":q", cmd) or
mem.eql(u8, ":quit", cmd) or
mem.eql(u8, ":exit", cmd)
) return;
mem.eql(u8, ":exit", cmd)) return;
if (mem.eql(u8, "G", cmd)) {
demo_tbl.row = user_list.items.len - 1;
active = .mid;
@ -143,8 +140,7 @@ pub fn main() !void {
}
for (0..cmd_input.buf.items.len) |_| _ = cmd_input.buf.orderedRemove(0);
cmd_input.cursor_idx = 0;
}
else try cmd_input.update(.{ .key_press = key });
} else try cmd_input.update(.{ .key_press = key });
},
}
moving = false;
@ -168,15 +164,15 @@ pub fn main() !void {
);
for (title_segs[0..]) |*title_seg|
title_seg.*.style.bg = if (active == .top) selected_bg else other_bg;
top_bar.fill(.{
.style = .{ .bg = if (active == .top) selected_bg else other_bg, }
});
top_bar.fill(.{ .style = .{
.bg = if (active == .top) selected_bg else other_bg,
} });
const logo_bar = vaxis.widgets.alignment.center(
top_bar,
44,
top_bar.height - (top_bar.height / 3),
);
try logo_bar.wrap(title_segs[0..]);
_ = try logo_bar.print(title_segs[0..], .{ .wrap = .word });
// - Middle
const middle_bar = win.initChild(
@ -203,9 +199,7 @@ pub fn main() !void {
.{ .limit = win.width },
.{ .limit = 1 },
);
if (active == .btm) bottom_bar.fill(.{
.style = .{ .bg = selected_bg }
});
if (active == .btm) bottom_bar.fill(.{ .style = .{ .bg = selected_bg } });
cmd_input.draw(bottom_bar);
// Render the screen

View file

@ -42,7 +42,7 @@ pub fn main() !void {
// Start the read loop. This puts the terminal in raw mode and begins
// reading user input
try loop.run(alloc);
try loop.run();
defer loop.stop();
// Optionally enter the alternate screen
@ -85,7 +85,7 @@ pub fn main() !void {
loop.stop();
var child = std.process.Child.init(&.{"nvim"}, alloc);
_ = try child.spawnAndWait();
try loop.run(alloc);
try loop.run();
try vx.enterAltScreen();
vx.queueRefresh();
} else if (key.matches(vaxis.Key.enter, .{})) {

View file

@ -84,7 +84,7 @@ pub fn drawTable(
.ul_style = if (idx == table_ctx.col) .single else .dotted,
},
}};
try hdr.wrap(seg[0..]);
_ = try hdr.print(seg[0..], .{ .wrap = .word });
}
const max_items = if (data_list.items.len > table_win.height -| 1) table_win.height -| 1 else data_list.items.len;
@ -120,7 +120,7 @@ pub fn drawTable(
.text = if (data.len > table_ctx.col_width and alloc != null) try fmt.allocPrint(alloc.?, "{s}...", .{data[0..(table_ctx.col_width -| 4)]}) else data,
.style = .{ .bg = row_bg },
}};
try row_win.wrap(seg[0..]);
_ = try row_win.print(seg[0..], .{ .wrap = .word });
return;
}
const item_fields = meta.fields(DataT);
@ -157,7 +157,7 @@ pub fn drawTable(
.text = if (item_txt.len > table_ctx.col_width and alloc != null) try fmt.allocPrint(alloc.?, "{s}...", .{item_txt[0..(table_ctx.col_width -| 4)]}) else item_txt,
.style = .{ .bg = row_bg },
}};
try item_win.wrap(seg[0..]);
_ = try item_win.print(seg[0..], .{ .wrap = .word });
}
}
}