added a capability to enable language-specific customization of the indenter

svn: r10604
This commit is contained in:
Robby Findler 2008-07-04 21:22:39 +00:00
parent 4993e26b0a
commit f4e0398c1e
3 changed files with 44 additions and 10 deletions

View File

@ -288,6 +288,9 @@
(install-help-browser-preference-panel)
(drscheme:tools:add-prefs-panel)
(drscheme:language:register-capability 'drscheme:tabify-menu-callback
(or/c false/c (-> (is-a?/c text%) number? number? void?))
(λ (t a b) (send t tabify-selection a b)))
(drscheme:language:register-capability 'drscheme:autocomplete-words (listof string?) '())
(drscheme:language:register-capability 'drscheme:define-popup
(or/c (cons/c string? string?) false/c)

View File

@ -3159,15 +3159,38 @@ module browser threading seems wrong.
scheme-menu
(λ (x y) (drscheme:module-overview:module-overview this)))
(make-object separator-menu-item% scheme-menu)
(make-object menu:can-restore-menu-item%
(string-constant reindent-menu-item-label)
scheme-menu
(send-method (λ (x) (send x tabify-selection))))
(make-object menu:can-restore-menu-item%
(string-constant reindent-all-menu-item-label)
scheme-menu
(send-method (λ (x) (send x tabify-all)))
#\i)
(let ([cap-val
(λ ()
(let* ([tab (get-current-tab)]
[defs (send tab get-defs)]
[settings (send defs get-next-settings)]
[language (drscheme:language-configuration:language-settings-language settings)])
(send language capability-value 'drscheme:tabify-menu-callback)))])
(new menu:can-restore-menu-item%
[label (string-constant reindent-menu-item-label)]
[parent scheme-menu]
[demand-callback (λ (m) (send m enable (cap-val)))]
[callback (send-method
(λ (x)
(let ([f (cap-val)])
(when f
(f x
(send x get-start-position)
(send x get-end-position))))))])
(new menu:can-restore-menu-item%
[label (string-constant reindent-all-menu-item-label)]
[parent scheme-menu]
[callback
(send-method
(λ (x)
(let ([f (cap-val)])
(when f
(f x 0 (send x last-position))))))]
[shortcut #\i]
[demand-callback (λ (m) (send m enable (cap-val)))]))
(make-object menu:can-restore-menu-item%
(string-constant box-comment-out-menu-item-label)
scheme-menu

View File

@ -981,7 +981,10 @@ all of the names in the tools library, for use defining keybindings
@itemize{
@item{ @scheme[(drscheme:language:register-capability 'drscheme:check-syntax-button (flat-contract boolean?) #t)]
--- controls the visiblity of the check syntax button
}@item{ @scheme[(drscheme:language:register-capability 'drscheme:language-menu-title (flat-contract string?) (string-constant scheme-menu-name))]
}@item{ @schemeblock[(drscheme:language:register-capability
'drscheme:language-menu-title
(flat-contract string?)
(string-constant scheme-menu-name))]
--- controls the name of the menu just to the right of the language menu (defaultly named ``Scheme'')
}@item{ @scheme[(drscheme:language:register-capability 'drscheme:define-popup (or/c (cons/c string? string?) false/c) (cons "(define" "(define ...)"))]
--- specifies the prefix that the define popup should look for and what label it should have,
@ -1006,6 +1009,11 @@ all of the names in the tools library, for use defining keybindings
--- determines if the insert scheme box, insert scheme splice box, and the insert xml box menu item ins the special menu are visible
}@item{ @scheme[(drscheme:language:register-capability 'drscheme:autocomplete-words (listof string?) '())]
--- determines the list of words that are used when completing words in this language
}@item{ @schemeblock[(drscheme:language:register-capability
'drscheme:tabify-menu-callback
(or/c false/c (-> (is-a?/c text%) number? number? void?))
(λ (t a b) (send t tabify-selection a b)))]
--- is used as the callback when the ``Reindent'' or ``Reindent All'' menu is selected. The first argument is the editor, and the second and third are a range in the editor.
}}})
(proc-doc/names