╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ main_wasm.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
222 export fn _onMouseClick(focus_id: u32) void { 223 onMouseClick(focus_id) catch |err| { 224 var buf: [256]u8 = undefined; 225 const str = std.fmt.bufPrint(&buf, "onMouseClick: {}", .{err}) catch unreachable; 226 consoleLog(str); 227 }; 228 } 229 230 export fn _setFocus(focus_id: u32) void { 231 setFocus(focus_id) catch |err| { 232 var buf: [256]u8 = undefined; 233 const str = std.fmt.bufPrint(&buf, "setFocus: {}", .{err}) catch unreachable; 234 consoleLog(str); 235 }; 236 } 237 238 // js calls this when the value of an overlay <input> changes; we replace 239 // the matching TextInput's content with the supplied utf-8 bytes. 240 export fn _setTextInputValue(focus_id: u32, value_ptr: [*]const u8, value_len: u32) void { 241 setTextInputValue(focus_id, value_ptr[0..value_len]) catch |err| { 242 var buf: [256]u8 = undefined; 243 const str = std.fmt.bufPrint(&buf, "setTextInputValue: {}", .{err}) catch unreachable; 244 consoleLog(str); 245 }; 246 } 247 248 fn setTextInputValue(focus_id: u32, bytes: []const u8) !void { 249 const root_ptr = if (root) |*r| r else return error.NotStarted; 250 const root_focus = root_ptr.getFocus(); 251 const child = root_focus.children.get(focus_id) orelse return error.UnknownFocusId; 252 switch (child.focus.kind) { 253 .text_input, .text_input_password, .text_area => {}, 254 else => return error.NotATextInput, 255 } 256 const ti = session.text_inputs.get(focus_id) orelse return error.UnknownFocusId; 257 try ti.setContent(allocator, bytes); 258 // mirror the TTY behavior in Login.View.input: editing an input clears 259 // the stale failure flag so the "(invalid)" label doesn't linger after 260 // the user has typed a correction 261 session.data.login_failure = null; 262 } 263