chore!: change to use v3 of Tcell (#2286)
* Remove SGR 8 * Remove `<backspace2>` * Migrate to v3 of Tcell * Refactor key handling functionality * Bump Tcell version * Replace `SetContent` API with `Put` API * bump dependencies * Use new color package * Fix cursor position for grapheme clusters * Some editing fixes to support grapheme clusters * Ignore carriage return when printing * Move grapheme cluster handling into misc.go * Fix length of filenames containing emoji * Use slices.Concat * Use `string` instead of `[]rune` for `win.print` * Add note about modifier limitations * Update `CHANGELOG.md`
This commit is contained in:
1 parent
a446855e76
commit
6ec60cf9d8
21 files changed
+558
-463
No files matched your search
@@ -16,10 +16,10 @@ import (
|
||||
"unicode"
|
||||
|
||||
"github.com/mattn/go-runewidth"
|
||||
"github.com/rivo/uniseg"
|
||||
)
|
||||
|
||||
var (
|
||||
reModKey = regexp.MustCompile(`<(c|s|a)-(.+)>`)
|
||||
reRulerSub = regexp.MustCompile(`%[apmcsvfithPd]|%\{[^}]+\}`)
|
||||
reSixelSize = regexp.MustCompile(`"1;1;(\d+);(\d+)`)
|
||||
)
|
||||
@@ -84,6 +84,25 @@ func runeSliceWidthLastRange(rs []rune, maxWidth int) []rune {
|
||||
return rs
|
||||
}
|
||||
|
||||
// firstGraphemeCluster returns the runes forming the first grapheme cluster of
|
||||
// the input.
|
||||
func firstGraphemeCluster(rs []rune) []rune {
|
||||
gr := uniseg.NewGraphemes(string(rs))
|
||||
gr.Next()
|
||||
return gr.Runes()
|
||||
}
|
||||
|
||||
// lastGraphemeCluster returns the runes forming the last grapheme cluster of
|
||||
// the input.
|
||||
func lastGraphemeCluster(rs []rune) []rune {
|
||||
gr := uniseg.NewGraphemes(string(rs))
|
||||
var last []rune
|
||||
for gr.Next() {
|
||||
last = gr.Runes()
|
||||
}
|
||||
return last
|
||||
}
|
||||
|
||||
// cmdEscape is used to escape whitespace and special characters with
|
||||
// backslashes in a given string.
|
||||
func cmdEscape(s string) string {
|
||||
|
||||
Reference in new issue
Block a user