|
VirtualKeyboard.Langs.CN = new function () {
var self = this;
self.INPArr = [];
/**
* Callback to process keyboard input in the current IME style
*
* @see VirtualKeyboard.processChar
* @param {String} chr current input char
* @param {String} buf actual processing buffer
* @return {Array} new buffer contents and length
* @scope protected
*/
self.processChar = function (chr, buf) {
var num, str, arr
if (chr=='\u0008') { // backspace
if (buf && (str=buf.slice(0,-1))) {
VirtualKeyboard.IME.show(self.INPArr[str.toLowerCase()] || []);
return [str,str.length]
} else {
VirtualKeyboard.IME.hide()
return ['',0] //total delete; some other cases
}
} else { //non backspace
str=buf+chr
arr = self.INPArr[str.toLowerCase()] || []
if (arr.length) { // miao
VirtualKeyboard.IME.show((typeof arr =='string')? self.INPArr[str.toLowerCase()]=arr.split('') : arr)
return [str, str.length]
} else if(VirtualKeyboard.IME.getSuggestions().length) { // not a part of a syllable
if (isFinite(num=parseInt(chr))) { // miao3
str = VirtualKeyboard.IME.getChar(num);
if (!str) { //miao9 - no such variant
return[buf,buf.length]
} else {
VirtualKeyboard.IME.hide();
return[str,0]
}
} else if ((arr = self.INPArr[chr.toLowerCase()] || []).length) { //nih
str=VirtualKeyboard.IME.getSuggestions()[0]
VirtualKeyboard.IME.setSuggestions((typeof arr =='string')? self.INPArr[str.toLowerCase()]=arr.split('') : arr)
return [str+chr,1]
} else { // ni,
str=VirtualKeyboard.IME.getSuggestions()[0]
VirtualKeyboard.IME.hide()
return [str+(chr.charCodeAt()==10? '': chr),0]
}
}
}
return [buf+chr,0] //non-chinese talk
}
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.