On this page:
drracket:  unit:  tab<%>
break-callback
can-close?
disable-evaluation
enable-evaluation
get-breakables
get-defs
get-directory
get-enabled
get-frame
get-ints
is-current-tab?
is-running?
on-close
reset-offer-kill
set-breakables
add-bkg-running-color
remove-bkg-running-color
touched
get-last-touched
drracket:  unit:  tab%
make-object
clear-annotations
drracket:  unit:  program-editor-mixin
after-delete
after-insert
drracket:  unit:  interactions-canvas%
new
drracket:  unit:  frame%
new
add-show-menu-items
break-callback
change-to-file
find-matching-tab
change-to-tab
edit-menu:  between-select-all-and-find
execute-callback
file-menu:  between-open-and-revert
file-menu:  between-print-and-close
file-menu:  between-save-as-and-print
file-menu:  print-string
file-menu:  save-as-string
file-menu:  save-string
get-break-button
get-button-panel
get-canvas
get-canvas%
get-definitions/  interactions-panel-parent
get-editor
get-editor%
get-execute-button
get-text-to-search
make-searchable
on-close
on-size
still-untouched?
update-save-button
update-save-message
update-shown
drracket:  unit:  frame<%>
get-language-menu
ensure-defs-shown
ensure-rep-hidden
ensure-rep-shown
get-current-tab
get-tab-filename
get-tab-count
open-in-new-tab
create-new-tab
next-tab
prev-tab
move-current-tab-right
move-current-tab-left
reorder-tabs
close-current-tab
get-definitions-canvas
get-definitions-text
get-insert-menu
get-interactions-canvas
get-interactions-text
get-tabs
on-tab-change
register-capability-menu-item
register-toolbar-button
register-toolbar-buttons
unregister-toolbar-button
sort-toolbar-buttons-panel
drracket:  unit:  definitions-text<%>
after-set-next-settings
begin-metadata-changes
end-metadata-changes
get-next-settings
get-tab
set-needs-execution-message
set-next-settings
set-filename
set-modified
drracket:  unit:  definitions-canvas%
drracket:  unit:  get-definitions-text%
drracket:  unit:  get-program-editor-mixin
drracket:  unit:  add-to-program-editor-mixin
drracket:  unit:  open-drscheme-window
drracket:  unit:  add-search-help-desk-menu-item
drracket:  unit:  teachpack-callbacks
drracket:  unit:  struct:  teachpack-callbacks
drracket:  unit:  make-teachpack-callbacks
drracket:  unit:  find-symbol

14 drracket:unit

method

(send a-drracket:unit:tab break-callback)  void?

Specification: This method is called when the break button is clicked and this tab is the active tab.

Default implementation: By default, breaks any evaluation that may be happening at this point.

method

(send a-drracket:unit:tab can-close?)  boolean?

Refine this method with augment.
Specification: This method is called to determine if it is okay to close this tab.

Default implementation: Calls the definitions text’s and interactions text’s can-close? method.

method

(send a-drracket:unit:tab disable-evaluation)  void?

Disables the Run button, and the Run menu item and locks the interactions window, and the definitions window.

method

(send a-drracket:unit:tab enable-evaluation)  void?

Enables the Run button, and the Run menu item and unlocks (via the lock method) the interactions window and the definitions window.

method

(send a-drracket:unit:tab get-breakables)

  
(or/c thread? false/c)
(or/c custodian? false/c)

method

(send a-drracket:unit:tab get-defs)

  (is-a?/c drracket:unit:definitions-text<%>)
This text is initially the top half of the DrRacket window and contains the users program.

This text defaults to a text% object, but if you change drracket:get/extend:extend-definitions-text procedure, it will use the extended class to create the text.

method

(send a-drracket:unit:tab get-directory)

  (or/c string? false/c)
This is the directory that the file is saved in, or the directory DrRacket started up in, if the file has not been saved.

method

(send a-drracket:unit:tab get-enabled)  boolean?

Indicates if evaluation is currently enabled in this tab. Evaluation is typically disabled when some evaluation is already running (in another thread).

method

(send a-drracket:unit:tab get-frame)

  (is-a?/c drracket:unit:frame%)
Returns the frame that this tab is inside.

