this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

examples: update terminal example

+30 -61
+30 -61
examples/vt.zig
··· 44 44 }, 45 45 .scrollback_size = 0, 46 46 }; 47 - const argv1 = [_][]const u8{"senpai"}; 48 - const argv2 = [_][]const u8{"nvim"}; 49 - const argv3 = [_][]const u8{"senpai"}; 50 - // const argv = [_][]const u8{"senpai"}; 51 - // const argv = [_][]const u8{"comlink"}; 52 - var vt1 = try vaxis.widgets.Terminal.init( 53 - alloc, 54 - &argv1, 55 - &env, 56 - &vx.unicode, 57 - vt_opts, 58 - ); 59 - defer vt1.deinit(); 60 - try vt1.spawn(); 61 - var vt2 = try vaxis.widgets.Terminal.init( 62 - alloc, 63 - &argv2, 64 - &env, 65 - &vx.unicode, 66 - vt_opts, 67 - ); 68 - defer vt2.deinit(); 69 - try vt2.spawn(); 70 - var vt3 = try vaxis.widgets.Terminal.init( 47 + // const shell = env.get("SHELL") orelse "bash"; 48 + const shell = "fish"; 49 + // const ed = env.get("EDITOR") orelse "nvim"; 50 + // const pager = env.get("EDITOR") orelse "nvim"; 51 + const argv = [_][]const u8{shell}; 52 + var vt = try vaxis.widgets.Terminal.init( 71 53 alloc, 72 - &argv3, 54 + &argv, 73 55 &env, 74 56 &vx.unicode, 75 57 vt_opts, 76 58 ); 77 - defer vt3.deinit(); 78 - try vt3.spawn(); 59 + defer vt.deinit(); 60 + try vt.spawn(); 79 61 80 62 while (true) { 81 63 std.time.sleep(8 * std.time.ns_per_ms); 64 + // try vt events first 65 + while (vt.tryEvent()) |event| { 66 + switch (event) { 67 + .bell => {}, 68 + .exited => return, 69 + } 70 + } 82 71 while (loop.tryEvent()) |event| { 83 72 switch (event) { 84 - .key_press => |key| if (key.matches('c', .{ .ctrl = true })) return, 73 + .key_press => |key| { 74 + if (key.matches('c', .{ .ctrl = true })) return; 75 + try vt.update(.{ .key_press = key }); 76 + }, 85 77 .winsize => |ws| { 86 78 try vx.resize(alloc, tty.anyWriter(), ws); 87 79 }, ··· 90 82 91 83 const win = vx.window(); 92 84 win.clear(); 93 - const left = win.child(.{ 94 - .width = .{ .limit = win.width / 2 }, 85 + const child = win.child(.{ 86 + .x_off = 4, 87 + .y_off = 2, 88 + .width = .{ .limit = win.width - 8 }, 89 + .height = .{ .limit = win.width - 6 }, 95 90 .border = .{ 96 - .where = .right, 91 + .where = .all, 97 92 }, 98 93 }); 99 94 100 - const right_top = win.child(.{ 101 - .x_off = left.width + 1, 102 - .height = .{ .limit = win.height / 2 }, 103 - .border = .{ 104 - .where = .bottom, 105 - }, 106 - }); 107 - const right_bot = win.child(.{ 108 - .x_off = left.width + 1, 109 - .y_off = right_top.height + 1, 110 - }); 111 - 112 - try vt1.resize(.{ 113 - .rows = left.height, 114 - .cols = left.width, 95 + try vt.resize(.{ 96 + .rows = child.height, 97 + .cols = child.width, 115 98 .x_pixel = 0, 116 99 .y_pixel = 0, 117 100 }); 118 - try vt2.resize(.{ 119 - .rows = right_top.height, 120 - .cols = right_bot.width, 121 - .x_pixel = 0, 122 - .y_pixel = 0, 123 - }); 124 - try vt3.resize(.{ 125 - .rows = right_bot.height, 126 - .cols = right_bot.width, 127 - .x_pixel = 0, 128 - .y_pixel = 0, 129 - }); 130 - try vt1.draw(left); 131 - try vt2.draw(right_top); 132 - try vt3.draw(right_bot); 101 + try vt.draw(child); 133 102 134 103 try vx.render(tty.anyWriter()); 135 104 }