Skip to content

Commit 641baaa

Browse files
committed
Improvements to output module
1 parent 327f10a commit 641baaa

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Diff for: output/table.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (t *Table) Render() string {
139139
case Minimum:
140140
selectedWidth = widths[x]
141141
case Average:
142-
selectedWidth = average[x] + variance[x]*2
142+
selectedWidth = average[x] + variance[x]*3
143143
}
144144
}
145145
res += separator

Diff for: output/text.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package output
1919

2020
import (
2121
"fmt"
22+
"unicode/utf8"
2223

2324
"github.com/fatih/color"
2425
)
@@ -27,6 +28,8 @@ var red = color.New(color.FgRed).SprintfFunc()
2728
var blue = color.New(color.FgBlue).SprintfFunc()
2829
var green = color.New(color.FgGreen).SprintfFunc()
2930
var yellow = color.New(color.FgYellow).SprintfFunc()
31+
var white = color.New(color.FgWhite).SprintfFunc()
32+
var hiWhite = color.New(color.FgHiWhite).SprintfFunc()
3033

3134
func Red(in string) *Text {
3235
return &Text{raw: red(in), clean: in}
@@ -44,6 +47,14 @@ func Yellow(in string) *Text {
4447
return &Text{raw: yellow(in), clean: in}
4548
}
4649

50+
func White(in string) *Text {
51+
return &Text{raw: white(in), clean: in}
52+
}
53+
54+
func HiWhite(in string) *Text {
55+
return &Text{raw: hiWhite(in), clean: in}
56+
}
57+
4758
type TextBox interface {
4859
Len() int
4960
Pad(availableWidth int) string
@@ -56,7 +67,7 @@ type Text struct {
5667
}
5768

5869
func (t *Text) Len() int {
59-
return len(t.clean)
70+
return utf8.RuneCountInString(t.clean)
6071
}
6172

6273
// func (t *Text) String() string {

0 commit comments

Comments
 (0)