Skip to main content

API

This is a complete listing of all of the API functions that cy provides in the top-level Janet environment (ie you do not need to import or use anything.)

Janet code executed with cy can also access everything from Janet's standard library except for anything in spork. In addition, Janet's ev family of functions probably will not work; I have never tested them.

Concepts​

Binding​

Several API functions related to binding keys return a Binding. A Binding table represents a single key sequence and its associated function. Each table has the following properties:

  • :node: the NodeID where the binding is defined.
  • :sequence: a list of strings representing the key sequence that will execute this action. If the original call to key/bind used a regex, it will be returned as a string with a re: prefix.
  • :function: the Janet function that will be called when this sequence is executed.

For example:

{
:node 1
:sequence ["ctrl+a" "t"]
:function <some function>
}

Color​

Some API functions, such as style/render, accept colors as input. cy supports True Color colors specified in hexadecimal along with ANSI 16 and ANSI-256 colors. Under the hood, cy uses charmbracelet/lipgloss and thus supports its color references.

You can read more about color support in terminal emulators here.

Examples of valid colors:

"#ffffff" # true color
"#123456" # true color
"255" # ANSI 256
"0" # ANSI 16

Color map​

A color map is a mapping from one color to another. They can represented by Janet structs or tables:

# The "zenburn" color map
# This maps the default 16 ANSI colors to hand-picked RGB colors
@{"0" "#383838"
"1" "#dca3a3"
"2" "#5f7f5f"
"3" "#e0cf9f"
"4" "#7cb8bb"
"5" "#dc8cc3"
"6" "#93e0e3"
"7" "#dcdccc"
"8" "#6f6f6f"
"9" "#dfaf8f"
"10" "#404040"
"11" "#606060"
"12" "#808080"
"13" "#c0c0c0"
"14" "#000000"
"15" "#ffffff"}

For more information about color maps, see the relevant section in the parameters chapter.

Command​

cmd/query and {{api/commands}} return Commands, which are structs that look like this:

{:text "echo 'Hello, World!'" # The command that was run
:directory "/some/dir"
# When the command started executing
:executed-at {} # Time
# When it finished
:completed-at {} # Time
# These three properties only have internal meaning for now
:prompted 23
:executed 26
:completed 52
:pending false
# Input and output are Selections, which can currently only be passed to
# input/find previews. Refer to the standard library.
:input @[{:from (97 6)
:to (97 7)}]
:output {:from (98 0)
:to (98 42)}}

NodeID​

Many API functions have a parameter of type NodeID, which can be one of two values:

  • :root which is a short way of referring to cy's top-level group.
  • An integer that refers to a node in cy's node tree. You cannot infer these yourself, but they are returned from API functions like pane/current and group/children.

Time​

