+
+ if (lyxrc.auto_number) {
+ static string const number_operators = "+-/*";
+ static string const number_unary_operators = "+-";
+ static string const number_seperators = ".,:";
+
+ if (current_font.number() == LyXFont::ON) {
+ if (!isdigit(c) && !contains(number_operators, c) &&
+ !(contains(number_seperators, c) &&
+ cursor.pos() >= 1 &&
+ cursor.pos() < cursor.par()->size() &&
+ GetFont(bview->buffer(),
+ cursor.par(),
+ cursor.pos()).number() == LyXFont::ON &&
+ GetFont(bview->buffer(),
+ cursor.par(),
+ cursor.pos()-1).number() == LyXFont::ON)
+ )
+ Number(bview); // Set current_font.number to OFF
+ } else if (isdigit(c) &&
+ real_current_font.isVisibleRightToLeft()) {
+ Number(bview); // Set current_font.number to ON
+
+ if (cursor.pos() > 0) {
+ char const c = cursor.par()->GetChar(cursor.pos() - 1);
+ if (contains(number_unary_operators, c) &&
+ (cursor.pos() == 1 ||
+ cursor.par()->IsSeparator(cursor.pos() - 2) ||
+ cursor.par()->IsNewline(cursor.pos() - 2) )
+ ) {
+ SetCharFont(bview->buffer(),
+ cursor.par(),
+ cursor.pos() - 1,
+ current_font);
+ } else if (contains(number_seperators, c) &&
+ cursor.pos() >= 2 &&
+ GetFont(bview->buffer(),
+ cursor.par(),
+ cursor.pos()-2).number() == LyXFont::ON) {
+ SetCharFont(bview->buffer(),
+ cursor.par(),
+ cursor.pos() - 1,
+ current_font);
+ }
+ }
+ }
+ }
+
+