Skip to content

Instantly share code, notes, and snippets.

@Metaxal
Created May 2, 2020 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Metaxal/cfe71127092d2ec95013cc81a5b88cd6 to your computer and use it in GitHub Desktop.
Save Metaxal/cfe71127092d2ec95013cc81a5b88cd6 to your computer and use it in GitHub Desktop.
Display a "All tabs" menu in DrRacket
#lang racket/base
(require racket/gui/base
racket/class
quickscript)
;;; The default 'Tabs' menu in DrRacket lists only the first 10 tabs.
;;; This script displays all tabs, which is particularly convenient when
;;; there are many tabs and not all of them are visible.
(define-script all-tabs
#:label "All tabs"
(λ (str #:frame fr)
(define menu-bar (send fr get-menu-bar))
(define menu
(new menu% [parent menu-bar] [label "All Tabs"]
[demand-callback
(λ (menu)
(send fr begin-container-sequence)
(for ([it (in-list (send menu get-items))])
(send it delete))
(new menu-item% [parent menu] [label "&Remove menu"]
[callback (λ _ (send menu delete))])
(for ([t (in-range (send fr get-tab-count))]
[tab (in-list (send fr get-tabs))])
(new menu-item% [parent menu]
[label (format "~a: ~a" t (send fr get-tab-filename t))]
[callback (λ _ (send fr change-to-tab tab))]))
(send fr end-container-sequence))]))
#f))
@Metaxal
Copy link
Author

Metaxal commented May 2, 2020

Have a Menu that displays all open tabs in DrRacket. (Currently, DrRacket displays only the first 10).

How to install: Click on Scripts | Manage scripts | New script...

Enter "All tabs" (a new script opens filled with a template).
Replace the template with the code below. Save the file.

Click on Scripts | All tabs. A new menu "All tabs" appears in DrRacket!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment