📄 syntax.js
字号:
} else { if ( prev < 128 ) { if (next < 128 ) { return String.fromCharCode ( prev, next ) ; } else { idx2 = getIndex ( next ) ; if ( beg_form[idx2] != 0 ) { code2 = getUniCode ( beg_form[idx2] ) ; } else { code2 = next ; } return String.fromCharCode ( prev, code2 ) ; } } else if ( next < 128 || next==getUniCode(U_COMMA) || next==getUniCode(U_QUESTION) ) { idx = getIndex ( prev ) ; if ( end_form[idx] != 0 ) { code = getUniCode ( end_form[idx] ) ; } else { code = prev ; } return String.fromCharCode ( code, next ) ; } idx = getIndex ( prev ) ; idx2 = getIndex ( next ) ; code = prev ; str2 = joint_special ( idx, idx2 ) ; if ( str2 != "" ) { return str2 ; } if ( beg_tab[idx] == WD_BEG ) { if ( beg_form[idx2] != 0 ) { code2 = getUniCode ( beg_form[idx2] ) ; } else { code2 = next ; } } else if ( beg_tab[idx] == IN_BEG ) { if ( in_beg_form[idx2] != 0 ) { code2 = getUniCode ( in_beg_form[idx2] ) ; } else { code2 = next ; } } else { if ( med_form[idx] != 0 ) { code = getUniCode( med_form[idx] ) ; } else { code = prev ; } if ( rev_med_form[idx2] != 0 ) { code2 = getUniCode ( rev_med_form[idx2] ) ; } else { code2 = next ; } } } return String.fromCharCode ( code, code2 ) ; } // a regular input key is pressed (non-backspace, non-delete) if ( prev == -1 ) { // nothing in front, inserting text at the beginning of text if ( next == -1 ) { // and nothing in back, the first character idx1 = map_index ( cur, -1 ) ; code = getUniCode ( idx1 ) ; if ( end_form[idx1] != 0 ) { code = getUniCode ( end_form[idx1] ) ; } str = String.fromCharCode ( code ) ; } else { // inserting at the beginning of the text if ( next < 128 || next==getUniCode(U_COMMA) || next==getUniCode(U_QUESTION) ) { str = getContextString ( -1, cur, -1 ) + String.fromCharCode(next) ; return str ; } idx1 = map_index ( cur, prev ) ; idx2 = getIndex ( next ) ; // next charcode index code1 = getUniCode ( idx1 ) ; if ( is_alien ( idx1 ) || is_wd_beginner(idx1) ) { if ( beg_form[idx2] != 0 ) { code2 = getUniCode ( beg_form[idx2] ) ; } else { code2 = next ; } } else if ( is_in_beginner ( idx1 ) ) { if ( in_beg_form[idx2] != 0 ) { code2 = getUniCode ( in_beg_form[idx2] ) ; } else { code2 = next ; } } else { str2 = joint_special ( idx1, idx2 ) ; if ( str2 != "" ) { return str2 ; } if ( rev_med_form[idx2] != 0 ) { // update the next letter if necessary code2 = getUniCode ( rev_med_form[idx2] ) ; } else { code2 = next ; } } str = String.fromCharCode ( code1, code2 ) ; } } else if ( next == -1 ) { // inserting text at the end of the text if ( prev < 128 ) { str = String.fromCharCode(prev) + getContextString ( -1, cur, -1 ) ; return str ; } idx = getIndex ( prev ) ; code = getUniCode ( map_index ( cur, idx ) ) ; // ucode for cur idx1 = getIndex ( code ) ; // current code index str2 = joint_special ( idx, idx1 ) ; if ( str2 != "" ) { return str2 ; } if ( is_alien (idx1) == true ) { // if cur is not regular char if ( end_form[ idx ] != 0 ) { // check for end form code1 = getUniCode ( end_form[idx] ) ; str = String.fromCharCode ( code1, getUniCode(idx1) ) ; } else { str = String.fromCharCode ( prev, code ) ; } } else { if ( med_form[idx] != 0 ) { // see if to use medial form code1 = getUniCode ( med_form[idx] ) ; } else { code1 = prev ; } if ( end_form[idx1] != 0 ) { code = getUniCode ( end_form[idx1] ) ; } str = String.fromCharCode ( code1, code ) ; } } else { // inserting a letter in the middle of the text idx = getIndex ( prev ) ; // previous charcode index code = getUniCode ( map_index ( cur, idx ) ) ; // ucode for cur idx1 = getIndex ( code ) ; // current code index idx2 = getIndex ( next ) ; // next charcode index /* if ( next == String("\r").charCodeAt(0) ) { str = getContextString ( prev, cur, -1 ) + String.fromCharCode(next) ; return str ; } */ if ( next < 128 || next==getUniCode(U_COMMA) || next==getUniCode(U_QUESTION) ) { if ( prev < 128 ) { str=String.fromCharCode(prev)+getContextString(-1,cur,-1)+String.fromCharCode(next); } else { str= getContextString(prev,cur, -1) + String.fromCharCode(next) ; } return str ; } if ( is_alien ( idx1 ) ) { if ( end_form[ idx ] != 0 ) { // check for end form code1 = getUniCode ( end_form[idx] ) ; str1 = String.fromCharCode ( code1, getUniCode(idx1) ) ; } else { str1 = String.fromCharCode ( prev, code ) ; } if ( beg_form[idx2] != 0 ) { str2 = String.fromCharCode ( getUniCode ( beg_form[idx2] ) ) ; } else { str2 = String.fromCharCode(next) ; } str = str1.concat ( str2 ) ; } else if ( is_wd_beginner ( idx1 ) ) { if ( beg_form[idx2] != 0 ) { str2 = String.fromCharCode ( getUniCode ( beg_form[idx2] ) ) ; } else { str2 = String.fromCharCode(next) ; } str1 = joint_special ( idx, idx1 ) ; if ( str1 != "" ) { return str1.concat ( str2 ) ; } if ( med_form[idx] != 0 ) { // see if to use medial form code1 = getUniCode ( med_form[idx] ) ; } else { code1 = prev ; } str1 = String.fromCharCode ( code1, code ) ; str = str1.concat ( str2 ) ; } else if ( is_in_beginner(idx1) ) { if ( in_beg_form[idx2] != 0 ) { str2 = String.fromCharCode ( getUniCode ( in_beg_form[idx2] ) ) ; } else { str2 = String.fromCharCode ( next ) ; } str1 = joint_special ( idx, idx1 ) ; if ( str1 != "" ) { return str1.concat ( str2 ) ; } if ( med_form[idx] != 0 ) { // see if to use medial form code1 = getUniCode ( med_form[idx] ) ; } else { code1 = prev ; } str1 = String.fromCharCode ( code1, code ) ; str = str1.concat ( str2 ) ; } else { if ( med_form[idx] != 0 ) { // see if to use medial form code1 = getUniCode ( med_form[idx] ) ; } else { code1 = prev ; } str2 = joint_special ( idx1, idx2 ) ; if ( str2 != "" ) { str1 = String.fromCharCode ( code1 ) ; return str1.concat ( str2 ) ; } if ( rev_med_form[idx2] != 0 ) { // update the next letter if necessary code2 = getUniCode ( rev_med_form[idx2] ) ; } else { code2 = getUniCode ( idx2 ) ; } str = String.fromCharCode ( code1, code, code2 ) ; } } return str ;};/* * joint_special ( idx1, idx2 ) -- return a single character string if idx1 and * idx2 forms a special joint letter such as LA, _LA, __AA, etc. */function joint_special ( idx1, idx2 ) { var i = -1 ; if ( idx1 == LEE || idx1 == LEE_ ) { // for LA if ( idx2 == AA || idx2 == _AA || idx2 == _AA_ || idx2 == __AA ) { i = LA ; } } else if ( idx1 == _LEE || idx1 == _LEE_ ) { // for _LA if ( idx2 == AA || idx2 == _AA || idx2 == _AA_ || idx2 == __AA ) { i = _LA ; } } else if ( idx1 == I_ ) { // for I_ + _AA = AA, _I_ + _AA = __AA, etc. if ( idx2 == AA || idx2 == _AA || idx2 == _AA_ ) { i = AA ; } else if ( idx2 == AE || idx2 == _AE || idx2 == _AE_ ) { i = AE ; } else if ( idx2 == OO || idx2 == _OO || idx2 == S_OO ) { i = OO ; } else if ( idx2 == OE || idx2 == _OE || idx2 == S_OE ) { i = OE ; } else if ( idx2 == UU || idx2 == _UU || idx2 == S_UU ) { i = UU ; } else if ( idx2 == UE || idx2 == _UE || idx2 == S_UE ) { i = UE ; } else if ( idx2 == DSH ) { //i = II ; } else if ( idx2 == _E_ ) { //i = EE ; } } else if ( idx1 == _I_ ) { if ( idx2 == AA || idx2 == _AA || idx2 == _AA_ ) { i = __AA ; } else if ( idx2 == AE || idx2 == _AE || idx2 == _AE_ ) { i = __AE ; } else if ( idx2 == OO || idx2 == _OO || idx2 == S_OO ) { i = __OO ; } else if ( idx2 == OE || idx2 == _OE || idx2 == S_OE ) { i = __OE ; } else if ( idx2 == UU || idx2 == _UU || idx2 == S_UU ) { i = __UU ; } else if ( idx2 == UE || idx2 == _UE || idx2 == S_UE ) { i = __UE ; } else if ( idx2 == DSH ) { //i = _II ; } else if ( idx2 == _E_ ) { //i = _EE ; } } if ( i != -1 ) { return String.fromCharCode ( getUniCode ( i ) ) ; } return "" ;}function is_alien ( code ) { if ( code == SPACE || code == DOT || code == EXCLAMATION || code == U_QUESTION || code == U_SEMICOLON || code == U_COMMA || code == MINUS || code == ONE || code == TWO || code == THREE || code == FOUR || code == FIVE || code == SIX || code == SEVEN || code == EIGHT || code == NINE || code == ZERO || code == ASTERISC || code == PERCENT || code == DOLLAR || code == POUND || code == AT || code == WEDGE || code == AND || code == LPAREN || code == RPAREN || code == PLUS || code == EQUAL || code == TILDE || code == UNDERSCORE || code == COLON || code == LFEED || code == DQUOTE || code == SQUOTE || code == RBRACK || code == LBRACK || code == LBRACE || code == RBRACE || code == LTHAN || code == GTHAN || code == FSLASH || code == PIPE || code == PRIM ) { return true ; } return false ;};/* * is_wd_beginner ( idx ) -- returns true if idx represents an Uyghur character that * mandates the next character be in the beginning form. */function is_wd_beginner ( idx ) // should next character be in beginning form{ if ( idx == AA || idx == _AA_ || idx == _AA || idx == __AA || idx == AE || idx == _AE_ || idx == _AE || idx == __AE || idx == LA || idx == _LA ) { return true ; } return false ;};/* * is_wd_beginner ( idx ) -- returns true if idx represents an Uyghur character that * mandates the next character be in the in-word beginning form. */function is_in_beginner ( idx )//should next character be in in-word beginning form{ return beg_tab[idx] == IN_BEG ;};function getUniCode ( charCode ) { var ucode ; ucode = char_code[charCode] ; return ucode ;};/* * getIndex ( uniChar ) -- reverse lookup the index from code_char table */function getIndex ( uniChar ){ var i ; for ( i = AA ; i <= LFEED ; i++ ) { if ( char_code[i] == uniChar ) { return i ; } }};/* * map_index ( input, prev ) -- returns the index for input according to the previous character */function map_index ( input, prev ){ var wd_beg, in_beg ; var str = String.fromCharCode ( input ) ; cur = str.charAt(0) ; wd_beg = beg_tab [prev] ; if ( wd_beg != WD_BEG ) { in_beg = beg_tab[prev] ; } if ( wd_beg == WD_BEG || prev == -1 ) { switch ( cur ) { case 'a' : return EHE_ ; case 'A' : return EHE_ ; case 'b' : case 'B' : return BEE_ ; case 'c' : case 'C' : return GHEE_ ; case 'd' : return DEE ; case 'D' : return SZEE ; case 'e' : return EE_ ; case 'E' : return EE_ ; case 'f' : return AA ; case 'F' : return FEE_ ; case 'g' : return AE ; case 'G' : return GEE_ ; case 'h' : return II_ ; case 'H' : return HEE_ ; case 'i' : case 'I' : return NGEE_ ; case 'j' : return QEE_ ; case 'J' : return JEE_ ; case 'k' : return KEE_ ; case 'K' : return OE ; case 'l' : return LEE_ ; case 'L' : return LA ; case 'm' : case 'M' : return MEE_ ; case 'n' : case 'N' : return NEE_ ; case 'o' : case 'O' : // capital 'Oh' return OO ; case 'p' : case 'P' : return PEE_ ; case 'q' : case 'Q' : return CHEE_ ; case 'r' : case 'R' : return REE ; case 's' : case 'S' : return SEE_ ; case 't' : return TEE_ ; case 'u' : case 'U' : return UU ; case 'v' : case 'V' : return UE ; case 'w' : case 'W' : return VEE ; case 'x' : case 'X' : return SHEE_ ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -