Recent Changes - Search:

WikiDoc

Categories

The [regPrefixChar] command

Commands.RegPrefixCharCommand History

Hide minor edits - Show changes to markup

September 30, 2009, at 09:04 AM by bd - Removed experimental
Changed line 2 from:
This file documents the new [regPrefixChar] command as of version 8.2a1d5 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.
to:
This file documents the new [regPrefixChar] command as of version 8.2a1d5 of AlphaX.
June 10, 2008, at 01:59 PM by bd - Typo
Changed lines 23-26 from:
  • the -regexp argument is required. It specifies, by the means of a regular expression expr, the values among which the infix can be chosen. For instance, if we wanted to allow any digit between 0 and 5 and the letters a, b, c, the value of the option would be ((| [0-5abc] |))
to:
  • the -regexp argument is required. It specifies, by the means of a regular expression expr, the values among which the infix can be chosen. For instance, if we wanted to allow any digit between 0 and 5 and the letters a, b, c, the value of the option would be
 
[0-5abc]

April 28, 2007, at 03:11 PM by bd - Added sentence about empty infix
Deleted line 0:
Added lines 72-75:

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.

April 26, 2007, at 06:25 AM by bd - numPrefixChar becomes regPrefixChar
Changed lines 1-22 from:

(:title The [numPrefixChar] command:)

This file documents the new [numPrefixChar] command as of version 8.2a1d5 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.

The [numPrefixChar] command lets you define composite bindings which expect a number to be entered before an action is triggered. For instance, the Embrace package implements complex bindings involving an infix, like ctrl-B 3 S. Such a binding means that the user has to press the ctrl-B key combo, then press 3 and then press S. The result is that the 3 preceding words are enclosed in a pair of square brackets.

Until now, in order to obtain such a behavior, one had to implement a series of bindings involving the [prefixChar] command. This technique allows only for a limited set of values for the number (currently the Embrace package installs bindings for values 1 to 5).

The new [numPrefixChar] command simplifies the definition of bindings with an infix number and removes the limitation: it is now possible to enter any value for the infix number.

Here is an example to demonstrate how it works. Say we want to define a complex binding like

to:

(:title The [regPrefixChar] command:)

This file documents the new [regPrefixChar] command as of version 8.2a1d5 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.

Introduction

The [regPrefixChar] command lets you define composite bindings involving an infix. For instance, the Embrace package implements complex bindings like ctrl-B 3 S: here B is the prefix, 3 is the infix and S is the suffix (or key combo). Such a binding means that the user has to press the ctrl-B key combo, then press 3 and then press S. The result of this action, as implemented by the the Embrace package, is that the 3 preceding words are enclosed in a pair of square brackets.

The new [regPrefixChar] command lets you specify a regular expression defining the permitted values for the infix.

Synopsis

The syntax of the [regPrefixChar] command is

Changed line 21 from:
     ctrl-B num S
to:
     regPrefixChar -regexp expr ?-prompt str?
Changed lines 23-24 from:

where num is any integer value. This example makes use of the new [binding] command also introduced

to:

The arguments have the following meaning:

  • the -regexp argument is required. It specifies, by the means of a regular expression expr, the values among which the infix can be chosen. For instance, if we wanted to allow any digit between 0 and 5 and the letters a, b, c, the value of the option would be ((| [0-5abc] |))
  • the -prompt argument is optional. It specifies the text of the prompt string written in the status bar as a label for the input field. If it is not specified, the prefix combo (for instance ctrl-B in the preceding example) is used as a default.

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.

Howto

Here 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

Changed lines 45-46 from:

for more details about this command.

to:

for more details about it.

Changed lines 53-54 from:

The simple ctrl-B combo must be bound to the new [numPrefixChar] command instead of [prefixChar]:

to:

The ctrl-B prefix combo must be bound to the [regPrefixChar] command (instead of the simple [prefixChar] command used to create composite bindings without an infix):

