Angus Leeming wrote: > ..and what's a PackagesList? Is the compiler looking for > > LaTeXFeatures::PackagesList LaTeXFeatures::packages_; > > perhaps?
Umm. Thank you both. The static list works now. The only drawback (vs. non-static) is that you have to restart LyX to get packages.lst reparsed. But I think we can live with that. Attached is the final patch, including Georg's lyx2lyx changes (thanks!). I will apply soon. Regards, Jürgen
Index: development/FORMAT =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/development/FORMAT,v retrieving revision 1.34 diff -u -r1.34 FORMAT --- development/FORMAT 6 Jan 2005 16:52:07 -0000 1.34 +++ development/FORMAT 24 Jan 2005 16:23:55 -0000 @@ -1,6 +1,14 @@ LyX file-format changes ----------------------- +2005-01-23 Jürgen Spitzmüller <[EMAIL PROTECTED]> + + * format incremented to 240. + * new bufferparam: + \output_changes {true|false} + (should the change tracking marks be visible in the output or not?) + * lyx2lyx should just delete the param in 239. + 2005-01-06 José Matos <[EMAIL PROTECTED]> * format incremented to 239. Index: lib/lyx2lyx/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/ChangeLog,v retrieving revision 1.57 diff -u -r1.57 ChangeLog --- lib/lyx2lyx/ChangeLog 6 Jan 2005 18:32:44 -0000 1.57 +++ lib/lyx2lyx/ChangeLog 24 Jan 2005 16:24:26 -0000 @@ -1,3 +1,8 @@ +2005-01-24 Georg Baum <[EMAIL PROTECTED]> + + * LyX.py: format up to 240. + * lyx_1_4.py (convert_output_changes, revert_output_changes): new + 2005-01-06 José Matos <[EMAIL PROTECTED]> * lyx_1_4.py (normalize_paragraph_params): add start_of_appendix Index: lib/lyx2lyx/LyX.py =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/LyX.py,v retrieving revision 1.9 diff -u -r1.9 LyX.py --- lib/lyx2lyx/LyX.py 6 Jan 2005 16:52:07 -0000 1.9 +++ lib/lyx2lyx/LyX.py 24 Jan 2005 16:24:27 -0000 @@ -46,7 +46,7 @@ ("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]), ("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]), ("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3"]), - ("1_4", range(223,240), ["1.4.0cvs","1.4"])] + ("1_4", range(223,241), ["1.4.0cvs","1.4"])] def formats_list(): Index: lib/lyx2lyx/lyx_1_4.py =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/lyx_1_4.py,v retrieving revision 1.22 diff -u -r1.22 lyx_1_4.py --- lib/lyx2lyx/lyx_1_4.py 6 Jan 2005 18:32:44 -0000 1.22 +++ lib/lyx2lyx/lyx_1_4.py 24 Jan 2005 16:24:30 -0000 @@ -1534,6 +1534,24 @@ ## +# Add/remove output_changes parameter +# +def convert_output_changes (file): + i = find_token(file.header, '\\tracking_changes', 0) + if i == -1: + file.warning("Malformed lyx file: Missing '\\tracking_changes'.") + return + file.header.insert(i+1, '\\output_changes true') + + +def revert_output_changes (file): + i = find_token(file.header, '\\output_changes', 0) + if i == -1: + return + del file.header[i] + + +## # Convertion hub # @@ -1556,9 +1574,11 @@ normalize_papersize, strip_end_space]], [237, [use_x_boolean]], [238, [update_latexaccents]], - [239, [normalize_paragraph_params]]] + [239, [normalize_paragraph_params]], + [240, [convert_output_changes]]] -revert = [[238, []], +revert = [[239, [revert_output_changes]], + [238, []], [237, []], [236, [use_x_binary]], [235, [denormalize_papersize, remove_begin_body,remove_begin_header, Index: lib/ui/stdmenus.ui =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ui/stdmenus.ui,v retrieving revision 1.38 diff -u -r1.38 stdmenus.ui --- lib/ui/stdmenus.ui 15 Jan 2005 18:36:02 -0000 1.38 +++ lib/ui/stdmenus.ui 24 Jan 2005 16:24:31 -0000 @@ -372,6 +372,7 @@ Item "Merge Changes...|M" "merge-changes" Item "Accept All Changes|A" "accept-all-changes" Item "Reject All Changes|R" "reject-all-changes" + Item "Show changes in output|S" "output-changes" End # Index: src/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 --- src/BufferView_pimpl.C 10 Jan 2005 19:17:38 -0000 1.567 +++ src/BufferView_pimpl.C 24 Jan 2005 16:24:33 -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: src/LaTeXFeatures.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeXFeatures.C,v retrieving revision 1.115 diff -u -r1.115 LaTeXFeatures.C --- src/LaTeXFeatures.C 19 Jan 2005 11:44:29 -0000 1.115 +++ src/LaTeXFeatures.C 24 Jan 2005 16:24:34 -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; @@ -44,6 +46,9 @@ namespace biblio = lyx::biblio; +LaTeXFeatures::PackagesList LaTeXFeatures::packages_; + + LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, bool n) : buffer_(&b), params_(p), nice_(n) {} @@ -66,6 +71,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 +146,14 @@ bool LaTeXFeatures::isRequired(string const & name) const { return find(features_.begin(), features_.end(), name) != features_.end(); +} + + +bool LaTeXFeatures::isAvailable(string const & name) const +{ + if (packages_.empty()) + getAvailable(); + return find(packages_.begin(), packages_.end(), name) != packages_.end(); } Index: src/LaTeXFeatures.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeXFeatures.h,v retrieving revision 1.58 diff -u -r1.58 LaTeXFeatures.h --- src/LaTeXFeatures.h 19 Jan 2005 15:03:27 -0000 1.58 +++ src/LaTeXFeatures.h 24 Jan 2005 16:24:34 -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? + static void getAvailable(); /// Is the package required? bool isRequired(std::string const & name) const; + /// Is the (required) package available? + bool isAvailable(std::string const & name) const; /// 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; + /// + static PackagesList packages_; /// typedef std::set<Language const *> LanguageList; /// Index: src/LyXAction.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.203 diff -u -r1.203 LyXAction.C --- src/LyXAction.C 27 Dec 2004 16:30:27 -0000 1.203 +++ src/LyXAction.C 24 Jan 2005 16:24:35 -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: src/buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.606 diff -u -r1.606 buffer.C --- src/buffer.C 20 Jan 2005 21:34:22 -0000 1.606 +++ src/buffer.C 24 Jan 2005 16:24:37 -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: src/bufferparams.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferparams.C,v retrieving revision 1.96 diff -u -r1.96 bufferparams.C --- src/bufferparams.C 19 Jan 2005 15:03:29 -0000 1.96 +++ src/bufferparams.C 24 Jan 2005 16:24:39 -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: src/bufferparams.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferparams.h,v retrieving revision 1.53 diff -u -r1.53 bufferparams.h --- src/bufferparams.h 19 Jan 2005 15:03:29 -0000 1.53 +++ src/bufferparams.h 24 Jan 2005 16:24:39 -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: src/changes.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/changes.C,v retrieving revision 1.10 diff -u -r1.10 changes.C --- src/changes.C 5 Jan 2005 20:21:24 -0000 1.10 +++ src/changes.C 24 Jan 2005 16:24:40 -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: src/changes.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/changes.h,v retrieving revision 1.5 diff -u -r1.5 changes.h --- src/changes.h 19 Jan 2005 15:03:29 -0000 1.5 +++ src/changes.h 24 Jan 2005 16:24:41 -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: src/lfuns.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v retrieving revision 1.39 diff -u -r1.39 lfuns.h --- src/lfuns.h 27 Dec 2004 16:30:27 -0000 1.39 +++ src/lfuns.h 24 Jan 2005 16:24:41 -0000 @@ -354,6 +354,7 @@ LFUN_PREVIOUSBUFFER, // 270 LFUN_WORDS_COUNT, + LFUN_OUTPUT_CHANGES, // jspitzm 20050121 LFUN_LASTACTION // end of the table }; Index: src/paragraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v retrieving revision 1.399 diff -u -r1.399 paragraph.C --- src/paragraph.C 6 Jan 2005 16:52:08 -0000 1.399 +++ src/paragraph.C 24 Jan 2005 16:24:44 -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: src/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 --- src/paragraph_pimpl.C 26 Sep 2004 08:24:08 -0000 1.98 +++ src/paragraph_pimpl.C 24 Jan 2005 16:24:45 -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; }