Add auto icon mode fallback and Nerd Font docs

This commit is contained in:
vrubelroman 2026-04-24 14:44:49 +03:00
parent ef47410bcf
commit 780150500d
6 changed files with 193 additions and 18 deletions

View file

@ -64,6 +64,7 @@ type PreviewOptions struct {
DirectoryPreviewLimit int
HumanReadableSize bool
ThemeName string
UseNerdIcons bool
}
func BuildPreview(entry Entry, options PreviewOptions) Preview {
@ -317,7 +318,7 @@ func buildDirectoryPreview(path string, options PreviewOptions) string {
if entry.IsParent {
continue
}
icon := previewIcon(entry)
icon := previewIcon(entry, options.UseNerdIcons)
size := ""
if !entry.IsDir {
@ -338,7 +339,26 @@ func buildDirectoryPreview(path string, options PreviewOptions) string {
return strings.Join(lines, "\n")
}
func previewIcon(entry Entry) string {
func previewIcon(entry Entry, useNerdIcons bool) string {
if !useNerdIcons {
switch entry.Category() {
case "directory":
return "[D]"
case "config":
return "[C]"
case "text":
return "[T]"
case "image":
return "[I]"
case "executable":
return "[X]"
case "archive":
return "[A]"
default:
return "[F]"
}
}
switch entry.Category() {
case "directory":
return ""