From d195cc757c312692b34bf011ff1de75db4b6ca98 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 18 Mar 2019 23:41:32 -0700 Subject: [PATCH] fixes #264 tcell breaks grapheme clusters --- _demos/unicode.go | 6 +++--- cell.go | 18 ++---------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/_demos/unicode.go b/_demos/unicode.go index ee046fb..15cc8aa 100644 --- a/_demos/unicode.go +++ b/_demos/unicode.go @@ -1,4 +1,4 @@ -// Copyright 2015 The TCell Authors +// Copyright 2019 The TCell Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use file except in compliance with the License. @@ -22,7 +22,7 @@ import ( "github.com/gdamore/tcell" "github.com/gdamore/tcell/encoding" - "github.com/mattn/go-runewidth" + runewidth "github.com/mattn/go-runewidth" ) var row = 0 @@ -127,7 +127,7 @@ func main() { putln(s, "ZWJ: \U0001f9db\u200d\u2640 (female vampire)") putln(s, "ZWJ: \U0001f9db\u200d\u2642 (male vampire)") putln(s, "Family: \U0001f469\u200d\U0001f467\u200d\U0001f467 (woman girl girl)\n") - + putln(s, "Region: \U0001f1fa\U0001f1f8 (USA! USA!)\n") putln(s, "") putln(s, "Box:") putln(s, string([]rune{ diff --git a/cell.go b/cell.go index 957b62f..c7f8f1a 100644 --- a/cell.go +++ b/cell.go @@ -1,4 +1,4 @@ -// Copyright 2015 The TCell Authors +// Copyright 2019 The TCell Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use file except in compliance with the License. @@ -15,7 +15,7 @@ package tcell import ( - "github.com/mattn/go-runewidth" + runewidth "github.com/mattn/go-runewidth" ) type cell struct { @@ -49,20 +49,6 @@ func (cb *CellBuffer) SetContent(x int, y int, c := &cb.cells[(y*cb.w)+x] c.currComb = append([]rune{}, combc...) - i := 0 - for i < len(c.currComb) { - r := c.currComb[i] - if r == '\u200d' { - i += 2 - continue - } - if runewidth.RuneWidth(r) != 0 { - // not a combining character, yank it - c.currComb = append(c.currComb[:i-1], c.currComb[i+1:]...) - continue - } - i++ - } if c.currMain != mainc { c.width = runewidth.RuneWidth(mainc)