using lyx::CoordCache;
using lyx::docstring;
+using lyx::odocstream;
using lyx::Point;
using lyx::cap::copySelection;
}
-void InsetMathNest::cursorPos(CursorSlice const & sl, bool /*boundary*/,
- int & x, int & y) const
+void InsetMathNest::cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool /*boundary*/,
+ int & x, int & y) const
{
// FIXME: This is a hack. Ideally, the coord cache should not store
// absolute positions, but relative ones. This would mean to call
// absolute again when actually drawing the cursor. What a mess.
BOOST_ASSERT(ptr_cmp(&sl.inset(), this));
MathArray const & ar = sl.cell();
- CoordCache & coord_cache = sl.text()->bv()->coordCache();
+ CoordCache const & coord_cache = bv.coordCache();
if (!coord_cache.getArrays().has(&ar)) {
// this can (semi-)legally happen if we just created this cell
// and it never has been drawn before. So don't ASSERT.
void InsetMathNest::dump() const
{
- WriteStream os(lyxerr);
+ lyx::odocstringstream oss;
+ WriteStream os(oss);
os << "---------------------------------------------\n";
write(os);
os << "\n";
for (idx_type i = 0, n = nargs(); i != n; ++i)
os << cell(i) << "\n";
os << "---------------------------------------------\n";
+ lyxerr << lyx::to_utf8(oss.str());
}
}
-int InsetMathNest::latex(Buffer const &, std::ostream & os,
+int InsetMathNest::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
WriteStream wi(os, runparams.moving_arg, true);
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;
}
cur.posLeft();
cur.pushLeft(*cur.nextInset());
}
- // FIXME: Change to
- // } else if (!interpret(cur, cmd.argument()[0])) {
- // when interpret accepts UCS4 characters
- } else if (!interpret(cur, lyx::to_utf8(cmd.argument()))) {
+ } else if (!interpretChar(cur, cmd.argument()[0])) {
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
cur.undispatched();
}
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() == "_") {
+ interpretChar(cur, cmd.argument()[0]);
+ } else
cur.niceInsert(lyx::to_utf8(cmd.argument()));
break;
}
}
-bool InsetMathNest::interpret(LCursor & cur, char c)
+bool InsetMathNest::interpretChar(LCursor & cur, lyx::char_type c)
{
//lyxerr << "interpret 2: '" << c << "'" << endl;
string save_selection;
}
if (isalpha(c)) {
- cur.activeMacro()->setName(name + c);
+ cur.activeMacro()->setName(name + lyx::to_ascii(docstring(1, c)));
return true;
}
cur.niceInsert(MathAtom(new InsetMathComment));
} else if (c == '#') {
BOOST_ASSERT(cur.activeMacro());
- cur.activeMacro()->setName(name + c);
+ cur.activeMacro()->setName(name + lyx::to_ascii(docstring(1, c)));
} else {
cur.backspace();
- cur.niceInsert(createInsetMath(string(1, c)));
+ cur.niceInsert(createInsetMath(lyx::to_ascii(docstring(1, c))));
}
return true;
}
// One character big delimiters. The others are handled in
- // the other interpret() method.
+ // interpretString().
latexkeys const * l = in_word_set(name.substr(1));
if (name[0] == '\\' && l && l->inset == "big") {
string delim;
delim = "\\}";
break;
default:
- delim = string(1, c);
+ delim = lyx::to_ascii(docstring(1, c));
break;
}
if (InsetMathBig::isBigInsetDelim(delim)) {
if (c == '{')
cur.niceInsert(MathAtom(new InsetMathBrace));
else if (c != ' ')
- interpret(cur, c);
+ interpretChar(cur, c);
return true;
}
if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' ||
c == '%' || c == '_' || c == '^') {
- cur.niceInsert(createInsetMath(string(1, c)));
+ cur.niceInsert(createInsetMath(lyx::to_ascii(docstring(1, 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;
}