original commit: 4079dc8a87a4b3754da97f60457162c0c04ad005
This commit is contained in:
Robby Findler 2002-07-02 03:36:09 +00:00
parent 40fb70fbe5
commit 7b40de8849
6 changed files with 52 additions and 7 deletions

View File

@ -733,6 +733,12 @@
"Sets the selection of the recently opened file to" "Sets the selection of the recently opened file to"
"\\var{start} and \\var{end}.") "\\var{start} and \\var{end}.")
(handler:size-recently-opened-files
(number? . -> . void?)
(num)
"Sizes the 'framework:recently-opened-files/pos preference"
"list length to \\var{num}.")
(icon:get-paren-highlight-bitmap (icon:get-paren-highlight-bitmap
(-> (is-a?/c bitmap%)) (-> (is-a?/c bitmap%))
() ()

View File

@ -897,6 +897,7 @@
[canceled? (cancel-due-to-unsaved-changes editor)]) [canceled? (cancel-due-to-unsaved-changes editor)])
(unless canceled? (unless canceled?
(send editor begin-edit-sequence) (send editor begin-edit-sequence)
(send editor lock #f)
(send editor set-filename #f) (send editor set-filename #f)
(send editor erase) (send editor erase)
(send editor set-modified #f) (send editor set-modified #f)
@ -965,7 +966,10 @@
filename filename
(send editor get-start-position) (send editor get-start-position)
(send editor get-end-position)))))) (send editor get-end-position))))))
(send editor begin-edit-sequence)
(send editor lock #f)
(send editor load-file filename) (send editor load-file filename)
(send editor end-edit-sequence)
(void)))) (void))))
(inherit get-label) (inherit get-label)

View File

@ -144,8 +144,6 @@
;; type recent-list-item = (list/p string? number? number?) ;; type recent-list-item = (list/p string? number? number?)
(define recent-max-count 50)
;; add-to-recent : string -> void ;; add-to-recent : string -> void
(define (add-to-recent filename) (define (add-to-recent filename)
(let* ([old-list (preferences:get 'framework:recently-opened-files/pos)] (let* ([old-list (preferences:get 'framework:recently-opened-files/pos)]
@ -157,7 +155,7 @@
(if old-ent (cadr old-ent) 0) (if old-ent (cadr old-ent) 0)
(if old-ent (caddr old-ent) 0))] (if old-ent (caddr old-ent) 0))]
[added-in (cons new-ent (remove new-ent old-list compare-recent-list-items))] [added-in (cons new-ent (remove new-ent old-list compare-recent-list-items))]
[new-recent (size-down added-in)]) [new-recent (size-down added-in (preferences:get 'framework:recent-max-count))])
(preferences:set 'framework:recently-opened-files/pos new-recent))) (preferences:set 'framework:recently-opened-files/pos new-recent)))
;; compare-recent-list-items : recent-list-item recent-list-item -> boolean ;; compare-recent-list-items : recent-list-item recent-list-item -> boolean
@ -167,8 +165,8 @@
;; size-down : (listof X) -> (listof X)[< recent-max-count] ;; size-down : (listof X) -> (listof X)[< recent-max-count]
;; takes a list of stuff and returns the ;; takes a list of stuff and returns the
;; front of the list, up to `recent-max-count' items ;; front of the list, up to `recent-max-count' items
(define (size-down new-recent) (define (size-down new-recent n)
(let loop ([n recent-max-count] (let loop ([n n]
[new-recent new-recent]) [new-recent new-recent])
(cond (cond
[(zero? n) null] [(zero? n) null]
@ -178,6 +176,15 @@
(loop (- n 1) (loop (- n 1)
(cdr new-recent)))]))) (cdr new-recent)))])))
;; size-recently-opened-files : number -> void
;; sets the recently-opened-files/pos preference
;; to a size limited by `n'
(define (size-recently-opened-files n)
(preferences:set
'framework:recently-opened-files/pos
(size-down (preferences:get 'framework:recently-opened-files/pos)
n)))
;; set-recent-position : string number number -> void ;; set-recent-position : string number number -> void
;; updates the recent menu preferences ;; updates the recent menu preferences
;; with the positions `start' and `end' ;; with the positions `start' and `end'

View File

@ -14,9 +14,20 @@
(import mred^ (import mred^
[preferences : framework:preferences^] [preferences : framework:preferences^]
[exit : framework:exit^] [exit : framework:exit^]
[group : framework:group^]) [group : framework:group^]
[handler : framework:handler^])
;; preferences ;; preferences
(preferences:set-default 'framework:recent-max-count
50
(lambda (x) (and (number? x)
(x . > . 0)
(integer? x))))
(preferences:add-callback
'framework:recent-max-count
(lambda (p v)
(handler:size-recently-opened-files v)))
(preferences:set-default 'framework:last-url-string "" string?) (preferences:set-default 'framework:last-url-string "" string?)
(preferences:set-default 'framework:recently-opened-sort-by 'age (preferences:set-default 'framework:recently-opened-sort-by 'age
(lambda (x) (or (eq? x 'age) (eq? x 'name)))) (lambda (x) (or (eq? x 'age) (eq? x 'name))))

View File

@ -374,6 +374,21 @@
(lambda (p v) (lambda (p v)
(send c set-value (pref->bool v)))))) (send c set-value (pref->bool v))))))
(define (make-recent-items-slider parent)
(let ([slider (instantiate slider% ()
(parent parent)
(label (string-constant number-of-open-recent-items))
(min-value 1)
(max-value 100)
(init-value (get 'framework:recent-max-count))
(callback (lambda (slider y)
(set 'framework:recent-max-count
(send slider get-value)))))])
(add-callback
'framework:recent-max-count
(lambda (p v)
(send slider set-value v)))))
(define (add-scheme-checkbox-panel) (define (add-scheme-checkbox-panel)
(letrec ([add-scheme-checkbox-panel (letrec ([add-scheme-checkbox-panel
(lambda () (lambda ()
@ -403,6 +418,7 @@
(add-checkbox-panel (add-checkbox-panel
(string-constant editor-prefs-panel-label) (string-constant editor-prefs-panel-label)
(lambda (editor-panel) (lambda (editor-panel)
(make-recent-items-slider editor-panel)
(make-check editor-panel (make-check editor-panel
'framework:autosaving-on? 'framework:autosaving-on?
(string-constant auto-save-files) (string-constant auto-save-files)

View File

@ -384,7 +384,8 @@
install-recent-items install-recent-items
add-to-recent add-to-recent
set-recent-position set-recent-position
set-recent-items-frame-superclass)) set-recent-items-frame-superclass
size-recently-opened-files))
(define-signature framework:handler^ (define-signature framework:handler^
((open framework:handler-class^) ((open framework:handler-class^)
(open framework:handler-fun^))) (open framework:handler-fun^)))