Show file name and extension for filetypes without previews
This commit is contained in:
parent
75c3019756
commit
4d4b287a4a
1 changed files with 6 additions and 1 deletions
|
|
@ -123,6 +123,7 @@ func write_file_metadata(abspath string, metadata fs.FileInfo, entries []fs.DirE
|
|||
add := func(key, val string) { fmt.Fprintf(&buf, "%s: %s\n", key, val) }
|
||||
ftype := metadata.Mode().Type()
|
||||
const file_icon = " "
|
||||
fmt.Fprintln(&buf, filepath.Base(abspath))
|
||||
switch ftype {
|
||||
case 0:
|
||||
add("Size", humanize.Bytes(uint64(metadata.Size())))
|
||||
|
|
@ -175,7 +176,11 @@ func NewDirectoryPreview(abspath string, metadata fs.FileInfo) Preview {
|
|||
}
|
||||
|
||||
func NewFileMetadataPreview(abspath string, metadata fs.FileInfo) Preview {
|
||||
title := icons.IconForFileWithMode(filepath.Base(abspath), metadata.Mode().Type(), false) + " File"
|
||||
ext := filepath.Ext(abspath)
|
||||
if ext == "" {
|
||||
ext = "File"
|
||||
}
|
||||
title := icons.IconForFileWithMode(filepath.Base(abspath), metadata.Mode().Type(), false) + " " + ext
|
||||
h, t := write_file_metadata(abspath, metadata, nil)
|
||||
return &MessagePreview{title: title, msg: h, trailers: t}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue