On Thu, Jun 01, 2017 at 02:12:56PM +0000, Guenter Milde wrote: > > Below is a "stub patch", that tries to achieve this but fails due to my > limite understanding of C++ and LyX code. > I copy-pasted from Text.cpp and factory.cpp and did some edits. > However, in a test file (2.1 file containing ---), the inserted ERT was > empty and the console showed > > Lexer.cpp (934): Missing 'ert'-tag in InsetERT::string2params. Got -- > instead. Line: 0 > > Also, I would prefer the new-created ERT-insets to be "closed" (less > distractive in the GUI).
Please, try the attached. I don't know what you are trying to do, but I hope you are not trying to sabotage the last fixes to the en/emdash mess. I would be really upset to see all of them as ert. If this is a first step toward a really clean solution (to solve I don't know what), that would be fine, though. -- Enrico
diff --git a/src/Text.cpp b/src/Text.cpp index 038553ba44..617e782701 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -52,6 +52,7 @@ #include "insets/InsetText.h" #include "insets/InsetBibitem.h" #include "insets/InsetCaption.h" +#include "insets/InsetERT.h" #include "insets/InsetNewline.h" #include "insets/InsetNewpage.h" #include "insets/InsetArgument.h" @@ -508,10 +509,15 @@ void Text::readParToken(Paragraph & par, Lexer & lex, else par.insert(par.size(), from_ascii("---"), font, change); } else { - if (token == "\\twohyphens") - par.insertChar(par.size(), 0x2013, font, change); - else - par.insertChar(par.size(), 0x2014, font, change); + InsetERT * ert = new InsetERT(buf, InsetCollapsable::Collapsed); + if (token == "\\twohyphens") { + ert->setText(from_ascii("--"), font, + buf->params().track_changes); + } else { + ert->setText(from_ascii("---"), font, + buf->params().track_changes); + } + par.insertInset(par.size(), ert, font, change); } } else if (token == "\\backslash") { par.appendChar('\\', font, change);