mirror of
https://github.com/gizak/termui.git
synced 2025-04-26 13:48:54 +08:00
adding containsStyle func
This commit is contained in:
parent
29db86d4f2
commit
238057237b
@ -167,6 +167,12 @@ func findStylePositions(s string) []int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func containsStyle(s string) bool {
|
func containsStyle(s string) bool {
|
||||||
|
if strings.HasPrefix(s, string(tokenBeginStyledText)) &&
|
||||||
|
strings.HasSuffix(s, string(tokenEndStyle)) &&
|
||||||
|
strings.Contains(s, string(tokenEndStyledText)) &&
|
||||||
|
strings.Contains(s, string(tokenBeginStyle)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package termui
|
package termui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBreakBlocksIntoStrings(t *testing.T) {
|
func TestBreakBlocksIntoStrings(t *testing.T) {
|
||||||
items := breakBlocksIntoStrings("test [blue](fg:blue,mod:bold) and [red](fg:red) and maybe even [foo](bg:red)!")
|
items := breakBlocksIntoStrings("test [blue](fg:blue,mod:bold) and [red](fg:red) and maybe even [foo](bg:red)!")
|
||||||
fmt.Println(strings.Join(items, ""))
|
if len(items) != 7 {
|
||||||
|
t.Fatal("wrong length", len(items))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindStylePositions(t *testing.T) {
|
func TestFindStylePositions(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user