╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
790 }; 791 792 // the "a:" navigation link for the commits page walking from commit `oid` within 793 // `identity`, showing the selected commit's first `start` hunks (0 = default). 794 fn commitsLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8, start: usize) ![]const u8 { 795 const route = ui.RoutablePage.repoCommitsRoute(identity, .object, oid, start) orelse return error.RouteTooLong; 796 const url = try route.toUrl(page_arena); 797 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 798 } 799 800 // the "a:" link to the files tab at commit `oid` (an object ref), at its root 801 // directory, within `identity` ("owner/name"). 802 fn filesObjectLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8) ![]const u8 { 803 const route = ui.RoutablePage.repoFilesRoute(identity, .object, oid, "", 0) orelse return error.RouteTooLong; 804 const url = try route.toUrl(page_arena); 805 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 806 } 807 808 // the in-page "ai:" anchor for selecting `oid` in `identity`'s commit list. it 809 // points at the same route as commitsLink but the "ai:" prefix keeps wasm clicks 810 // in-page (crossPageLink ignores it); the href is only followed with js off. 811 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8) ![]const u8 { 812 const route = ui.RoutablePage.repoCommitsRoute(identity, .object, oid, 0) orelse return error.RouteTooLong; 813 const url = try route.toUrl(page_arena); 814 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{url}); 815 } 816 817 // the "viewing <ref_or_oid> <value>" banner shown above the log. 818 pub const Header = struct { 819 content: []const u8, 820 821 pub fn init(aa: std.mem.Allocator, ref_or_oid: ui.RoutablePage.RefOrOid, value: []const u8) !Header { 822 return .{ 823 .content = try std.fmt.allocPrint(aa, "viewing {s} {s}", .{ @tagName(ref_or_oid), value }), 824 }; 825 } 826 827 pub const View = struct { 828 box: wgt.Box(ui.Widget), 829 data: *const Header, 830 831 pub fn init(allocator: std.mem.Allocator, data: *const Header, session: *ui.Session) !Header.View { 832 _ = session; 833 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); 834 errdefer box.deinit(allocator); 835 836 var text_box = try wgt.TextBox(ui.Widget).init(allocator, data.content, .{ .border_style = .hidden, .wrap_kind = .none }); 837 errdefer text_box.deinit(allocator); 838 try box.children.put(allocator, text_box.getFocus().id, .{ .widget = .{ .text_box = text_box }, .rect = null, .min_size = null }); 839 840 return .{ .box = box, .data = data }; 841 } 842 843 pub fn deinit(self: *Header.View, allocator: std.mem.Allocator) void { 844 self.box.deinit(allocator); 845 } 846 847 pub fn build(self: *Header.View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 848 self.clearGrid(); 849 try self.box.build(allocator, constraint, root_focus); 850 } 851 852 pub fn input(self: *Header.View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 853 _ = self; 854 _ = allocator; 855 _ = key; 856 _ = root_focus; 857 } 858 859 pub fn clearGrid(self: *Header.View) void { 860 self.box.clearGrid(); 861 } 862 863 pub fn getGrid(self: Header.View) ?Grid { 864 return self.box.getGrid(); 865 } 866 867 pub fn getFocus(self: *Header.View) *Focus { 868 return self.box.getFocus(); 869 } 870 }; 871 }; 872