File tree 2 files changed +17
-12
lines changed
2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -4,19 +4,14 @@ import (
4
4
"fmt"
5
5
"math"
6
6
"time"
7
- "regexp"
8
7
"strings"
9
8
"strconv"
10
9
"github.com/fatih/color"
10
+ "github.com/drn/nerd-ls/util"
11
11
"github.com/drn/nerd-ls/node"
12
12
"github.com/drn/nerd-ls/humanize"
13
13
)
14
14
15
- const ansi = "[\u001B \u009B ][[\\ ]()#;?]*(?:(?:(?:[a-zA-Z\\ d]*(?:;[a-zA-Z\\ d]" +
16
- "*)*)?\u0007 )|(?:(?:\\ d{1,4}(?:;\\ d{0,4})*)?[\\ dA-PRZcf-ntqry=>" +
17
- "<~]))"
18
- var ansiRegex = regexp .MustCompile (ansi )
19
-
20
15
// Long - Format listing in long format.
21
16
func Long (nodes []node.Node ) {
22
17
// populate values
@@ -31,7 +26,7 @@ func Long(nodes []node.Node) {
31
26
for i := range values {
32
27
lengths [i ] = make ([]int , len (values [i ]))
33
28
for j := range values [i ] {
34
- length := len (strip (values [i ][j ]))
29
+ length := len (util . StripColor (values [i ][j ]))
35
30
lengths [i ][j ] = length
36
31
if length > maxLengths [j ] {
37
32
maxLengths [j ] = length
@@ -109,11 +104,6 @@ func formatTime(node node.Node) string {
109
104
)
110
105
}
111
106
112
- // strips ANSI color codes from string
113
- func strip (str string ) string {
114
- return ansiRegex .ReplaceAllString (str , "" )
115
- }
116
-
117
107
func formatMode (mode string ) string {
118
108
runes := []rune (mode )
119
109
Original file line number Diff line number Diff line change
1
+ package util
2
+
3
+ import (
4
+ "regexp"
5
+ )
6
+
7
+ const ansi = "[\u001B \u009B ][[\\ ]()#;?]*(?:(?:(?:[a-zA-Z\\ d]*(?:;[a-zA-Z\\ d]" +
8
+ "*)*)?\u0007 )|(?:(?:\\ d{1,4}(?:;\\ d{0,4})*)?[\\ dA-PRZcf-ntqry=>" +
9
+ "<~]))"
10
+ var ansiRegex = regexp .MustCompile (ansi )
11
+
12
+ // StripColor - strips ANSI color codes from string
13
+ func StripColor (str string ) string {
14
+ return ansiRegex .ReplaceAllString (str , "" )
15
+ }
You can’t perform that action at this time.
0 commit comments