Vincent van Ravesteijn wrote: > This is a patch without the crash. nice thanks. i'm slowly moving to user configurable behaviour. once you feel satisfied with your code, please put it into trunk, so i can start to improve it.
enough for today. pavel
diff --git a/development/FORMAT b/development/FORMAT index f241639..e44fa82 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,10 @@ LyX file-format changes ----------------------- +2009-12-15 Vincent van Ravesteijn <v...@lyx.org>, Pavel Sanda <sa...@lyx.org> + * Format incremented to 374: instant preview of ERTs + Add preview parameter for each ERT inset, possible values 0,1. + 2009-12-07 JĂźrgen SpitzmĂźller <sp...@lyx.org> * Format incremented to 373: merge g-brief-de and g-brief-en classes into one g-brief class. diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index cd665bf..1e700b3 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -1131,6 +1131,17 @@ def revert_gbrief(document): document.set_textclass() +def revert_ERT_preview(document): + " Remove the preview line from ERT inset " + i = 0 + while True: + i = find_token(document.body, "\\begin_inset ERT", i) + if i == -1: + break + if document.body[i+1].find("preview") == 0: + del document.body[i+1] + i = i + 1 + ## # Conversion hub # @@ -1163,10 +1174,13 @@ convert = [[346, []], [370, []], [371, []], [372, []], - [373, [merge_gbrief]] + [373, [merge_gbrief]], + [374, []] ] -revert = [[372, [revert_gbrief]], +revert = [ + [373, [revert_ERT_preview]], + [372, [revert_gbrief]], [371, [revert_fontenc]], [370, [revert_mhchem]], [369, [revert_suppress_date]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 90512f0..3bc7406 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -127,7 +127,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 373; // jspitzm: merge g-brief class +int const LYX_FORMAT = 374; // sanda: ip for erts typedef map<string, bool> DepClean; typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache; diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index 80b3af3..25243d3 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -50,7 +50,8 @@ using namespace lyx::support; namespace lyx { InsetERT::InsetERT(Buffer * buf, CollapseStatus status) - : InsetCollapsable(buf), preview_(new RenderPreview(this)) + : InsetCollapsable(buf), preview_(new RenderPreview(this)), + display_preview_(false) { status_ = status; } @@ -82,10 +83,19 @@ InsetERT::~InsetERT() void InsetERT::write(ostream & os) const { os << "ERT" << "\n"; + os << "preview " << display_preview_ << "\n"; InsetCollapsable::write(os); } +void InsetERT::read(Lexer &lex) +{ + lex.setContext("InsetERT::read"); + lex >> "preview" >> display_preview_; + InsetCollapsable::read(lex); +} + + int InsetERT::plaintext(odocstream & os, OutputParams const & rp) const { if (!rp.inIndexEntry) diff --git a/src/insets/InsetERT.h b/src/insets/InsetERT.h index 4be3ece..a8046b3 100644 --- a/src/insets/InsetERT.h +++ b/src/insets/InsetERT.h @@ -71,6 +71,8 @@ private: /// void write(std::ostream & os) const; /// + void read(Lexer &); + /// int plaintext(odocstream &, OutputParams const &) const; /// int docbook(odocstream &, OutputParams const &) const; @@ -96,6 +98,8 @@ private: boost::scoped_ptr<RenderPreview> preview_; /// mutable bool use_preview_; + /// user setting for Instant Preview of this ERT + bool display_preview_; };