dev-srcloc
Matthew Butterick 8 years ago
parent 09297e0cad
commit 522057f692

@ -1,8 +1,8 @@
#lang br #lang br
(require racket/draw) (require racket/draw)
(provide buttons) (provide make-jsonic-buttons)
(define buttons (define make-jsonic-buttons
(list (let ([label "Insert expression"] (list (let ([label "Insert expression"]
[bitmap (make-object bitmap% 16 16)] [bitmap (make-object bitmap% 16 16)]
[callback (λ (drr-frame) [callback (λ (drr-frame)

@ -3,7 +3,7 @@
syntax-color/racket-lexer syntax-color/racket-lexer
parser-tools/lex-sre) parser-tools/lex-sre)
(provide color-lexer) (provide color-jsonic)
(define in-racket-expr? #f) (define in-racket-expr? #f)
@ -15,7 +15,7 @@
(check-true (at-racket-boundary? (open-input-string "$@foo"))) (check-true (at-racket-boundary? (open-input-string "$@foo")))
(check-false (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 (define jsonic-lexer
(lexer (lexer
[(eof) (values lexeme 'eof #f #f #f)] [(eof) (values lexeme 'eof #f #f #f)]

@ -1,10 +1,10 @@
#lang at-exp br #lang at-exp br
(require br/indent) (require br/indent)
(provide indenter) (provide indent-jsonic)
(define indent-width 2) (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 this-line (line tb this-pos))
(define prev-line (previous-line tb this-pos)) (define prev-line (previous-line tb this-pos))
(define prev-indent (or (line-indent tb prev-line) 0)) (define prev-indent (or (line-indent tb prev-line) 0))
@ -34,6 +34,5 @@
} }
here here
) )
(displayln (test-indenter indenter test-str)) (check-equal? (str->indents (test-indenter indent-jsonic test-str))
(check-equal? (str->indents (test-indenter indenter test-str))
(map (λ(x) (* x indent-width)) '(0 0 1 1 2 2 1 1 0)))) (map (λ(x) (* x indent-width)) '(0 0 1 1 2 2 1 1 0))))

@ -1,27 +1,14 @@
#lang br/quicklang #lang br/quicklang
(module reader br (module reader br
(require "reader.rkt") (require "reader.rkt" "colorer.rkt"
(provide read-syntax)) "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])))
Loading…
Cancel
Save