Skip to content

Commit

Permalink
feat: pasting
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Oct 28, 2023
1 parent d983eea commit c1d8e9a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/cy/cy-boot.janet
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
(key/bind :root [prefix "q"] "kill the cy server" (fn [&] (cy/kill-server)))
(key/bind :root [prefix "d"] "detach from the cy server" (fn [&] (cy/detach)))
(key/bind :root [prefix "p"] "enter replay mode" (fn [&] (cy/replay)))
(key/bind :root [prefix "P"] "" (fn [&] (cy/paste)))

# should actions just be functions with docstrings?
#(key/action increase-margins "increase margins by 5 columns"
Expand Down
23 changes: 23 additions & 0 deletions pkg/cy/janet.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,29 @@ func (c *Cy) initJanet(ctx context.Context) (*janet.VM, error) {
// TODO(cfoust): 10/08/23 reattach all clients
client.Attach(node)
},
"cy/paste": func(user interface{}) {
client, ok := user.(*Client)
if !ok {
return
}

buffer := client.buffer
if len(buffer) == 0 {
return
}

node := client.Node()
if node == nil {
return
}

pane, ok := node.(*tree.Pane)
if !ok {
return
}

pane.Write([]byte(buffer))
},
"log": func(text string) {
c.log.Info().Msgf(text)
},
Expand Down

0 comments on commit c1d8e9a

Please sign in to comment.