diff --git a/beautiful-racket/br/demo/jsonic-2/toolbar.rkt b/beautiful-racket/br/demo/jsonic-2/buttons.rkt similarity index 86% rename from beautiful-racket/br/demo/jsonic-2/toolbar.rkt rename to beautiful-racket/br/demo/jsonic-2/buttons.rkt index 5f279fe..bbc7b25 100644 --- a/beautiful-racket/br/demo/jsonic-2/toolbar.rkt +++ b/beautiful-racket/br/demo/jsonic-2/buttons.rkt @@ -1,8 +1,8 @@ #lang br (require racket/draw) -(provide buttons) +(provide make-jsonic-buttons) -(define buttons +(define make-jsonic-buttons (list (let ([label "Insert expression"] [bitmap (make-object bitmap% 16 16)] [callback (λ (drr-frame) diff --git a/beautiful-racket/br/demo/jsonic-2/color-lexer.rkt b/beautiful-racket/br/demo/jsonic-2/colorer.rkt similarity index 92% rename from beautiful-racket/br/demo/jsonic-2/color-lexer.rkt rename to beautiful-racket/br/demo/jsonic-2/colorer.rkt index f55cfc8..6803ad8 100644 --- a/beautiful-racket/br/demo/jsonic-2/color-lexer.rkt +++ b/beautiful-racket/br/demo/jsonic-2/colorer.rkt @@ -3,7 +3,7 @@ syntax-color/racket-lexer parser-tools/lex-sre) -(provide color-lexer) +(provide color-jsonic) (define in-racket-expr? #f) @@ -15,7 +15,7 @@ (check-true (at-racket-boundary? (open-input-string "$@foo"))) (check-false (at-racket-boundary? (open-input-string "foo$@")))) -(define (color-lexer input-port) +(define (color-jsonic input-port) (define jsonic-lexer (lexer [(eof) (values lexeme 'eof #f #f #f)] diff --git a/beautiful-racket/br/demo/jsonic-2/indenter.rkt b/beautiful-racket/br/demo/jsonic-2/indenter.rkt index ed22a36..1531ebe 100644 --- a/beautiful-racket/br/demo/jsonic-2/indenter.rkt +++ b/beautiful-racket/br/demo/jsonic-2/indenter.rkt @@ -1,10 +1,10 @@ #lang at-exp br (require br/indent) -(provide indenter) +(provide indent-jsonic) (define indent-width 2) -(define (indenter tb [this-pos 0]) +(define (indent-jsonic tb [this-pos 0]) (define this-line (line tb this-pos)) (define prev-line (previous-line tb this-pos)) (define prev-indent (or (line-indent tb prev-line) 0)) @@ -34,6 +34,5 @@ } here ) - (displayln (test-indenter indenter test-str)) - (check-equal? (str->indents (test-indenter indenter test-str)) + (check-equal? (str->indents (test-indenter indent-jsonic test-str)) (map (λ(x) (* x indent-width)) '(0 0 1 1 2 2 1 1 0)))) \ No newline at end of file diff --git a/beautiful-racket/br/demo/jsonic-2/main.rkt b/beautiful-racket/br/demo/jsonic-2/main.rkt index 93f4807..e1cacdc 100644 --- a/beautiful-racket/br/demo/jsonic-2/main.rkt +++ b/beautiful-racket/br/demo/jsonic-2/main.rkt @@ -1,27 +1,14 @@ #lang br/quicklang (module reader br - (require "reader.rkt") - (provide read-syntax)) + (require "reader.rkt" "colorer.rkt" + "indenter.rkt" "buttons.rkt") + (provide read-syntax get-info) + (define (get-info port mod line col pos) + (define (handle-query key default) + (case key + [(color-lexer) color-jsonic] + [(drracket:indentation) indent-jsonic] + [(drracket:toolbar-buttons) make-jsonic-buttons] + [else default])) + handle-query)) -#| -Demonstrate: -+ contracts -+ unit tests -+ color lexing -+ indentation -+ toolbar buttons -+ docs -+ info.rkt -|# - - -(define (get-info . _) - (λ (key default) - (case key - [(color-lexer) - (dynamic-require 'br/demo/jsonic/color-lexer 'color-lexer (λ () #f))] - [(drracket:indentation) - (dynamic-require 'br/demo/jsonic/indenter 'indenter (λ () #f))] - [(drracket:toolbar-buttons) - (dynamic-require 'br/demo/jsonic/toolbar 'buttons (λ () #f))] - [else default]))) \ No newline at end of file