From 95debe6353b6fc99d56a11c29415ad5ebb573001 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 21 Feb 2010 02:06:57 +0000 Subject: [PATCH] added keyboard shortcuts for the first 9 tabs to the windows menu (on the mac) svn: r18245 --- collects/drscheme/private/main.ss | 11 +++++++++++ collects/drscheme/private/unit.ss | 15 ++++++++++----- collects/scribblings/tools/unit.scrbl | 11 ++++++++++- .../string-constants/english-string-constants.ss | 1 + 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/collects/drscheme/private/main.ss b/collects/drscheme/private/main.ss index 1f46e3d613..b9b70de1ab 100644 --- a/collects/drscheme/private/main.ss +++ b/collects/drscheme/private/main.ss @@ -561,6 +561,17 @@ (let ([frame (find-frame item)]) (when frame (send frame next-tab))))]) + (let ([frame (find-frame windows-menu)]) + (unless (= 1 (send frame get-tab-count)) + (for ([i (in-range 0 (send frame get-tab-count))] + #:when (< i 9)) + (new menu-item% + [parent windows-menu] + [label (format "Tab ~a: ~a" (+ i 1) (send frame get-tab-filename i))] + [shortcut (integer->char (+ (char->integer #\1) i))] + [callback + (λ (a b) + (send frame change-to-nth-tab i))])))) (new separator-menu-item% [parent windows-menu])))) ;; Check for any files lost last time. diff --git a/collects/drscheme/private/unit.ss b/collects/drscheme/private/unit.ss index 15a8ba5033..3a65ae2abf 100644 --- a/collects/drscheme/private/unit.ss +++ b/collects/drscheme/private/unit.ss @@ -2080,6 +2080,9 @@ module browser threading seems wrong. (unless (equal? label (send tabs-panel get-item-label (send tab get-i))) (send tabs-panel set-item-label (send tab get-i) label)))) + (define/public (get-tab-filename i) + (get-defs-tab-filename (send (list-ref tabs i) get-defs))) + (define/private (get-defs-tab-label defs tab) (let ([fn (send defs get-filename)] [i-prefix (or (for/or ([i (in-list tabs)] @@ -2090,11 +2093,13 @@ module browser threading seems wrong. "")]) (string-append i-prefix - (add-modified-flag - defs - (if fn - (get-tab-label-from-filename fn) - (send defs get-filename/untitled-name)))))) + (get-defs-tab-filename defs)))) + + (define/private (get-defs-tab-filename defs) + (let ([fn (send defs get-filename)]) + (if fn + (get-tab-label-from-filename fn) + (send defs get-filename/untitled-name)))) (define/private (get-tab-label-from-filename fn) (let* ([take-n diff --git a/collects/scribblings/tools/unit.scrbl b/collects/scribblings/tools/unit.scrbl index 2f98278140..8cb65a76ba 100644 --- a/collects/scribblings/tools/unit.scrbl +++ b/collects/scribblings/tools/unit.scrbl @@ -574,7 +574,16 @@ Shows the interactions window Returns the currently active tab. } - + +@defmethod[(get-tab-filename [i (<=/c 0 (#,(method drscheme:unit:frame% get-tab-count)))]) string?]{ + Returns a string naming the file in the @scheme[i]th tab or, if + the file is not saved, something like ``Untitled''. +} + +@defmethod[(get-tab-count) exact-positive-integer?]{ + Returns the number of open tabs in the frame. +} + @defmethod[(open-in-new-tab [filename (or/c path-string? #f)]) void?]{ Opens a new tab in this frame. If @scheme[filename] is a @scheme[path-string?], It loads that file in the definitions window of the new tab. diff --git a/collects/string-constants/english-string-constants.ss b/collects/string-constants/english-string-constants.ss index 2fa1e1206a..827da39cd9 100644 --- a/collects/string-constants/english-string-constants.ss +++ b/collects/string-constants/english-string-constants.ss @@ -730,6 +730,7 @@ please adhere to these guidelines: (most-recent-window "Most Recent Window") (next-tab "Next Tab") (prev-tab "Previous Tab") + (tab-i "Tab ~a") ;; menu item in the windows menu under mac os x. ~a is filled with a number between 1 and 9. (view-menu-label "&View") (show-overview "Show &Program Contour")