From 53853d696a9a6317cad6fd4d0372abb47a1d53c5 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 12 Feb 2013 13:09:28 -0600 Subject: [PATCH] add increase/decrease font size menu items (ala browsers) --- collects/drracket/private/frame.rkt | 12 ++++++-- collects/drracket/private/unit.rkt | 28 +++++++++++++++++-- .../private/english-string-constants.rkt | 4 +++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/collects/drracket/private/frame.rkt b/collects/drracket/private/frame.rkt index ab8d77a8ee..777090a7eb 100644 --- a/collects/drracket/private/frame.rkt +++ b/collects/drracket/private/frame.rkt @@ -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] diff --git a/collects/drracket/private/unit.rkt b/collects/drracket/private/unit.rkt index 98a5b93d6f..9e4d47f842 100644 --- a/collects/drracket/private/unit.rkt +++ b/collects/drracket/private/unit.rkt @@ -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)) diff --git a/collects/string-constants/private/english-string-constants.rkt b/collects/string-constants/private/english-string-constants.rkt index a0b51a5b2c..f0b33b7985 100644 --- a/collects/string-constants/private/english-string-constants.rkt +++ b/collects/string-constants/private/english-string-constants.rkt @@ -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