method

(send a-drracket:unit:tab get-ints)

  (is-a?/c drracket:rep:text%)
This text is initially the bottom half of the DrRacket window and contains the users interactions with the REPL.

This text defaults to a drracket:rep:text% object, but if you use the drracket:get/extend:extend-interactions-text procedure, it will use the extended class to create the text.

method

(send a-drracket:unit:tab is-current-tab?)  boolean?

Indicates if this tab is the currently active tab.

method

(send a-drracket:unit:tab is-running?)  boolean?

Indicates if the running message in the bottom right of DrRacket’s frame should be “running” or “not running” when this frame is active.

method

(send a-drracket:unit:tab on-close)  void?

Refine this method with augment.
Specification: This method is called when the tab is closed.

Default implementation: Calls the definitions text’s on-close and interactions text’s on-close methods.

method

(send a-drracket:unit:tab reset-offer-kill)  void?

method

(send a-drracket:unit:tab set-breakables thread    
  custodian)  void?
  thread : (or/c thread? false/c)
  custodian : (or/c custodian? false/c)

method

(send a-drracket:unit:tab add-bkg-running-color id    
  color    
  label)  void?
  id : symbol?
  color : (or/c string? (is-a?/c color%))
  label : string?
This method is final, so it cannot be overridden.
Sets the color of the circle in the bottom-right corner of the DrRacket window to color with the tooltip window that appears over it containing label. If multiple colors are registered they are all shown.

method

(send a-drracket:unit:tab remove-bkg-running-color id)  void?

  id : symbol?
This method is final, so it cannot be overridden.
Removes the color and label added with id.

method

(send a-drracket:unit:tab touched)  void?

This method is final, so it cannot be overridden.
Called by the system to indicate that the tab has just been switched to from another tab in the same frame (when the frame has the focus) or the frame itself has come to the front (via on-activate) and the tab is the current tab in that frame.

This method updates the private state that get-last-touched returns.

method

(send a-drracket:unit:tab get-last-touched)  flonum?

This method is final, so it cannot be overridden.
Returns the time that this tab was last focused, as counted by current-inexact-milliseconds.

class

drracket:unit:tab% : class?

  superclass: object%

  extends: drracket:unit:tab<%>
The base class that implements the tab’s functionality.

constructor

(make-object drracket:unit:tab%)

  (is-a?/c drracket:unit:tab%)

method

(send a-drracket:unit:tab clear-annotations)  void?

Clears any error highlighting; calls clear-annotations.

mixin

drracket:unit:program-editor-mixin : (class? . -> . class?)

  argument extends/implements: text%
 editor:basic<%>
This mixes in the ability to reset the highlighting for error message when the user modifies the buffer. Use it for editors that have program text where errors can occur.

method

(send a-drracket:unit:program-editor after-delete start 
  len) 
  void?
  start : number
  len : number
Augments after-delete in text%.
Calls the inner method.

Resets an error highlighting.

method

(send a-drracket:unit:program-editor after-insert start 
  len) 
  void?
  start : number
  len : number
Augments after-insert in text%.
Calls the inner method.

Resets an error highlighting.

Passes all arguments to super-init.

This frame inserts the Racket and Language menus into the menu bar as it is initialized.

constructor

(new drracket:unit:frame% ...superclass-args...)

  (is-a?/c drracket:unit:frame%)
Passes all arguments to super-init.

method

(send a-drracket:unit:frame add-show-menu-items show-menu)

  void?
  show-menu : (is-a?/c menu%)
Adds the “Show Definitions”, “Show Interactions” and “Show Contour” menu items.

method

(send a-drracket:unit:frame break-callback)  void?

Specification: This method is called when the user clicks on the break button or chooses the break menu item.

Default implementation: Breaks the user’s evaluation started by the Run button (or possibly a queued callback in the user’s eventspace).

method

(send a-drracket:unit:frame change-to-file file)  void?

  file : string?
Loads this file into this already created frame. In normal DrRacket use, this method is only called if this is the first frame opened and no editing has occurred. It should be safe to call this at anytime, however.

method

