tweak to Nadeem's commit
This commit is contained in:
parent
8f3343cd01
commit
49a0b950b7
|
@ -8,7 +8,6 @@ added get-regions
|
||||||
|
|
||||||
(require racket/class
|
(require racket/class
|
||||||
racket/gui/base
|
racket/gui/base
|
||||||
(prefix-in r: racket/match) ; does 'match' conflict with something else
|
|
||||||
syntax-color/token-tree
|
syntax-color/token-tree
|
||||||
syntax-color/paren-tree
|
syntax-color/paren-tree
|
||||||
syntax-color/default-lexer
|
syntax-color/default-lexer
|
||||||
|
@ -1045,32 +1044,33 @@ added get-regions
|
||||||
(end-edit-sequence) ;; wraps up the net-zero editing changes done by get-close-paren etc.
|
(end-edit-sequence) ;; wraps up the net-zero editing changes done by get-close-paren etc.
|
||||||
(undo) ;; to avoid messing up the editor's modified state in case of a simple skip
|
(undo) ;; to avoid messing up the editor's modified state in case of a simple skip
|
||||||
|
|
||||||
;; an action is either '(insert) or '(skip p) where p is a position
|
(define (insert)
|
||||||
(define the-action
|
(for ([c (in-string insert-str)])
|
||||||
(r:match smart-skip
|
(on-default-char (new key-event% (key-code c))))
|
||||||
[#f '(insert)]
|
(+ pos (string-length insert-str)))
|
||||||
['adjacent (if (and next-close-start next-close-adj?
|
(define (skip p)
|
||||||
(string=? insert-str next-close-str))
|
(set-position p)
|
||||||
`(skip ,next-close-end)
|
p)
|
||||||
`(insert))]
|
|
||||||
['forward (cond
|
|
||||||
[(and outer-close-start
|
|
||||||
(or fixup? (string=? insert-str outer-close-str)))
|
|
||||||
`(skip ,outer-close-end)]
|
|
||||||
[(and next-close-start
|
|
||||||
(or fixup? (string=? insert-str next-close-str)))
|
|
||||||
`(skip ,next-close-end)]
|
|
||||||
[else `(insert)])]
|
|
||||||
[_ (error 'insert-close-paren
|
|
||||||
(format "invalid smart-skip option: ~a" smart-skip))]))
|
|
||||||
|
|
||||||
(define end-pos
|
(define end-pos
|
||||||
(r:match the-action
|
(cond
|
||||||
[(list 'insert)
|
[(not smart-skip) (insert)]
|
||||||
(for-each (λ(c) (on-default-char (new key-event% (key-code c))))
|
[(eq? smart-skip 'adjacent)
|
||||||
(string->list insert-str))
|
(if (and next-close-start next-close-adj?
|
||||||
(+ pos (string-length insert-str))]
|
(string=? insert-str next-close-str))
|
||||||
[(list 'skip p) (set-position p) p]))
|
(skip next-close-end)
|
||||||
|
(insert))]
|
||||||
|
[(eq? smart-skip 'forward)
|
||||||
|
(cond
|
||||||
|
[(and outer-close-start
|
||||||
|
(or fixup? (string=? insert-str outer-close-str)))
|
||||||
|
(skip outer-close-end)]
|
||||||
|
[(and next-close-start
|
||||||
|
(or fixup? (string=? insert-str next-close-str)))
|
||||||
|
(skip next-close-end)]
|
||||||
|
[else (insert)])]
|
||||||
|
[else (error 'insert-close-paren
|
||||||
|
(format "invalid smart-skip option: ~a" smart-skip))]))
|
||||||
|
|
||||||
(when (and flash? (not stopped?)) (flash-from end-pos)))
|
(when (and flash? (not stopped?)) (flash-from end-pos)))
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
more to use the #lang language (unless they are using the teaching
|
more to use the #lang language (unless they are using the teaching
|
||||||
languages)
|
languages)
|
||||||
|
|
||||||
. Automatic-parenthesis mode improvements:
|
. Automatic-parenthesis mode improvements
|
||||||
|
(thanks to Nadeem Abdul Hamid)
|
||||||
|
|
||||||
- Added some "smart-skip" behavior to insert-close-paren,
|
- Added some "smart-skip" behavior to insert-close-paren,
|
||||||
described in the documentation.
|
described in the documentation.
|
||||||
- When auto-parens mode is enabled,
|
- When auto-parens mode is enabled,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user