╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ main_wasm.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
197 var buf: [256]u8 = undefined; 198 const str = std.fmt.bufPrint(&buf, "init: {}", .{err}) catch unreachable; 199 consoleLog(str); 200 }; 201 } 202 203 export fn _tick(min_height: u32, max_width: u32) bool { 204 tick(min_height, max_width) catch |err| { 205 var buf: [256]u8 = undefined; 206 const str = std.fmt.bufPrint(&buf, "tick: {}", .{err}) catch unreachable; 207 consoleLog(str); 208 return false; 209 }; 210 return true; 211 } 212 213 export fn _onKeyDown(key_code: u32) void { 214 onKeyDown(key_code) catch |err| { 215 var buf: [256]u8 = undefined; 216 const str = std.fmt.bufPrint(&buf, "onKeyDown: {}", .{err}) catch unreachable; 217 consoleLog(str); 218 }; 219 } 220 221 export fn _onMouseClick(focus_id: u32) void { 222 onMouseClick(focus_id) catch |err| { 223 var buf: [256]u8 = undefined; 224 const str = std.fmt.bufPrint(&buf, "onMouseClick: {}", .{err}) catch unreachable; 225 consoleLog(str); 226 }; 227 } 228 229 export fn _setFocus(focus_id: u32) void { 230 setFocus(focus_id) catch |err| { 231 var buf: [256]u8 = undefined; 232 const str = std.fmt.bufPrint(&buf, "setFocus: {}", .{err}) catch unreachable; 233 consoleLog(str); 234 }; 235 } 236 237 // js calls this when the value of a native <input> changes; we replace 238 // the matching TextInput's content with the supplied utf-8 bytes. 239 export fn _setTextInputValue(focus_id: u32, value_ptr: [*]const u8, value_len: u32) void { 240 setTextInputValue(focus_id, value_ptr[0..value_len]) catch |err| { 241 var buf: [256]u8 = undefined; 242 const str = std.fmt.bufPrint(&buf, "setTextInputValue: {}", .{err}) catch unreachable; 243 consoleLog(str); 244 }; 245 } 246 247 fn setTextInputValue(focus_id: u32, bytes: []const u8) !void { 248 const root_ptr = if (root) |*r| r else return error.NotStarted; 249 const root_focus = root_ptr.getFocus(); 250 const child = root_focus.children.get(focus_id) orelse return error.UnknownFocusId; 251 switch (child.focus.kind) { 252 .text_input, .text_input_password, .text_area => {}, 253 else => return error.NotATextInput, 254 } 255 const ti = session.text_inputs.get(focus_id) orelse return error.UnknownFocusId; 256 try ti.setContent(allocator, bytes); 257 } 258