mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
better ert handling
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2213 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
faa697a2a9
commit
bade84c1f8
@ -9,9 +9,8 @@ src/converter.C
|
||||
src/CutAndPaste.C
|
||||
src/debug.C
|
||||
src/exporter.C
|
||||
src/ext_l10n.h
|
||||
src/figureForm.C
|
||||
src/figure_form.C
|
||||
src/figureForm.C
|
||||
src/FontLoader.C
|
||||
src/frontends/controllers/ButtonController.h
|
||||
src/frontends/controllers/character.C
|
||||
@ -89,67 +88,67 @@ src/frontends/qt2/paragraphdlgimpl.C
|
||||
src/frontends/qt2/tabularcreatedlgimpl.C
|
||||
src/frontends/xforms/combox.C
|
||||
src/frontends/xforms/FileDialog.C
|
||||
src/frontends/xforms/FormBibitem.C
|
||||
src/frontends/xforms/form_bibitem.C
|
||||
src/frontends/xforms/FormBibtex.C
|
||||
src/frontends/xforms/FormBibitem.C
|
||||
src/frontends/xforms/form_bibtex.C
|
||||
src/frontends/xforms/FormBibtex.C
|
||||
src/frontends/xforms/form_browser.C
|
||||
src/frontends/xforms/FormCharacter.C
|
||||
src/frontends/xforms/form_character.C
|
||||
src/frontends/xforms/FormCitation.C
|
||||
src/frontends/xforms/FormCharacter.C
|
||||
src/frontends/xforms/form_citation.C
|
||||
src/frontends/xforms/FormCopyright.C
|
||||
src/frontends/xforms/FormCitation.C
|
||||
src/frontends/xforms/form_copyright.C
|
||||
src/frontends/xforms/FormCredits.C
|
||||
src/frontends/xforms/FormCopyright.C
|
||||
src/frontends/xforms/form_credits.C
|
||||
src/frontends/xforms/FormDocument.C
|
||||
src/frontends/xforms/FormCredits.C
|
||||
src/frontends/xforms/form_document.C
|
||||
src/frontends/xforms/FormError.C
|
||||
src/frontends/xforms/FormDocument.C
|
||||
src/frontends/xforms/form_error.C
|
||||
src/frontends/xforms/FormExternal.C
|
||||
src/frontends/xforms/FormError.C
|
||||
src/frontends/xforms/form_external.C
|
||||
src/frontends/xforms/FormFiledialog.C
|
||||
src/frontends/xforms/FormExternal.C
|
||||
src/frontends/xforms/form_filedialog.C
|
||||
src/frontends/xforms/FormGraphics.C
|
||||
src/frontends/xforms/FormFiledialog.C
|
||||
src/frontends/xforms/form_graphics.C
|
||||
src/frontends/xforms/FormInclude.C
|
||||
src/frontends/xforms/FormGraphics.C
|
||||
src/frontends/xforms/form_include.C
|
||||
src/frontends/xforms/FormIndex.C
|
||||
src/frontends/xforms/FormInclude.C
|
||||
src/frontends/xforms/form_index.C
|
||||
src/frontends/xforms/FormIndex.C
|
||||
src/frontends/xforms/FormLog.C
|
||||
src/frontends/xforms/FormMathsBitmap.C
|
||||
src/frontends/xforms/FormMathsDeco.C
|
||||
src/frontends/xforms/form_maths_deco.C
|
||||
src/frontends/xforms/FormMathsDelim.C
|
||||
src/frontends/xforms/FormMathsDeco.C
|
||||
src/frontends/xforms/form_maths_delim.C
|
||||
src/frontends/xforms/FormMathsMatrix.C
|
||||
src/frontends/xforms/FormMathsDelim.C
|
||||
src/frontends/xforms/form_maths_matrix.C
|
||||
src/frontends/xforms/FormMathsPanel.C
|
||||
src/frontends/xforms/FormMathsMatrix.C
|
||||
src/frontends/xforms/form_maths_panel.C
|
||||
src/frontends/xforms/FormMathsSpace.C
|
||||
src/frontends/xforms/FormMathsPanel.C
|
||||
src/frontends/xforms/form_maths_space.C
|
||||
src/frontends/xforms/FormMinipage.C
|
||||
src/frontends/xforms/FormMathsSpace.C
|
||||
src/frontends/xforms/form_minipage.C
|
||||
src/frontends/xforms/FormParagraph.C
|
||||
src/frontends/xforms/FormMinipage.C
|
||||
src/frontends/xforms/form_paragraph.C
|
||||
src/frontends/xforms/FormPreamble.C
|
||||
src/frontends/xforms/FormParagraph.C
|
||||
src/frontends/xforms/form_preamble.C
|
||||
src/frontends/xforms/FormPreferences.C
|
||||
src/frontends/xforms/FormPreamble.C
|
||||
src/frontends/xforms/form_preferences.C
|
||||
src/frontends/xforms/FormPrint.C
|
||||
src/frontends/xforms/FormPreferences.C
|
||||
src/frontends/xforms/form_print.C
|
||||
src/frontends/xforms/FormRef.C
|
||||
src/frontends/xforms/FormPrint.C
|
||||
src/frontends/xforms/form_ref.C
|
||||
src/frontends/xforms/FormSearch.C
|
||||
src/frontends/xforms/FormRef.C
|
||||
src/frontends/xforms/form_search.C
|
||||
src/frontends/xforms/FormTabular.C
|
||||
src/frontends/xforms/FormSearch.C
|
||||
src/frontends/xforms/form_tabular.C
|
||||
src/frontends/xforms/FormTabularCreate.C
|
||||
src/frontends/xforms/FormTabular.C
|
||||
src/frontends/xforms/form_tabular_create.C
|
||||
src/frontends/xforms/FormToc.C
|
||||
src/frontends/xforms/FormTabularCreate.C
|
||||
src/frontends/xforms/form_toc.C
|
||||
src/frontends/xforms/FormUrl.C
|
||||
src/frontends/xforms/FormToc.C
|
||||
src/frontends/xforms/form_url.C
|
||||
src/frontends/xforms/FormUrl.C
|
||||
src/frontends/xforms/FormVCLog.C
|
||||
src/frontends/xforms/input_validators.C
|
||||
src/frontends/xforms/Menubar_pimpl.C
|
||||
|
@ -1,3 +1,11 @@
|
||||
2001-07-10 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* buffer.C (readLyXformat2): initailize the ert comp. variables.
|
||||
(readLyXformat2): rename return_par to first_par, use lyxlex's
|
||||
pushToken and remove the manual push handling.
|
||||
(parseSingleLyXformat2Token): add another ert comp. variable:
|
||||
in_tabular, rename return_par to first_par. handle newlines better
|
||||
|
||||
2001-07-05 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* kbsequence.C (getiso): redirect debug info to Debug::KBMAP.
|
||||
|
98
src/buffer.C
98
src/buffer.C
@ -278,6 +278,18 @@ void Buffer::setFileName(string const & newfile)
|
||||
}
|
||||
|
||||
|
||||
// We'll remove this later. (Lgb)
|
||||
namespace {
|
||||
|
||||
string last_inset_read;
|
||||
string inset_ert_contents;
|
||||
bool ert_active = false;
|
||||
bool in_tabular = false;
|
||||
|
||||
} // anon
|
||||
|
||||
|
||||
|
||||
// candidate for move to BufferView
|
||||
// (at least some parts in the beginning of the func)
|
||||
//
|
||||
@ -288,74 +300,65 @@ void Buffer::setFileName(string const & newfile)
|
||||
// Returns false if "\the_end" is not read for formats >= 2.13. (Asger)
|
||||
bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
|
||||
{
|
||||
#ifdef NO_LATEX
|
||||
inset_ert_contents.erase();
|
||||
ert_active = false;
|
||||
in_tabular = false;
|
||||
#endif
|
||||
|
||||
int pos = 0;
|
||||
Paragraph::depth_type depth = 0;
|
||||
bool the_end_read = false;
|
||||
|
||||
Paragraph * return_par = 0;
|
||||
Paragraph * first_par = 0;
|
||||
LyXFont font(LyXFont::ALL_INHERIT, params.language);
|
||||
if (file_format < 216 && params.language->lang() == "hebrew")
|
||||
font.setLanguage(default_language);
|
||||
// If we are inserting, we cheat and get a token in advance
|
||||
bool has_token = false;
|
||||
string pretoken;
|
||||
|
||||
if (!par) {
|
||||
par = new Paragraph;
|
||||
} else {
|
||||
// We are inserting into an existing document
|
||||
users->text->breakParagraph(users);
|
||||
return_par = users->text->firstParagraph();
|
||||
first_par = users->text->firstParagraph();
|
||||
pos = 0;
|
||||
markDirty();
|
||||
// We don't want to adopt the parameters from the
|
||||
// document we insert, so we skip until the text begins:
|
||||
while (lex.IsOK()) {
|
||||
lex.nextToken();
|
||||
pretoken = lex.GetString();
|
||||
string const pretoken = lex.GetString();
|
||||
if (pretoken == "\\layout") {
|
||||
has_token = true;
|
||||
lex.pushToken(pretoken);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (lex.IsOK()) {
|
||||
if (has_token) {
|
||||
has_token = false;
|
||||
} else {
|
||||
lex.nextToken();
|
||||
pretoken = lex.GetString();
|
||||
}
|
||||
string const token = lex.GetString();
|
||||
|
||||
if (pretoken.empty()) continue;
|
||||
if (token.empty()) continue;
|
||||
|
||||
lyxerr[Debug::PARSER] << "Handling token: `"
|
||||
<< token << "'" << endl;
|
||||
|
||||
the_end_read =
|
||||
parseSingleLyXformat2Token(lex, par, return_par,
|
||||
pretoken, pos, depth,
|
||||
font
|
||||
);
|
||||
parseSingleLyXformat2Token(lex, par, first_par,
|
||||
token, pos, depth,
|
||||
font);
|
||||
}
|
||||
|
||||
if (!return_par)
|
||||
return_par = par;
|
||||
if (!first_par)
|
||||
first_par = par;
|
||||
|
||||
paragraph = return_par;
|
||||
paragraph = first_par;
|
||||
|
||||
return the_end_read;
|
||||
}
|
||||
|
||||
|
||||
// We'll remove this later. (Lgb)
|
||||
namespace {
|
||||
|
||||
string last_inset_read;
|
||||
string inset_ert_contents;
|
||||
bool ert_active = false;
|
||||
|
||||
} // anon
|
||||
|
||||
|
||||
void Buffer::insertErtContents(Paragraph * par, int & pos,
|
||||
LyXFont const & font, bool set_inactive)
|
||||
{
|
||||
@ -374,7 +377,7 @@ void Buffer::insertErtContents(Paragraph * par, int & pos,
|
||||
|
||||
bool
|
||||
Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
Paragraph *& return_par,
|
||||
Paragraph *& first_par,
|
||||
string const & token, int & pos,
|
||||
Paragraph::depth_type & depth,
|
||||
LyXFont & font
|
||||
@ -413,6 +416,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
++pos;
|
||||
} else if (token == "\\layout") {
|
||||
#ifdef NO_LATEX
|
||||
in_tabular = false;
|
||||
// Do the insetert.
|
||||
insertErtContents(par, pos, font);
|
||||
#endif
|
||||
@ -480,8 +484,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
++pos;
|
||||
} else {
|
||||
#endif
|
||||
if (!return_par)
|
||||
return_par = par;
|
||||
if (!first_par)
|
||||
first_par = par;
|
||||
else {
|
||||
par = new Paragraph(par);
|
||||
}
|
||||
@ -847,7 +851,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
}
|
||||
// Small hack so that files written with klyx will be
|
||||
// parsed correctly.
|
||||
if (return_par) {
|
||||
if (first_par) {
|
||||
par->params().spacing(Spacing(tmp_space, tmp_val));
|
||||
} else {
|
||||
params.spacing.set(tmp_space, tmp_val);
|
||||
@ -999,6 +1003,9 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
// But insets should read it, it is a part of
|
||||
// the inset isn't it? Lgb.
|
||||
} else if (token == "\\begin_inset") {
|
||||
#ifdef NO_LATEX
|
||||
insertErtContents(par, pos, font);
|
||||
#endif
|
||||
readInset(lex, par, pos, font);
|
||||
} else if (token == "\\SpecialChar") {
|
||||
LyXLayout const & layout =
|
||||
@ -1030,13 +1037,26 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
++pos;
|
||||
} else if (token == "\\newline") {
|
||||
#ifdef NO_LATEX
|
||||
// Since we cannot know it this is only a regular newline or a
|
||||
// tabular cell delimter we have to handle the ERT here.
|
||||
|
||||
if (!in_tabular && ert_active) {
|
||||
inset_ert_contents += char(Paragraph::META_NEWLINE);
|
||||
} else {
|
||||
// Since we cannot know it this is only a regular
|
||||
// newline or a tabular cell delimter we have to
|
||||
// handle the ERT here.
|
||||
insertErtContents(par, pos, font, false);
|
||||
#endif
|
||||
|
||||
par->insertChar(pos, Paragraph::META_NEWLINE, font);
|
||||
++pos;
|
||||
}
|
||||
#else
|
||||
par->insertChar(pos, Paragraph::META_NEWLINE, font);
|
||||
++pos;
|
||||
#endif
|
||||
} else if (token == "\\LyXTable") {
|
||||
#ifdef NO_LATEX
|
||||
in_tabular = true;
|
||||
#endif
|
||||
Inset * inset = new InsetTabular(*this);
|
||||
inset->read(this, lex);
|
||||
par->insertInset(pos, inset, font);
|
||||
@ -1225,8 +1245,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
par->previous(0);
|
||||
parBeforeMinipage = p;
|
||||
minipar = par;
|
||||
if (!return_par || (return_par == par))
|
||||
return_par = p;
|
||||
if (!first_par || (first_par == par))
|
||||
first_par = p;
|
||||
|
||||
InsetMinipage * mini = new InsetMinipage;
|
||||
mini->pos(static_cast<InsetMinipage::Position>(minipar->params().pextraAlignment()));
|
||||
|
@ -1,3 +1,7 @@
|
||||
2001-07-10 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* insetert.C (latex): handle META_NEWLINE
|
||||
|
||||
2001-07-09 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* insetert.h: a normal InsetText can insert insets, but we won't.
|
||||
|
@ -119,7 +119,15 @@ int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/,
|
||||
{
|
||||
Paragraph::size_type siz = inset.paragraph()->size();
|
||||
for (Paragraph::size_type i = 0; i != siz; ++i) {
|
||||
os << inset.paragraph()->getChar(i);
|
||||
char c = inset.paragraph()->getChar(i);
|
||||
switch (c) {
|
||||
case Paragraph::META_NEWLINE:
|
||||
os << '\n';
|
||||
break;
|
||||
default:
|
||||
os << c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user