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