File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,41 +10,30 @@ import (
1010// NewCell returns a new cell. This is a convenience function that initializes a
1111// new cell with the given content. The cell's width is determined by the
1212// content using [runewidth.RuneWidth].
13- func NewCell (r rune , comb ... rune ) * Cell {
14- width := runewidth .StringWidth (string (append ([]rune {r }, comb ... )))
15- return & Cell {
16- Rune : r ,
17- Comb : comb ,
18- Width : width ,
19- }
13+ func NewCell (r rune , comb ... rune ) (c * Cell ) {
14+ c = new (Cell )
15+ c .Rune = r
16+ c .Comb = comb
17+ c .Width = runewidth .StringWidth (string (append ([]rune {r }, comb ... )))
18+ return
2019}
2120
2221// NewCellString returns a new cell with the given string content. This is a
2322// convenience function that initializes a new cell with the given content. The
2423// cell's width is determined by the content using [wcwidth.StringWidth].
2524// This will only use the first combined rune in the string. If the string is
2625// empty, it will return an empty cell with a width of 0.
27- func NewCellString (s string ) * Cell {
28- var r rune
29- var comb []rune
30- var w int
31- for i , c := range s {
26+ func NewCellString (s string ) (c * Cell ) {
27+ c = new (Cell )
28+ c .Width = runewidth .StringWidth (s )
29+ for i , r := range s {
3230 if i == 0 {
33- r = c
34- w = runewidth .RuneWidth (c )
31+ c .Rune = r
3532 continue
3633 }
37- if runewidth .RuneWidth (c ) > 0 {
38- break
39- }
40- comb = append (comb , c )
41- }
42-
43- return & Cell {
44- Rune : r ,
45- Comb : comb ,
46- Width : w ,
34+ c .Comb = append (c .Comb , r )
4735 }
36+ return
4837}
4938
5039// NewGraphemeCell returns a new cell. This is a convenience function that
You can’t perform that action at this time.
0 commit comments