mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
fix: fixed a minor UI bug while rendering table cells with special UTF8 characters (fixes #211)
This commit is contained in:
parent
07938f8a6c
commit
89434e1a2a
1 changed files with 2 additions and 3 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
var ansi = regexp.MustCompile("\033\\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]")
|
||||
|
@ -13,8 +14,7 @@ func viewLen(s string) int {
|
|||
for _, m := range ansi.FindAllString(s, -1) {
|
||||
s = strings.Replace(s, m, "", -1)
|
||||
}
|
||||
|
||||
return len(s)
|
||||
return utf8.RuneCountInString(s)
|
||||
}
|
||||
|
||||
func maxLen(strings []string) int {
|
||||
|
@ -59,7 +59,6 @@ func padded(s string, maxLen int, align Alignment) string {
|
|||
}
|
||||
|
||||
func AsTable(w io.Writer, columns []string, rows [][]string) {
|
||||
|
||||
for i, col := range columns {
|
||||
columns[i] = fmt.Sprintf(" %s ", col)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue