╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Files.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1089 } 1090 1091 // a search result's bottom label: the directory it sits in, empty at the root. 1092 // a directory too wide for the list column is clipped from the left. 1093 fn resultDirLabel(aa: std.mem.Allocator, path: []const u8) ![]const u8 { 1094 const slash = std.mem.lastIndexOfScalar(u8, path, '/') orelse return ""; 1095 const dir = path[0..slash]; 1096 // the row's border and the label's padding take two columns each 1097 const max_width = View.list_max_width - 4; 1098 var width = try xitui.width.displayWidth(dir); 1099 if (width <= max_width) return aa.print(" {s} ", .{dir}); 1100 1101 const ellipsis = ".."; 1102 var iter = (try std.unicode.Utf8View.init(dir)).iterator(); 1103 var start: usize = 0; 1104 while (width > max_width - ellipsis.len) { 1105 const slice = iter.nextCodepointSlice() orelse break; 1106 width -= xitui.width.cellWidth(try std.unicode.utf8Decode(slice)); 1107 start += slice.len; 1108 } 1109 return aa.print(" " ++ ellipsis ++ "{s} ", .{dir[start..]}); 1110 } 1111