fixed on-save-file with wx:....copy

original commit: 02ac59a2e99da8407035aca660938b303444cc3d
This commit is contained in:
Matthew Flatt 1996-09-09 19:45:26 +00:00
parent a0f0cb32fd
commit c7923e541a

View File

@ -178,6 +178,7 @@
[super-on-local-char on-local-char] [super-on-local-char on-local-char]
[super-on-save-file on-save-file] [super-on-save-file on-save-file]
[super-after-save-file after-save-file]
[super-after-set-position after-set-position] [super-after-set-position after-set-position]
@ -195,11 +196,11 @@
[super-after-delete after-delete] [super-after-delete after-delete]
[super-after-set-size-constraint after-set-size-constraint]) [super-after-set-size-constraint after-set-size-constraint])
(private (private
[styles-fixed-edit-modified? #f]) [styles-fixed-edit-modified? #f]
[restore-file-format void]) ; the function void, not #<void>
(public (public
[on-save-file [on-save-file
(let ([skip-check #f] (let ([has-non-text-snips
[has-non-text-snips
(lambda () (lambda ()
(let loop ([s (find-snip 0 wx:const-snip-after)]) (let loop ([s (find-snip 0 wx:const-snip-after)])
(cond (cond
@ -208,29 +209,31 @@
(loop (send s next))] (loop (send s next))]
[else #t])))]) [else #t])))])
(lambda (name format) (lambda (name format)
(unless (or skip-check (when (and (or (= format wx:const-media-ff-same)
(= format wx:const-media-ff-std) (= format wx:const-media-ff-copy))
(= format wx:const-media-ff-guess) (not (= (get-file-format)
(and (= format wx:const-media-ff-same) wx:const-media-ff-std)))
(= (get-file-format) (cond
wx:const-media-ff-std))) [(= format wx:const-media-ff-copy)
(dynamic-wind (set! restore-file-format
(lambda () (set! skip-check #t)) (let ([f (get-file-format)])
(lambda () (lambda ()
(cond (set! restore-file-format void)
[(= format wx:const-media-ff-copy) (set-file-format f))))
(let ([format (get-file-format)]) (set-file-format wx:const-media-ff-std)]
(set-file-format wx:const-media-ff-std) [(and (has-non-text-snips)
(save-file name format) (or (not (mred:preferences:get-preference 'mred:verify-change-format))
(set-file-format format))] (mred:gui-utils:get-choice "Save this file as plain text?" "No" "Yes")))
[(and (has-non-text-snips) (set-file-format wx:const-media-ff-std)]
(or (not (mred:preferences:get-preference 'mred:verify-change-format)) [else (void)]))
(mred:gui-utils:get-choice "Save this file as plain text?" "No" "Yes"))) (or (super-on-save-file name format)
(save-file name wx:const-media-ff-std)] (begin
[else (void)])) (restore-file-format)
(lambda () (set! skip-check #f)))) #f))))]
(super-on-save-file name format)))] [after-save-file
(lambda (success)
(super-after-save-file success)
(restore-file-format))]
[autowrap-bitmap mred:icon:autowrap-bitmap] [autowrap-bitmap mred:icon:autowrap-bitmap]