diff options
author | Jesse Duffield Duffield <jesseduffieldduffield@Jesses-MacBook-Pro-3.local> | 2019-02-25 22:11:35 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-02 17:49:30 +1100 |
commit | 8c0ea8f45fde1dfddd23198fcb06ae77468e3a3a (patch) | |
tree | ba923f1b86c26327ceec9f12de619265229bf642 /pkg/utils | |
parent | afbc028ad6f2b8a580f6b22d13f3313ba5c44cf6 (diff) |
mouse support
Diffstat (limited to 'pkg/utils')
-rw-r--r-- | pkg/utils/utils.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index b704c2576..cb1648dea 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -160,7 +160,8 @@ func renderDisplayableList(items []Displayable, isFocused bool) (string, error) return strings.Join(paddedDisplayStrings, "\n"), nil } -func decolorise(str string) string { +// Decolorise strips a string of color +func Decolorise(str string) string { re := regexp.MustCompile(`\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]`) return re.ReplaceAllString(str, "") } @@ -172,7 +173,7 @@ func getPadWidths(stringArrays [][]string) []int { padWidths := make([]int, len(stringArrays[0])-1) for i := range padWidths { for _, strings := range stringArrays { - uncoloredString := decolorise(strings[i]) + uncoloredString := Decolorise(strings[i]) if len(uncoloredString) > padWidths[i] { padWidths[i] = len(uncoloredString) } |