| 1 | package vaxisscip-go gomod git.sr.ht/~rockorager/vaxis . `git.sr.ht/~rockorager/vaxis`/ |
| 2 | |
| 3 | import "github.com/rivo/unisegscip-go gomod github.com/rivo/uniseg v0.4.4 `github.com/rivo/uniseg`/" |
| 4 | |
| 5 | // Character is a single extended-grapheme-cluster. It also contains the width |
| 6 | // of the EGC |
| 7 | type Characterscip-go gomod git.sr.ht/~rockorager/vaxis . `git.sr.ht/~rockorager/vaxis`/Character# struct { |
| 8 | Graphemescip-go gomod git.sr.ht/~rockorager/vaxis . `git.sr.ht/~rockorager/vaxis`/Character#Grapheme. string |
| 9 | Widthscip-go gomod git.sr.ht/~rockorager/vaxis . `git.sr.ht/~rockorager/vaxis`/Character#Width. int |
| 10 | } |
| 11 | |
| 12 | // Converts a string into a slice of Characters suitable to assign to terminal cells |
| 13 | func Charactersscip-go gomod git.sr.ht/~rockorager/vaxis . `git.sr.ht/~rockorager/vaxis`/Characters().(s string) []Characterscip-go gomod git.sr.ht/~rockorager/vaxis . `git.sr.ht/~rockorager/vaxis`/Character# { |
| 14 | egcs := make([]Characterscip-go gomod git.sr.ht/~rockorager/vaxis . `git.sr.ht/~rockorager/vaxis`/Character#, 0, len(s)) |
| 15 | state := -1 |
| 16 | cluster := "" |
| 17 | w := 0 |
| 18 | for s != "" { |
| 19 | cluster, s, w, state = unisegscip-go gomod github.com/rivo/uniseg v0.4.4 `github.com/rivo/uniseg`/.FirstGraphemeClusterInStringscip-go gomod github.com/rivo/uniseg v0.4.4 `github.com/rivo/uniseg`/FirstGraphemeClusterInString().(s, state) |
| 20 | if cluster == "\t" { |
| 21 | for i := 0; i < 8; i += 1 { |
| 22 | egcs = append(egcs, Characterscip-go gomod git.sr.ht/~rockorager/vaxis . `git.sr.ht/~rockorager/vaxis`/Character#{" ", 1}) |
| 23 | } |
| 24 | continue |
| 25 | } |
| 26 | egcs = append(egcs, Characterscip-go gomod git.sr.ht/~rockorager/vaxis . `git.sr.ht/~rockorager/vaxis`/Character#{cluster, w}) |
| 27 | } |
| 28 | return egcs |
| 29 | } |