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