╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ input.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
39 const entry = root_focus.children.get(focus_id) orelse return false; 40 const r = entry.rect; 41 return mouse.x >= r.x and mouse.y >= r.y and 42 mouse.x < r.x + r.size.width and mouse.y < r.y + r.size.height; 43 } 44 45 /// the tab index after a left/right arrow press, clamped to the ends, 46 /// or null when the key doesn't move the selection 47 pub fn moveTab(key: Key, current_tab: usize, tab_count: usize) ?usize { 48 var new_tab = current_tab; 49 switch (key) { 50 .arrow_left => new_tab -|= 1, 51 .arrow_right => if (new_tab + 1 < tab_count) { 52 new_tab += 1; 53 }, 54 else => {}, 55 } 56 return if (new_tab != current_tab) new_tab else null; 57 } 58 59 /// enter counts only on the focused button; a click counts anywhere on it 60 pub fn activated(root_focus: *Focus, button_id: usize, key: Key) bool { 61 return switch (key) { 62 .enter => root_focus.grandchild_id == button_id, 63 .mouse => |mouse| leftClickOn(root_focus, button_id, mouse), 64 else => false, 65 }; 66 } 67