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