╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ input.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
21 pub fn rowDelta(key: Key, count: isize) ?isize { 22 switch (key) { 23 .arrow_up => return -1, 24 .arrow_down => return 1, 25 .page_up => return -10, 26 .page_down => return 10, 27 .home => return -count, 28 .end => return count, 29 .scroll_up => return -1, 30 .scroll_down => return 1, 31 else => {}, 32 } 33 return null; 34 } 35 36 /// whether `mouse` is a left press inside the rect of `focus_id`'s focus entry 37 pub fn leftClickOn(root_focus: *Focus, focus_id: usize, mouse: Mouse) bool { 38 if (mouse.button != .left) return false; 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