parent
630bdf19f3
commit
d776e728ef
4 changed files with 24 additions and 16 deletions
2
LICENSE
2
LICENSE
|
@ -39,6 +39,8 @@ Bugfixes in ANSI escape sequence handling as well as TextView
|
|||
Sun Jul 12 13:34:19 2020 +0200
|
||||
TextView.GetText() and .GetRegionText() didn't filter out empty colour tags. Fixes #453
|
||||
|
||||
The cview license applies to all other commits.
|
||||
|
||||
----------
|
||||
|
||||
cview license:
|
||||
|
|
6
go.mod
6
go.mod
|
@ -3,11 +3,11 @@ module gitlab.com/tslocum/cview
|
|||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/gdamore/tcell/v2 v2.1.1-0.20201225194624-29bb185874fd
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3
|
||||
github.com/gdamore/tcell/v2 v2.1.1-0.20210125004847-19e17097d8fe
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0
|
||||
github.com/mattn/go-runewidth v0.0.10
|
||||
github.com/rivo/uniseg v0.2.0
|
||||
gitlab.com/tslocum/cbind v0.1.4
|
||||
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 // indirect
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
|
||||
golang.org/x/text v0.3.5 // indirect
|
||||
)
|
||||
|
|
13
go.sum
13
go.sum
|
@ -1,10 +1,12 @@
|
|||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||
github.com/gdamore/tcell/v2 v2.0.0-dev/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||
github.com/gdamore/tcell/v2 v2.1.1-0.20201225194624-29bb185874fd h1:66OLuRCaOFojnLK9eB0YTo8CU9AgHtfvBWvLsz/8r+I=
|
||||
github.com/gdamore/tcell/v2 v2.1.1-0.20201225194624-29bb185874fd/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||
github.com/gdamore/tcell/v2 v2.1.1-0.20210125004847-19e17097d8fe h1:D4zQq/0ep0XCtgkmA+dUvQNYMoiW2+2336rdlAucr10=
|
||||
github.com/gdamore/tcell/v2 v2.1.1-0.20210125004847-19e17097d8fe/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
|
@ -17,8 +19,11 @@ gitlab.com/tslocum/cbind v0.1.4 h1:cbZXPPcieXspk8cShoT6efz7HAT8yMNQcofYWNizis4=
|
|||
gitlab.com/tslocum/cbind v0.1.4/go.mod h1:RvwYE3auSjBNlCmWeGspzn+jdLUVQ8C2QGC+0nP9ChI=
|
||||
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201013132646-2da7054afaeb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 h1:nVuTkr9L6Bq62qpUqKo/RnZCFfzDBL0bYo6w9OJUqZY=
|
||||
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M=
|
||||
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
|
|
19
util.go
19
util.go
|
@ -25,7 +25,7 @@ const (
|
|||
|
||||
// Common regular expressions.
|
||||
var (
|
||||
colorPattern = regexp.MustCompile(`\[([a-zA-Z]+|#[0-9a-zA-Z]{6}|\-)?(:([a-zA-Z]+|#[0-9a-zA-Z]{6}|\-)?(:([lbdiru]+|\-)?)?)?\]`)
|
||||
colorPattern = regexp.MustCompile(`\[([a-zA-Z]+|#[0-9a-zA-Z]{6}|\-)?(:([a-zA-Z]+|#[0-9a-zA-Z]{6}|\-)?(:([bdilrsu]+|\-)?)?)?\]`)
|
||||
regionPattern = regexp.MustCompile(`\["([a-zA-Z0-9_,;: \-\.]*)"\]`)
|
||||
escapePattern = regexp.MustCompile(`\[([a-zA-Z0-9_,;: \-\."#]+)\[(\[*)\]`)
|
||||
nonEscapePattern = regexp.MustCompile(`(\[[a-zA-Z0-9_,;: \-\."#]+\[*)\]`)
|
||||
|
@ -55,7 +55,7 @@ var (
|
|||
InputFieldMaxLength func(maxLength int) func(text string, ch rune) bool
|
||||
)
|
||||
|
||||
// Transformation describes a widget modification.
|
||||
// Transformation describes a widget state modification.
|
||||
type Transformation int
|
||||
|
||||
// Widget transformations.
|
||||
|
@ -192,30 +192,30 @@ func overlayStyle(background tcell.Color, defaultStyle tcell.Style, fgColor, bgC
|
|||
|
||||
if attributes == "-" {
|
||||
style = style.Bold(defAttr&tcell.AttrBold > 0)
|
||||
style = style.Blink(defAttr&tcell.AttrBlink > 0)
|
||||
style = style.Dim(defAttr&tcell.AttrDim > 0)
|
||||
style = style.Italic(defAttr&tcell.AttrItalic > 0)
|
||||
style = style.Blink(defAttr&tcell.AttrBlink > 0)
|
||||
style = style.Reverse(defAttr&tcell.AttrReverse > 0)
|
||||
style = style.Underline(defAttr&tcell.AttrUnderline > 0)
|
||||
style = style.StrikeThrough(defAttr&tcell.AttrStrikeThrough > 0)
|
||||
style = style.Underline(defAttr&tcell.AttrUnderline > 0)
|
||||
} else if attributes != "" {
|
||||
style = style.Normal()
|
||||
for _, flag := range attributes {
|
||||
switch flag {
|
||||
case 'l':
|
||||
style = style.Blink(true)
|
||||
case 'b':
|
||||
style = style.Bold(true)
|
||||
case 'd':
|
||||
style = style.Dim(true)
|
||||
case 'i':
|
||||
style = style.Italic(true)
|
||||
case 'l':
|
||||
style = style.Blink(true)
|
||||
case 'r':
|
||||
style = style.Reverse(true)
|
||||
case 'u':
|
||||
style = style.Underline(true)
|
||||
case 's':
|
||||
style = style.StrikeThrough(true)
|
||||
case 'u':
|
||||
style = style.Underline(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -226,11 +226,12 @@ func overlayStyle(background tcell.Color, defaultStyle tcell.Style, fgColor, bgC
|
|||
// SetAttributes sets attributes on a style.
|
||||
func SetAttributes(style tcell.Style, attrs tcell.AttrMask) tcell.Style {
|
||||
return style.
|
||||
Blink(attrs&tcell.AttrBlink != 0).
|
||||
Bold(attrs&tcell.AttrBold != 0).
|
||||
Dim(attrs&tcell.AttrDim != 0).
|
||||
Italic(attrs&tcell.AttrItalic != 0).
|
||||
Blink(attrs&tcell.AttrBlink != 0).
|
||||
Reverse(attrs&tcell.AttrReverse != 0).
|
||||
StrikeThrough(attrs&tcell.AttrStrikeThrough != 0).
|
||||
Underline(attrs&tcell.AttrUnderline != 0)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue