diff --git a/collects/framework/gui-utils.rkt b/collects/framework/gui-utils.rkt index 353c0346bb..413b28fa90 100644 --- a/collects/framework/gui-utils.rkt +++ b/collects/framework/gui-utils.rkt @@ -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 diff --git a/collects/framework/private/autosave.rkt b/collects/framework/private/autosave.rkt index 3380d5bc55..9881f49d20 100644 --- a/collects/framework/private/autosave.rkt +++ b/collects/framework/private/autosave.rkt @@ -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)