Skip to content

Commit

Permalink
feat: replay story
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Jan 12, 2024
1 parent ab4dd7d commit 1c4ddd2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/src/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ If your terminal is wider than 80 columns, you'll notice that the pane does not

All actions in `cy`, such as creating panes and switching between them, are triggered by sequences of keys.

{{story cast cy/viewport -w 100}}
{{story cast cy/viewport --width 120 --height 26}}

Here are a few you can try:

Expand All @@ -34,6 +34,8 @@ Here are a few you can try:

## 3. Entering replay mode

{{story cast cy/replay}}

## 4. Creating a new shell

To create a new shell, type `ctrl+a` `j`. This creates a new pane running your default shell in your current working directory. You can return to the old one with `ctrl+l`; this cycles between all of the panes in the current **group**. In `cy`, a group is just a container for panes or other groups.
Expand Down
14 changes: 10 additions & 4 deletions pkg/cy/stories.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,20 @@ func init() {
stories.Register("cy/replay", Replay, stories.Config{
Input: []interface{}{
stories.Wait(stories.Some),
stories.Type("seq 1 100", "enter"),
stories.Type("this is a test", "enter"),
stories.Wait(stories.More),
stories.Type("seq 1 10", "enter"),
stories.Wait(stories.More),
stories.Type("ctrl+a", "p"),
stories.Wait(stories.Some),
stories.Type("gg", "space"),
stories.Type("left", "left", "left", "left"),
stories.Wait(stories.ALot),
stories.Type("space"),
stories.Wait(stories.ALot),
stories.Type("?", "test", "enter"),
stories.Wait(stories.ALot),
stories.Type("h", "h", "h"),
stories.Wait(stories.ALot),
stories.Type("@", "space"),
stories.Wait(stories.Some),
},
})
}
6 changes: 5 additions & 1 deletion pkg/stories/ui/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ func (k *Keys) Update(msg tea.Msg) (taro.Model, tea.Cmd) {
k.presses = k.presses[1:]
return k, nil
case taro.KeyMsg:
name := msg.String()
if string(msg.Runes) == " " || msg.Type == taro.KeySpace {
name = "space"
}
k.presses = append(k.presses, keyPress{
stamp: time.Now(),
key: msg.String(),
key: name,
})
return k, func() tea.Msg {
time.Sleep(10 * time.Second)
Expand Down

0 comments on commit 1c4ddd2

Please sign in to comment.