Adapted to slight change in rivo/uniseg.

pull/749/head
Oliver 2 years ago
parent 4b7fb7ecd6
commit c6cff75ed5

@ -6,7 +6,7 @@ require (
github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mattn/go-runewidth v0.0.13
github.com/rivo/uniseg v0.3.0
github.com/rivo/uniseg v0.3.1
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 // indirect
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
)

@ -7,8 +7,8 @@ github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.3.0 h1:eyC18g7xB83Dv/xlJXLgNkRidVoR7nqFZBJvqo/K188=
github.com/rivo/uniseg v0.3.0/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rivo/uniseg v0.3.1 h1:SDPP7SHNl1L7KrEFCSJslJ/DM9DT02Nq2C61XrfHMmk=
github.com/rivo/uniseg v0.3.1/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY=
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

@ -807,7 +807,7 @@ func (t *TextView) reindexBuffer(width int) {
extract := runewidth.Truncate(str, width, "")
if len(extract) == 0 {
// We'll extract at least one grapheme cluster.
extract, _, _ = uniseg.FirstGraphemeClusterInString(str, -1)
extract, _, _, _ = uniseg.FirstGraphemeClusterInString(str, -1)
}
if t.wordWrap && len(extract) < len(str) {
// Add any spaces from the next line.

@ -451,7 +451,7 @@ func stringWidth(text string) (width int) {
chWidth int
cl string
)
cl, text, state = uniseg.FirstGraphemeClusterInString(text, state)
cl, text, _, state = uniseg.FirstGraphemeClusterInString(text, state)
for _, r := range cl {
chWidth = runewidth.RuneWidth(r)
if chWidth > 0 {
@ -591,7 +591,7 @@ func iterateString(text string, callback func(main rune, comb []rune, textPos, t
state := -1
for len(text) > 0 {
var cluster string
cluster, text, state = uniseg.FirstGraphemeClusterInString(text, state)
cluster, text, _, state = uniseg.FirstGraphemeClusterInString(text, state)
var width int
runes := make([]rune, 0, len(cluster))

Loading…
Cancel
Save