void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
{
recordUndo(cur);
- string sel = to_utf8(cur.selectionAsString(false));
+ docstring sel = cur.selectionAsString(false);
//lyxerr << "selection is: '" << sel << "'" << endl;
// It may happen that sel is empty but there is a selection
// create a macro if we see "\\newcommand"
// somewhere, and an ordinary formula
// otherwise
- istringstream is(sel);
- if (sel.find("\\newcommand") == string::npos
- && sel.find("\\def") == string::npos)
+ if (sel.find(from_ascii("\\newcommand")) == string::npos
+ && sel.find(from_ascii("\\def")) == string::npos)
{
InsetMathHull * formula = new InsetMathHull;
+ istringstream is(to_utf8(sel));
LyXLex lex(0, 0);
lex.setStream(is);
formula->read(cur.buffer(), lex);
// delimiters are left out
formula->mutate(hullSimple);
cur.insert(formula);
- } else
- cur.insert(new MathMacroTemplate(is));
+ } else {
+ cur.insert(new MathMacroTemplate(sel));
+ }
}
cur.message(from_utf8(N_("Math editor mode")));
}
break;
}
+ case LFUN_UNICODE_INSERT: {
+ if (cmd.argument().empty())
+ break;
+ docstring hexstring = cmd.argument();
+ if (lyx::support::isHex(hexstring)) {
+ char_type c = lyx::support::hexToInt(hexstring);
+ if (c > 32 && c < 0x10ffff) {
+ lyxerr << "Inserting c: " << c << endl;
+ docstring s = docstring(1, c);
+ lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, s));
+ }
+ }
+ break;
+ }
+
case LFUN_QUOTE_INSERT: {
cap::replaceSelection(cur);
Paragraph & par = cur.paragraph();
case LFUN_BUFFER_BEGIN:
case LFUN_BUFFER_BEGIN_SELECT:
case LFUN_BUFFER_END_SELECT:
+ case LFUN_UNICODE_INSERT:
// these are handled in our dispatch()
enable = true;
break;