summaryrefslogtreecommitdiffstats
path: root/tui/format.go
diff options
context:
space:
mode:
authorDaniel Milde <daniel@milde.cz>2024-04-24 15:46:15 +0200
committerDaniel Milde <daniel@milde.cz>2024-04-24 16:07:50 +0200
commite7dbd1ab21039927cde67717917553c3cfaf4aeb (patch)
tree1ff60b4567da879454da078cd2358513487c387f /tui/format.go
parent688804fff1eda6172b159c76c8f4b09a92c97b12 (diff)
refactor: constants for colors
Diffstat (limited to 'tui/format.go')
-rw-r--r--tui/format.go40
1 files changed, 26 insertions, 14 deletions
diff --git a/tui/format.go b/tui/format.go
index 84ad967..001c004 100644
--- a/tui/format.go
+++ b/tui/format.go
@@ -9,6 +9,18 @@ import (
"github.com/rivo/tview"
)
+const (
+ blackOnWhite = "[black:white:-]"
+ blackOnBlue = "[#000000:#2479d0:-]"
+ whiteOnBlack = "[white:black:-]"
+
+ orangeBold = "[#e67100::b]"
+ blueBold = "[#3498db::b]"
+
+ defaultColor = "[-::]"
+ defaultColorBold = "[::b]"
+)
+
func (ui *UI) formatFileRow(item fs.Item, maxUsage int64, maxSize int64, marked, ignored bool) string {
var part int
@@ -23,9 +35,9 @@ func (ui *UI) formatFileRow(item fs.Item, maxUsage int64, maxSize int64, marked,
row := string(item.GetFlag())
if ui.UseColors && !marked && !ignored {
- row += "[#e67100::b]"
+ row += orangeBold
} else {
- row += "[::b]"
+ row += defaultColorBold
}
if ui.ShowApparentSize {
@@ -42,21 +54,21 @@ func (ui *UI) formatFileRow(item fs.Item, maxUsage int64, maxSize int64, marked,
if ui.showItemCount {
if ui.UseColors && !marked && !ignored {
- row += "[#e67100::b]"
+ row += orangeBold
} else {
- row += "[::b]"
+ row += defaultColorBold
}
row += fmt.Sprintf("%11s ", ui.formatCount(item.GetItemCount()))
}
if ui.showMtime {
if ui.UseColors && !marked && !ignored {
- row += "[#e67100::b]"
+ row += orangeBold
} else {
- row += "[::b]"
+ row += defaultColorBold
}
row += fmt.Sprintf(
- "%s [-::]",
+ "%s "+defaultColor,
item.GetMtime().Format("2006-01-02 15:04:05"),
)
}
@@ -72,9 +84,9 @@ func (ui *UI) formatFileRow(item fs.Item, maxUsage int64, maxSize int64, marked,
if item.IsDir() {
if ui.UseColors && !marked && !ignored {
- row += "[#3498db::b]/"
+ row += blueBold + "/"
} else {
- row += "[::b]/"
+ row += defaultColorBold + "/"
}
}
row += tview.Escape(item.GetName())
@@ -85,15 +97,15 @@ func (ui *UI) formatSize(size int64, reverseColor bool, transparentBg bool) stri
var color string
if reverseColor {
if ui.UseColors {
- color = "[#000000:#2479d0:-]"
+ color = blackOnBlue
} else {
- color = "[black:white:-]"
+ color = blackOnWhite
}
} else {
if transparentBg {
- color = "[-::]"
+ color = defaultColor
} else {
- color = "[white:black:-]"
+ color = whiteOnBlack
}
}
@@ -105,7 +117,7 @@ func (ui *UI) formatSize(size int64, reverseColor bool, transparentBg bool) stri
func (ui *UI) formatCount(count int) string {
row := ""
- color := "[-::]"
+ color := defaultColor
count64 := float64(count)
switch {