switch (cc) {
case '^':
case '$':
case '@':
if (sbcur != null)
throw new WrongValueException("Combination of Shift, Alt and Ctrl not supported: "+keys);
sbcur = cc == '^' ? sbctl: cc == '@' ? sbalt: sbsft;
break;
case '#':
{
int k = j + 1;
for (; k < len; ++k) {
final char c2 = (char)keys.charAt(k);
if ((c2 > 'Z' || c2 < 'A') && (c2 > 'z' || c2 < 'a')
&& (c2 > '9' || c2 < '0'))
break;
}
if (k == j + 1)
throw new WrongValueException(MCommon.UNEXPECTED_CHARACTER, new Object[] {new Character(cc), keys});
final String s = keys.substring(j+1, k).toLowerCase();
if ("pgup".equals(s)) cc = 'A';
else if ("pgdn".equals(s)) cc = 'B';
else if ("end".equals(s)) cc = 'C';
else if ("home".equals(s)) cc = 'D';
else if ("left".equals(s)) cc = 'E';
else if ("up".equals(s)) cc = 'F';
else if ("right".equals(s)) cc = 'G';
else if ("down".equals(s)) cc = 'H';
else if ("ins".equals(s)) cc = 'I';
else if ("del".equals(s)) cc = 'J';
else if (s.length() > 1 && s.charAt(0) == 'f') {
final int v;
try {
v = Integer.parseInt(s.substring(1));
} catch (Throwable ex) {
throw new WrongValueException("Unknown #"+s+" in "+keys);
}
if (v == 0 || v > 12)
throw new WrongValueException("Unsupported function key: #f"+v);
cc = (char)('O' + v); //'P': F1, 'Q': F2... 'Z': F12
} else
throw new WrongValueException("Unknown #"+s+" in "+keys);
if (sbcur == null) sbext.append(cc);
else {
sbcur.append(cc);
sbcur = null;
}
j = k - 1;
}
break;
default:
if (sbcur == null || ((cc > 'Z' || cc < 'A')
&& (cc > 'z' || cc < 'a') && (cc > '9' || cc < '0')))
throw new WrongValueException(MCommon.UNEXPECTED_CHARACTER, new Object[] {new Character(cc), keys});
if (sbcur == sbsft)
throw new WrongValueException("$"+cc+" not supported: "+keys);
if (cc <= 'Z' && cc >= 'A')
cc = (char)(cc + ('a' - 'A')); //to lower case
sbcur.append(cc);
sbcur = null;