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