original commit: 68476f7d0cba9c25e2e8e4422cf4f03dfb90256c
This commit is contained in:
Robby Findler 2000-08-13 14:49:40 +00:00
parent a16ddc1dcd
commit ad2528e6ad

View File

@ -119,7 +119,7 @@
[(= (position-line f) line) [(= (position-line f) line)
(let ([f-1 (- f 2)]) ;; -1 to go back one, -1 to be before char (let ([f-1 (- f 2)]) ;; -1 to go back one, -1 to be before char
(cond (cond
[(= f 0) [(< f-1 0)
#t] #t]
[(and (= (position-line f-1) line) [(and (= (position-line f-1) line)
(not (char=? (get-character f-1) #\\ ))) (not (char=? (get-character f-1) #\\ )))
@ -246,93 +246,87 @@
[mismatch-color (make-object color% "PINK")]) [mismatch-color (make-object color% "PINK")])
(opt-lambda ([just-clear? #f]) (opt-lambda ([just-clear? #f])
(when highlight-parens? (when highlight-parens?
(dynamic-wind (set! in-highlight-parens? #t)
(lambda () (begin-edit-sequence)
(set! in-highlight-parens? #t) (clear-old-locations)
(begin-edit-sequence)) (set! clear-old-locations void)
(lambda () (unless just-clear?
(clear-old-locations) (let* ([here (get-start-position)]
(set! clear-old-locations void) [there (get-end-position)]
(unless just-clear? [slash?
(let* ([here (get-start-position)] (lambda (before after)
[there (get-end-position)] (and (>= before 0)
[slash? (>= after 0)
(lambda (before after) (let ([text (get-text before after)])
(and (>= before 0) (and (string? text)
(>= after 0) (>= (string-length text) 1)
(let ([text (get-text before after)]) (char=? #\\ (string-ref text 0))))))]
(and (string? text) [is-paren?
(>= (string-length text) 1) (lambda (f)
(char=? #\\ (string-ref text 0))))))] (lambda (char)
[is-paren? (ormap (lambda (x) (char=? char (string-ref (f x) 0)))
(lambda (f) (scheme-paren:get-paren-pairs))))]
(lambda (char) [is-left-paren? (is-paren? car)]
(ormap (lambda (x) (char=? char (string-ref (f x) 0))) [is-right-paren? (is-paren? cdr)])
(scheme-paren:get-paren-pairs))))] (when (and (= here there)
[is-left-paren? (is-paren? car)] (not (in-single-line-comment? here)))
[is-right-paren? (is-paren? cdr)])
(when (and (= here there)
(not (in-single-line-comment? here)))
(let/ec k ;; before, after : (list number number boolean)
;; numbers indicate the range to highlight
;; before, after : (list number number boolean) ;; boolean indicates if it is an errorneous highlight
;; numbers indicate the range to highlight (let ([before
;; boolean indicates if it is an errorneous highlight (cond
(let ([before [(and (> here 0)
(cond (is-right-paren? (get-character (sub1 here))))
[(and (> here 0) (cond
(is-right-paren? (get-character (sub1 here)))) [(slash? (- here 2) (- here 1)) #f]
(cond [(scheme-paren:backward-match
[(slash? (- here 2) (- here 1)) #f] this here (get-limit here)
[(scheme-paren:backward-match backward-cache)
this here (get-limit here) =>
backward-cache) (lambda (end-pos)
=> (list end-pos here #f))]
(lambda (end-pos) [else (list (- here 1) here #t)])]
(list end-pos here #f))] [else #f])]
[else (list (- here 1) here #t)])] [after
[else #f])] (cond
[after [(is-left-paren? (get-character here))
(cond (cond
[(is-left-paren? (get-character here)) [(slash? (- here 1) here) #f]
(cond [(scheme-paren:forward-match
[(slash? (- here 1) here) #f] this here (last-position)
[(scheme-paren:forward-match forward-cache)
this here (last-position) =>
forward-cache) (lambda (end-pos)
=> (list here end-pos #f))]
(lambda (end-pos) [else (list here (+ here 1) #t)])]
(list here end-pos #f))] [else #f])]
[else (list here (+ here 1) #t)])] [handle-single
[else #f])] (lambda (single)
[handle-single (let* ([left (mzlib:function:first single)]
(lambda (single) [right (mzlib:function:second single)]
(let* ([left (mzlib:function:first single)] [error? (mzlib:function:third single)]
[right (mzlib:function:second single)] [off (highlight-range
[error? (mzlib:function:third single)] left
[off (highlight-range right
left (if error? mismatch-color match-color)
right (icon:get-paren-highlight-bitmap)
(if error? mismatch-color match-color) (= there here left))])
(icon:get-paren-highlight-bitmap) (set! clear-old-locations
(= there here left))]) (let ([old clear-old-locations])
(set! clear-old-locations (lambda ()
(let ([old clear-old-locations]) (old)
(lambda () (off))))))])
(old)
(off))))))]) (cond
[(and after before)
(cond (handle-single after)
[(and after before) (handle-single before)]
(handle-single after) [after (handle-single after)]
(handle-single before)] [before (handle-single before)]
[after (handle-single after)] [else (void)])))))
[before (handle-single before)] (end-edit-sequence)
[else (void)]))))))) (set! in-highlight-parens? #f))))]
(lambda ()
(end-edit-sequence)
(set! in-highlight-parens? #f))))))]
[get-limit (lambda (pos) 0)] [get-limit (lambda (pos) 0)]