Jean-Marc Lasgouttes wrote: > >>>>> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes: > The patch looks good. A few remarks: > > + case LFUN_OUTPUT_CHANGES: { > + LaTeXFeatures features(*buf, buf->params(), false); > + if (!features.isAvailable("dvipost")) > + buf->params().output_changes = false; > + flag.enabled(buf && buf->params().tracking_changes > + && features.isAvailable("dvipost")); > + flag.setOnOff(buf->params().output_changes); > + break; > + } > > You should not change variables from ::getStatus. Why do you reset > BufferParams::output_changes there?
Valid remark. It was just easier, but of course it is better if the param does not get touched but rather ignored if dvipost is not available. I changed this in the new patch. > + > + case LFUN_OUTPUT_CHANGES: { > + Buffer * buf = bv_->buffer(); > + if (!buf->params().tracking_changes) > + break; > + else { > + bool const state = buf->params().output_changes; > + buf->params().output_changes = !state; > + } > + break; > + } > > The LFUN is disabled when tracking_changes is off, so you do not need > to test for this condition. OK. > +void LaTeXFeatures::getAvailable() > > I am not sure putting this list in LaTeXFeatures like that is the best > solution, since packages.lst will be parsed everytime one exports to > latex... You may want to turn packages_ into a static variable and > make getPackage static too. I tried this, but then I get linking errors in LaTeXFeatures.C ("packages_ not defined"). Can you give me some more detailed guidelines please? > --- bufferparams.h 19 Jan 2005 15:03:29 -0000 1.53 > +++ bufferparams.h 23 Jan 2005 17:03:30 -0000 > @@ -209,6 +209,8 @@ > bool use_bibtopic; > /// revision tracking for this buffer ? > bool tracking_changes; > + /// output changes to dvi? > + bool output_changes; > > The 'to dvi' part is a bit to terse here. You could maybe add here a > short motivation for this variable, based on what you just wrote. Done. Updated patch (without the getAvailable() changes) attached. Regards, Jürgen > JMarc
Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.567 diff -u -r1.567 BufferView_pimpl.C --- BufferView_pimpl.C 10 Jan 2005 19:17:38 -0000 1.567 +++ BufferView_pimpl.C 24 Jan 2005 12:37:52 -0000 @@ -34,6 +34,7 @@ #include "gettext.h" #include "intl.h" #include "insetiterator.h" +#include "LaTeXFeatures.h" #include "lyx_cb.h" // added for Dispatch functions #include "lyx_main.h" #include "lyxfind.h" @@ -972,6 +973,14 @@ flag.setOnOff(buf->params().tracking_changes); break; + case LFUN_OUTPUT_CHANGES: { + LaTeXFeatures features(*buf, buf->params(), false); + flag.enabled(buf && buf->params().tracking_changes + && features.isAvailable("dvipost")); + flag.setOnOff(buf->params().output_changes); + break; + } + case LFUN_MERGE_CHANGES: case LFUN_ACCEPT_CHANGE: // what about these two case LFUN_REJECT_CHANGE: // what about these two @@ -1070,6 +1079,13 @@ case LFUN_TRACK_CHANGES: trackChanges(); break; + + case LFUN_OUTPUT_CHANGES: { + Buffer * buf = bv_->buffer(); + bool const state = buf->params().output_changes; + buf->params().output_changes = !state; + break; + } case LFUN_MERGE_CHANGES: owner_->getDialogs().show("changes"); Index: LaTeXFeatures.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeXFeatures.C,v retrieving revision 1.115 diff -u -r1.115 LaTeXFeatures.C --- LaTeXFeatures.C 19 Jan 2005 11:44:29 -0000 1.115 +++ LaTeXFeatures.C 24 Jan 2005 12:37:53 -0000 @@ -22,6 +22,7 @@ #include "Floating.h" #include "FloatList.h" #include "language.h" +#include "lyxlex.h" #include "lyx_sty.h" #include "lyxrc.h" @@ -30,6 +31,7 @@ #include <sstream> using lyx::support::IsSGMLFilename; +using lyx::support::LibFileSearch; using lyx::support::MakeRelPath; using lyx::support::OnlyPath; @@ -66,6 +68,39 @@ } +void LaTeXFeatures::getAvailable() +{ + LyXLex lex(0, 0); + string real_file = LibFileSearch("", "packages.lst"); + + if (real_file.empty()) + return; + + lex.setFile(real_file); + + if (!lex.isOK()) + return; + + bool finished = false; + // Parse config-file + while (lex.isOK() && !finished) { + switch (lex.lex()) { + case LyXLex::LEX_FEOF: + finished = true; + break; + default: + string const name = lex.getString(); + PackagesList::const_iterator begin = packages_.begin(); + PackagesList::const_iterator end = packages_.end(); + if (find(begin, end, name) == end) + packages_.push_back(name); + } + } + + return; +} + + void LaTeXFeatures::useLayout(string const & layoutname) { // Some code to avoid loops in dependency definition @@ -108,6 +143,14 @@ bool LaTeXFeatures::isRequired(string const & name) const { return find(features_.begin(), features_.end(), name) != features_.end(); +} + + +bool LaTeXFeatures::isAvailable(string const & name) +{ + if (packages_.empty()) + getAvailable(); + return find(packages_.begin(), packages_.end(), name) != packages_.end(); } Index: LaTeXFeatures.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeXFeatures.h,v retrieving revision 1.58 diff -u -r1.58 LaTeXFeatures.h --- LaTeXFeatures.h 19 Jan 2005 15:03:27 -0000 1.58 +++ LaTeXFeatures.h 24 Jan 2005 12:37:53 -0000 @@ -62,8 +62,12 @@ void addExternalPreamble(std::string const &); /// Provide a string name-space to the requirements void require(std::string const & name); + /// Which of the required packages are installed? + void getAvailable(); /// Is the package required? bool isRequired(std::string const & name) const; + /// Is the (required) package available? + bool isAvailable(std::string const & name); /// void useFloat(std::string const & name); /// @@ -96,6 +100,10 @@ FeaturesList features_; /// FeaturesList preamble_snippets_; + /// The available (required) packages + typedef std::list<std::string> PackagesList; + /// + PackagesList packages_; /// typedef std::set<Language const *> LanguageList; /// Index: LyXAction.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.203 diff -u -r1.203 LyXAction.C --- LyXAction.C 27 Dec 2004 16:30:27 -0000 1.203 +++ LyXAction.C 24 Jan 2005 12:37:54 -0000 @@ -305,6 +305,7 @@ { LFUN_ESCAPE, "escape", ReadOnly }, { LFUN_TOOLTIPS_TOGGLE, "toggle-tooltips", NoBuffer }, { LFUN_TRACK_CHANGES, "track-changes", Noop }, + { LFUN_OUTPUT_CHANGES, "output-changes", Noop }, { LFUN_MERGE_CHANGES, "merge-changes", Noop }, { LFUN_ACCEPT_CHANGE, "accept-change", Noop }, { LFUN_REJECT_CHANGE, "reject-change", Noop }, Index: buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.606 diff -u -r1.606 buffer.C --- buffer.C 20 Jan 2005 21:34:22 -0000 1.606 +++ buffer.C 24 Jan 2005 12:37:57 -0000 @@ -139,7 +139,7 @@ namespace { -int const LYX_FORMAT = 239; +int const LYX_FORMAT = 240; } // namespace anon @@ -1185,7 +1185,8 @@ { LyXTextClass const & tclass = params().getLyXTextClass(); - if (params().tracking_changes) { + if (features.isAvailable("dvipost") && params().tracking_changes + && params().output_changes) { features.require("dvipost"); features.require("color"); } Index: bufferparams.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferparams.C,v retrieving revision 1.96 diff -u -r1.96 bufferparams.C --- bufferparams.C 19 Jan 2005 15:03:29 -0000 1.96 +++ bufferparams.C 24 Jan 2005 12:37:59 -0000 @@ -341,6 +341,7 @@ cite_engine = biblio::ENGINE_BASIC; use_bibtopic = false; tracking_changes = false; + output_changes = false; secnumdepth = 3; tocdepth = 3; language = default_language; @@ -508,6 +509,8 @@ lex >> use_bibtopic; } else if (token == "\\tracking_changes") { lex >> tracking_changes; + } else if (token == "\\output_changes") { + lex >> output_changes; } else if (token == "\\branch") { lex.next(); string branch = lex.getString(); @@ -711,6 +714,7 @@ } os << "\\tracking_changes " << convert<string>(tracking_changes) << "\n"; + os << "\\output_changes " << convert<string>(output_changes) << "\n"; if (tracking_changes) { AuthorList::Authors::const_iterator it = pimpl_->authorlist.begin(); @@ -1100,7 +1104,7 @@ lyxpreamble += "\\makeatother\n"; // dvipost settings come after everything else - if (tracking_changes) { + if (features.isAvailable("dvipost") && tracking_changes && output_changes) { lyxpreamble += "\\dvipostlayout\n" "\\dvipost{osstart color push Red}\n" Index: bufferparams.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferparams.h,v retrieving revision 1.53 diff -u -r1.53 bufferparams.h --- bufferparams.h 19 Jan 2005 15:03:29 -0000 1.53 +++ bufferparams.h 24 Jan 2005 12:37:59 -0000 @@ -209,6 +209,14 @@ bool use_bibtopic; /// revision tracking for this buffer ? bool tracking_changes; + /** This param decides if change tracking marks should be output + * (using the dvipost package) or if the current "state" of the + * document should be output instead. Since dvipost needs dvi + * specials, it only works with dvi/ps output (the param will be + * ignored with other output flavors and disabled when dbipost is + * not installed). + */ + bool output_changes; /// Time ago we agreed that this was a buffer property [ale990407] std::string parentname; /// Index: changes.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/changes.C,v retrieving revision 1.10 diff -u -r1.10 changes.C --- changes.C 5 Jan 2005 20:21:24 -0000 1.10 +++ changes.C 24 Jan 2005 12:38:00 -0000 @@ -495,11 +495,12 @@ int Changes::latexMarkChange(std::ostream & os, - Change::Type const old, Change::Type const change) + Change::Type const old, Change::Type const change, + bool const & output) { - if (old == change) + if (!output || old == change) return 0; - + string const start("\\changestart{}"); string const end("\\changeend{}"); string const son("\\overstrikeon{}"); Index: changes.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/changes.h,v retrieving revision 1.5 diff -u -r1.5 changes.h --- changes.h 19 Jan 2005 15:03:29 -0000 1.5 +++ changes.h 24 Jan 2005 12:38:01 -0000 @@ -89,7 +89,8 @@ /// output latex to mark a transition between two changetypes /// returns length of text outputted - static int latexMarkChange(std::ostream & os, Change::Type old, Change::Type change); + static int latexMarkChange(std::ostream & os, Change::Type old, + Change::Type change, bool const & output); /// output .lyx file format for transitions between changes static void lyxMarkChange(std::ostream & os, int & column, Index: lfuns.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v retrieving revision 1.39 diff -u -r1.39 lfuns.h --- lfuns.h 27 Dec 2004 16:30:27 -0000 1.39 +++ lfuns.h 24 Jan 2005 12:38:01 -0000 @@ -354,6 +354,7 @@ LFUN_PREVIOUSBUFFER, // 270 LFUN_WORDS_COUNT, + LFUN_OUTPUT_CHANGES, // jspitzm 20050121 LFUN_LASTACTION // end of the table }; Index: paragraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v retrieving revision 1.399 diff -u -r1.399 paragraph.C --- paragraph.C 6 Jan 2005 16:52:08 -0000 1.399 +++ paragraph.C 24 Jan 2005 12:38:04 -0000 @@ -27,6 +27,7 @@ #include "debug.h" #include "gettext.h" #include "language.h" +#include "LaTeXFeatures.h" #include "lyxfont.h" #include "lyxrc.h" #include "lyxrow.h" @@ -900,6 +901,15 @@ } LyXFont basefont; + + LaTeXFeatures features(buf, bparams, runparams.nice); + + // output change tracking marks only if desired, + // if dvipost is installed, + // and with dvi/ps (other formats don't work) + bool const output = bparams.output_changes + && runparams.flavor == OutputParams::LATEX + && features.isAvailable("dvipost"); // Maybe we have to create a optional argument. pos_type body_pos = beginOfBody(); @@ -1010,23 +1020,28 @@ Change::Type change = pimpl_->lookupChange(i); - column += Changes::latexMarkChange(os, running_change, change); + column += Changes::latexMarkChange(os, running_change, + change, output); running_change = change; - OutputParams rp = runparams; - rp.free_spacing = style->free_spacing; - rp.local_language = font.language()->babel(); - rp.intitle = style->intitle; - pimpl_->simpleTeXSpecialChars(buf, bparams, - os, texrow, rp, - font, running_font, - basefont, outerfont, open_font, - running_change, - *style, i, column, c); + // do not output text which is marked deleted + // if change tracking output is not desired + if (output || running_change != Change::DELETED) { + OutputParams rp = runparams; + rp.free_spacing = style->free_spacing; + rp.local_language = font.language()->babel(); + rp.intitle = style->intitle; + pimpl_->simpleTeXSpecialChars(buf, bparams, + os, texrow, rp, + font, running_font, + basefont, outerfont, open_font, + running_change, + *style, i, column, c); + } } column += Changes::latexMarkChange(os, - running_change, Change::UNCHANGED); + running_change, Change::UNCHANGED, output); // If we have an open font definition, we have to close it if (open_font) { Index: paragraph_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_pimpl.C,v retrieving revision 1.98 diff -u -r1.98 paragraph_pimpl.C --- paragraph_pimpl.C 26 Sep 2004 08:24:08 -0000 1.98 +++ paragraph_pimpl.C 24 Jan 2005 12:38:05 -0000 @@ -503,9 +503,17 @@ break; } + // output change tracking marks only if desired, + // if dvipost is installed, + // and with dvi/ps (other formats don't work) + LaTeXFeatures features(buf, bparams, runparams.nice); + bool const output = bparams.output_changes + && runparams.flavor == OutputParams::LATEX + && features.isAvailable("dvipost"); + if (inset->isTextInset()) { column += Changes::latexMarkChange(os, running_change, - Change::UNCHANGED); + Change::UNCHANGED, output); running_change = Change::UNCHANGED; }