Changed line 57 from:
     binding create {z 'B'} numPrefixChar
to:
     binding create {z 'B'} {regPrefixChar -regex {[0-9r]}}
Changed lines 59-64 from:

Now, when the user presses ctrl-B, AlphaX will be expecting a number (possibly several digits) and a non-digit keypress (the letter S in this example). As soon as the S is entered, AlphaX invokes the proc associated with the action after appending the entered value to the list of arguments. For instance, if the user entered ctrl-B 15 S, the proc would be invoked as

to:

The regular expression [0-9r] specifies that the infix can be either a number or the letter r. It could also be written as (\d|r).

Now, when the user presses ctrl-B, AlphaX will be expecting the infix followed by the key combo (the letter S in this example). As soon as the S is entered, AlphaX invokes the proc associated with the binding after appending the infix to the list of arguments. For instance, if the user entered ctrl-B 15 S, the proc would be invoked as

Changed lines 71-79 from:

If the user did not enter any number and pressed ctrl-B S directly then no additional argument would be appended to the proc. This implies that the proc's last argument, representing the infix, be of type default (argument with a default value). For instance

 
     proc fooActionProc {arg1 arg2 ... {infix ""} } {
         # definition
     }

to:

with the result that the 15 preceding words will be enclosed in a pair of brackets.

Changed lines 74-75 from:

(add your comments here...)


to:

(add your comments here...)

April 24, 2007, at 02:00 PM by bd - Updated doc ([action] command removed)
Deleted line 0:
Changed line 40 from:
     binding create {z 'B'} prefixChar
to:
     binding create {z 'B'} numPrefixChar
April 24, 2007, at 01:59 PM by bd - Updated doc ([action] command removed)
Changed lines 3-4 from:
This file documents the new [numPrefixChar] command introduced in version 8.2a1d1 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.
to:
This file documents the new [numPrefixChar] command as of version 8.2a1d5 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.
Changed lines 28-34 from:

This example makes use of the new [binding] command also introduced in version 8.2a1d1 of AlphaX. See the BindingCommand page for more details about this command.

The action triggered by the combo must be defined with the [action] command. For instance:

to:

This example makes use of the new [binding] command also introduced in version 8.2a1d1 of AlphaX. See the BindingCommand page for more details about this command.

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:

Changed line 36 from:
     set theAction [action create -script {embrace::toggle "\[" "\]"}]
to:
     binding create -prefix {z 'B'} {"" 'S'} {embrace::toggle "\[" "\]"}]
Changed lines 38-39 from:

The composite binding is defined with the [binding] command and takes the action token as its last argument:

to:

The simple ctrl-B combo must be bound to the new [numPrefixChar] command instead of [prefixChar]:

Changed line 41 from:
     binding create -prefix {z 'B'} {"" 'S'} $theAction
to:
     binding create {z 'B'} prefixChar
Deleted lines 42-47:

The simple ctrl-B combo must be bound to the new [numPrefixChar] command instead of [prefixChar]:

 
     set countAction [action create -script "numPrefixChar"]
     binding create {z 'B'} $countAction

Changed lines 62-63 from:

(add your comments here...)

to:

(add your comments here...)


February 19, 2007, at 07:45 PM by bd - Renamed the command [numPrefixChar]
Changed lines 1-6 from:

(:title The [countedPrefixChar] command:)

This file documents the new [countedPrefixChar] command introduced in version 8.2a1d1 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.

The [countedPrefixChar] command lets you define composite bindings

to:

(:title The [numPrefixChar] command:)

This file documents the new [numPrefixChar] command introduced in version 8.2a1d1 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.

The [numPrefixChar] command lets you define composite bindings

Changed line 17 from:

The new [countedPrefixChar] command simplifies the definition

to:

The new [numPrefixChar] command simplifies the definition

Changed lines 27-31 from:

This example makes use of the new [action] and [binding] commands also introduced in version 8.2a1d1 of AlphaX. See the ActionCommand and BindingCommand pages for more details about these commands.

