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 {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,15 @@
|
||||
package termui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBreakBlocksIntoStrings(t *testing.T) {
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user