5.5 Tool Support
Librraies such as shrubbery/syntax-color and shrubbery/indentation provide tools for working with shrubbery-based programs. They generally follow DrRacket’s protocols, but they are also intended to support other tools where the protocols can be adapted.
5.5.1 Language Configuration
(require (submod shrubbery reader)) |
The (submod shrubbery reader) module provides read, read-syntax, and "get-info" functions as normal for a reader submodule, but read and read-syntax accept an extra #:variant argument in the sense of shrubbery/variant. To better cooperate with new languages that are defined with syntax/module-reader, the (submod shrubbery reader) module also provides get-info-proc and make-get-info-proc.
procedure
(get-info-proc key default make-default [ #:variant variant]) → any/c key : symbol? default : any/c make-default : (-> symbol? any/c -> any/c) variant : variant? = default-variant
procedure
(make-get-info-proc [#:variant variant]) → procedure?
variant : variant? = default-variant
5.5.2 Syntax Coloring
(require shrubbery/syntax-color) | package: shrubbery-lib |
procedure
(shrubbery-lexer in pos status [ #:variant variant])
→
(or/c string? eof-object?)
(or/c symbol? (and/c (hash/c symbol? any/c) immutable?)) (or/c symbol? #f) (or/c number? #f) (or/c number? #f) exact-nonnegative-integer? any/c in : input-port? pos : exact-nonnegative-integer? status : any/c variant : variant? = default-variant
procedure
(shrubbery-text-mode-lexer in pos status [ #:variant variant])
→
(or/c string? eof-object?)
(or/c symbol? (and/c (hash/c symbol? any/c) immutable?)) (or/c symbol? #f) (or/c number? #f) (or/c number? #f) exact-nonnegative-integer? any/c in : input-port? pos : exact-nonnegative-integer? status : any/c variant : variant? = default-variant
procedure
(make-shrubbery-lexer [#:variant variant]) → procedure?
variant : variant? = default-variant
procedure
(make-shrubbery-text-mode-lexer [#:variant variant]) → procedure?
variant : variant? = default-variant
5.5.3 Indentation
(require shrubbery/indentation) | package: shrubbery-lib |
procedure
(shrubbery-indentation text pos [ #:multi? multi? #:always? always? #:reverse? reverse? #:stop-pos stop-pos #:variant variant])
→
(or/c #f exact-nonnegative-integer? (list/c exact-nonnegative-integer? string?) (listof (or/c exact-nonnegative-integer? (list/c exact-nonnegative-integer? string?)))) text : (is-a?/c color-textoid<%>) pos : exact-nonnegative-integer? multi? : any/c = #f always? : any/c = multi? reverse? : any/c = (not always?) stop-pos : exact-nonnegative-integer? = 0 variant : variant? = default-variant
If the current indentation matches a valid indentation but others are possible, the result when multi? is #f corresponds to the next valid indentation in a sequence of possibilities.
multi?: Returns all possible indentations, instead of just the first one.
always?: When #f, returns the line’s current indentation if that indentation is valid instead of cycling to the next valid indentation. This argument is provided as #f when indenting for a newly created line, for example.
reverse?: When true, causes the a sequence of valid indentations to be used or returned in reverse order. This argument’s default is #t when always? is #f so that a new line starts at the most-indented possibility.
stop-pos: Indicates a position in text where indentation should stop inspecting, instead of considering the effect of earlier characters.
variant: See shrubbery/variant.
procedure
(shrubbery-range-indentation text start-pos end-pos [ #:reverse? reverse? #:variant variant])
→
(or/c #f (listof (list/c exact-nonnegative-integer? string?))) text : (is-a?/c color-textoid<%>) start-pos : exact-nonnegative-integer? end-pos : exact-nonnegative-integer? reverse? : any/c = #f variant : variant? = default-variant
procedure
(shrubbery-range-indentation/reverse-choices text start-pos end-pos [ #:variant variant])
→
(or/c #f (listof (list/c exact-nonnegative-integer? string?))) text : (is-a?/c color-textoid<%>) start-pos : exact-nonnegative-integer? end-pos : exact-nonnegative-integer? variant : variant? = default-variant
procedure
(make-shrubbery-indentation [#:variant variant]) → procedure?
variant : variant? = default-variant
procedure
(make-shrubbery-range-indentation [#:variant variant])
→ procedure? variant : variant? = default-variant
procedure
(make-shrubbery-range-indentation/reverse-choices [#:variant variant])
→ procedure? variant : variant? = default-variant
5.5.4 Term and Group Navigation
(require shrubbery/navigation) | package: shrubbery-lib |
procedure
(shrubbery-grouping-position text pos limit-pos direction [ #:variant variant]) → (or/c #f #t natural?) text : (is-a?/c color-textoid<%>) pos : exact-nonnegative-integer? limit-pos : exact-nonnegative-integer? direction : (or/c 'up 'down 'backward 'forward) variant : variant? = default-variant
procedure
(make-shrubbery-grouping-position [#:variant variant])
→ procedure? variant : variant? = default-variant
5.5.5 Keystrokes
(require shrubbery/keystroke) | package: shrubbery-lib |
procedure
(make-shrubbery-keystrokes [#:variant variant]) → list?
variant : variant? = default-variant