diff --git a/pkg/cy/cy-boot.janet b/pkg/cy/cy-boot.janet index 41265bad..6ef50a51 100644 --- a/pkg/cy/cy-boot.janet +++ b/pkg/cy/cy-boot.janet @@ -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" diff --git a/pkg/cy/janet.go b/pkg/cy/janet.go index 42667a0c..f8265104 100644 --- a/pkg/cy/janet.go +++ b/pkg/cy/janet.go @@ -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) },