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