Skip to content

Commit

Permalink
Clean up terminal fmt stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Borzov authored and Dmitry Borzov committed Dec 22, 2014
1 parent 584618d commit 420b5ca
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 43 deletions.
34 changes: 32 additions & 2 deletions fmt.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// fmt.go, complements render.go, containing stuff to format output in the stdoutt/terminal,
// but fmt.go is for more bash-specific/lower level stuff
// fmt.go for sutff to format output in the stdoutt/terminal
package main

import (
"fmt"
"sort"
"strings"
"syscall"
"unicode/utf8"
Expand All @@ -22,6 +22,36 @@ var (
maxFileNameSize = columnSize - 7
)

func render() {
SetColumnSize()
Traverse()
renderSummary()
}

func renderSummary() {
printHR()
printCentered(fmt.Sprintf(c.Color("[white]lsp \"[red]%s[white]\""), presentPath(mode.absolutePath)) + 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())
}
}
}

// PrintColumns prints two-column table row, nicely formatted and shortened if needed
func PrintColumns(filename, description string) {
indentSize := columnSize - utf8.RuneCountInString(filename)
Expand Down
40 changes: 0 additions & 40 deletions render.go

This file was deleted.

1 change: 0 additions & 1 deletion symlonko

This file was deleted.

0 comments on commit 420b5ca

Please sign in to comment.