╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ main_wasm.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
198 var buf: [256]u8 = undefined; 199 const str = std.fmt.bufPrint(&buf, "onKeyDown: {}", .{err}) catch unreachable; 200 consoleLog(str); 201 }; 202 } 203 204 export fn _onMouseClick(focus_id: u32) void { 205 onMouseClick(focus_id) catch |err| { 206 var buf: [256]u8 = undefined; 207 const str = std.fmt.bufPrint(&buf, "onMouseClick: {}", .{err}) catch unreachable; 208 consoleLog(str); 209 }; 210 } 211 212 export fn _setFocus(focus_id: u32) void { 213 setFocus(focus_id) catch |err| { 214 var buf: [256]u8 = undefined; 215 const str = std.fmt.bufPrint(&buf, "setFocus: {}", .{err}) catch unreachable; 216 consoleLog(str); 217 }; 218 } 219 220 // js calls this when the value of an overlay <input> changes; we replace 221 // the matching TextInput's content with the supplied utf-8 bytes. 222 export fn _setTextInputValue(focus_id: u32, value_ptr: [*]const u8, value_len: u32) void { 223 setTextInputValue(focus_id, value_ptr[0..value_len]) catch |err| { 224 var buf: [256]u8 = undefined; 225 const str = std.fmt.bufPrint(&buf, "setTextInputValue: {}", .{err}) catch unreachable; 226 consoleLog(str); 227 }; 228 } 229 230 fn setTextInputValue(focus_id: u32, bytes: []const u8) !void { 231 const root_ptr = if (root) |*r| r else return error.NotStarted; 232 const root_focus = root_ptr.getFocus(); 233 const child = root_focus.children.get(focus_id) orelse return error.UnknownFocusId; 234 switch (child.focus.kind) { 235 .text_input, .text_input_password => {}, 236 else => return error.NotATextInput, 237 } 238 const ti = session.text_inputs.get(focus_id) orelse return error.UnknownFocusId; 239 try ti.setContent(allocator, bytes); 240 // mirror the TTY behavior in Login.View.input: editing an input clears 241 // the stale failure flag so the "(invalid)" label doesn't linger after 242 // the user has typed a correction 243 session.data.login_failure = null; 244 } 245