fullContextMatch (KFCM)
Summary
Context matching: Returns true if the current context matches the specified rule context specification.
Syntax
keyman.interface.fullContextMatch(n, Pelem, rule);
or
KeymanWeb.KFCM(n, Pelem, rule); // Shorthand
Parameters
n- Type:
number - Relative position of the caret for the context match attempt.
Pelem- Type:
Element - The element being operated upon.
rule- Type:
Array(ContextEntry) - The rule context specification to be matched.
Return Value
booleantrueif the context matches the rule specificationrule, otherwisefalse.
Rule specification
Each ContextEntry in the rule array must be one of the following six types:
-
A plain string with one character
-
A
DeadkeyEntryobject with the following members:t'd'- Indicates to expect a
deadkeyentry. dnumber- The integer ID of the deadkey to match.
-
An
AnyEntryobject with the following members: -
An
IndexEntryobject with the following members:t'i'- Indicates the use of an
indexstatement. istring- the store string to be indexed for output corresponding to a previous
any onumber- the index of the corresponding
anyin the rule's context, starting from 1.
-
A
ContextExobject with the following members:t'c'- Indicates the use of a
contextstatement. cnumber- The position in context to be matched by the current context location.
-
A
NulEntryobject with the following member:t'n'- Indicates the use of a context-based
nulrule.
The rule will be interpreted left to right, starting at the specified relative position to the caret.
Description
This is a core element of keyboard input management within KeymanWeb introduced with version 10.0, typically called automatically during keystroke processing events. For comparison with Developer 'rules' from keyboard source code...
store(pair_1) 'aA'
store(pair_2) 'bB'
c Lots of keyboard rules...
dk(money) 'c' any(pair_1) index(pair_2, 3) + '.' > 'taxi'
would have Javascript roughly as follows:
// In the keyboard store definitions:
this.s_pair_1 = 'aA'; // store(pair_1) 'aA'
this.s_pair_2 = 'bB'; // store(pair_2) 'bB'
// For the deadkey:
this.d_money = 0; // dk(money)'s internal id
// Within the keyboard rule-matching function:
var matched = keyman.interface.fullContextMatch(4, element, {
{t:'d', d:this.d_money}, // dk(money)
'c', // 'c'
{t:'a', a:this.s_pair_1}, // 'any(pair_1)'
{t:'i', i:this.s_pair_2, o:3} // 'index(pair_2, 3)'
});


