|
WikiDoc |
The [regPrefixChar] command
IntroductionThe [regPrefixChar] command lets you define composite bindings
involving an infix. For instance, the Embrace package implements
complex bindings like The new [regPrefixChar] command lets you specify a regular expression defining the permitted values for the infix. SynopsisThe syntax of the [regPrefixChar] command is
regPrefixChar -regexp expr ?-prompt str?
The arguments have the following meaning:
[0-5abc]
Concerning the infix, the following rules apply: in the case digits are allowed by the regular expression, it is possible to enter several digits in a row, that is to say to compose numbers, before the key combo. Otherwise the infix is a single character. For instance, in the example above, the infix could be either a number composed of digits between 0 and 5 (like 1, 20, 54321, etc.) or one of the letters a, b, or c. HowtoHere is an example to demonstrate how the command works. Say we want to define a complex binding like
ctrl-B infix S
where infix is iether a number or the letter r. Note that this example makes use of the new [binding] command introduced in version 8.2a1d1 of AlphaX. See the BindingCommand page for more details about it. The action triggered by the combo is a Tcl proc or a Tcl script. The composite binding is defined with the [binding] command and takes the Tcl script as its last argument. For instance:
binding create -prefix {z 'B'} {"" 'S'} {embrace::toggle "\[" "\]"}]
The
binding create {z 'B'} {regPrefixChar -regex {[0-9r]}}
The regular expression Now, when the user presses
embrace::toggle "\[" "\]" 15
with the result that the 15 preceding words will be enclosed in a pair of brackets. If the user did not enter any number or character recognized as an infix and pressed ctrl-B S directly then the argument appended to the proc would be empty. (add your comments here...) |
|
Edit -
History -
Print -
Recent Changes -
Search
Page last modified on September 30, 2009, at 09:04 AM
|
Hosted on
|