The (time/*) family of functions works with Time values, which are similar (but not identical) to the value returned by Janet's built-in (os/date) function.

Time values are structs with the following properties:

{:dst false # unused, just to mimic (os/date)
:hours 10
:milliseconds 624
:minutes 15
:month 9
:month-day 15
:seconds 31
:utc false # if false, properties are in local time
:week-day 0
:year 2024
:year-day 259}

For specifics on the range of each scalar property, consult the documentation for Go's time package, such as for time.Weekday().

Style​

A style struct is used with style/render to apply styling effects to text. Style structs can contain any of the following properties:

  • :fg: The foreground color of the text.
  • :bg: The background color of the text.
  • :width: The number of horizontal cells the text should occupy. Padding is added if this value exceeds the length of the text.
  • :height: The number of vertical cells the text should occupy. Padding is added if this value exceeds the height of the text.
  • :align-horizontal: One of :left, :center, or :right. If :width is greater than the length of the text, the text will be aligned according to this property.
  • :align-vertical: One of :top, :center, or :bottom. If :height is greater than the height of the text, the text will be aligned according to this property.
  • :bold: A boolean indicating whether the text should be bolded.
  • :italic: A boolean indicating whether the text should be italic.
  • :underline: A boolean indicating whether the text should be underlined.
  • :strikethrough: A boolean indicating whether the text should be struck through.
  • :reverse: A boolean indicating whether the foreground and background color should be reversed.
  • :blink: A boolean indicating whether the text should blink.
  • :faint: A boolean indicating whether the text should be faint.

For example:

{:bg "4"
:bold true
:width 15}

Symbols​

action/add-node action/browse-animations action/choose-frame action/clear-layout action/close-leaf action/close-project action/close-tab action/command-palette action/cpu-profile action/ctrl-r action/detach action/grow-split action/insert-thumb action/jump-command action/jump-group-pane action/jump-history-command action/jump-pane action/jump-pane-command action/jump-project action/jump-screen-lines action/jump-shell action/kill-and-reattach action/kill-layout-view action/kill-pane action/kill-server action/margins-160 action/margins-80 action/margins-bigger action/margins-smaller action/memory-profile action/move-down action/move-left action/move-right action/move-up action/new-leaf action/new-project action/new-shell action/new-tab action/next-leaf action/next-pane action/next-tab action/open-log action/open-replay action/paste action/paste-clipboard action/prev-leaf action/prev-pane action/prev-tab action/random-frame action/recall-command action/reload-config action/remove-layout-view action/remove-parent action/rename-leaf action/rename-pane action/rename-tab action/replay-playback-1x action/replay-playback-2x action/replay-playback-5x action/replay-playback-reverse-1x action/replay-playback-reverse-2x action/replay-playback-reverse-5x action/search-borg action/set-borders-title action/set-borders-title-bottom action/set-layout-borders action/set-pane-colors action/show-color-map action/shrink-split action/split-down action/split-left action/split-right action/split-up action/toggle-margins action/toggle-zoom action/trace assoc clipboard/get clipboard/set cmd/commands cmd/execute cmd/kill cmd/new cmd/path cmd/pid cmd/query cmd/status cmd/title cmd/wait color-maps/get color-maps/get-all color-maps/get-id color-maps/set cy/cpu-profile cy/detach cy/id cy/kill-server cy/memory-profile cy/paste cy/reload-config cy/trace cy/version exec/file expect-error group/children group/leaves group/mkdir group/new input/find input/ok? input/text input/thumbs input/thumbs/default-patterns key/action key/bind key/bind-many key/bind-many-tag key/current key/get key/get-actions key/remap key/unbind layout/assoc layout/attach layout/attach-first layout/attach-id layout/attach-path layout/attached? layout/bar layout/borders layout/color-map layout/detach layout/find layout/find-last layout/get layout/get-meta layout/grid layout/has? layout/hsplit layout/leaf layout/map layout/margins layout/move layout/move-down layout/move-left layout/move-right layout/move-up layout/new layout/path layout/remove-attached layout/replace layout/replace-attached layout/set layout/set-meta layout/split layout/split-down layout/split-left layout/split-right layout/split-up layout/stack layout/successors layout/tab layout/tabs layout/type? layout/view layout/view? layout/vsplit layout/zoom msg/log msg/toast pane/attach pane/current pane/history-backward pane/history-forward pane/screen pane/scrollback pane/send-bytes pane/send-keys pane/send-text param/get param/rset param/set param/set-many path/abs path/base path/expand path/glob path/join register/get register/insert register/set replay/beginning replay/big-word-backward replay/big-word-end-backward replay/big-word-end-forward replay/big-word-forward replay/command-backward replay/command-forward replay/command-select-backward replay/command-select-forward replay/copy replay/copy-clipboard replay/copy-default replay/cursor-down replay/cursor-down-screen replay/cursor-left replay/cursor-right replay/cursor-up replay/cursor-up-screen replay/end replay/end-of-line replay/end-of-screen-line replay/first-non-blank replay/first-non-blank-screen replay/half-page-down replay/half-page-up replay/jump-again replay/jump-backward replay/jump-forward replay/jump-reverse replay/jump-to-backward replay/jump-to-forward replay/last-non-blank replay/last-non-blank-screen replay/middle-of-line replay/middle-of-screen-line replay/open replay/open-file replay/quit replay/screen-bottom replay/screen-middle replay/screen-top replay/scroll-cursor-bottom replay/scroll-cursor-center replay/scroll-cursor-top replay/scroll-down replay/scroll-up replay/search-again replay/search-backward replay/search-forward replay/search-reverse replay/select replay/select-block replay/select-circle replay/select-inner-big-word replay/select-inner-word replay/select-line replay/start-of-line replay/start-of-screen-line replay/swap-screen replay/time-play replay/time-playback-rate replay/time-step-back replay/time-step-forward replay/word-backward replay/word-end-backward replay/word-end-forward replay/word-forward search/cancel search/first search/focus-input search/last search/new search/next search/prev shell/attach shell/new signal/send signal/wait style/render style/text test test-no-context time/format time/now tree/exists? tree/group? tree/id tree/name tree/pane? tree/parent tree/path tree/rm tree/root tree/set-name viewport/get-animations viewport/get-frames viewport/set-frame


action/add-node​

function

(action/add-node)

Add a node to the layout.

source

action/browse-animations​

function

(action/browse-animations)

Browse animations.

source

action/choose-frame​

function

(action/choose-frame)

Choose a frame.

source

action/clear-layout​

function

(action/clear-layout)

Clear out the layout.

source

action/close-leaf​

function

(action/close-leaf)

Close the current leaf in the stack.

source

action/close-project​

function

(action/close-project)

Close the current project.

source

action/close-tab​

function

(action/close-tab)

Close the current tab.

source

action/command-palette​

function

(action/command-palette)

Open the command palette.

source

action/cpu-profile​

function

(action/cpu-profile)

Save a CPU profile to cy's socket directory.

source

action/ctrl-r​

function

(action/ctrl-r)

Find a recent command and insert it into the current shell.

source

action/detach​

function

(action/detach)

Detach from the cy server.

source

action/grow-split​

function

(action/grow-split)

Grow the current view within its split.

source

action/insert-thumb​

function

(action/insert-thumb)

Select a thumb and insert it into the current pane.

source

action/jump-command​

function

(action/jump-command)

Jump to the output of a command.

source

action/jump-group-pane​

function

(action/jump-group-pane)

Jump to a pane that is a descendant of the current group.

source

action/jump-history-command​

function

(action/jump-history-command)

Find a command and open its .borg file.

source

action/jump-pane​

function

(action/jump-pane)

Jump to a pane.

source

action/jump-pane-command​

function

(action/jump-pane-command)

Jump to a pane based on a command.

source

action/jump-project​

function

(action/jump-project)

Jump to a project.

source

action/jump-screen-lines​

function

(action/jump-screen-lines)

Jump to a pane based on screen lines.

source

action/jump-shell​

function

(action/jump-shell)

Jump to a shell.

source

action/kill-and-reattach​

function

(action/kill-and-reattach)

Remove the current pane from the node tree and attach to a new one.

A new shell will be created if the current pane is the last one in the layout.

source

action/kill-layout-view​

function

(action/kill-layout-view)

Remove the current view from the layout and the node tree.

source

action/kill-pane​

function

(action/kill-pane)

Kill the process of the current pane, but do not detach from it.

source

action/kill-server​

function

(action/kill-server)

Kill the cy server.

source

action/margins-160​

function

(action/margins-160)

Set margins to 160 columns.

source

action/margins-80​

function

(action/margins-80)

Set margins to 80 columns.

source

action/margins-bigger​

function

(action/margins-bigger)

Increase margins by 5 columns.

source

action/margins-smaller​

function

(action/margins-smaller)

Decrease margins by 5 columns.

source

action/memory-profile​

function

(action/memory-profile)

Save a memory profile to cy's socket directory.

source

action/move-down​

function

(action/move-down)

Move down to the next view.

source

action/move-left​

function

(action/move-left)

Move left to the next view.

source

action/move-right​

function

(action/move-right)

Move right to the next view.

source

action/move-up​

function

(action/move-up)

Move up to the next view.

source

action/new-leaf​

function

(action/new-leaf)

Create a new leaf in the stack.

source

action/new-project​

function

(action/new-project)

Create a new project.

source

action/new-shell​

function

(action/new-shell)

Create a new shell.

source

action/new-tab​

function

(action/new-tab)

Create a new tab.

source

action/next-leaf​

function

(action/next-leaf)

Switch to the next leaf in a stack.

source

action/next-pane​

function

(action/next-pane)

Move to the next sibling pane.

source

action/next-tab​

function

(action/next-tab)

Switch to the next tab.

source

action/open-log​

function

(action/open-log)

Open a .borg file.

source

action/open-replay​

function

(action/open-replay)

Enter replay mode for the current pane.

source

action/paste​

function

(action/paste)

Insert the contents of the default register.

source

action/paste-clipboard​

function

(action/paste-clipboard)

Insert the contents of the system clipboard.

source

action/prev-leaf​

function

(action/prev-leaf)

Switch to the previous leaf in a stack.

source

action/prev-pane​

function

(action/prev-pane)

Move to the previous sibling pane.

source

action/prev-tab​

function

(action/prev-tab)

Switch to the previous tab.

source

action/random-frame​

function

(action/random-frame)

Switch to a random frame.

source

action/recall-command​

function

(action/recall-command)

Recall the output of a command to the current shell.

source

action/reload-config​

function

(action/reload-config)

Reload the cy configuration.

source

action/remove-layout-view​

function

(action/remove-layout-view)

Remove the current view from the layout.

source

action/remove-parent​

function

(action/remove-parent)

Remove the parent of the current node.

source

action/rename-leaf​

function

(action/rename-leaf)

Rename the current leaf in the stack.

source

action/rename-pane​

function

(action/rename-pane)

Rename the current pane.

source

action/rename-tab​

function

(action/rename-tab)

Rename the current tab.

source

action/replay-playback-1x​

function

(action/replay-playback-1x)

Set the playback rate to 1x real time.

source

action/replay-playback-2x​

function

(action/replay-playback-2x)

Set the playback rate to 2x real time.

source

action/replay-playback-5x​

function

(action/replay-playback-5x)

Set the playback rate to 5x real time.

source

action/replay-playback-reverse-1x​

function

(action/replay-playback-reverse-1x)

Set the playback rate to -1x real time (backwards).

source

action/replay-playback-reverse-2x​

function

(action/replay-playback-reverse-2x)

Set the playback rate to -2x real time (backwards).

source

action/replay-playback-reverse-5x​

function

(action/replay-playback-reverse-5x)

Set the playback rate to -5x real time (backwards).

source

action/search-borg​

function

(action/search-borg)

Search all recorded .borg files for a pattern.

source

action/set-borders-title​

function

(action/set-borders-title)

Set the :title for a :borders node.

source

action/set-borders-title-bottom​

function

(action/set-borders-title-bottom)

Set the :title-bottom for a :borders node.

source

action/set-layout-borders​

function

(action/set-layout-borders)

Change the border style across the entire layout.

source

action/set-pane-colors​

function

(action/set-pane-colors)

Set the color map for the current pane.

source

action/show-color-map​

function

(action/show-color-map)

Send a toast with the ID of the current color map.

source

action/shrink-split​

function

(action/shrink-split)

Shrink the current view within its split.

source

action/split-down​

function

(action/split-down)

Split the current view downwards.

source

action/split-left​

function

(action/split-left)

Split the current view to the left.

source

action/split-right​

function

(action/split-right)

Split the current view to the right.

source

action/split-up​

function

(action/split-up)

Split the current view upwards.

source

action/toggle-margins​

function

(action/toggle-margins)

Toggle the screen's margins.

source

action/toggle-zoom​

function

(action/toggle-zoom)

Toggle zoom on the current pane.

source

action/trace​

function

(action/trace)

Save a trace to cy's socket directory.

source

assoc​

function

(assoc s key value)

Set a property in a struct, returning a new struct.

source

clipboard/get​

function

(clipboard/get)

Get the current contents of the OS clipboard. For now this only works if you are using the system clipboard directly. See :use-system-clipboard for more information.

source

clipboard/set​

function

(clipboard/set text)

Set the contents of the OS clipboard to text. See also: :use-system-clipboard.

source

cmd/commands​

function

(cmd/commands target)

Get the commands executed in a particular pane. Returns an array of Commands. target is a NodeID.

source

cmd/execute​

function

(cmd/execute args &named env stdin)

Execute a shell command and return its output.

note

Since cy does not use Janet's event loop, the built-in (os/execute) does not work.

args is an array/tuple of strings. The first element is the command. The rest are arguments (just like (os/execute)).

Optional named parameters:

  • :env (struct): Additional environment variables to set.
  • :stdin (string): Input to pass to the command's standard input.

Returns a struct with:

  • :stdout (string): The command's standard output.
  • :stderr (string): The command's standard error.
  • :exit-code (int): The exit code (0 indicates success).

Subprocesses can communicate with the cy server via cy exec.

A non-zero exit code is not treated as an error; check the :exit-code field to determine if the command succeeded.

Some examples:

# Run a simple command
(def result (cmd/execute ["echo" "hello"]))
(print (result :stdout)) # => "hello\n"

# Pass input via stdin
(def result (cmd/execute ["cat"] :stdin "hello world"))
(print (result :stdout)) # => "hello world"

# Set environment variables
(def result (cmd/execute ["sh" "-c" "echo $MY_VAR"] :env {"MY_VAR" "hello"}))
(print (result :stdout)) # => "hello\n"

# Check exit code
(def result (cmd/execute ["false"]))
(print (result :exit-code)) # => 1

source

cmd/kill​

function

(cmd/kill target)

Kill the pane specified by target. target is a NodeID.

source

cmd/new​

function

(cmd/new parent &named path restart command args name temp)

Run command with args and working directory path in a new pane as a child of the group specified by parent. You may also provide the name of the new pane. If command is not specified, (cmd/new) defaults to the current user's shell. parent is a NodeID.

If restart is true, when the command exits, it will be rerun. However, if the command exits with a non-zero exit code more than three times in a second, it will not be run again.

If temp is true, the pane will not record to disk and will retain all output in memory. This is equivalent to setting :data-directory to "".

Some examples:

# Create a new shell in the root group
(cmd/new :root)

# `args` is a list of strings
(cmd/new :root :command "less" :args @["README.md"])

source

cmd/path​

function

(cmd/path target)

Get the working directory of the program running in the pane specified by target. target is a NodeID.

source

cmd/pid​

function

(cmd/pid target)

Get the process ID (PID) of the command running in the pane specified by target. target is a NodeID.

source

cmd/query​

function

(cmd/query)

Query all of the commands stored in the command database.

source

cmd/status​

function

(cmd/status target)

Get the current lifecycle status of the command running in the pane specified by target. target is a NodeID.

Returns one of the following strings:

  • "starting": The command is starting up.
  • "healthy": The command is running normally.
  • "failed": The command exited with a non-zero exit code.
  • "complete": The command exited successfully.
  • "killed": The command was killed.

Unlike cmd/wait, this function returns immediately without blocking.

source

cmd/title​

function

(cmd/title target)

Get the terminal title of the pane specified by target. Returns the title as set by the program running in the terminal (e.g. via OSC escape sequences). target is a NodeID.

source

cmd/wait​

function

(cmd/wait target &named remove)

Block until the command running in the pane specified by target exits, then return its output and exit code. target is a NodeID.

Optional named parameters:

  • :remove (bool, default false): Remove the pane from the node tree after the command exits.

Returns a struct with:

  • :output (string): The terminal output of the command.
  • :exit-code (int): The exit code (0 indicates success).

(cmd/wait) cannot be used on panes created with :restart true.

Some examples:

# Run a command in a visible pane and wait for it
(def pane (cmd/new :root :command "echo" :args @["hello"] :temp true))
(def result (cmd/wait pane :remove true))
(print (result :output))
(print (result :exit-code)) # => 0

source

color-maps/get​

function

(color-maps/get id)

Get a color map by id.

source

color-maps/get-all​

function

(color-maps/get-all)

Get all of the built-in color maps.

source

color-maps/get-id​

function

(color-maps/get-id target)

Get the ID of the color map of the target node.

source

color-maps/set​

function

(color-maps/set target id)

Set the :color-map parameter of the target node to the color map specified by id. Also sets the :color-map-id parameter.

target is a NodeID.

source

cy/cpu-profile​

function

(cy/cpu-profile)

Save a 15-second CPU profile captured with pprof to the socket directory. This is only useful for debugging.

source

cy/detach​

function

(cy/detach)

Detach from the cy server.

source

cy/id​

function

(cy/id)

Get the unique integer identifier for the current client.

source

cy/kill-server​

function

(cy/kill-server)

Kill the cy server, disconnecting all clients.

source

cy/memory-profile​

function

(cy/memory-profile)

source

cy/paste​

function

(cy/paste arg0)

Paste the text in the copy buffer to the current pane.

source

cy/reload-config​

function

(cy/reload-config)

Detect and (re)evaluate cy's configuration. This uses the same configuration detection scheme described in the Configuration chapter.

source

cy/trace​

function

(cy/trace)

Save a 15-second trace captured with runtime/trace to the socket directory. This is only useful for debugging.

source

cy/version​

function

(cy/version)

Get version information about the cy server. Returns a struct with the following fields:

  • :version: The cy version string.
  • :go-version: The Go version used to build the server.
  • :git-commit: The Git commit hash of the build.
  • :build-time: The time the server was built.

source

exec/file​

function

(exec/file path)

Execute the Janet file found at path. Throws any errors that occur during execution.

source

expect-error​

macro

(expect-error & body)

group/children​

function

(group/children group)

Get the NodeIDs for all of group's child nodes.

source

group/leaves​

function

(group/leaves group)

Get the NodeIDs for all of the leaf nodes reachable from group. In other words, this is a list of all of the NodeIDs for all panes that are descendants of group.

source

group/mkdir​

function

(group/mkdir group path)

Get the group at the end of path from the perspective of group, creating any groups that do not exist. Returns the NodeID of the final group.

For example:

(group/mkdir :root "/foo/bar/baz")
# Returns the NodeID of "baz"

This function throws an error if any node in the path already exists and is not a group.

source

group/new​

function

(group/new parent &named name)

Create a new group with parent and (optionally) name.

parent is a NodeID.

source

input/find​

function

(input/find inputs &named prompt full reverse animated headers)

(input/find) is a general-purpose fuzzy finder. When invoked, it prompts the user to choose from one of the items provided in inputs. (input/find) does not return until the user makes a choice; if they choose nothing (such as by hitting ctrl+c), it returns nil.

inputs is an array with elements that can take different forms depending on the desired behavior. See more on the page about fuzzy finding.

This function supports a range of named parameters that adjust its functionality:

  • :animated (boolean): Enable and disable background animation.
  • :case-sensitive (boolean): Whether the matching algorithm should respect differences in case. The default is false.
  • :full (boolean): If true, occupy the entire screen.
  • :headers ([]string): Provide a title for each column. This is mostly used for filtering tabular data.
  • :prompt (string): The text that will be shown beneath the search window.
  • :reverse (boolean): Display from the top of the screen (rather than the bottom.)
  • :width (int): Set the width of the match window (if not in full screen mode.)
  • :height (int): Set the maximum height of the match window. This applies both in full screen and floating mode.

source

input/ok?​

function

(input/ok? prompt)

Prompt the user to accept an operation with y/n. Returns true if the user presses 'y' or 'Y', false if they press 'n' or 'N', and nil if they cancel or press any other key.

source

input/text​

function

(input/text prompt &named preset placeholder full reverse animated single)

(input/text) prompts the user with a freeform text input. If the input is non-empty when the user presses enter, (input/text) returns the value of the text input; otherwise it returns nil.

The only required parameter, prompt, is a string that determines the prompt text that is shown below the text input.

This function supports a range of named parameters that adjust its functionality:

  • :preset (string): Pre-fill the value of the text input.
  • :placeholder (string): This string will be shown when the text input is empty.
  • :full (boolean): If true, occupy the entire screen.
  • :reverse (boolean): Display from the top of the screen (rather than the bottom.)
  • :animated (boolean): Enable and disable background animation.
  • :single (boolean): If true, accept only a single character and return immediately when any printable character is typed, without requiring the user to press Enter.

source

input/thumbs​

function

(input/thumbs &named alphabet regexp)

(input/thumbs) searches the contents of the screen for matches of a set of patterns and prompts the user to select one using short sequences of characters. The return value of the function is the match text or nil if the user did not select anything. This is similar to the functionality offered by tmux-thumbs or tmux-fingers. Unlike those programs, (input/thumbs) searches across the entire screen and is sensitive to pane boundaries, so matches that occur in wrapped lines will still appear.

This function supports the following named parameters:

  • :alphabet (string): Set the character set used for generating hints. Default is "asdfqwerzxcvjklmiuopghtybn".
  • :patterns ([]string): Array of regular expressions to search for.

Patterns​

Regular expressions supplied to the :patterns parameter have special behavior for effectively matching content on the screen:

  • If a pattern has a named capture group called match, the content matched by that group will be used as the match (as opposed to any other matched group.)
    • Example (filenames): (?P<match>([.\w\-@$~\[\]]+)?(/[.\w\-@$\[\]]+)+)
  • If a pattern has several capture groups, a match of the full pattern will produce several matches.
    • Example (git diffs): diff --git a/([.\w\-@~\[\]]+?/[.\w\-@\[\]]+) b/([.\w\-@~\[\]]+?/[.\w\-@\[\]]+)
    • If this pattern matches, hints will appear over the text following a/ and b/

source

input/thumbs/default-patterns​

function

(input/thumbs/default-patterns)

Get the default search patterns used by input/thumbs. This is useful for extending the default patterns without replacing them.

source

key/action​

macro

(key/action name docstring & body)

Register an action. Equivalent to the Janet built-in (defn), but requires a docstring.

An action is just a Janet function that is registered to the cy server with a short human-readable string description. It provides a convenient method for making some functionality you use often more discoverable.

In a similar way to other modern applications, cy has a command palette (invoked by default with ctrl+a ctrl+p [?], see action/command-palette) in which all registered actions will appear.

source

key/bind​

function

(key/bind target sequence callback)

Bind the key sequence sequence to callback for node target, which is a NodeID, :time (for time mode), or :copy (for copy mode). target can refer to any group or pane.

sequence is a key sequence, which consists of a tuple with string elements that are either key literals ("h"), preset key specifiers ("ctrl+a"), or regex patterns ([:re "^[a-z]$"]).

Read more about binding keys in the dedicated chapter.

source

key/bind-many​

macro

(key/bind-many scope & body)

Bind many bindings at once in the same scope.

For example:

(key/bind-many :root
[prefix "j"] action/new-shell
[prefix "n"] action/new-project)

source

key/bind-many-tag​

macro

(key/bind-many-tag scope tag & body)

Bind many bindings at once in the same scope, adding the provided tag.

source

key/current​

function

(key/current)

Get all of the bindings accessible to the current client as an array of Bindings. It contains all of the bindings defined by the node to which the client is attached and its ancestors. In other words, this is equivalent to the list of bindings against which the client's key presses are compared.

source

key/get​

function

(key/get target)

Get all of target's bindings. target is a NodeID, :time, or :copy. Returns an array of Bindings. Note that this does not return bindings defined in an ancestor node, only those defined on the node itself.

source

key/get-actions​

function

(key/get-actions)

Get all registered actions.

source

key/remap​

function

(key/remap target from to)

Remap all bindings that begin with sequence from to sequence to for node target, which is a NodeID, :time, or :copy. Empty sequences ([]) are not currently supported for from and to.

For example, to remap all of the default bindings that begin with ctrl+a to ctrl+v:

(key/remap :root ["ctrl+a"] ["ctrl+v"])

source

key/unbind​

function

(key/unbind target sequence)

Clear all bindings that begin with sequence for node target, which is a NodeID, :time, or :copy. Note that the empty sequence [] will unbind all keys in the scope.

sequence is a key sequence, which consists of a tuple with string elements that are either key literals ("h"), preset key specifiers ("ctrl+a"), or regex patterns ([:re "^[a-z]$"]).

The following code snippet will unbind all of cy's default keybindings that begin with ctrl+a:

(key/unbind :root ["ctrl+a"])

source

layout/assoc​

function

(layout/assoc layout path node)

Set the node at the given path in layout to the provided node. Returns a copy of the original layout with the node changed.

source

layout/attach​

function

(layout/attach layout path)

Attach to the node at path in layout.

source

layout/attach-first​

function

(layout/attach-first layout)

Attach to the first pane found in the layout.

source

layout/attach-id​

function

(layout/attach-id node)

Get the NodeID of the attached node for the given node.

source

layout/attach-path​

function

(layout/attach-path node)

Get the path to the attached node for the given node.

source

layout/attached?​

function

(layout/attached? node)

Report whether node or one of its descendants is attached.

source

layout/bar​

function

(layout/bar text node &named bottom meta)

Convenience function for creating a new :bar node.

source

layout/borders​

function

(layout/borders node &named title title-bottom border border-fg border-bg meta)

Convenience function for creating a new :borders node.

source

layout/color-map​

function

(layout/color-map map node &named meta)

Convenience function for creating a new :color-map node.

source

layout/detach​

function

(layout/detach node)

Detach the attached node in the tree.

source

layout/find​

function

(layout/find node predicate)

Get the path to the first node satisfying the predicate function or nil if none exists.

source

layout/find-last​

function

(layout/find-last layout path predicate)

Get the path to the last node in the path where (predicate node) evaluates to true.

source

layout/get​

function

(layout/get)

Get the layout of the current user.

source

layout/get-meta​

function

(layout/get-meta layout path predicate)

Get the path and :meta value of the nearest ancestor along path that has a non-nil :meta field. The predicate is called with the node. Returns a tuple [path meta] or nil.

source

layout/grid​

function

(layout/grid nodes &keys args)

Arrange nodes in a grid layout.

Takes an array of layout nodes and arranges them in a grid pattern using nested splits. The grid dimensions are calculated to be roughly square, preferring wider layouts over taller ones.

Any additional named parameters are passed through to the split nodes (e.g., :border, :border-fg, :border-bg).

Example:

# Create a 2x2 grid of panes
(layout/set
(layout/new
(layout/grid @[(attach :id 1)
(view :id 2)
(view :id 3)
(view :id 4)]
:border :rounded)))

source

layout/has?​

function

(layout/has? node predicate)

Report whether this node or one of its descendants matches the predicate function.

source

layout/hsplit​

function

(layout/hsplit a b &named cells percent border border-fg border-bg meta)

Convenience function for creating a new horizontal :split node.

source

layout/leaf​

function

(layout/leaf node &named active title title-bottom border border-fg border-bg)

Convenience function for creating a new leaf (inside of a :stack node).

source

layout/map​

function

(layout/map mapping layout)

Pass all nodes in the tree into a mapping function.

source

layout/margins​

function

(layout/margins node &named cols rows border border-fg border-bg meta)

Convenience function for creating a new :margins node.

source

layout/move​

function

(layout/move layout is-axis axis-successors)

This function attaches to the pane nearest to the one the user is currently attached to along an axis. It returns a new copy of layout with the attachment point changed or returns the same layout if no motion could be completed.

is-axis is a unary function that, given a node, returns a boolean that indicates whether the node is arranged along the axis in question. For example, when moving vertically, a vertical split (two panes on top of each other) would return true.

successors is a unary function that, given a node where is-axis was true, returns the paths of all of the child nodes accessible from the node in the order of their appearance along the axis.

For example, when moving vertically upwards, for a vertical split node this function would return @[[:b] [:a]], because :b is the first node from the bottom, and when moving vertically downwards it would return @[[:a] [:b]] because :a is the first node from the top.

source

layout/move-down​

function

(layout/move-down layout)

Change the layout by moving to the next node "below" the attached pane.

source

layout/move-left​

function

(layout/move-left layout)

Change the layout by moving to the next node to the left of the attached pane.

source

layout/move-right​

function

(layout/move-right layout)

Change the layout by moving to the next node to the right of the attached pane.

source

layout/move-up​

function

(layout/move-up layout)

Change the layout by moving to the next node "above" the attached pane.

source

layout/new​

macro

(layout/new body)

Macro for quickly creating layouts. layout/new replaces shorthand versions of node creation functions with their longform versions and also includes a few abbreviations that do not exist elsewhere in the API.

Supported short forms:

  • active-leaf: A :leaf with :active=true inside of a :stack node.
  • active-tab: A :tab with :active=true inside of a :tabs node.
  • attach: An attached :view node.
  • bar: A :bar node.
  • borders: A :borders node.
  • color-map: A :color-map node.
  • hsplit: A :split node with :vertical=false.
  • leaf: A :leaf inside of a :stack node.
  • margins: A :margins node.
  • view: A detached :view node.
  • split: A :split node.
  • stack: A :stack node.
  • tab: A :tab inside of a :tabs node.
  • tabs: A :tabs node.
  • vsplit: A :split node with :vertical=true.

See the layouts chapter for more information.

source

layout/path​

function

(layout/path node path)

Resolve the path to a node. Returns nil if any portion of the path is invalid.

source

layout/remove-attached​

function

(layout/remove-attached layout)

Remove the attached node from the layout, simplifying the nearest ancestor with children.

source

layout/replace​

function

(layout/replace node path replacer)

Replace the node at the path by passing it through a replacer function.

source

layout/replace-attached​

function

(layout/replace-attached node replacer)

Replace the attached pane in this tree with a new one using the provided replacer function. This function will be invoked with a single argument, the node that is currently attached, and it should return a new node.

source

layout/set​

function

(layout/set layout)

Set the layout of the current user.

source

layout/set-meta​

function

(layout/set-meta layout path value)

Set the :meta value of the node at path. Returns a new layout.

source

layout/split​

function

(layout/split a b &named vertical cells percent border border-fg border-bg meta)

Convenience function for creating a new :split node.

source

layout/split-down​

function

(layout/split-down layout node)

Split the currently attached pane into two vertically, replacing the bottom pane with the given node.

source

layout/split-left​

function

(layout/split-left layout node)

Split the currently attached pane into two horizontally, replacing the left pane with the given node.

source

layout/split-right​

function

(layout/split-right layout node)

Split the currently attached pane into two horizontally, replacing the right pane with the given node.

source

layout/split-up​

function

(layout/split-up layout node)

Split the currently attached pane into two vertically, replacing the top pane with the given node.

source

layout/stack​

function

(layout/stack leaves &named border border-fg border-bg meta)

Convenience function for creating a new :stack node.

source

layout/successors​

function

(layout/successors node)

Get the paths to all of the direct children of this node.

For example:

# For a node of type :split
@[[:a] [:b]]
# For a node of type :view (it has no children)
@[]

source

layout/tab​

function

(layout/tab name node &named active)

Convenience function for creating a new tab (inside of a :tabs node).

source

layout/tabs​

function

(layout/tabs tabs &named active-fg active-bg inactive-fg inactive-bg bg bottom meta)

Convenience function for creating a new :tabs node.

source

layout/type?​

function

(layout/type? type node)

Report whether node is of the provided type.

source

layout/view​

function

(layout/view &named id attached remove-on-exit meta)

Convenience function for creating a new :view node.

source

layout/view?​

function

(layout/view? node)

Report whether node is of type :view.

source

layout/vsplit​

function

(layout/vsplit a b &named cells percent border border-fg border-bg meta)

Convenience function for creating a new vertical :split node.

source

layout/zoom​

function

(layout/zoom layout)

Toggle zoom on the attached pane.

source

msg/log​

function

(msg/log level message)

Log message to the /logs pane. level must be one of :info, :warn, :error.

source

msg/toast​

function

(msg/toast level message)

Send a toast with message to the client. level must be one of :info, :warn, :error.

source

pane/attach​

function

(pane/attach pane)

Attach to pane, which is a NodeID that must correspond to a pane. This is similar to tmux's attach command.

source

pane/current​

function

(pane/current)

Get the NodeID of the current pane. When called from cy exec, returns the pane where the command was invoked. When called from a keybinding or action, returns the pane the client is viewing.

source

pane/history-backward​

function

(pane/history-backward)

Move backward in the pane history. Works in a similar way to vim's ctrl+o.

source

pane/history-forward​

function

(pane/history-forward)

Move forward in the pane history. Works in a similar way to vim's ctrl+i.

source

pane/screen​

function

(pane/screen pane)

Get a snapshot of the visible grid of the pane referred to by NodeID. This is what is displayed on screen right now; for the full logical history, use pane/scrollback.

Returns a struct with:

  • :lines (array of strings): The visible screen lines, one per row of the terminal.
  • :is-alt (boolean): Whether the terminal is in alternate screen mode (e.g., when running vim, htop, or other fullscreen applications).

(def result (pane/screen pane))
(print (result :lines))
(print (result :is-alt))

source

pane/scrollback​

function

(pane/scrollback pane)

Get the full logical history of the pane referred to by NodeID: the scrollback buffer plus the current screen, reflowed at the pane's current width. Returns an array of strings.

Unlike pane/screen, blank padding rows are collapsed and there is no alternate-screen indicator. This is the right call for capturing the complete output of a command, while pane/screen is better for snapshotting a fullscreen application.


(def lines (pane/scrollback pane))
(print (string/join lines "\n"))

source

pane/send-bytes​

function

(pane/send-bytes pane data)

Send raw bytes to the pane referred to by NodeID. Unlike pane/send-text, data is written directly to the pane's underlying stream without bracketed paste wrapping, so escape sequences will be interpreted by the shell.


# Send an escape sequence to the pane
(pane/send-bytes pane "\x1b[1;6y")

source

pane/send-keys​

function

(pane/send-keys pane keys)

Send keys to the pane referred to by NodeID. keys is an array of strings. Strings that are not key specifiers will be written as-is.


# Send ctrl+c to the pane
(pane/send-keys pane @["ctrl+c"])

source

pane/send-text​

function

(pane/send-text pane text)

Send text to the pane referred to by NodeID. Unlike pane/send-keys, text will not be interpreted as a key specifier.

source

param/get​

function

(param/get key &named target)

Get the value of the parameter with key, which must be a keyword.

Parameter values are retrieved in the following order:

  1. The client's parameter table, which overrides all other parameters and can be set with (param/set :client ...).
  2. The parameter table for the node the client is attached to and every parent node's parameter table, recursively, until the root node is reached.
  3. The default value for default parameters.

If target is provided, it must be either :client, a NodeID, or :persist.

When :target is a NodeID, it can be used to get parameter values from the perspective of another node in the tree, since it does the same cascade that (param/get) does normally.

When target is :persist, retrieves values from cy's persistent store:

(param/get :my-key :target :persist)

source

param/rset​

function

(param/rset key value)

Set the value of a parameter at :root.

source

param/set​

function

(param/set target key value)

Set the value of the parameter at target for key to value. target must be either :client, a NodeID (such as :root), or :persist. value can be any Janet value, though (param/set) does enforce the type of default parameters.

When target is :persist, (param/set) stores values in cy's persistent store:

(param/set :persist :my-setting @{:data "value"})

source

param/set-many​

macro

(param/set-many target & body)

Set many params at once with the same target.

For example:

(param/set-many :root
:replay-play-bg "#ff0000"
:replay-time-bg "#00ff00")

source

path/abs​

function

(path/abs path)

Return the full absolute path for path. Calls Go's path/filepath.Abs.

source

path/base​

function

(path/base path)

Return the last element of path. Calls Go's path/filepath.Base.

source

path/expand​

function

(path/expand path)

Replace a leading ~ or ~/ in path with the current user's home directory. Paths that do not start with ~ are returned unchanged. ~user (expansion of another user's home) is not supported.

source

path/glob​

function

(path/glob pattern)

Return an array of all files matching pattern. Calls Go's path/filepath.Glob.

source

path/join​

function

(path/join paths)

Join the elements of the string array paths with the OS's file path separator. Calls Go's path/filepath.Join.

source

register/get​

function

(register/get register)

Get the contents of the given register.

source

register/insert​

function

(register/insert register)

Insert the contents of the given register in the current pane.

source

register/set​

function

(register/set register text)

Set the contents of the given register.

source

replay/beginning​

function

(replay/beginning)

Go to the beginning of the time range (in time mode) or the first line of the screen (in copy mode).

source

replay/big-word-backward​

function

(replay/big-word-backward)

Move to the beginning of the previous WORD. Equivalent to vim's B.

source

replay/big-word-end-backward​

function

(replay/big-word-end-backward)

Move to the end of the previous WORD. Equivalent to vim's gE.

source

replay/big-word-end-forward​

function

(replay/big-word-end-forward)

Move to the end of the next WORD. Equivalent to vim's E.

source

replay/big-word-forward​

function

(replay/big-word-forward)

Move to the beginning of the next WORD. Equivalent to vim's W.

source

replay/command-backward​

function

(replay/command-backward)

In time mode, jump to the moment in time just before the previous command was executed. In copy mode, move the cursor to the first character of the previous command that was executed.

source

replay/command-forward​

function

(replay/command-forward)

In time mode, jump to the moment in time just before the next command was executed. In copy mode, move the cursor to the first character of the next command.

source

replay/command-select-backward​

function

(replay/command-select-backward)

Move the cursor to the first character of the output of the previous command and select its output.

source

replay/command-select-forward​

function

(replay/command-select-forward)

Move the cursor to the first character of the output of the next command and select its output.

source

replay/copy​

function

(replay/copy arg0)

Yank the selection into the copy buffer.

source

replay/copy-clipboard​

function

(replay/copy-clipboard)

Yank the selection into the system clipboard.

source

replay/copy-default​

function

(replay/copy-default)

Yank the selection into the default register.

source

replay/cursor-down​

function

(replay/cursor-down)

Move cursor down one cell.

source

replay/cursor-down-screen​

function

(replay/cursor-down-screen)

source

replay/cursor-left​

function

(replay/cursor-left)

Move cursor left one cell.

source

replay/cursor-right​

function

(replay/cursor-right)

Move cursor right one cell.

source

replay/cursor-up​

function

(replay/cursor-up)

Move cursor up one cell.

source

replay/cursor-up-screen​

function

(replay/cursor-up-screen)

source

replay/end​

function

(replay/end)

Go to the end of the time range (in time mode) or the last line of the screen (in copy mode).

source

replay/end-of-line​

function

(replay/end-of-line)

Move to the last character of the physical line. Equivalent to vim's $.

source

replay/end-of-screen-line​

function

(replay/end-of-screen-line)

Move to the end of the screen line. Equivalent to vim's g$.

source

replay/first-non-blank​

function

(replay/first-non-blank)

Move to the first non-blank character of the physical line. Equivalent to vim's ^.

source

replay/first-non-blank-screen​

function

(replay/first-non-blank-screen)

Move to the first non-blank character of the screen line. Equivalent to vim's g^.

source

replay/half-page-down​

function

(replay/half-page-down)

Scroll the viewport half a page (half the viewport height) down.

source

replay/half-page-up​

function

(replay/half-page-up)

Scroll the viewport half a page (half the viewport height) up.

source

replay/jump-again​

function

(replay/jump-again)

Repeat the last character jump.

source

replay/jump-backward​

function

(replay/jump-backward char)

Jump to the previous instance of char on the current line.

source

replay/jump-forward​

function

(replay/jump-forward char)

Jump to the next instance of char on the current line.

source

replay/jump-reverse​

function

(replay/jump-reverse)

Repeat the inverse of the last character jump.

source

replay/jump-to-backward​

function

(replay/jump-to-backward char)

Jump to the cell after char before the cursor on the current line.

source

replay/jump-to-forward​

function

(replay/jump-to-forward char)

Jump to the cell before char after the cursor on the current line.

source

replay/last-non-blank​

function

(replay/last-non-blank)

Move to the last non-blank character of the physical line. Equivalent to vim's g_.

source

replay/last-non-blank-screen​

function

(replay/last-non-blank-screen)

Move to the last non-blank character of the screen line. Equivalent to vim's g<end>.

source

replay/middle-of-line​

function

(replay/middle-of-line)

Move to the middle of the physical line. Equivalent to vim's gM.

source

replay/middle-of-screen-line​

function

(replay/middle-of-screen-line)

Move to the middle of the screen line. Equivalent to vim's gm.

source

replay/open​

function

(replay/open id &named copy focus alt-screen)

Enter replay mode for pane id (which is a NodeID).

This function supports a range of named parameters that adjust its functionality:

  • :alt-screen (boolean): If true, attempt to swap to the terminal's alt screen.
  • :focus (vec2): A coordinate in the reference frame of the terminal. These cannot be derived from scratch; typically this comes from a Command.

source

replay/open-file​

function

(replay/open-file group path &named focus alt-screen highlights)

Open the .borg file found at path in a new replay window in group.

This function supports a range of named parameters that adjust its functionality:

  • :focus and :alt-screen from replay/open
  • :highlights (selection): Just like :focus, but is a struct with :from and :to fields. For the time being, this is not practical to derive by hand. See examples from the standard library.

For example:

(replay/open-file :root "some_borg.borg")

source

replay/quit​

function

(replay/quit)

Quit replay mode.

source

replay/screen-bottom​

function

(replay/screen-bottom)

source

replay/screen-middle​

function

(replay/screen-middle)

source

replay/screen-top​

function

(replay/screen-top)

source

replay/scroll-cursor-bottom​

function

(replay/scroll-cursor-bottom)

Scroll the viewport so the cursor line is at the bottom of the screen. Equivalent to vim's zb.

source

replay/scroll-cursor-center​

function

(replay/scroll-cursor-center)

Scroll the viewport so the cursor line is at the center of the screen. Equivalent to vim's zz.

source

replay/scroll-cursor-top​

function

(replay/scroll-cursor-top)

Scroll the viewport so the cursor line is at the top of the screen. Equivalent to vim's zt.

source

replay/scroll-down​

function

(replay/scroll-down)

Scroll the viewport one line down.

source

replay/scroll-up​

function

(replay/scroll-up)

Scroll the viewport one line up.

source

replay/search-again​

function

(replay/search-again)

Go to the next match in the direction of the last search.

source

replay/search-backward​

function

(replay/search-backward)

Search for a string backwards in time (in time mode) or in the scrollback buffer (in copy mode).

source

replay/search-forward​

function

(replay/search-forward)

Search for a string forwards in time (in time mode) or in the scrollback buffer (in copy mode).

source

replay/search-reverse​

function

(replay/search-reverse)

Go to the previous match in the direction of the last search.

source

replay/select​

function

(replay/select)

Enter visual select mode.

source

replay/select-block​

function

(replay/select-block)

Enter visual block select mode.

source

replay/select-circle​

function

(replay/select-circle)

Enter visual circle select mode. Selects cells within a filled circle inscribed in the bounding box of the two selection endpoints.

source

replay/select-inner-big-word​

function

(replay/select-inner-big-word)

source

replay/select-inner-word​

function

(replay/select-inner-word)

source

replay/select-line​

function

(replay/select-line)

Enter visual line select mode.

source

replay/start-of-line​

function

(replay/start-of-line)

Move to the first character of the physical line. Equivalent to vim's 0.

source

replay/start-of-screen-line​

function

(replay/start-of-screen-line)

Move to the first character of the screen line. Equivalent to vim's g0.

source

replay/swap-screen​

function

(replay/swap-screen)

Swap between the alt screen and the main screen. This allows you to return to the pane's scrollback without quitting a program that is using the alternate screen, such as vim or htop.

source

replay/time-play​

function

(replay/time-play)

Toggle playback.

source

replay/time-playback-rate​

function

(replay/time-playback-rate rate)

Set the playback rate to rate. Positive numbers indicate a multiplier of real time moving forwards, negative numbers, backwards. For example, a rate of 2 means that time will advance at twice the normal speed; -2 means that time will go backwards at -2x.

rate is clamped to the range [-10, 10].

source

replay/time-step-back​

function

(replay/time-step-back)

Step one event backward in time.

source

replay/time-step-forward​

function

(replay/time-step-forward)

Step one event forward in time.

source

replay/word-backward​

function

(replay/word-backward)

Move to the beginning of the previous word. Equivalent to vim's b.

source

replay/word-end-backward​

function

(replay/word-end-backward)

Move to the end of the previous word. Equivalent to vim's ge.

source

replay/word-end-forward​

function

(replay/word-end-forward)

Move to the end of the next word. Equivalent to vim's e.

source

replay/word-forward​

function

(replay/word-forward)

Move to the beginning of the next word. Equivalent to vim's w.

source

search/cancel​

function

(search/cancel)

Cancel the current operation or the input of a query string.

source

search/first​

function

(search/first)

Move to the first .borg file in the search results.

source

search/focus-input​

function

(search/focus-input)

Focus search mode's input bar so you can enter a new query string.

source

search/last​

function

(search/last)

Move to the last .borg file in the search results.

source

search/new​

function

(search/new parent query &named files workers)

Create a new instance of search mode as a child of parent with the given string query. parent is a NodeID. Calling this function will begin executing the search immediately, regardless of whether you attach to the new node.

This function supports a range of named parameters that adjust its functionality:

  • :files (list of strings): All of the .borg files to search in. By default this is populated with all of the .borg files present in the user's :data-directory.
  • :workers (integer): The number of workers (threads) to use to perform the search. Defaults to :num-search-workers.

source

search/next​

function

(search/next)

Move to the next .borg file in the search results.

source

search/prev​

function

(search/prev)

Move to the previous .borg file in the search results.

source

shell/attach​

function

(shell/attach &opt path)

Create a new shell initialized in the working directory path and attach to it.

source

shell/new​

function

(shell/new &opt path)

Create a new shell initialized in the working directory path. If path is not provided, this uses the path of the current pane.

source

signal/send​

function

(signal/send name value)

Send value to all goroutines waiting on the channel name, which is a keyword. Any call to signal/wait with the same name will unblock and return value. value can be any Janet value. If no one is waiting, the signal is silently dropped.

This is useful for inter-process coordination, for example between a cy exec script and a running pane.

# Signal with a value
(signal/send :my-channel {:status "done" :result 42})

source

signal/wait​

function

(signal/wait name &named timeout)

Block until the channel name is signaled via signal/send. name is a keyword. Returns the value that was passed to signal/send.

Multiple goroutines can wait on the same channel; all will be woken and receive the same value when the channel is signaled.

Optional named parameters:

  • :timeout (number, default 0): Maximum number of seconds to wait. A value of 0 means wait indefinitely. Returns an error if the timeout is reached.
# Wait with a 10-second timeout
(def result (signal/wait :my-channel :timeout 10))
(print result)

source

style/render​

function

(style/render style text)

Apply styling effects to some text. This function generates a string containing ANSI escape sequences that will style the provided text according to style.

All cy API functions that render text to the screen, such as layout/set and input/find accept input styled with style/render.

style is a Style struct.

For example:

(style/render
{:bg "4"
:bold true
:width 15
} "some text")

source

style/text​

function

(style/text text &named fg bg width height align-horizontal align-vertical bold italic underline strikethrough reverse blink faint)

Style the provided text with the attributes provided. This function is a convenient wrapper around style/render; instead of providing a struct, you may pass any of the attributes style/render supports as named parameters.

For example:

(style/text "foobar" :bg "#00ff00")
(style/text "foobar" :italic true :bold true :width 15)

source

test​

macro

(test name & body)

test-no-context​

macro

(test-no-context name & body)

time/format​

function

(time/format ts format)

Format a Time struct using the provided format string. This uses Go's Time.Format. cy provides all of Go's built-in time format layouts as constants, such as time/format/rfc-822.

For example:

(time/format (time/now) time/format/rfc-822)

source

time/now​

function

(time/now)

Return a Time struct representing the current local time.

source

tree/exists?​

function

(tree/exists? group path)

Return true if a node exists at the end of path from the perspective of group, false otherwise. Unlike tree/id, this does not throw an error if the path does not exist.

# Check if a node exists before creating it
(if (not (tree/exists? :root "/agents/my-agent"))
(group/mkdir :root "/agents/my-agent"))

source

tree/group?​

function

(tree/group? node)

Return true if node is a group, false otherwise. node is a NodeID.

source

tree/id​

function

(tree/id group path)

Get the NodeID of the node at the end of path from the perspective of group. Throws an error if any part of the path does not exist.

source

tree/name​

function

(tree/name node)

Get the name of node, which is a NodeID. This is the name of the node itself, not its path.

source

tree/pane?​

function

(tree/pane? node)

Return true if node is a pane, false otherwise. node is a NodeID.

source

tree/parent​

function

(tree/parent node)

Get the NodeID for the parent of node. If node is :root, (tree/parent) returns nil.

source

tree/path​

function

(tree/path node)

Get the path of node, which is a NodeID.

source

tree/rm​

function

(tree/rm node)

Remove the node and all of its child nodes. This will halt execution of any descendant panes. node is a NodeID.

source

tree/root​

function

(tree/root)

Get the NodeID that corresponds to the root node.

source

tree/set-name​

function

(tree/set-name node name)

Set the name of node to name. name will be stripped of all whitespace and slashes. node is a NodeID.

source

viewport/get-animations​

function

(viewport/get-animations)

Get a list of all of the available animations.

source

viewport/get-frames​

function

(viewport/get-frames)

Get a list of all of the available frames.

source

viewport/set-frame​

function

(viewport/set-frame frame)

Set the frame to frame, which is an identifier for the desired frame.

You can get all of the available frames with (viewport/get-frames) and also browse them here.

source