╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
961 962 // the "a:" link to the page showing `oid`'s message on its own. 963 fn messageLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8) ![]const u8 { 964 const route = ui.RoutablePage.repoCommitMessageRoute(identity, .object, oid) orelse return error.RouteTooLong; 965 const url = try route.toUrl(page_arena); 966 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 967 } 968 969 // the "viewing <ref_or_oid> <value>" banner shown above the log. 970 pub const Header = struct { 971 content: []const u8, 972 973 // `value` arrives url-encoded, so decode it for display. 974 pub fn init(aa: std.mem.Allocator, ref_or_oid: ui.RoutablePage.RefOrOid, value: []const u8) !Header { 975 const decoded = std.Uri.percentDecodeInPlace(try aa.dupe(u8, value)); 976 return .{ 977 .content = try std.fmt.allocPrint(aa, "viewing {s} {s}", .{ @tagName(ref_or_oid), decoded }), 978 }; 979 } 980 981 pub const View = struct { 982 box: wgt.Box(ui.Widget), 983 data: *const Header, 984 985 pub fn init(allocator: std.mem.Allocator, data: *const Header, session: *ui.Session) !Header.View { 986 _ = session; 987 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); 988 errdefer box.deinit(allocator); 989 990 var text_box = try wgt.TextBox(ui.Widget).init(allocator, data.content, .{ .border_style = .hidden, .wrap_kind = .none }); 991 errdefer text_box.deinit(allocator); 992 try box.children.put(allocator, text_box.getFocus().id, .{ .widget = .{ .text_box = text_box }, .rect = null, .min_size = null }); 993 994 return .{ .box = box, .data = data }; 995 } 996 997 pub fn deinit(self: *Header.View, allocator: std.mem.Allocator) void { 998 self.box.deinit(allocator); 999 } 1000 1001 pub fn build(self: *Header.View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 1002 self.clearGrid(); 1003 try self.box.build(allocator, constraint, root_focus); 1004 } 1005 1006 pub fn input(self: *Header.View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 1007 _ = self; 1008 _ = allocator; 1009 _ = key; 1010 _ = root_focus; 1011 } 1012 1013 pub fn clearGrid(self: *Header.View) void { 1014 self.box.clearGrid(); 1015 } 1016 1017 pub fn getGrid(self: Header.View) ?Grid { 1018 return self.box.getGrid(); 1019 } 1020 1021 pub fn getFocus(self: *Header.View) *Focus { 1022 return self.box.getFocus(); 1023 } 1024 }; 1025 }; 1026