def regen_text
@files =
begin
cwd.entries.sort_by do |f|
[f.directory? ? 0 : 1, f.basename.to_s]
end
rescue SystemCallError => e
BufferManager.flash "Error: #{e.message}"
[Pathname.new("."), Pathname.new("..")]
end.map do |f|
real_f = cwd + f
name = f.basename.to_s +
case
when real_f.symlink?
"@"
when real_f.directory?
"/"
else
""
end
[name, real_f]
end
size_width = @files.max_of { |name, f| f.human_size.length }
time_width = @files.max_of { |name, f| f.human_time.length }
@text = ["#{cwd}:"] + @files.map do |name, f|
sprintf "%#{time_width}s %#{size_width}s %s", f.human_time, f.human_size, name
end
end