Skip to content

Commit

Permalink
Improvements to output module
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Oct 19, 2018
1 parent b6322eb commit d92bfb9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion output/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (t *Table) Render() string {
case Minimum:
selectedWidth = widths[x]
case Average:
selectedWidth = average[x] + variance[x]*2
selectedWidth = average[x] + variance[x]*3
}
}
res += separator
Expand Down
13 changes: 12 additions & 1 deletion output/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package output

import (
"fmt"
"unicode/utf8"

"github.com/fatih/color"
)
Expand All @@ -27,6 +28,8 @@ var red = color.New(color.FgRed).SprintfFunc()
var blue = color.New(color.FgBlue).SprintfFunc()
var green = color.New(color.FgGreen).SprintfFunc()
var yellow = color.New(color.FgYellow).SprintfFunc()
var white = color.New(color.FgWhite).SprintfFunc()
var hiWhite = color.New(color.FgHiWhite).SprintfFunc()

func Red(in string) *Text {
return &Text{raw: red(in), clean: in}
Expand All @@ -44,6 +47,14 @@ func Yellow(in string) *Text {
return &Text{raw: yellow(in), clean: in}
}

func White(in string) *Text {
return &Text{raw: white(in), clean: in}
}

func HiWhite(in string) *Text {
return &Text{raw: hiWhite(in), clean: in}
}

type TextBox interface {
Len() int
Pad(availableWidth int) string
Expand All @@ -56,7 +67,7 @@ type Text struct {
}

func (t *Text) Len() int {
return len(t.clean)
return utf8.RuneCountInString(t.clean)
}

// func (t *Text) String() string {
Expand Down

0 comments on commit d92bfb9

Please sign in to comment.