-
- if (c == 0) { // Dead key, do nothing
- //lyxerr << "deadkey" << endl;
- break;
- }
-
- if (isalpha(c)) {
- if (mathcursor->getLastCode() == LM_TC_TEX) {
- mathcursor->macroModeOpen();
- mathcursor->clearLastCode();
- varcode = LM_TC_MIN;
- } else if (!varcode) {
- MathTextCodes f = mathcursor->getLastCode() ?
- mathcursor->getLastCode() :
- mathcursor->nextCode();
- varcode = MathIsAlphaFont(f) ?
- static_cast<MathTextCodes>(f) :
- LM_TC_VAR;
- }
-
- // lyxerr << "Varcode << vardoce;
- MathTextCodes char_code = varcode;
- if (greek_kb_flag) {
- char greek[26] =
- {'A', 'B', 'X', 0 , 'E', 0 , 0 , 'H', 'I', 0 ,
- 'K', 0 , 'M', 'N', 'O', 0 , 0 , 'P', 0 , 'T',
- 0, 0, 0, 0, 0 , 'Z' };
-
- if ('A' <= c && c <= 'Z' && greek[c - 'A']) {
- char_code = LM_TC_RM;
- c = greek[c - 'A'];
- } else
- char_code = LM_TC_SYMB;
- }
-
- mathcursor->insert(c, char_code);
-
- if (greek_kb_flag && char_code == LM_TC_RM)
- mathcursor->setLastCode(LM_TC_VAR);
-
- varcode = LM_TC_MIN;
-
- if (greek_kb_flag < 2)
- greek_kb_flag = 0;
-
- } else if (c == '{') {
- mathcursor->insert(new MathScopeInset);
- mathcursor->left();
- mathcursor->clearLastCode();
- } else if (strchr("!,:;", c) && (varcode == LM_TC_TEX||was_macro)) {
- mathcursor->insert(c, LM_TC_TEX);
- mathcursor->clearLastCode();
- } else if (c == '_' && varcode == LM_TC_TEX) {
- mathcursor->insert(c, LM_TC_SPECIAL);
- mathcursor->clearLastCode();
- } else if ('0' <= c && c <= '9' && (varcode == LM_TC_TEX||was_macro)) {
- mathcursor->macroModeOpen();
- mathcursor->clearLastCode();
- mathcursor->insert(c, LM_TC_MIN);
- } else if (('0' <= c && c <= '9') || strchr(";:!|[]().,?", c)) {
- MathTextCodes code = mathcursor->getLastCode();
- if (code != LM_TC_TEXTRM)
- code = LM_TC_CONST;
- mathcursor->insert(c, code);
- } else if (strchr("+/-*<>=", c)) {
- MathTextCodes code = mathcursor->getLastCode();
- if (code != LM_TC_TEXTRM)
- code = LM_TC_BOP;
- mathcursor->insert(c, code);
- } else if (strchr("#$%{|}", c)) {
- MathTextCodes code = mathcursor->getLastCode();
- if (code != LM_TC_TEXTRM)
- code = LM_TC_SPECIAL;
- mathcursor->insert(c, code);
- } else if (c == '_' || c == '^') {
- char s[2];
- s[0] = c;
- s[1] = 0;
- mathcursor->interpret(s);
- } else if (c == ' ') {
- if (!varcode) {
- MathTextCodes f = (mathcursor->getLastCode()) ?
- mathcursor->getLastCode() :
- mathcursor->nextCode();
- varcode = MathIsAlphaFont(f) ? f : LM_TC_VAR;
- }
-
- if (varcode == LM_TC_TEXTRM)
- mathcursor->insert(c, LM_TC_TEXTRM);
- else if (was_macro)
- mathcursor->macroModeClose();
- else if (mathcursor->popRight())
- ;
- else {
- // this would not work if the inset is in an table!
- //bv->text->cursorRight(bv, true);
- result = FINISHED;
- }
- } else if (c == '\'' || c == '@') {
- mathcursor->insert(c, LM_TC_VAR);
- } else if (c == '\\') {
- if (was_macro)
- mathcursor->macroModeClose();
- bv->owner()->message(_("TeX mode"));
- mathcursor->setLastCode(LM_TC_TEX);
- }