FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sourcegraph/lib/output/visible_string_width.go at main · zeroows/sourcegraph · GitHub
zeroows
/
sourcegraph
Public
forked from
sourcegraph/sourcegraph-public-snapshot
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sourcegraph
/
lib
/
output
/
visible_string_width.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
16 lines (12 loc) · 523 Bytes
Breadcrumbs
sourcegraph
/
lib
/
output
/
visible_string_width.go
Copy path
File metadata and controls
16 lines (12 loc) · 523 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package
output
import
(
"github.com/grafana/regexp"
"github.com/mattn/go-runewidth"
)
// This regex is taken from here:
// https://github.com/acarl005/stripansi/blob/5a71ef0e047df0427e87a79f27009029921f1f9b/stripansi.go
const
ansi
=
"[
\u001B
\u009B
][[
\\
]()#;?]*(?:(?:(?:[a-zA-Z
\\
d]*(?:;[a-zA-Z
\\
d]*)*)?
\u0007
)|(?:(?:
\\
d{1,4}(?:;
\\
d{0,4})*)?[
\\
dA-PRZcf-ntqry=><~]))"
var
ansiRegex
=
regexp
.
MustCompile
(
ansi
)
func
visibleStringWidth
(
str
string
)
int
{
return
runewidth
.
StringWidth
(
ansiRegex
.
ReplaceAllString
(
str
,
""
))
}
Back
|
FazBrowse Home
|
New Git URL