Juergen Spitzmueller wrote:
> Enrico Forestieri wrote:
>> With this patch the behavior is as in 1.3.7, including that when
>> selecting a math inset and pasting it outside of LyX, the delimiters are
>> still left out.
Enrico, could you file the paste outside of LyX bug in bugzilla, please (or
si it alreday there?)
>> Given that, I don't know why this patch is needed...
>
> try this:
> 1. write \text{test} in text mode
> 2. select it
> 3. hit C-M
>
> you get an ampty text inset. The patch fixes that.
OK, forget my previous post about being this no 1.4.0 stuff. I was confused.
Here is a better patch (only two code lines were changed), that does allow
all these cases:
\text{test}
$\text{test}$
\[\text{test}\]
\begin{align}\text{test}\end{align}
etc. Of course \text{test} can be replaced by anything that can be in a math
formula.
Jürgen, Enrico, it would be nice if you could test this one again, so that
it can go in 1.4.0. For me it does work.
> The bug is not about copy and paste, but about text->math conversion.
Yes.
Georg
Index: src/ChangeLog
===================================================================
--- src/ChangeLog (Revision 13280)
+++ src/ChangeLog (Arbeitskopie)
@@ -1,3 +1,7 @@
+2006-02-26 Georg Baum <[EMAIL PROTECTED]>
+
+ * text3.C (mathDispatch): fix math inset creation from string (bug 2315)
+
2006-02-28 Martin Vermeer <[EMAIL PROTECTED]>
* cursor.C (niceInsert): fix (properly) insertion of
Index: src/text3.C
===================================================================
--- src/text3.C (Revision 13280)
+++ src/text3.C (Arbeitskopie)
@@ -158,16 +158,21 @@ namespace {
// 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)
{
- cur.insert(new MathHullInset("simple"));
- cur.dispatch(FuncRequest(LFUN_RIGHT));
- cur.dispatch(FuncRequest(LFUN_INSERT_MATH, sel));
- } else {
- istringstream is(sel);
+ MathHullInset * formula = new MathHullInset;
+ LyXLex lex(0, 0);
+ lex.setStream(is);
+ formula->read(cur.buffer(), lex);
+ if (formula->getType() == "none")
+ // Don't create pseudo formulas if
+ // delimiters are left out
+ formula->mutate("simple");
+ cur.insert(formula);
+ } else
cur.insert(new MathMacroTemplate(is));
- }
}
cur.message(N_("Math editor mode"));
}