╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Files.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
990 return dir[0..slash]; 991 } 992 993 // a search result's bottom label: the directory it sits in, empty at the root. 994 // a directory too wide for the list column is clipped from the left. 995 fn resultDirLabel(aa: std.mem.Allocator, path: []const u8) ![]const u8 { 996 const slash = std.mem.lastIndexOfScalar(u8, path, '/') orelse return ""; 997 const dir = path[0..slash]; 998 // the row's border and the label's padding take two columns each 999 const max_width = View.list_max_width - 4; 1000 var width = try xitui.width.displayWidth(dir); 1001 if (width <= max_width) return std.fmt.allocPrint(aa, " {s} ", .{dir}); 1002 1003 const ellipsis = ".."; 1004 var iter = (try std.unicode.Utf8View.init(dir)).iterator(); 1005 var start: usize = 0; 1006 while (width > max_width - ellipsis.len) { 1007 const slice = iter.nextCodepointSlice() orelse break; 1008 width -= xitui.width.cellWidth(try std.unicode.utf8Decode(slice)); 1009 start += slice.len; 1010 } 1011 return std.fmt.allocPrint(aa, " " ++ ellipsis ++ "{s} ", .{dir[start..]}); 1012 } 1013