Note: build.sh updated to make sure that test:help build action:target doesn't also call test.sh by adding `:_all` meta-target. Note: CI will need a new help-keyman-com.sh build step to deploy web engine help. Fixes: #12347
3.6 KiB
| title |
|---|
| 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 adeadkeyentry.d:number: The integer ID of the deadkey to match. -
An
AnyEntryobject with the following members:t:'a': Indicates the use of ananystatement.a:string: The store string to be searched for a context matchn:booleanoptional :truesignals to negate the match, as with anotanystatement. -
An
IndexEntryobject with the following members:t:'i': Indicates the use of anindexstatement.i:string: the store string to be indexed for output corresponding to a previousanyo:number: the index of the correspondinganyin the rule's context, starting from 1. -
A
ContextExobject with the following members:t:'c': Indicates the use of acontextstatement.c:number: 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-basednulrule.
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)'
});