add increase/decrease font size menu items (ala browsers)

This commit is contained in:
Robby Findler 2013-02-12 13:09:28 -06:00
parent 61ddb91815
commit 53853d696a
3 changed files with 40 additions and 4 deletions

View File

@ -3,6 +3,8 @@
racket/match
racket/class
racket/string
racket/file
racket/math
"drsig.rkt"
mred
framework
@ -10,7 +12,6 @@
net/head
setup/plt-installer
help/bug-report
racket/file
setup/unpack)
(import [prefix drracket:unit: drracket:unit^]
@ -630,6 +631,13 @@
[(and (number? x) (string? y)) #t]
[(and (string? x) (number? y)) #f]))
(define sorted-items (sort items cmp))
(define (different-slots? item-key next-item-key)
(or (not (= (quotient item-key 100)
(quotient next-item-key 100)))
(not (= (sgn item-key)
(sgn next-item-key)))))
(for ([item (in-list sorted-items)]
[next-item (in-list (append (cdr sorted-items) (list #f)))])
(define item-key (get-key item))
@ -637,7 +645,7 @@
(define add-sep?
(cond
[(and (number? item-key) (number? next-item-key))
(not (= (quotient item-key 100) (quotient next-item-key 100)))]
(different-slots? item-key next-item-key)]
[(or (and (string? item-key) (string? next-item-key))
(not next-item-key))
#f]

View File

@ -3403,8 +3403,6 @@ module browser threading seems wrong.
(set-show-menu-sort-key logger-menu-item 205)
(set! show-line-numbers-menu-item
(new menu:can-restore-menu-item%
[label (if (show-line-numbers?)
@ -3417,6 +3415,32 @@ module browser threading seems wrong.
(show-line-numbers! (not value)))]))
(set-show-menu-sort-key show-line-numbers-menu-item 302)
(let ()
(define (font-adjust adj label key shortcut)
(define (adj-font _1 _2)
(preferences:set
'framework:standard-style-list:font-size
(adj (preferences:get
'framework:standard-style-list:font-size))))
(define (on-demand item)
(define lab
(format
label
(adj
(preferences:get
'framework:standard-style-list:font-size))))
(send item set-label lab))
(define item
(new menu:can-restore-menu-item%
(shortcut shortcut)
(label "")
(parent (get-show-menu))
(callback adj-font)
(demand-callback on-demand)))
(set-show-menu-sort-key item key))
(font-adjust add1 (string-constant increase-font-size) -2 #\=)
(font-adjust sub1 (string-constant decrease-font-size) -3 #\-))
(let ([split
(new menu:can-restore-menu-item%
(shortcut (if (eq? (system-type) 'macosx) #f #\m))

View File

@ -577,6 +577,10 @@ please adhere to these guidelines:
(example-text "Example Text:")
(only-warn-once "Only warn once when definitions and interactions are not synchronized")
; font size menu items in the 'view' menu; the ~a is filled with a number (font size)
(increase-font-size "Increase Font Size (To ~a)")
(decrease-font-size "Decrease Font Size (To ~a)")
; warning message when lockfile is around
(waiting-for-pref-lock "Waiting for the preferences lockfile...")
(pref-lock-not-gone