change backspace in overwrite mode to be more what one
might expect it to be
This commit is contained in:
parent
4140c530d6
commit
cf6a3d6ecb
|
@ -612,7 +612,16 @@
|
|||
(insert ch startpos (add1 startpos))
|
||||
(insert ch)))])
|
||||
(case code
|
||||
[(#\backspace) (delete)]
|
||||
[(#\backspace)
|
||||
(cond
|
||||
[(and overwrite-mode?
|
||||
(= endpos startpos)
|
||||
(not (zero? startpos)))
|
||||
(begin-edit-sequence)
|
||||
(insert #\space (- startpos 1) startpos)
|
||||
(set-position (- startpos 1) (- startpos 1))
|
||||
(end-edit-sequence)]
|
||||
[else (delete)])]
|
||||
[(#\rubout)
|
||||
(if (= endpos startpos)
|
||||
(when (endpos . < . len)
|
||||
|
|
|
@ -1561,6 +1561,31 @@
|
|||
(send t1 insert "Hello\tWorld")
|
||||
(send t1 get-extent (box 0) (box 0)))
|
||||
|
||||
;; ----------------------------------------
|
||||
;; Overwrite mode
|
||||
(let ([t (new text%)])
|
||||
(send t set-admin (new test-editor-admin%))
|
||||
(send t insert "abcdef")
|
||||
(send t set-position 3 3)
|
||||
(define (type c) (send t on-default-char (new key-event% [key-code c])))
|
||||
(send t set-overwrite-mode #t)
|
||||
(type #\z)
|
||||
(expect (send t get-start-position) 4)
|
||||
(expect (send t get-text) "abczef")
|
||||
(type #\backspace)
|
||||
(expect (send t get-start-position) 3)
|
||||
(expect (send t get-text) "abc ef")
|
||||
|
||||
(send t set-position 1)
|
||||
(type #\backspace)
|
||||
(expect (send t get-start-position) 0)
|
||||
(expect (send t get-text) " bc ef")
|
||||
|
||||
(type #\backspace)
|
||||
(expect (send t get-start-position) 0)
|
||||
(expect (send t get-text) " bc ef"))
|
||||
|
||||
|
||||
;; ----------------------------------------
|
||||
;; Identity and contracts
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user