X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FModuleList.cpp;h=e53af9b7e9f98d12dc315eefdcc17571cdbb5641;hb=2f271f61bcd514da3ab5b44d2b7bf61e12ac0c44;hp=0b88a8e8f24d1fcb881a1682c0796f335b814a34;hpb=5faad9ca68779c2a9f03a6ad0986ec1d7be6b5ec;p=lyx.git diff --git a/src/ModuleList.cpp b/src/ModuleList.cpp index 0b88a8e8f2..e53af9b7e9 100644 --- a/src/ModuleList.cpp +++ b/src/ModuleList.cpp @@ -13,16 +13,15 @@ #include "ModuleList.h" -#include "support/debug.h" #include "LaTeXFeatures.h" #include "Lexer.h" +#include "support/debug.h" #include "support/FileName.h" #include "support/filetools.h" #include "support/lstrings.h" #include -#include using namespace std; using namespace lyx::support; @@ -34,13 +33,15 @@ namespace lyx { ModuleList moduleList; -LyXModule::LyXModule(string const & n, string const & f, +LyXModule::LyXModule(string const & n, string const & i, string const & d, vector const & p, vector const & r, vector const & e): - name(n), filename(f), description(d), + name(n), id(i), description(d), packageList(p), requiredModules(r), excludedModules(e), checked(false) -{} +{ + filename = id + ".module"; +} bool LyXModule::isAvailable() { @@ -74,34 +75,30 @@ public: }; -//Much of this is borrowed from TextClassList::read() +//Much of this is borrowed from LayoutFileList::read() bool ModuleList::load() { FileName const real_file = libFileSearch("", "lyxmodules.lst"); LYXERR(Debug::TCLASS, "Reading modules from `" << real_file << '\''); if (real_file.empty()) { - lyxerr << "ModuleList::load(): unable to find " - "modules file `" - << to_utf8(makeDisplayPath(real_file.absFilename(), 1000)) - << "'.\nNo modules will be available." << endl; + LYXERR0("unable to find modules file `" + << to_utf8(makeDisplayPath(real_file.absFilename(), 1000)) + << "'.\nNo modules will be available."); return false; } - Lexer lex(0, 0); + Lexer lex; if (!lex.setFile(real_file)) { - lyxerr << "ModuleList::load():" - "lyxlex was not able to set file: " - << real_file << ".\nNo modules will be available." << endl; + LYXERR0("lyxlex was not able to set file: " + << real_file << ".\nNo modules will be available."); return false; } if (!lex.isOK()) { - lyxerr << "ModuleList::load():" << - "unable to open modules file `" - << to_utf8(makeDisplayPath(real_file.absFilename(), 1000)) - << "'\nNo modules will be available." - << endl; + LYXERR0("unable to open modules file `" + << to_utf8(makeDisplayPath(real_file.absFilename(), 1000)) + << "'\nNo modules will be available."); return false; } @@ -204,7 +201,7 @@ LyXModuleList::iterator ModuleList::end() } -LyXModule * ModuleList::operator[](string const & str) +LyXModule * ModuleList::getModuleByName(string const & str) { LyXModuleList::iterator it = modlist_.begin(); for (; it != modlist_.end(); ++it) @@ -215,4 +212,15 @@ LyXModule * ModuleList::operator[](string const & str) return 0; } +LyXModule * ModuleList::operator[](string const & str) +{ + LyXModuleList::iterator it = modlist_.begin(); + for (; it != modlist_.end(); ++it) + if (it->getID() == str) { + LyXModule & mod = *it; + return &mod; + } + return 0; +} + } // namespace lyx