-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from koki-develop/animation
- Loading branch information
Showing
8 changed files
with
188 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package printer | ||
|
||
import ( | ||
"time" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/mattn/go-runewidth" | ||
) | ||
|
||
var ( | ||
_ tea.Model = (*model)(nil) | ||
) | ||
|
||
type model struct { | ||
printer *Printer | ||
|
||
index int | ||
grasses []string | ||
} | ||
|
||
func newModel(p *Printer, grasses []string) *model { | ||
return &model{ | ||
printer: p, | ||
|
||
index: 0, | ||
grasses: grasses, | ||
} | ||
} | ||
|
||
func (m *model) Init() tea.Cmd { | ||
runewidth.DefaultCondition.EastAsianWidth = false | ||
|
||
return m.tick() | ||
} | ||
|
||
func (m *model) View() string { | ||
return m.printer.grasses(m.grasses, m.index) | ||
} | ||
|
||
type tickMsg struct{} | ||
|
||
func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
switch msg.Type { | ||
case tea.KeyCtrlC: | ||
return m, tea.Quit | ||
} | ||
case tickMsg: | ||
m.index++ | ||
if m.index == len(m.grasses) { | ||
return m, tea.Quit | ||
} | ||
return m, m.tick() | ||
} | ||
|
||
return m, nil | ||
} | ||
|
||
func (m *model) tick() tea.Cmd { | ||
return tea.Tick(10*time.Millisecond, func(time.Time) tea.Msg { | ||
return tickMsg{} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Output assets/animate.gif | ||
|
||
Require gh | ||
|
||
Set Shell "bash" | ||
Set FontSize 32 | ||
Set Width 2200 | ||
Set Height 600 | ||
Set PlaybackSpeed 0.5 | ||
|
||
Hide | ||
Type "go build ." Enter | ||
Type "gh extension remove grass" Enter | ||
Type "gh extension install ." Enter | ||
Type "gh grass --help" Enter | ||
Ctrl+l | ||
Sleep 3s | ||
Show | ||
|
||
Type "gh grass --animate" Sleep 500ms Enter | ||
Sleep 3650ms | ||
|
||
Sleep 5s |