adjust tab menu items in drracket

specifically:
- make <menukey>-9 always go to the last tab
  (following chrome, as suggested by Jens Axel)
- make the <menukey>-1 thru <menukey>-9 menu items
  always be present in the menu, even when there aren't
  tabs, so that the shortcuts always appear taken
  (and so that cmd-4 never inserts a 4 into your buffer)
This commit is contained in:
Robby Findler 2013-10-25 11:18:07 -05:00
parent 1bd1ca5192
commit 067498ddf4
2 changed files with 50 additions and 28 deletions

View File

@ -780,22 +780,41 @@
(when frame
(send frame move-current-tab-left))))])
(let ([frame (find-frame windows-menu)])
(unless (or (not frame) (= 1 (send frame get-tab-count)))
(unless (eq? (system-type) 'macosx)
(new separator-menu-item% [parent windows-menu]))
(for ([i (in-range 0 (send frame get-tab-count))]
#:when (< i 9))
(new menu-item%
[parent windows-menu]
[label (format (string-constant tab-i)
(+ 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))]))))
(define frame (find-frame windows-menu))
(when frame
(define tab-count (send frame get-tab-count))
(unless (eq? (system-type) 'macosx)
(new separator-menu-item% [parent windows-menu]))
(for ([i (in-range 1 10)])
(define sc (integer->char (+ (char->integer #\0) i)))
(cond
[(or (< tab-count i) (= 1 tab-count))
(send (new menu-item%
[parent windows-menu]
[label (format (string-constant tab-i/no-name) i)]
[shortcut sc]
[callback void])
enable #f)]
[(= i 9)
(new menu-item%
[parent windows-menu]
[label (format (string-constant tab-i)
i
(send frame get-tab-filename (- tab-count 1)))]
[shortcut sc]
[callback
(λ (a b)
(send frame change-to-nth-tab (- tab-count 1)))])]
[else
(new menu-item%
[parent windows-menu]
[label (format (string-constant tab-i)
i
(send frame get-tab-filename (- i 1)))]
[shortcut sc]
[callback
(λ (a b)
(send frame change-to-nth-tab (- i 1)))])])))
(when (eq? (system-type) 'macosx)
(new separator-menu-item% [parent windows-menu])))))

View File

@ -2267,18 +2267,21 @@
(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)]
[n (in-naturals 1)]
#:when (<= n 9))
(and (eq? i tab)
(format "~a: " n)))
"")])
(add-modified-flag
defs
(string-append
i-prefix
(get-defs-tab-filename defs)))))
(define tab-index
(for/or ([i (in-list tabs)]
[n (in-naturals 1)])
(and (eq? i tab) n)))
(define i-prefix
(cond
[(not tab-index) ""]
[(<= tab-index 8) (format "~a: " tab-index)]
[(= tab-index (get-tab-count)) "9: "]
[else ""]))
(add-modified-flag
defs
(string-append
i-prefix
(get-defs-tab-filename defs))))
(define/private (get-defs-tab-filename defs)
(let ([fn (send defs get-filename)])