Index: trunk/extensions/Narayam/ext.narayam.rules.ta99.js |
— | — | @@ -186,5 +186,6 @@ |
187 | 187 | 'namemsg': 'narayam-ta99', |
188 | 188 | 'extended_keyboard': false, |
189 | 189 | 'lookbackLength': 1, |
| 190 | + 'keyBufferLength': 1, |
190 | 191 | 'rules': rules |
191 | 192 | } ); |
Index: trunk/extensions/Narayam/ext.narayam.rules.bn-inscript.js |
— | — | @@ -121,6 +121,7 @@ |
122 | 122 | 'namemsg': 'narayam-bn-inscript', |
123 | 123 | 'extended_keyboard': true, |
124 | 124 | 'lookbackLength': 0, |
| 125 | + 'keyBufferLength': 0, |
125 | 126 | 'rules': rules, |
126 | 127 | 'rules_x': rules_x |
127 | 128 | } ); |
Index: trunk/extensions/Narayam/ext.narayam.rules.hi-inscript.js |
— | — | @@ -118,6 +118,7 @@ |
119 | 119 | 'namemsg': 'narayam-hi-inscript', |
120 | 120 | 'extended_keyboard': true, |
121 | 121 | 'lookbackLength': 0, |
| 122 | + 'keyBufferLength': 0, |
122 | 123 | 'rules': rules, |
123 | 124 | 'rules_x': rules_x |
124 | 125 | } ); |
\ No newline at end of file |
Index: trunk/extensions/Narayam/ext.narayam.rules.sa-inscript.js |
— | — | @@ -110,6 +110,7 @@ |
111 | 111 | 'namemsg': 'narayam-sa-inscript', |
112 | 112 | 'extended_keyboard': true, |
113 | 113 | 'lookbackLength': 0, |
| 114 | + 'keyBufferLength': 0, |
114 | 115 | 'rules': rules, |
115 | 116 | 'rules_x': rules_x |
116 | 117 | } ); |
\ No newline at end of file |
Index: trunk/extensions/Narayam/ext.narayam.core.js |
— | — | @@ -42,21 +42,21 @@ |
43 | 43 | /** |
44 | 44 | * Transliterate a string using the current scheme |
45 | 45 | * @param str String to transliterate |
46 | | - * @param lookback The lookback buffer |
| 46 | + * @param keyBuffer The key buffer |
47 | 47 | * @param useExtended Whether to use the extended part of the scheme |
48 | 48 | * @return Transliterated string, or str if no applicable transliteration found. |
49 | 49 | */ |
50 | | - function transliterate( str, lookback, useExtended ) { |
| 50 | + function transliterate( str, keyBuffer, useExtended ) { |
51 | 51 | var rules = currentScheme.extended_keyboard && useExtended ? |
52 | 52 | currentScheme.rules_x : currentScheme.rules; |
53 | 53 | for ( var i = 0; i < rules.length; i++ ) { |
54 | | - var lookbackMatch = true; |
55 | | - if ( rules[i][1].length > 0 && rules[i][1].length <= lookback.length ) { |
56 | | - // Try to match rules[i][1] at the end of the lookback buffer |
57 | | - lookbackMatch = new RegExp( rules[i][1] + '$' ).test( lookback ); |
| 54 | + var keyBufferMatch = true; |
| 55 | + if ( rules[i][1].length > 0 && rules[i][1].length <= keyBuffer.length ) { |
| 56 | + // Try to match rules[i][1] at the end of the key buffer |
| 57 | + keyBufferMatch = new RegExp( rules[i][1] + '$' ).test( keyBuffer ); |
58 | 58 | } |
59 | 59 | var regex = new RegExp( rules[i][0] + '$' ); |
60 | | - if ( lookbackMatch && regex.test( str ) ) { |
| 60 | + if ( keyBufferMatch && regex.test( str ) ) { |
61 | 61 | return str.replace( regex, rules[i][2] ); |
62 | 62 | } |
63 | 63 | } |
— | — | @@ -142,8 +142,8 @@ |
143 | 143 | } |
144 | 144 | |
145 | 145 | if ( e.which == 8 ) { // Backspace |
146 | | - // Blank the lookback buffer |
147 | | - $( this ).data( 'narayam-lookback', '' ); |
| 146 | + // Blank the keybuffer |
| 147 | + $( this ).data( 'narayam-keyBuffer', '' ); |
148 | 148 | return true; |
149 | 149 | } |
150 | 150 | |
— | — | @@ -166,16 +166,16 @@ |
167 | 167 | // to provide context for the transliteration regexes. |
168 | 168 | // We need to append c because it hasn't been added to $this.val() yet |
169 | 169 | var input = lastNChars( $this.val(), startPos, currentScheme.lookbackLength ) + c; |
170 | | - var lookback = $this.data( 'narayam-lookback' ); |
171 | | - var replacement = transliterate( input, lookback, e.altKey ); |
| 170 | + var keyBuffer = $this.data( 'narayam-keyBuffer' ); |
| 171 | + var replacement = transliterate( input, keyBuffer, e.altKey ); |
172 | 172 | |
173 | | - // Update the lookback buffer |
174 | | - lookback += c; |
175 | | - if ( lookback.length > currentScheme.lookbackLength ) { |
| 173 | + // Update the key buffer |
| 174 | + keyBuffer += c; |
| 175 | + if ( keyBuffer.length > currentScheme.keyBufferLength ) { |
176 | 176 | // The buffer is longer than needed, truncate it at the front |
177 | | - lookback = lookback.substring( lookback.length - currentScheme.lookbackLength ); |
| 177 | + keyBuffer = keyBuffer.substring( keyBuffer.length - currentScheme.keyBufferLength ); |
178 | 178 | } |
179 | | - $this.data( 'narayam-lookback', lookback ); |
| 179 | + $this.data( 'narayam-keyBuffer', keyBuffer ); |
180 | 180 | |
181 | 181 | // textSelection() magic is expensive, so we avoid it as much as we can |
182 | 182 | if ( replacement == input ) { |
— | — | @@ -221,7 +221,7 @@ |
222 | 222 | $newInputs |
223 | 223 | .bind( 'keydown.narayam', onkeydown ) |
224 | 224 | .bind( 'keypress.narayam', onkeypress ) |
225 | | - .data( 'narayam-lookback', '' ); |
| 225 | + .data( 'narayam-keyBuffer', '' ); |
226 | 226 | if ( enabled ) { |
227 | 227 | $newInputs.addClass( 'narayam-input' ); |
228 | 228 | } |
Index: trunk/extensions/Narayam/ext.narayam.rules.kn-inscript.js |
— | — | @@ -110,6 +110,7 @@ |
111 | 111 | 'namemsg': 'narayam-kn-inscript', |
112 | 112 | 'extended_keyboard': true, |
113 | 113 | 'lookbackLength': 0, |
| 114 | + 'keyBufferLength': 0, |
114 | 115 | 'rules': rules, |
115 | 116 | 'rules_x': rules_x |
116 | 117 | } ); |
\ No newline at end of file |
Index: trunk/extensions/Narayam/ext.narayam.rules.ml-inscript.js |
— | — | @@ -78,5 +78,6 @@ |
79 | 79 | 'namemsg': 'narayam-ml-inscript', |
80 | 80 | 'extended_keyboard': false, |
81 | 81 | 'lookbackLength': 0, |
| 82 | + 'keyBufferLength': 0, |
82 | 83 | 'rules': rules |
83 | 84 | } ); |
Index: trunk/extensions/Narayam/ext.narayam.rules.sa.js |
— | — | @@ -158,6 +158,7 @@ |
159 | 159 | jQuery.narayam.addScheme( 'sa', { |
160 | 160 | 'namemsg': 'narayam-sa', |
161 | 161 | 'extended_keyboard': false, |
162 | | - 'lookbackLength': 2, |
| 162 | + 'lookbackLength': 4, |
| 163 | + 'keyBufferLength': 1, |
163 | 164 | 'rules': rules |
164 | 165 | } ); |
Index: trunk/extensions/Narayam/ext.narayam.rules.ta.js |
— | — | @@ -105,6 +105,7 @@ |
106 | 106 | jQuery.narayam.addScheme( 'ta', { |
107 | 107 | 'namemsg': 'narayam-ta', |
108 | 108 | 'extended_keyboard': false, |
109 | | - 'lookbackLength': 1, |
| 109 | + 'lookbackLength': 4, |
| 110 | + 'keyBufferLength': 1, |
110 | 111 | 'rules': rules |
111 | 112 | } ); |
Index: trunk/extensions/Narayam/ext.narayam.rules.bn-avro.js |
— | — | @@ -191,6 +191,7 @@ |
192 | 192 | jQuery.narayam.addScheme( 'bn-avro', { |
193 | 193 | 'namemsg': 'narayam-bn-avro', |
194 | 194 | 'extended_keyboard': false, |
195 | | - 'lookbackLength': 5, |
| 195 | + 'lookbackLength': 3, |
| 196 | + 'keyBufferLength': 5, |
196 | 197 | 'rules': rules |
197 | 198 | } ); |
Index: trunk/extensions/Narayam/ext.narayam.rules.bn-nkb.js |
— | — | @@ -132,6 +132,7 @@ |
133 | 133 | 'namemsg': 'narayam-bn-nkb', |
134 | 134 | 'extended_keyboard': true, |
135 | 135 | 'lookbackLength': 0, |
| 136 | + 'keyBufferLength': 0, |
136 | 137 | 'rules': rules, |
137 | 138 | 'rules_x': rules_x |
138 | 139 | } ); |
Index: trunk/extensions/Narayam/ext.narayam.rules.kn.js |
— | — | @@ -144,5 +144,6 @@ |
145 | 145 | 'namemsg': 'narayam-kn', |
146 | 146 | 'extended_keyboard': false, |
147 | 147 | 'lookbackLength': 3, |
| 148 | + 'keyBufferLength': 1, |
148 | 149 | 'rules': rules |
149 | 150 | } ); |
\ No newline at end of file |
Index: trunk/extensions/Narayam/ext.narayam.rules.ml.js |
— | — | @@ -330,6 +330,7 @@ |
331 | 331 | jQuery.narayam.addScheme( 'ml', { |
332 | 332 | 'namemsg': 'narayam-ml', |
333 | 333 | 'extended_keyboard': false, |
334 | | - 'lookbackLength': 4, |
| 334 | + 'lookbackLength': 6, |
| 335 | + 'keyBufferLength': 2, |
335 | 336 | 'rules': rules |
336 | 337 | } ); |