this repo has no description
1const std = @import("std");
2const builtin = @import("builtin");
3
4pub const tty = @import("tty.zig");
5
6pub const Vaxis = @import("Vaxis.zig");
7
8pub const loop = @import("Loop.zig");
9pub const Loop = loop.Loop;
10
11pub const zigimg = @import("zigimg");
12
13pub const Queue = @import("queue.zig").Queue;
14pub const Key = @import("Key.zig");
15pub const Cell = @import("Cell.zig");
16pub const Segment = Cell.Segment;
17pub const PrintOptions = Window.PrintOptions;
18pub const Style = Cell.Style;
19pub const Color = Cell.Color;
20pub const Image = @import("Image.zig");
21pub const Mouse = @import("Mouse.zig");
22pub const Screen = @import("Screen.zig");
23pub const AllocatingScreen = @import("InternalScreen.zig");
24pub const Parser = @import("Parser.zig");
25pub const Window = @import("Window.zig");
26pub const widgets = @import("widgets.zig");
27pub const gwidth = @import("gwidth.zig");
28pub const ctlseqs = @import("ctlseqs.zig");
29pub const GraphemeCache = @import("GraphemeCache.zig");
30pub const grapheme = @import("grapheme");
31pub const Event = @import("event.zig").Event;
32pub const Unicode = @import("Unicode.zig");
33
34pub const vxfw = @import("vxfw/vxfw.zig");
35
36pub const Tty = tty.Tty;
37
38/// The size of the terminal screen
39pub const Winsize = struct {
40 rows: u16,
41 cols: u16,
42 x_pixel: u16,
43 y_pixel: u16,
44};
45
46/// Initialize a Vaxis application.
47pub fn init(alloc: std.mem.Allocator, opts: Vaxis.Options) !Vaxis {
48 return Vaxis.init(alloc, opts);
49}
50
51pub const Panic = struct {
52 pub const call = panic_handler;
53 pub const sentinelMismatch = std.debug.FormattedPanic.sentinelMismatch;
54 pub const unwrapError = std.debug.FormattedPanic.unwrapError;
55 pub const outOfBounds = std.debug.FormattedPanic.outOfBounds;
56 pub const startGreaterThanEnd = std.debug.FormattedPanic.startGreaterThanEnd;
57 pub const inactiveUnionField = std.debug.FormattedPanic.inactiveUnionField;
58 pub const messages = std.debug.FormattedPanic.messages;
59};
60
61/// Resets terminal state on a panic, then calls the default zig panic handler
62pub fn panic_handler(msg: []const u8, _: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
63 recover();
64 std.debug.defaultPanic(msg, ret_addr);
65}
66
67/// Resets the terminal state using the global tty instance. Use this only to recover during a panic
68pub fn recover() void {
69 if (tty.global_tty) |gty| {
70 const reset: []const u8 = ctlseqs.csi_u_pop ++
71 ctlseqs.mouse_reset ++
72 ctlseqs.bp_reset ++
73 ctlseqs.rmcup;
74
75 gty.anyWriter().writeAll(reset) catch {};
76
77 gty.deinit();
78 }
79}
80
81pub const log_scopes = enum {
82 vaxis,
83};
84
85/// the vaxis logo. In PixelCode
86pub const logo =
87 \\▄ ▄ ▄▄▄ ▄ ▄ ▄▄▄ ▄▄▄
88 \\█ █ █▄▄▄█ ▀▄ ▄▀ █ █ ▀
89 \\▀▄ ▄▀ █ █ ▄▀▄ █ ▀▀▀▄
90 \\ ▀▄▀ █ █ █ █ ▄█▄ ▀▄▄▄▀
91;
92
93test "refAllDecls" {
94 std.testing.refAllDecls(@This());
95}