╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │22 pub const Quit = @import("./ui/Quit.zig"); │ │23 pub const CloneUrl = @import("./ui/CloneUrl.zig"); │ │24 pub const Unauthorized = @import("./ui/Unauthorized.zig"); │ │25 + │ │26 +pub const clipped_bottom_label_max_len = 10 * 4; │ │27 │ │28 +pub fn clippedBottomLabel(buffer: []u8, text: []const u8) ![]const u8 { │ │29 + var iter = (try std.unicode.Utf8View.init(text)).iterator(); │ │30 + var end: usize = 0; │ │31 + var clipped_end: usize = 0; │ │32 + for (0..10) |i| { │ │33 + const codepoint = iter.nextCodepointSlice() orelse break; │ │34 + end += codepoint.len; │ │35 + if (i == 7) clipped_end = end; │ │36 + } │ │37 + const clipped = iter.nextCodepointSlice() != null; │ │38 + return try std.fmt.bufPrint(buffer, "{s}{s}", .{ text[0..if (clipped) clipped_end else end], if (clipped) ".." else "" });│ │39 +} │ │40 + │ │41 pub const PageKind = enum { │ │42 home, │ │43 user, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