fixed another path/string bug in the autosave recovery dialog

original commit: c455631eb327ede09ec0f21e1958f9cd043ce72a
This commit is contained in:
Robby Findler 2011-10-02 17:17:41 -05:00
parent 57b74886e6
commit 6bd97a2bad
2 changed files with 25 additions and 16 deletions

View File

@ -37,9 +37,11 @@
(quote-literal-label (apply format format-str args)))
;; quote-literal-label: string -> string
(define (quote-literal-label a-str)
(trim-string (regexp-replace* #rx"(&)" a-str "\\1\\1")
maximum-string-label-length))
(define (quote-literal-label a-str #:quote-amp? [quote-amp? #t])
(define quoted (if quote-amp?
(regexp-replace* #rx"(&)" a-str "\\1\\1")
a-str))
(trim-string quoted maximum-string-label-length))
;; selected-text-color : color
(define selected-text-color (send the-color-database find-color "black"))
@ -303,17 +305,18 @@
than @racket[size] by trimming the @racket[str]
and inserting an ellispses into it.})
(proc-doc
(proc-doc/names
gui-utils:quote-literal-label
(->i ([str string?])
()
[res (str)
(and/c string?
(lambda (str)
((string-length str) . <= . 200)))])
@{Constructs a string whose ampersand characters are
escaped; the label is also trimmed to <= 200
characters.})
(->* (string?)
(#:quote-amp? any/c)
(and/c string?
(λ (str) ((string-length str) . <= . 200))))
((string)
((quote-amp? #t)))
@{Constructs a string whose length is less than @racket[200] and,
if @racket[quote-amp?] is not @racket[#f], then it also quotes
the ampersand in the result (making the string suitable for use in
@racket[menu-item%] label, for example).})
(proc-doc
gui-utils:format-literal-label

View File

@ -239,7 +239,9 @@
(when filename-result
(disable-line)
(send msg2 set-label (string-constant autosave-recovered!))
(send msg1 set-label filename-result)))))]
(send msg1 set-label (gui-utils:quote-literal-label
(path->string filename-result)
#:quote-amp #f))))))]
[disable-line
(λ ()
(send recover enable #f)
@ -249,7 +251,7 @@
(send msg1-label min-width w)
(send msg2-label min-width w))
(void))))
;; delete-autosave : (list (union #f string[filename]) string[filename]) -> boolean
;; result indicates if delete occurred
(define (delete-autosave table-entry)
@ -297,7 +299,11 @@
(define vp (make-object vertical-panel% parent))
(define t (make-object show-files-text%))
(define msg1 (make-object message% label vp))
(define msg2 (make-object message% (path->string filename) vp))
(define msg2 (new message%
[label (gui-utils:quote-literal-label
(path->string filename)
#:quote-amp #f)]
[parent vp]))
(define ec (make-object editor-canvas% vp t))
(send t load-file filename)
(send t hide-caret #t)