:keybindings names one function that binds any number of
key strings. Each bound key runs a zero-arg function.
Example: Insert a UUID at the cursor with C-t
;; .cljconf/org.clojure/clojure-cli.repl.edn
{:keybindings dev.keybindings/install}(ns dev.keybindings
(:require [clojure-cli.repl.api :as api]))
(defn install [reader]
(api/bind-key reader (api/key-sequence "C-t")
(api/widget
(fn [] (.write (.getBuffer reader) (str (random-uuid)))))))api is the example's alias for clojure-cli.repl.api.
(api/key-sequence s): Given a key strings, return the characters the terminal sends for the corresponding keys.(api/widget f): Given a zero-arg functionf, return a JLine widget that runs it. Any return value offis ignored.(api/bind-key reader keyseq widget): Bind the widget to the keyseq.
(api/print-above segments): Given displaysegments, print them above the input line without disturbing in-progress input.(api/show-below segments): Given displaysegments, show them in a pane pinned under the input line. Nil segments clear the pane.(api/page title text): Given atitleandtext, display them full screen.
(api/eval-code code): Eval thecodestring on the server in the current namespace and return the merged response map (:value,:out,:err,:ex). This enables a binding in the client to run project code on the server.api/session: An atom holding the nREPL session.
api/current-ns,api/last-response: Atoms holding the current namespace and last eval response for use in prompts.(api/terminal-width),(api/terminal-height): Returns the current terminal size.
api/reader,(api/terminal): The LineReader (an atom) and the Terminal. For anything JLine offers that no helper provides access to, e.g., the cursor shape, built in widgets, buffer styling.