@@ -23,7 +23,8 @@ func NewCmdProtip(f *cmdutil.Factory, runF func(*ProtipOptions) error) *cobra.Co
2323 opts := & ProtipOptions {
2424 IO : f .IOStreams ,
2525 Sprites : map [string ]* Sprite {
26- "clippy" : Clippy (),
26+ "clippy" : Clippy (),
27+ "manatee" : Manatee (),
2728 },
2829 }
2930
@@ -50,6 +51,8 @@ func NewCmdProtip(f *cmdutil.Factory, runF func(*ProtipOptions) error) *cobra.Co
5051func protipRun (opts * ProtipOptions ) error {
5152 tcell .SetEncodingFallback (tcell .EncodingFallbackASCII )
5253
54+ tip := getProtip ()
55+
5356 style := tcell .StyleDefault
5457
5558 s , err := tcell .NewScreen ()
9699 break loop
97100 case <- time .After (time .Millisecond * 500 ):
98101 }
99- //w, h := s.Size()
100- //w, _ := s.Size()
101102 s .Clear ()
102103 drawSprite (s , 0 , 0 , style , opts .Sprite )
103- tipLines := []string {
104- "To merge a PR, review it until" ,
105- "it is approved." ,
106- }
107- drawProtip (s , opts .Sprite .Width , 1 , style , tipLines )
104+ drawProtip (s , opts .Sprite .Width , 1 , style , tip )
108105 s .Show ()
109106 }
110107
@@ -147,20 +144,20 @@ func drawProtip(s tcell.Screen, startX, startY int, st tcell.Style, tipLines []s
147144 topBorder += "-*"
148145 bottomBorder += "_*"
149146
150- emitStr (s , startX , startY , st , topBorder )
147+ drawStr (s , startX , startY , st , topBorder )
151148
152149 y := startY + 1
153150
154151 for iy , line := range tipLines {
155- emitStr (s , startX , y + iy , st , pad (line ))
152+ drawStr (s , startX , y + iy , st , pad (line ))
156153 y += iy
157154 }
158155
159- emitStr (s , startX , y + 1 , st , bottomBorder )
160- emitStr (s , startX , y + 2 , st , "/" )
156+ drawStr (s , startX , y + 1 , st , bottomBorder )
157+ drawStr (s , startX , y + 2 , st , "/" )
161158}
162159
163- func emitStr (s tcell.Screen , x , y int , style tcell.Style , str string ) {
160+ func drawStr (s tcell.Screen , x , y int , style tcell.Style , str string ) {
164161 for _ , c := range str {
165162 var comb []rune
166163 w := runewidth .RuneWidth (c )
@@ -175,7 +172,6 @@ func emitStr(s tcell.Screen, x, y int, style tcell.Style, str string) {
175172}
176173
177174func drawSprite (s tcell.Screen , x , y int , st tcell.Style , sp * Sprite ) {
178- // TODO worry about animation later
179175 cells := sp .Cells ()
180176 for y := 0 ; y < len (cells ); y ++ {
181177 row := cells [y ]
@@ -185,6 +181,3 @@ func drawSprite(s tcell.Screen, x, y int, st tcell.Style, sp *Sprite) {
185181 }
186182 sp .IncrFrame ()
187183}
188-
189- // Want to be able to have a sprite that occupies a rectangle and can animate internally relative to
190- // its own geometry.
0 commit comments