#lang scribble/manual @(require planet/scribble) @title{Script Plugin for DrRacket} @section{Introduction} The Scrit Plugin is a plugin for DrRacket that is similar to GEdit's External Tool plugin. Its purpose is to make it easy to extend DrRacket with small scripts that can be used in the definition window, on the selected text. @section{Example} Click on Scripts/New Script, and enter @italic{Reverse}. This creates and opens the .rkt and .rktd files. Also, a new entry automatically appears in the Scripts menu. In the .rkt file, modify the @racket[transform-input-string] function to the following: @codeblock|{ (define (transform-input-string str) (list->string (reverse (string->list str)))) }| Then go to a new tab, type some text, select it, and click on Scripts/Reverse. @section{Description} This DrRacket plugin adds a Script menu to the main window. This menu has several items, followed by the (initially empty) list of active scripts. The New Script item asks for a script name and creates 2 files: @itemlist[ @item{a .rkt file, the script itself (with a sample program)} @item{a .rktd file, the metadata of the script with the default values} ] These two files are automatically opened. The script menu is rebuild each time the user activates it, so that changes are taken into account as soon as possible. The default location of the scripts is in a subfolder of (find-system-path 'home-path). The directory of the user scripts can be change through DrRacket's preferences (in Edit/Preferences/Scripts). @subsection{The .rkt file} This is the script file. It must provide the @racket[transform-input-string] (that's not a very good name) function, as in the sample code. It is meant to be executable by itself, to ease the testing process. @subsection{The .rktd file} This is the metadata file. It contains an assocation list that defines the configuration of the script. Most options (label, shortcut, shortcut-prefix, help-string) are the same as for the @racket[menu-item%] constructor. There are some additional options: @itemlist[ @item{@racket[sub-menu : string?] A string for the label of the sub-menu in which the script will appear.} @item{@racket[output-to : (one-of 'selection 'new-tab 'message-box)] If @racket['selection], the output of the transform function replaces the selection in the current tab (or insert at the cursor if there is no selection). If @racket['new-tab], a new tab is created and the output of the scritp is written to it. If @racket['message-box], the output is displayed in a message-box. } ]