mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-05 17:36:32 +00:00
test wasm of the term package
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
// This is the C-ABI API for the terminal package. This isn't used
|
||||
// by other Zig programs but by C or WASM interfacing.
|
||||
//
|
||||
// NOTE: This is far, far from complete. We did a very minimal amount to
|
||||
// prove that compilation works, but we haven't completed coverage yet.
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
@@ -7,10 +10,10 @@ const Allocator = std.mem.Allocator;
|
||||
const Terminal = @import("main.zig").Terminal;
|
||||
|
||||
// The allocator that we want to use.
|
||||
const alloc = if (builtin.target.isWasm())
|
||||
std.heap.page_allocator
|
||||
const alloc = if (builtin.link_libc)
|
||||
std.heap.c_allocator
|
||||
else
|
||||
std.heap.c_allocator;
|
||||
std.heap.page_allocator;
|
||||
|
||||
export fn terminal_new(cols: usize, rows: usize) ?*Terminal {
|
||||
const term = Terminal.init(alloc, cols, rows) catch return null;
|
||||
@@ -25,3 +28,9 @@ export fn terminal_free(ptr: ?*Terminal) void {
|
||||
alloc.destroy(v);
|
||||
}
|
||||
}
|
||||
|
||||
export fn terminal_print(ptr: ?*Terminal, char: u32) void {
|
||||
if (ptr) |t| {
|
||||
t.print(@intCast(u21, char)) catch return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user