diff options
Diffstat (limited to 'core/Dir.zig')
| -rw-r--r-- | core/Dir.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/Dir.zig b/core/Dir.zig index 0f99e497..1be67378 100644 --- a/core/Dir.zig +++ b/core/Dir.zig @@ -105,10 +105,10 @@ fn readHost(gpa: std.mem.Allocator, local: []const u8) ![]u8 { /// first, every column as wide as the widest entry and a cell more, /// rounded up to a tab, and each row ending in a newline. Blanks pad where /// acme's tabs do: a pardes tab is a fixed width, not a stop. -pub fn columnate(gpa: std.mem.Allocator, entries: []const []const u8, width: usize) error{OutOfMemory}![]u8 { +pub fn columnate(tab_w: u16, gpa: std.mem.Allocator, entries: []const []const u8, width: usize) error{OutOfMemory}![]u8 { var colw: usize = 0; for (entries) |entry| { - const w = File.displayWidth(entry) + 1; + const w = File.displayWidth(tab_w, entry) + 1; colw = @max(colw, (w + tab - 1) / tab * tab); } const ncol = if (colw == 0) 1 else @max(1, width / colw); @@ -120,7 +120,7 @@ pub fn columnate(gpa: std.mem.Allocator, entries: []const []const u8, width: usi while (j < entries.len) : (j += nrow) { try out.appendSlice(gpa, entries[j]); if (j + nrow >= entries.len) break; - try out.appendNTimes(gpa, ' ', colw - File.displayWidth(entries[j])); + try out.appendNTimes(gpa, ' ', colw - File.displayWidth(tab_w, entries[j])); } try out.append(gpa, '\n'); } @@ -151,7 +151,7 @@ pub fn fit(p: *Pardes, pane: *Pane, cols: usize) void { defer p.gpa.free(entries); var it = std.mem.splitScalar(u8, l.names, '\n'); for (entries) |*entry| entry.* = it.next().?; - const text = columnate(p.gpa, entries, width) catch return; + const text = columnate(p.settings.tab, p.gpa, entries, width) catch return; if (std.mem.eql(u8, text, f.content)) p.gpa.free(text) else { File.setContent(p, f, text); panes.Output.resetBody(p, pane); @@ -252,7 +252,7 @@ pub fn show(p: *Pardes, from: usize, id: usize) void { const testing = std.testing; fn laidOut(names: []const []const u8, width: usize) ![]u8 { - return columnate(testing.allocator, names, width); + return columnate(config.tab_width, testing.allocator, names, width); } test "entries go down each column first, a column a tab wider than its widest entry, as acme's" { |
