3 Keybinding Language Reference
(require kb-base) | package: drracket-custom-keybindings |
3.1 Operations
This section describes every supported operation by the kb-base language. Every operation returns an kb-expr? that represents an expression interpreted by the kb-base interpreter. Similarly there is an buffer-safe-kb-expr? that represents an expression that doesn’t change the current editor buffer.
procedure
(insert-return) → kb-expr?
procedure
(delete start-expr [end-expr]) → kb-expr?
start-expr : (or/c exact-nonnegative-integer? symbol? kb-expr?)
end-expr : (or/c #f exact-nonnegative-integer? symbol? kb-expr?) = #f
procedure
(set-position pos-expr) → kb-expr?
pos-expr : (or/c exact-nonnegative-integer? symbol? kb-expr?)
procedure
(get-position) → kb-expr?
procedure
(last-position) → kb-expr?
procedure
(move-position code kind) → kb-expr?
code :
(or/c 'up 'down 'left 'right 'home 'end)
kind :
(or/c 'simple 'word 'line 'page 'sexp)
Additionally, takes a kind 'sexp, which works with 'right or 'left.
procedure
(forward-sexp) → kb-expr?
procedure
(backward-sexp) → kb-expr?
procedure
(down-sexp) → kb-expr?
procedure
(up-sexp) → kb-expr?
procedure
(get-forward-sexp) → kb-expr?
procedure
(forward-sexp-exists?) → kb-expr?
procedure
(get-character [pos]) → kb-expr?
pos : (or/c #f exact-nonnegative-integer? symbol? kb-expr?) = #f
procedure
(get-forward-word [pos]) → kb-expr?
pos : (or/c #f exact-nonnegative-integer? symbol? kb-expr?) = #f
procedure
(get-text start-expr end-expr) → kb-expr?
start-expr : (or/c exact-nonnegative-integer? symbol? kb-expr?) end-expr : (or/c exact-nonnegative-integer? symbol? kb-expr?)
procedure
(count-iters condition-expr step-size-expr step-type) → kb-expr? condition-expr : (or/c boolean? symbol? buffer-safe-kb-expr?) step-size-expr : (or/c number? symbol? kb-expr?)
step-type :
(or/c 'simple 'word 'line 'page 'sexp)
procedure
(seek-while condition-expr step-size-expr step-type) → kb-expr? condition-expr : (or/c boolean? symbol? buffer-safe-kb-expr?) step-size-expr : (or/c number? symbol? kb-expr?)
step-type :
(or/c 'simple 'word 'line 'page 'sexp)
syntax
(kb-let (let-clause ...+) body-expr)
let-clause = [id val-expr]
procedure
(kb-set! id new-val-expr) → kb-expr?
id : symbol?
new-val-expr :
(or/c string? number? char? boolean? symbol? kb-expr?)
procedure
(kb-if condition-expr thn-expr else-expr) → kb-expr?
condition-expr : (or/c boolean? symbol? kb-expr?) thn-expr : (or/c string? number? char? boolean? symbol? kb-expr?) else-expr : (or/c string? number? char? boolean? symbol? kb-expr?)
procedure
(kb-equal? expr1 expr2) → kb-expr?
expr1 : (or/c string? number? char? boolean? symbol? kb-expr?) expr2 : (or/c string? number? char? boolean? symbol? kb-expr?)
procedure
(kb-or expr1 expr2) → kb-expr?
expr1 : (or/c boolean? symbol? kb-expr?) expr2 : (or/c boolean? symbol? kb-expr?)
procedure
(kb-and expr1 expr2) → kb-expr?
expr1 : (or/c boolean? symbol? kb-expr?) expr2 : (or/c boolean? symbol? kb-expr?)
procedure
(kb-gte expr1 expr2) → kb-expr?
expr1 : (or/c number? symbol? kb-expr?) expr2 : (or/c number? symbol? kb-expr?)
procedure
(kb-lte expr1 expr2) → kb-expr?
expr1 : (or/c number? symbol? kb-expr?) expr2 : (or/c number? symbol? kb-expr?)
procedure
(kb-gt expr1 expr2) → kb-expr?
expr1 : (or/c number? symbol? kb-expr?) expr2 : (or/c number? symbol? kb-expr?)
procedure
(kb-lt expr1 expr2) → kb-expr?
expr1 : (or/c number? symbol? kb-expr?) expr2 : (or/c number? symbol? kb-expr?)
procedure
(add num-expr1 num-expr2) → kb-expr?
num-expr1 : (or/c number? symbol? kb-expr?) num-expr2 : (or/c number? symbol? kb-expr?)
procedure
(sub num-expr1 num-expr2) → kb-expr?
num-expr1 : (or/c number? symbol? kb-expr?) num-expr2 : (or/c number? symbol? kb-expr?)
3.2 Helpers
This section documents helpers provided by the kb-base language.
The kb-base package also provides a few utilities to make testing easier. Since programs written in this language run in the context of an editor window (specifically a racket:text<%>), these test utilities handle setting that editor up and getting results back from running programs.
procedure
(make-kb stroke kb-program name active-range stx) → vector? stroke : string? kb-program : (or/c string? number? char? boolean? symbol? kb-expr?) name : string?
active-range :
(or/c 'local 'global (cons/c exact-nonnegative-integer? exact-nonnegative-integer?)) stx : syntax?
3.3 Testing Utilities
(require kb-base/test-utils) | |
package: drracket-custom-keybindings |
procedure
→
any/c exact-nonnegative-integer? string? editor : (is-a?/c racket:text<%>) kb-program : (or/c string? number? char? boolean? symbol? kb-expr?)
procedure
(test-kb-program kb-program [ test-proc] #:setup-proc setup-proc) → any/c kb-program : (or/c string? number? char? boolean? symbol? kb-expr?)
test-proc :
(-> any/c exact-nonnegative-integer? string? any/c) =
(λ (val pos text) (values val pos text))
setup-proc :
(-> (is-a?/c racket:text<%>) any/c)