diff --git a/collects/mred/finder.ss b/collects/mred/finder.ss index 8bfb0131..98c902c4 100644 --- a/collects/mred/finder.ss +++ b/collects/mred/finder.ss @@ -3,6 +3,7 @@ (import [mred:debug : mred:debug^] [mred:container : mred:container^] [mred:preferences : mred:preferences^] + [mred:gui-utils : mred:gui-utils^] [mzlib:string : mzlib:string^] [mzlib:function : mzlib:function^] [mzlib:file : mzlib:file^]) @@ -36,6 +37,8 @@ #t] [else #f]))) + (mred:preferences:set-preference-default 'mred:show-periods-in-dirlist #f) + (define finder-dialog% (class mred:container:dialog-box% (save-mode? replace-ok? multi-mode? result-box start-dir @@ -51,68 +54,79 @@ dirs current-dir last-selected - [select-counter 0]) (private [set-directory (lambda (dir) ; dir is normalied - (set! current-dir dir) - (set! last-directory dir) - (let-values - ([(dir-list menu-list) - (let loop ([this-dir dir] - [dir-list ()] - [menu-list ()]) - (let-values ([(base-dir in-dir dir?) (split-path this-dir)]) - (if (eq? wx:platform 'windows) - (mzlib:string:string-lowercase! in-dir)) - (let* ([dir-list (cons this-dir dir-list)] - [menu-list (cons in-dir menu-list)]) - (if base-dir - (loop base-dir dir-list menu-list) - ; No more - (values dir-list menu-list)))))]) - (set! dirs (reverse dir-list)) - - (send dir-choice clear) - (let loop ([choices (reverse menu-list)]) - (unless (null? choices) - (send dir-choice append (car choices)) - (loop (cdr choices)))) - (send dir-choice set-selection 0) - (send top-panel force-redraw)) - - (send name-list clear) - (send name-list set - (mzlib:function:quicksort - (let loop ([l (directory-list dir)]) - (if (null? l) - '() - (let ([s (car l)] - [rest (loop (cdr l))]) - (if (directory-exists? (build-path dir s)) - (cons - (string-append s - (case wx:platform - (unix "/") - (windows "\\") - (macintosh ":"))) - rest) - (if (or (not file-filter) + (mred:gui-utils:show-busy-cursor + (lambda () + (set! current-dir dir) + (set! last-directory dir) + (let-values + ([(dir-list menu-list) + (let loop ([this-dir dir] + [dir-list ()] + [menu-list ()]) + (let-values ([(base-dir in-dir dir?) (split-path this-dir)]) + (if (eq? wx:platform 'windows) + (mzlib:string:string-lowercase! in-dir)) + (let* ([dir-list (cons this-dir dir-list)] + [menu-list (cons in-dir menu-list)]) + (if base-dir + (loop base-dir dir-list menu-list) + ; No more + (values dir-list menu-list)))))]) + (set! dirs (reverse dir-list)) + + (send dir-choice clear) + (let loop ([choices (reverse menu-list)]) + (unless (null? choices) + (send dir-choice append (car choices)) + (loop (cdr choices)))) + (send dir-choice set-selection 0) + (send top-panel force-redraw)) + + (send name-list clear) + (send name-list set + (mzlib:function:quicksort + (let ([no-periods? (not (mred:preferences:get-preference + 'mred:show-periods-in-dirlist))]) + (let loop ([l (directory-list dir)]) + (if (null? l) + null + (let ([s (car l)] + [rest (loop (cdr l))]) + (cond + [(and no-periods? + (<= 1 (string-length s)) + (char=? (string-ref s 0) #\.)) + rest] + [(directory-exists? (build-path dir s)) + (cons (string-append s + (case wx:platform + [(unix) "/"] + [(windows) "\\"] + [else ":"])) + rest)] + [(or (not file-filter) (mzlib:string:regexp-match-exact? file-filter s)) - (cons s rest) - rest))))) - (if (eq? wx:platform 'unix) string