diff --git a/collects/drracket/private/module-language-tools.rkt b/collects/drracket/private/module-language-tools.rkt index 858a0fd619..14c7c42b66 100644 --- a/collects/drracket/private/module-language-tools.rkt +++ b/collects/drracket/private/module-language-tools.rkt @@ -156,23 +156,27 @@ (set! hash-lang-language (get-text 0 pos)) (set! hash-lang-last-location pos) (clear-things-out) + (define info-proc + (if (vector? info-result) + (vector-ref info-result 0) + info-result)) + (define (ctc-on-info-proc-result ctc res) + (contract ctc + res + (if (vector? info-result) + 'hash-lang-racket + (get-lang-name pos)) + 'drracket/private/module-language-tools)) (when info-result (register-new-buttons - (contract (or/c #f (listof (list/c string? - (is-a?/c bitmap%) - (-> (is-a?/c drracket:unit:frame<%>) any)))) - ((if (vector? info-result) - (vector-ref info-result 0) - info-result) - 'drscheme:toolbar-buttons #f) - (if (vector? info-result) - 'hash-lang-racket - (get-lang-name pos)) - 'drracket/private/module-language-tools) - ((if (vector? info-result) - (vector-ref info-result 0) - info-result) - 'drscheme:opt-out-toolbar-buttons '()))))))) + (ctc-on-info-proc-result (or/c #f (listof (list/c string? + (is-a?/c bitmap%) + (-> (is-a?/c drracket:unit:frame<%>) any)))) + (or (info-proc 'drracket:toolbar-buttons #f) + (info-proc 'drscheme:toolbar-buttons #f))) + (ctc-on-info-proc-result (or/c #f (listof symbol?)) + (or (info-proc 'drracket:opt-out-toolbar-buttons '()) + (info-proc 'drscheme:opt-out-toolbar-buttons '()))))))))) (inherit get-tab) diff --git a/collects/drracket/tool-lib.rkt b/collects/drracket/tool-lib.rkt index 5cb76d568d..500b058b77 100644 --- a/collects/drracket/tool-lib.rkt +++ b/collects/drracket/tool-lib.rkt @@ -27,7 +27,8 @@ all of the names in the tools library, for use defining keybindings (require (for-syntax racket/base)) (require/doc drracket/private/ts ;; probably this also has to be an absolute require - racket/base scribble/manual) + racket/base scribble/manual + scribblings/tools/doc-util) (require/doc (for-label errortrace/errortrace-key racket/pretty @@ -94,12 +95,14 @@ all of the names in the tools library, for use defining keybindings These buttons are ``opt out'', meaning that if the language doesn't explicitly ask to not have this button (or all such buttons), the button will appear. - See @racket[read-language] for more details on how language's specify how to opt out. - DrRacket will invoke the @tt{get-info} proc from @racket[read-language] with - @indexed-racket['drscheme:opt-out-toolbar-buttons]. If the result is a list of symbols, the - listed symbols are opted out. If the result is @racket[#f], all buttons are opted - out. The default is the empty list, meaning that all opt-out buttons appear. - }) + @language-info-def[drracket:opt-out-toolbar-buttons]{ + See @racket[read-language] for more details on how a language can opt out. + DrRacket will invoke the @tt{get-info} proc from @racket[read-language] with + @racket['drracket:opt-out-toolbar-buttons] + (and @indexed-racket['drscheme:opt-out-toolbar-buttons] for backwards compatibility). + If the result is a list of symbols, the + listed symbols are opted out. If the result is @racket[#f], all buttons are opted + out. The default is the empty list, meaning that all opt-out buttons appear.}}) (proc-doc/names drracket:module-language-tools:add-online-expansion-handler diff --git a/collects/scribblings/framework/color.scrbl b/collects/scribblings/framework/color.scrbl index cfc1ef6e50..646e96c994 100644 --- a/collects/scribblings/framework/color.scrbl +++ b/collects/scribblings/framework/color.scrbl @@ -201,7 +201,7 @@ The @racket[position] is the place to put the parenthesis, and @racket[char] is the parenthesis to be added (e.g., that the user typed). If @racket[fixup?] is true, the right kind of closing parenthesis will be - chosen from the set previously passed to @racket[start-colorer]---but only + chosen from the set previously passed to @method[color:text<%> start-colorer]---but only if an inserted @racket[char] would be colored as a parenthesis (i.e., with the @racket['parenthesis] classification). Otherwise, @racket[char] will be inserted, even if it is not the right kind. If @racket[flash?] is true, diff --git a/collects/scribblings/guide/hash-languages.scrbl b/collects/scribblings/guide/hash-languages.scrbl index 2b27b58b0c..4cf5b57aee 100644 --- a/collects/scribblings/guide/hash-languages.scrbl +++ b/collects/scribblings/guide/hash-languages.scrbl @@ -357,7 +357,7 @@ response to a @racket['color-lexer] query. The set of symbols that a programming tool uses for queries is entirely between the tool and the languages that choose to cooperate with it. For example, in addition to @racket['color-lexer], -DrRacket uses a @racket['drscheme:toolbar-buttons] query to determine +DrRacket uses a @racket['drracket:toolbar-buttons] query to determine which buttons should be available in the toolbar to operate on modules using the language. diff --git a/collects/scribblings/tools/common.rkt b/collects/scribblings/tools/common.rkt index 137c1cab40..c5f1cf6fc2 100644 --- a/collects/scribblings/tools/common.rkt +++ b/collects/scribblings/tools/common.rkt @@ -5,12 +5,14 @@ scribble/basic scribble/extract racket/class - racket/contract) -(provide (all-from-out scribble/manual) - (all-from-out scribble/basic) - (all-from-out scribble/extract) - (all-from-out racket/class) - (all-from-out racket/contract)) + racket/contract + "doc-util.rkt") +(provide (all-from-out scribble/manual + scribble/basic + scribble/extract + racket/class + racket/contract + "doc-util.rkt")) (require (for-label racket/gui/base racket/snip @@ -30,8 +32,10 @@ (all-from-out framework))) (provide tools-title tools-include tools-include/drs) + (define (tools-title name) - (title (tt (format "drracket:~a" name)))) + (define str (format "drracket:~a" name)) + (title #:tag str (tt str))) (define-syntax (tools-include stx) (syntax-case stx () diff --git a/collects/scribblings/tools/module-language-tools.scrbl b/collects/scribblings/tools/module-language-tools.scrbl index f86fb289b1..f830e7de15 100644 --- a/collects/scribblings/tools/module-language-tools.scrbl +++ b/collects/scribblings/tools/module-language-tools.scrbl @@ -1,20 +1,29 @@ #lang scribble/doc @(require "common.rkt") -@(tools-title "module-language-tools") +@tools-title["module-language-tools"] +@language-info-def[drracket:toolbar-buttons]{ If the result of @racket[read-language] for a language is a function, DrRacket will query it to determine if there are any new toolbar buttons to be used when editing files in this language (when DrRacket's language is set to the Module language). +} -Specifically, DrRacket will pass @indexed-racket['drscheme:toolbar-buttons] +Specifically, DrRacket will pass @indexed-racket['drracket:toolbar-buttons] to the function and expect back a value matching this contract: -@racketblock[(listof (list/c string? - (is-a?/c bitmap%) - (-> (is-a?/c drracket:unit:frame<%>) any)))] +@racketblock[(or/c (listof (list/c string? + (is-a?/c bitmap%) + (-> (is-a?/c drracket:unit:frame<%>) any))) + #f)] which is then used to create new toolbar buttons, one for each list in the -first. The string is the label on the button; the bitmap is the icon (it should be 16x16), -and the function is called when the button is clicked. +first. The string is the label on the button; the bitmap is the icon +(it should be 16x16), and the function is called when the button is clicked. +If the result is @racket[#f], then no toolbar buttons are created. + +If @racket['drracket:toolbar-buttons] is not recognized, DrRacket will also +pass @indexed-racket['drscheme:toolbar-buttons]; this is for backwards +compatibility and new code should not use it. + @(tools-include "module-language-tools") diff --git a/collects/scribblings/tools/tools.scrbl b/collects/scribblings/tools/tools.scrbl index ab54990d95..0146f22a35 100644 --- a/collects/scribblings/tools/tools.scrbl +++ b/collects/scribblings/tools/tools.scrbl @@ -17,8 +17,7 @@ (define (FileFirst x) @tt[x]) ;; indexing missing (define-syntax-rule (item/cap x . ys) - (item (indexed-racket x) ": " . ys))) ;; indexing missing - + (item (indexed-racket x) ": " . ys))) @title{Extending DrRacket} @@ -259,11 +258,39 @@ text ``egg''. If so, it adds ``easter '' just before. @section[#:tag "adding-languages"]{Adding Languages to DrRacket} @index{adding languages to DrRacket} -@subsection{Adding Module-based Languages to DrRacket} +@subsection{@tt{#lang}-based Langauges in DrRacket} + If a language can be implemented as a module (see @racket[module] for details), then the simplest and best way to use the language is via the ``Use the language declared the in source'' checkbox in the @onscreen{Language} dialog. +In this case, DrRacket's appearance can still be customized to +the language; it uses @racket[read-language] with these arguments +as the @racket[_key] argument to the @racket[_get-info] function to do so: + +@itemize[@item{@language-info-ref[drracket:toolbar-buttons]} + @item{@language-info-ref[drracket:opt-out-toolbar-buttons]} + @item{@language-info-ref[color-lexer]}] + +@language-info-def[color-lexer]{ + When a language's @racket[_get-info] procedure responds to @racket['color-lexer], it + is expected to return a procedure suitable to pass as the @racket[_get-token] + argument to @method[color:text<%> start-colorer]. +} + +The recognized token styles (specified implicitly via @method[color:text<%> start-colorer]'s +@racket[_token-sym->style] argument) are: +@itemize[@item{@indexed-racket['symbol]} + @item{@indexed-racket['keyword]} + @item{@indexed-racket['comment]} + @item{@indexed-racket['string]} + @item{@indexed-racket['constant]} + @item{@indexed-racket['parenthesis]} + @item{@indexed-racket['error]} + @item{@indexed-racket['other]}] +These precise colors for these identifiers are controlled by the preferences dialog in DrRacket. + +@subsection{Adding Module-based Languages to DrRacket} For backwards compatibility, DrRacket also supports and @@ -539,7 +566,7 @@ uses Racket mode. @section{Language-specific capabilities} -@subsection{Customizing DrRacket's behavior} +@subsection[#:tag "drracket:lang-languages-customization"]{Customizing DrRacket's behavior} When using the language declared in the source, DrRacket queries that language via @racket[module-compiled-language-info] to determine