forked from dborzov/lsp
/
render.go
49 lines (43 loc) · 988 Bytes
/
render.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"fmt"
"sort"
c "github.com/mitchellh/colorstring"
)
const (
briefcaseRune = '💼'
gitRune = '😻'
musicRune = '🎼'
pythonRune = '🐍'
javaRune = '🍵'
documentRune = '📄'
commonPrefix = "[blue]"
descriptionIndent = " "
)
func render() {
SetColumnSize()
Traverse()
renderSummary()
}
func renderSummary() {
printHR()
printCentered(fmt.Sprintf(c.Color("[white]lsp \"[red]%s[white]\""), presentPath(mode.targetPath)) + fmt.Sprintf(c.Color(", [red]%v[white] files, [red]%v[white] directories"), len(FileList), len(Trie.Ch["dirs"].Fls)))
for _, cm := range mode.comments {
printCentered(cm)
}
}
func renderFiles(fls []*FileInfo) {
switch {
case mode.size:
sort.Sort(sizeSort(fls))
case mode.time:
sort.Sort(timeSort(fls))
default:
sort.Sort(alphabeticSort(fls))
}
for _, fl := range fls {
if !fl.hidden {
PrintColumns(fl.f.Name(), fl.Description())
}
}
}