to:

This example makes use of the new [binding] command also introduced in version 8.2a1d1 of AlphaX. See the BindingCommand page for more details about this command.

Changed line 42 from:

The simple ctrl-B combo must be bound to the new [countedPrefixChar] command

to:

The simple ctrl-B combo must be bound to the new [numPrefixChar] command

Changed line 45 from:
     set countAction [action create -script "countedPrefixChar"]
to:
     set countAction [action create -script "numPrefixChar"]
Changed lines 49-50 from:

(possibly several digits) and a non-digit keypress (the letter S in our example). As soon as S is

to:

(possibly several digits) and a non-digit keypress (the letter S in this example). As soon as the S is

Changed line 60 from:

type default (argument with a default value). For instance

to:

type default (argument with a default value). For instance

Changed line 67 from:

(add your comments here...)

to:

(add your comments here...)

February 08, 2007, at 09:55 AM by bd - Doc for new [countedPrefixChar] command (minor fixes)
Changed line 23 from:

Here is an example to demonstrate this works. Say we want to define a

to:

Here is an example to demonstrate how it works. Say we want to define a

Changed line 51 from:

(possibly several digits) and the letter S. As soon as the letter S is

to:

(possibly several digits) and a non-digit keypress (the letter S in our example). As soon as S is

Changed line 61 from:

type default. For instance

to:

type default (argument with a default value). For instance

February 08, 2007, at 09:12 AM by bd - Doc for new [countedPrefixChar] command
Added lines 4-5:

February 08, 2007, at 09:11 AM by bd - Doc for new [countedPrefixChar] command
Added lines 1-66:

(:title The [countedPrefixChar] command:)

This file documents the new [countedPrefixChar] command introduced in version 8.2a1d1 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.

The [countedPrefixChar] command lets you define composite bindings which expect a number to be entered before an action is triggered. For instance, the Embrace package implements complex bindings involving an infix, like ctrl-B 3 S. Such a binding means that the user has to press the ctrl-B key combo, then press 3 and then press S. The result is that the 3 preceding words are enclosed in a pair of square brackets.

Until now, in order to obtain such a behavior, one had to implement a series of bindings involving the [prefixChar] command. This technique allows only for a limited set of values for the number (currently the Embrace package installs bindings for values 1 to 5).

The new [countedPrefixChar] command simplifies the definition of bindings with an infix number and removes the limitation: it is now possible to enter any value for the infix number.

Here is an example to demonstrate this works. Say we want to define a complex binding like

 
     ctrl-B num S

where num is any integer value. This example makes use of the new [action] and [binding] commands also introduced in version 8.2a1d1 of AlphaX. See the ActionCommand and BindingCommand pages for more details about these commands.

The action triggered by the combo must be defined with the [action] command. For instance:

 
     set theAction [action create -script {embrace::toggle "\[" "\]"}]

The composite binding is defined with the [binding] command and takes the action token as its last argument:

 
     binding create -prefix {z 'B'} {"" 'S'} $theAction

The simple ctrl-B combo must be bound to the new [countedPrefixChar] command instead of [prefixChar]:

 
     set countAction [action create -script "countedPrefixChar"]
     binding create {z 'B'} $countAction

Now, when the user presses ctrl-B, AlphaX will be expecting a number (possibly several digits) and the letter S. As soon as the letter S is entered, AlphaX invokes the proc associated with the action after appending the entered value to the list of arguments. For instance, if the user entered ctrl-B 15 S, the proc would be invoked as

 
     embrace::toggle "\[" "\]" 15

If the user did not enter any number and pressed ctrl-B S directly then no additional argument would be appended to the proc. This implies that the proc's last argument, representing the infix, be of type default. For instance

 
     proc fooActionProc {arg1 arg2 ... {infix ""} } {
         # definition
     }


(add your comments here...)

Page last modified on September 30, 2009, at 09:04 AM
Hosted on SourceForge.net Logo