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