╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Comment.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
323 var previous = try linkBox(allocator, session, "← previous", route orelse return error.RouteTooLong); 324 errdefer previous.deinit(allocator); 325 try row.children.put(allocator, previous.getFocus().id, .{ .widget = .{ .text_box = previous }, .rect = null, .min_size = null }); 326 } 327 if (has_more) { 328 const start = window.start + page_size; 329 const route = commentsRoute(thread_kind, identity, thread_id, selected_id, start); 330 var next = try linkBox(allocator, session, "next →", route orelse return error.RouteTooLong); 331 errdefer next.deinit(allocator); 332 try row.children.put(allocator, next.getFocus().id, .{ .widget = .{ .text_box = next }, .rect = null, .min_size = null }); 333 } 334 row.getFocus().child_id = row.children.keys()[0]; 335 try box.children.put(allocator, row.getFocus().id, .{ .widget = .{ .box = row }, .rect = null, .min_size = null }); 336 } 337 338 fn commentsRoute(kind: evt.EventKind, identity: []const u8, thread_id: []const u8, selected_id: ?[]const u8, start: usize) ?ui.RoutablePage { 339 return if (selected_id) |id| 340 ui.RoutablePage.repoThreadCommentRoute(kind, identity, thread_id, id, start) 341 else 342 ui.RoutablePage.repoThreadCommentsRoute(kind, identity, thread_id, start); 343 } 344 345 fn commentNewRoute(kind: evt.EventKind, identity: []const u8, thread_id: []const u8, parent_id: []const u8) ?ui.RoutablePage { 346 return ui.RoutablePage.repoThreadCommentNewRoute(kind, identity, thread_id, parent_id); 347 } 348 349 fn commentEditRoute(kind: evt.EventKind, identity: []const u8, thread_id: []const u8, comment_id: []const u8) ?ui.RoutablePage { 350 return ui.RoutablePage.repoThreadCommentEditRoute(kind, identity, thread_id, comment_id); 351 } 352 353 fn removeRoute(kind: evt.EventKind, identity: []const u8, thread_id: []const u8, comment_id: []const u8) ?ui.RoutablePage { 354 return ui.RoutablePage.repoThreadRemoveRoute(kind, identity, thread_id, comment_id); 355 } 356 357 pub fn linkBox(allocator: std.mem.Allocator, session: *ui.Session, text: []const u8, route: ui.RoutablePage) !wgt.TextBox { 358 var box = try wgt.TextBox.init(allocator, text, .{ .border = .single, .round_corners = true, .wrap_kind = .none }); 359 errdefer box.deinit(allocator); 360 box.getFocus().mode = .all; 361 box.getFocus().kind = .{ .custom = try session.page_arena.allocator().print("a:{s}", .{try route.toUrl(session.page_arena)}) }; 362 return box; 363 } 364