mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
wasm: export terminal core API
This commit is contained in:
@ -6,6 +6,7 @@ const builtin = @import("builtin");
|
||||
pub usingnamespace @import("os/wasm.zig");
|
||||
pub usingnamespace @import("os/wasm/log.zig");
|
||||
pub usingnamespace @import("font/main.zig");
|
||||
pub usingnamespace @import("terminal/main.zig");
|
||||
|
||||
// Set our log level. We try to get as much logging as possible but in
|
||||
// ReleaseSmall mode where we're optimizing for space, we elevate the
|
||||
|
@ -28,6 +28,11 @@ pub const EraseLine = csi.EraseLine;
|
||||
pub const TabClear = csi.TabClear;
|
||||
pub const Attribute = sgr.Attribute;
|
||||
|
||||
/// If we're targeting wasm then we export some wasm APIs.
|
||||
pub usingnamespace if (builtin.target.isWasm()) struct {
|
||||
pub usingnamespace @import("wasm.zig");
|
||||
} else struct {};
|
||||
|
||||
test {
|
||||
@import("std").testing.refAllDecls(@This());
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
// This is the main file for the WASM module. The WASM module just
|
||||
// imports the C API.
|
||||
|
||||
pub usingnamespace @import("c_api.zig");
|
@ -8,12 +8,8 @@ const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Terminal = @import("main.zig").Terminal;
|
||||
|
||||
// The allocator that we want to use.
|
||||
const alloc = if (builtin.link_libc)
|
||||
std.heap.c_allocator
|
||||
else
|
||||
std.heap.page_allocator;
|
||||
const wasm = @import("../os/wasm.zig");
|
||||
const alloc = wasm.alloc;
|
||||
|
||||
export fn terminal_new(cols: usize, rows: usize) ?*Terminal {
|
||||
const term = Terminal.init(alloc, cols, rows) catch return null;
|
||||
@ -31,6 +27,6 @@ export fn terminal_free(ptr: ?*Terminal) void {
|
||||
|
||||
export fn terminal_print(ptr: ?*Terminal, char: u32) void {
|
||||
if (ptr) |t| {
|
||||
t.print(@intCast(u21, char)) catch return null;
|
||||
t.print(@intCast(u21, char)) catch return;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user