+
+ 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 (strchr("!,:;{}", c) && (varcode == LM_TC_TEX||was_macro)) {
+ mathcursor->Insert(c, LM_TC_TEX);
+ if (c == '{') {
+ mathcursor->Insert('}', LM_TC_TEX);
+ mathcursor->Left();
+ }
+ mathcursor->clearLastCode();
+ // varcode = LM_TC_MIN;
+ } else if (c == '_' && varcode == LM_TC_TEX) {
+ mathcursor->Insert(c, LM_TC_SPECIAL);
+ mathcursor->clearLastCode();
+ // varcode = LM_TC_MIN;
+ } 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)) {
+ mathcursor->Insert(c, LM_TC_CONST);
+ } else if (strchr("+/-*<>=", c)) {
+ mathcursor->Insert(c, LM_TC_BOP);
+ } else if (strchr(latex_special_chars, c) && c!= '_') {
+ mathcursor->Insert(c, LM_TC_SPECIAL);
+ } else if (c == '_' || c == '^') {
+ char s[2];
+ s[0] = c;
+ s[1] = 0;
+ mathcursor->Interpret(s);
+ } else if (c == ' ') {
+ if (!varcode) {
+ short f = (mathcursor->getLastCode()) ?
+ mathcursor->getLastCode() :
+ static_cast<MathedTextCodes>(mathcursor->GetFCode());
+ varcode = MathIsAlphaFont(f) ?
+ static_cast<MathedTextCodes>(f) :
+ LM_TC_VAR;
+ }
+
+ if (varcode == LM_TC_TEXTRM) {
+ mathcursor->Insert(c, LM_TC_TEXTRM);
+ } else if (was_macro) {
+ mathcursor->MacroModeClose();
+ } else if (sp) {
+ int isp = (sp->GetSpace()<5) ? sp->GetSpace()+1: 0;
+ sp->SetSpace(isp);
+ space_on = true;
+ } else if (!mathcursor->Pop() && mathcursor->IsEnd())
+ result = FINISHED;
+ } else if (c == '\'' || c == '@') {
+ mathcursor->Insert (c, LM_TC_VAR);
+ } else if (c == '\\') {
+ if (was_macro)
+ mathcursor->MacroModeClose();
+ bv->owner()->getMiniBuffer()->Set(_("TeX mode"));
+ mathcursor->setLastCode(LM_TC_TEX);