(send a-drracket:unit:frame find-matching-tab p)

  (or/c (is-a?/c drracket:unit:tab%) #f)
  p : path-string?
Returns the tab that is currently editing p, if there is one in this frame. Returns #f otherwise.

method

(send a-drracket:unit:frame change-to-tab tab)  void?

  tab : (is-a?/c drracket:unit:tab%)
Makes tab visible in this frame.

method

(send a-drracket:unit:frame edit-menu:between-select-all-and-find edit-menu)

  void?
  edit-menu : (is-a?/c menu%)
Adds the "Split" and "Collapse" menu items.

method

(send a-drracket:unit:frame execute-callback)  void?

Specification: This method is called when the user clicks on the Run button or chooses the Run menu item.

Default implementation: It calls ensure-rep-shown and then it calls evaluate-from-port passing in the result of get-interactions-text and its entire range, unless the first two characters are #! in which case, it skips the first line.

method

(send a-drracket:unit:frame file-menu:between-open-and-revert file-menu)

  void?
  file-menu : (is-a?/c menu%)
Calls the super method and adds a separator-menu-item% to the menu.

method

(send a-drracket:unit:frame file-menu:between-print-and-close file-menu)

  void?
  file-menu : (is-a?/c menu%)
Adds a menu item for printing the interactions.

method

(send a-drracket:unit:frame file-menu:between-save-as-and-print file-menu)

  void?
  file-menu : (is-a?/c menu%)
Adds a submenu that contains various save options:
  • save definitions as text

  • save interactions

  • save interactions as

  • save interactions as text

and adds a separator item.

method

(send a-drracket:unit:frame file-menu:print-string)  void?

returns "Definitions"

method

(send a-drracket:unit:frame file-menu:save-as-string)  void?

Returns "Definitions".

method

(send a-drracket:unit:frame file-menu:save-string)  void?

Returns "Definitions".

method

(send a-drracket:unit:frame get-break-button)

  (is-a?/c button%)
Returns the break button. Mostly used for test suites.

method

(send a-drracket:unit:frame get-button-panel)

  (is-a?/c horizontal-panel%)
This panel goes along the top of the DrRacket window and has buttons for important actions the user frequently executes.

A tool can add a button to this panel to make some new functionality easily accessible to the user.

See also mrlib’s switchable-button%.

method

(send a-drracket:unit:frame get-canvas)

  (is-a?/c editor-canvas%)
Returns the result of get-definitions-canvas.

method

(send a-drracket:unit:frame get-canvas%)  (is-a?/c canvas%)

method

(send a-drracket:unit:frame get-definitions/interactions-panel-parent)

  (is-a?/c vertical-panel%)
(send a-drracket:unit:frame get-definitions/interactions-panel-parent)
  void?
Specification: This method is provided so that tools can add area-container<%>s to the DrRacket frame. Override this method so that it returns a child of the super-classes’s result and insert new children in between.

Default implementation: First case:

Returns the result of get-area-container

Second case:

method

(send a-drracket:unit:frame get-editor)  (is-a?/c editor<%>)

Returns the result of get-definitions-text.

method

(send a-drracket:unit:frame get-editor%)  (is-a?/c editor<%>)

method

(send a-drracket:unit:frame get-execute-button)

  (is-a?/c button%)
Returns the Run button. Mostly used for test suites.

method

(send a-drracket:unit:frame get-text-to-search)

  (is-a?/c text:searching%)
returns the text that is active in the last canvas passed to make-searchable

method

(send a-drracket:unit:frame make-searchable canvas)  void?

  canvas : (is-a?/c drracket:unit:interactions-canvas%)
stores the canvas, until get-text-to-search is called.

method

(send a-drracket:unit:frame on-close)  void?

Sends the result of get-interactions-text the shutdown and on-close methods.

Always calls the inner method.

method

(send a-drracket:unit:frame on-size)  void?

Overrides on-size in window<%>.
Updates the preferences for the window width and height so next time a DrRacket window is opened, it will be this width and height.

method

(send a-drracket:unit:frame still-untouched?)  boolean?

Specification: determines if the definitions window has not been modified. Used in conjunction with change-to-file.

Default implementation: Returns #t if the buffer is empty, it has not been saved and it is unmodified.

method

(send a-drracket:unit:frame update-save-button modified?)

  void?
  modified? : any/c
This method hides or shows the save button, based on the modified? argument.

If the save button has not been created yet, it remembers the modified? argument as an initial visibility for the save button.

This method is called by the set-modified method.

method

(send a-drracket:unit:frame update-save-message name)  void?

  name : string?
Updates the save message on the DrRacket frame. This method is called by the set-filename method.

method

(send a-drracket:unit:frame update-shown)  void?

Updates the interactions, definitions, and contour menu items based on the contents of the windows.

method

(send a-drracket:unit:frame get-language-menu)

  (is-a?/c menu%)
Returns the language-specific menu. This menu is called the Racket menu in the Racket language but is, in general, controlled by the 'drscheme:language-menu-title capability (see drracket:language:register-capability for details on capabilities).

method

(send a-drracket:unit:frame ensure-defs-shown)  void?

Ensures that the definitions window is visible.

method

(send a-drracket:unit:frame ensure-rep-hidden)  void?

Makes sure the rep is hidden (by making the definitions window visible).

method

(send a-drracket:unit:frame ensure-rep-shown rep)  void?

  rep : (is-a?/c drracket:rep:text<%>)
This method is called to force the rep window to be visible when, for example, an error message is put into the rep. Also ensures that the appropriate tab is visible, if necessary.

method

(send a-drracket:unit:frame get-current-tab)

  (is-a?/c drracket:unit:tab<%>)
Returns the currently active tab.

method

(send a-drracket:unit:frame get-tab-filename i)  string?

  i : (<=/c 0 (get-tab-count))
Returns a string naming the file in the ith tab or, if the file is not saved, something like “Untitled”.

method

(send a-drracket:unit:frame get-tab-count)

  exact-positive-integer?
Returns the number of open tabs in the frame.

method

(send a-drracket:unit:frame open-in-new-tab filename)  void?

  filename : (or/c path-string? #f)
Opens a new tab in this frame. If filename is a path-string?, It loads that file in the definitions window of the new tab.

method

(send a-drracket:unit:frame create-new-tab)  void?

Creates a new tab.

method

(send a-drracket:unit:frame next-tab)  void?

Switches to the next tab.

method

(send a-drracket:unit:frame prev-tab)  void?

Switches to the previous tab.

method

(send a-drracket:unit:frame move-current-tab-right)  void?

Swaps the current tab with its right-hand neighbor.

method

(send a-drracket:unit:frame move-current-tab-left)  void?

Swaps the current tab with its left-hand neighbor.

method

(send a-drracket:unit:frame reorder-tabs tab-order)  void?

  tab-order : (listof exact-nonnegative-integer?)
Reorders the tabs according to tab-order.

Each element in tab-order identifies a tab by its position in the list get-tabs, and the position of this element identifies the new position of the tab.

For example, considering that there are only 3 tabs open, (send a-drracket-frame reorder-tabs '(2 1 0)) swaps the first and last tabs, leaving the middle one unchanged.

method

(send a-drracket:unit:frame close-current-tab)  void?

This method is final, so it cannot be overridden.
Closes the current tab, making some other tab visible. If there is only one tab open, this method does nothing.

method

(send a-drracket:unit:frame get-definitions-canvas)

  (is-a?/c drracket:unit:definitions-canvas%)
This canvas is the canvas containing the get-definitions-text. It is initially the top half of the DrRacket window.

This canvas defaults to a drracket:unit:definitions-canvas% object, but if you change the drracket:get/extend:extend-definitions-canvas procedure, it will use the class in the parameter to create the canvas.

method

(send a-drracket:unit:frame get-definitions-text)

  (is-a?/c drracket:unit:definitions-text%)
Calls result of get-current-tab’s get-defs method.

method

(send a-drracket:unit:frame get-insert-menu)  (is-a?/c menu%)

Specification: Returns the Insert menu.

method

(send a-drracket:unit:frame get-interactions-canvas)

  (instanceof (derivedfrom drracket:unit:interactions-canvas%))
This canvas is the canvas containing the get-interactions-text. It is initially the bottom half of the DrRacket window.

This canvas defaults to a drracket:unit:interactions-canvas% object, but if you use the drracket:get/extend:extend-interactions-canvas procedure, it will use the extended class to create the canvas.

method

(send a-drracket:unit:frame get-interactions-text)

  (is-a?/c drracket:rep:text%)
Calls result of get-current-tab’s get-ints method.

method

(send a-drracket:unit:frame get-tabs)

  (listof (is-a?/c drracket:unit:tab<%>))
Returns the list of tabs in this frame.

method

(send a-drracket:unit:frame on-tab-change from-tab    
  to-tab)  void?
  from-tab : (is-a?/c drracket:unit:tab<%>)
  to-tab : (is-a?/c drracket:unit:tab<%>)
Refine this method with augment.
Specification: Called after a new tab becomes the selected tab in the frame.

Default implementation: The from-tab argument is the previously selected tab, and the to-tab argument is the newly selected tab.

method

(send a-drracket:unit:frame register-capability-menu-item 
  key 
  menu) 
  void?
  key : symbol
  menu : (is-a? menu%)
Registers the menu item that was most recently added as being controlled by the capability key. This means that the (boolean) value of the capability determines if the menu item is present in the menu (the capability is checked when the menus are clicked on).

This assumes that the menu items in this menu are not moved around, except by the this capability. If they are, things can go funny (i.e., no good checks are in place).

Note that the capability must be registered separately, via drracket:language:register-capability.

method

(send a-drracket:unit:frame register-toolbar-button 
  tb 
  [#:number num]) 
  void?
  tb : (is-a?/c switchable-button%)
  num : (or/c #f real?) = #f
Registers the toolbar button tb.

The num argument controls the ordering of tb with respect to other toolbar buttons. If it is #f, then a number one smaller than the currently smallest number is used.

The buttons are sorted by their numbers, from left to right in horizontal mode and from top to bottom in vertical mode. If buttons are in sub-panels they cannot, in general, be sorted entirely by number without changing the panel structure, but when a sub-panel appears as a sibling of some toolbar buttons, the sorting routine looks for the smallest number appearing in a button in the sub-panel, and uses that number when sorting the panel that appears with the buttons.

A number of buttons already come with numbers: the Stop button’s number is 101, the Run button’s number is 100, the Scribble PDF button’s number is 99, the Scribble HTML button’s number is 98, the Macro Stepper button’s number is 70, the Debug button’s number is 60, the Stepper button’s number is 59, and the Check Syntax button’s number is 50.

All three are children of the panel returned by get-button-panel.

Registration is required so that the toolbar buttons properly switch orientation when the toolbar’s position is moved and the ordering via the number argument is preserved. See also sort-toolbar-buttons-panel.

method

(send a-drracket:unit:frame register-toolbar-buttons 
  tbs 
  [#:numbers nums]) 
  void?
  tbs : (listof (is-a?/c switchable-button%))
  nums : (listof (or/c real? #f)) = (make-list (length tbs) #f)
Simultaneously registers the toolbar buttons tbs.

See also register-toolbar-button.

method

(send a-drracket:unit:frame unregister-toolbar-button tb)

  void?
  tb : (is-a?/c switchable-button%)
Unregisters the toolbar button tb. Use this method to ensure that the button is not referenced by this frame and thus can be gc’d.

method

(send a-drracket:unit:frame sort-toolbar-buttons-panel)

  void?
Sorts the children of get-button-panel, according to the number argument passed to register-toolbar-button.

This interface is implemented by the definitions text.

method

(send a-drracket:unit:definitions-text after-set-next-settings language-settings)

  void?
  language-settings : language-settings
Refine this method with augment.
Specification: Called when the next settings changes. See also get-next-settings.

Default implementation:

method

(send a-drracket:unit:definitions-text begin-metadata-changes)

  void?
Augment this method to be notified when DrRacket is changing the buffer to insert metadata. The metadata is only inserted during saving, so tools that track changes to DrRacket will need to ignore changes that occur after this method is called, and before end-metadata-changes is called.

A call to begin-metadata-changes will always be followed with a call to end-metadata-changes (ie, the calls cannot be nested).

method

(send a-drracket:unit:definitions-text end-metadata-changes)

  void?
Called when the changes to insert metadata are done, and the editor is back to its state at the time of the call to begin-metadata-changes.

A call to begin-metadata-changes will always be followed with a call to end-metadata-changes (ie, the calls cannot be nested).

method

(send a-drracket:unit:definitions-text get-next-settings)

  language-settings
This method returns the language-settings that will be used when the user next clicks Run in this DrRacket window.

method

(send a-drracket:unit:definitions-text get-tab)

  (is-a?/c drracket:unit:tab%)
Returns the editor’s enclosing tab.

method

(send a-drracket:unit:definitions-text set-needs-execution-message msg)

  void?
  msg : string?
Specification: This method, when called, puts this DrRacket window in a state such that interactions submitted to the REPL will trigger a yellow warning message. The state is reset when the program is next Run.

Default implementation: Records msg and uses it the next time the user submits an interaction (unless the Runs first).

method

(send a-drracket:unit:definitions-text set-next-settings 
  language-settings 
  [update-prefs?]) 
  void?
  language-settings : language-settings
  update-prefs? : any/c = #t
Changes the language settings for this window. If update-prefs? is a true value, the preference is changed, which affects newly created windows.

See also after-set-next-settings and get-next-settings.

method

(send a-drracket:unit:definitions-text set-filename 
  filename 
  [temporary?]) 
  void?
  filename : (or/c path-string? #f)
  temporary? : any/c = #f
Overrides set-filename in editor<%>.
The class that is the result of (get-drracket:unit:definitions-text%) overrides this method and calls update-save-message.

method

(send a-drracket:unit:definitions-text set-modified modified?)

  void?
  modified? : any/c
Overrides set-modified in editor<%>.
The class that is the result of (get-drracket:unit:definitions-text%) overrides this method and calls update-save-button.

Initializes the visibility of the save button.

Returns the class used to implement the definitions text in the DrRacket frame. Its result mixes in drracket:unit:program-editor-mixin.

Returns a mixin that must be mixed in to any text% object that might contain program text (and thus can be in the source field of some syntax object).

procedure

(drracket:unit:add-to-program-editor-mixin mixin)  void?

  mixin : ((subclass?/c text%) . -> . (subclass?/c text%))
This function can only be called in phase 1 (see Implementing DrRacket Plugins for details).

Adds mixin to the result of drracket:unit:get-program-editor-mixin.

procedure

(drracket:unit:open-drscheme-window [filename 
  #:show? show?]) 
  (is-a?/c drracket:unit:frame%)
  filename : (or/c string? #f) = #f
  show? : boolean? = #t
Opens a DrRacket frame that displays filename, or, if filename is #f, an empty file.

If show? is #t, then the show is not invoked before the function returns; otherwise it is.

procedure

(drracket:unit:add-search-help-desk-menu-item text    
  menu    
  position    
  [add-sep])  void?
  text : (is-a?/c text%)
  menu : (is-a?/c menu-item-container<%>)
  position : exact-nonnegative-integer?
  add-sep : (-> any) = void
Adds a menu item to menu that searches in Help Desk for the word around position in text.

If there is only whitespace around position, then no menu-item%s are added, and add-sep is not called. If there is something to be added, then add-sep is called before the menu item is created.

struct

(struct drracket:unit:teachpack-callbacks (get-names
    add
    remove
    remove-all)
    #:extra-constructor-name
    make-drracket:unit:teachpack-callbacks)
  get-names : (-> any/c (listof string?))
  add : (-> any/c path-string? any/c)
  remove : (-> path-string? any/c any/c)
  remove-all : (-> any/c any/c)
Holds callbacks for teachpack operations. DrRacket invokes these functions in response to GUI operations being triggered.

Each of the any/cs that appear in the field contracts are actually the settings of a language.

The get-names field returns the names of the teachpacks in the given settings; add returns a new settings that includes the path-string? argument as a new teachpack; remove removes the given teachpack and remove-all removes them all.

procedure

(drracket:unit:find-symbol text pos)  string?

  text : (is-a?/c text%)
  pos : exact-nonnegative-integer?
returns a string that corresponds to the a symbol surrounding pos (in text).

This is intended to be used with the “f1” keybinding for searching in the documentation, so the result is not always a symbol, but instead a best effort to find something that is likely to be useful to search for around a point in the text.