╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ main_wasm.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
129 const str = std.fmt.bufPrint(&buf, "init: {}", .{err}) catch unreachable; 130 consoleLog(str); 131 }; 132 } 133 134 export fn _tick(min_height: u32, max_width: u32) bool { 135 tick(min_height, max_width) catch |err| { 136 var buf: [256]u8 = undefined; 137 const str = std.fmt.bufPrint(&buf, "tick: {}", .{err}) catch unreachable; 138 consoleLog(str); 139 return false; 140 }; 141 return true; 142 } 143 144 export fn _onKeyDown(key_code: u32) void { 145 onKeyDown(key_code) catch |err| { 146 var buf: [256]u8 = undefined; 147 const str = std.fmt.bufPrint(&buf, "onKeyDown: {}", .{err}) catch unreachable; 148 consoleLog(str); 149 }; 150 } 151 152 export fn _onMouseClick(focus_id: u32) void { 153 onMouseClick(focus_id) catch |err| { 154 var buf: [256]u8 = undefined; 155 const str = std.fmt.bufPrint(&buf, "onMouseClick: {}", .{err}) catch unreachable; 156 consoleLog(str); 157 }; 158 } 159 160 // js calls this when the value of an overlay <input> changes; we replace 161 // the matching TextInput's content with the supplied utf-8 bytes. 162 export fn _setTextInputValue(focus_id: u32, value_ptr: [*]const u8, value_len: u32) void { 163 setTextInputValue(focus_id, value_ptr[0..value_len]) catch |err| { 164 var buf: [256]u8 = undefined; 165 const str = std.fmt.bufPrint(&buf, "setTextInputValue: {}", .{err}) catch unreachable; 166 consoleLog(str); 167 }; 168 } 169 170 fn setTextInputValue(focus_id: u32, bytes: []const u8) !void { 171 const root_ptr = if (root) |*r| r else return error.NotStarted; 172 const root_focus = root_ptr.getFocus(); 173 const child = root_focus.children.get(focus_id) orelse return error.UnknownFocusId; 174 switch (child.focus.kind) { 175 .text_input, .text_input_password => {}, 176 else => return error.NotATextInput, 177 } 178 const ti: *wgt.TextInput(ui.Widget) = @fieldParentPtr("focus", child.focus); 179 try ti.setContent(allocator, bytes); 180 // mirror the TTY behavior in Login.View.input: editing an input clears 181 // the stale failure flag so the "(invalid)" label doesn't linger after 182 // the user has typed a correction 183 session.data.login_failure = null; 184 } 185