if (cmd.argument().size() != 1) {
recordUndo(cur);
string const arg = lyx::to_utf8(cmd.argument());
- if (!interpret(cur, arg))
+ if (!interpretString(cur, arg))
cur.insert(arg);
break;
}
// FIXME: Change to
// } else if (!interpret(cur, cmd.argument()[0])) {
// when interpret accepts UCS4 characters
- } else if (!interpret(cur, lyx::to_utf8(cmd.argument()))) {
- cmd = FuncRequest(LFUN_FINISHED_RIGHT);
- cur.undispatched();
+ } else {
+ std::string arg0 = lyx::to_utf8(docstring(1, cmd.argument()[0]));
+ if (!interpretChar(cur, arg0[0])) {
+ cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+ cur.undispatched();
+ }
}
break;
case LFUN_ERT_INSERT:
// interpret this as if a backslash was typed
recordUndo(cur, Undo::ATOMIC);
- interpret(cur, '\\');
+ interpretChar(cur, '\\');
break;
case LFUN_MATH_SUBSCRIPT:
// interpret this as if a _ was typed
recordUndo(cur, Undo::ATOMIC);
- interpret(cur, '_');
+ interpretChar(cur, '_');
break;
case LFUN_MATH_SUPERSCRIPT:
// interpret this as if a ^ was typed
recordUndo(cur, Undo::ATOMIC);
- interpret(cur, '^');
+ interpretChar(cur, '^');
break;
// FIXME: We probably should swap parts of "math-insert" and "self-insert"
// math-insert only handles special math things like "matrix".
case LFUN_MATH_INSERT: {
recordUndo(cur, Undo::ATOMIC);
- if (cmd.argument() == "^" || cmd.argument() == "_")
- interpret(cur, cmd.argument()[0]);
- else
+ if (cmd.argument() == "^" || cmd.argument() == "_") {
+ std::string arg0 = lyx::to_utf8(docstring(1, cmd.argument()[0]));
+ interpretChar(cur, arg0[0]);
+ } else
cur.niceInsert(lyx::to_utf8(cmd.argument()));
break;
}
}
-bool InsetMathNest::interpret(LCursor & cur, char c)
+bool InsetMathNest::interpretChar(LCursor & cur, char c)
{
//lyxerr << "interpret 2: '" << c << "'" << endl;
string save_selection;
if (c == '{')
cur.niceInsert(MathAtom(new InsetMathBrace));
else if (c != ' ')
- interpret(cur, c);
+ interpretChar(cur, c);
return true;
}
}
-bool InsetMathNest::interpret(LCursor & cur, string const & str)
+bool InsetMathNest::interpretString(LCursor & cur, string const & str)
{
// Create a InsetMathBig from cur.cell()[cur.pos() - 1] and t if
// possible
if (up)
cur.niceInsert(createInsetMath("mathcircumflex"));
else
- interpret(cur, '_');
+ interpretChar(cur, '_');
return true;
}
/// interpret \p c and insert the result at the current position of
/// of \p cur. Return whether the cursor should stay in the formula.
- bool interpret(LCursor & cur, char c);
+ bool interpretChar(LCursor & cur, char c);
///
bool script(LCursor & cur, bool,
std::string const & save_selection = std::string());
/// interpret \p str and insert the result at the current position of
/// \p cur if it is something known. Return whether \p cur was
/// inserted.
- bool interpret(LCursor & cur, std::string const & str);
+ bool interpretString(LCursor & cur, std::string const & str);
private:
/// lfun handler