Skip to content

Commit

Permalink
feat: file icons
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakenelf committed Mar 16, 2024
1 parent dd6434f commit de082f7
Show file tree
Hide file tree
Showing 11 changed files with 495 additions and 1,491 deletions.
1 change: 1 addition & 0 deletions filetree/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func getDirectoryListingCmd(directoryName string, showHidden, directoriesOnly, f
Extension: filepath.Ext(fileInfo.Name()),
IsDirectory: fileInfo.IsDir(),
CurrentDirectory: workingDirectory,
FileInfo: fileInfo,
})
}

Expand Down
2 changes: 2 additions & 0 deletions filetree/model.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package filetree

import (
"os"
"time"

"github.com/charmbracelet/lipgloss"
Expand All @@ -15,6 +16,7 @@ type DirectoryItem struct {
Extension string
CurrentDirectory string
IsDirectory bool
FileInfo os.FileInfo
}

type Model struct {
Expand Down
17 changes: 7 additions & 10 deletions filetree/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"strings"

"github.com/charmbracelet/lipgloss"

"github.com/mistakenelf/fm/icons"
)

func (m Model) View() string {
Expand All @@ -24,17 +26,15 @@ func (m Model) View() string {
case i == m.Cursor && !m.Disabled:
iconColor := m.inactiveItemColor
textColor := m.inactiveItemColor

if i == m.Cursor && !m.Disabled {
iconColor = m.selectedItemColor
textColor = m.selectedItemColor
}

if m.showIcons {
icon := "🗀 "
if !file.IsDirectory {
icon = "🗎 "
}
fileList.WriteString(lipgloss.NewStyle().Bold(true).Foreground(iconColor).Render(icon))
icon := icons.Icons.GetIcon(file.FileInfo)
fileList.WriteString(lipgloss.NewStyle().Bold(true).Foreground(iconColor).Render(icon) + " ")
}

fileList.WriteString(lipgloss.NewStyle().Bold(true).Foreground(textColor).Render(file.Name) + "\n")
Expand All @@ -43,11 +43,8 @@ func (m Model) View() string {
textColor := m.unselectedItemColor

if m.showIcons {
icon := "🗀 "
if !file.IsDirectory {
icon = "🗎 "
}
fileList.WriteString(lipgloss.NewStyle().Bold(true).Foreground(iconColor).Render(icon))
icon := icons.Icons.GetIcon(file.FileInfo)
fileList.WriteString(lipgloss.NewStyle().Bold(true).Foreground(iconColor).Render(icon) + " ")
}

fileList.WriteString(lipgloss.NewStyle().Bold(true).Foreground(textColor).Render(file.Name) + "\n")
Expand Down
62 changes: 0 additions & 62 deletions icons/directories.go

This file was deleted.

0 comments on commit de082f7

Please sign in to comment.