3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
17 #include "tex_helpers.h"
22 #include "support/filetools.h"
23 #include "support/lstrings.h"
24 #include "support/systemcall.h"
25 #include "support/path.h"
26 #include "support/lyxalgo.h"
37 extern string user_lyxdir; // home of *Files.lst
41 vector<string> listWithoutPath(vector<string> & dbase)
43 vector<string>::iterator it = dbase.begin();
44 vector<string>::iterator end = dbase.end();
45 for (; it != end; ++it)
46 *it = OnlyFilename(*it);
52 // build filelists of all availabe bst/cls/sty-files. done through
53 // kpsewhich and an external script, saved in *Files.lst
54 void rescanTexStyles()
56 // Run rescan in user lyx directory
59 one.startscript(Systemcall::Wait,
60 LibFileSearch("scripts", "TeXFiles.sh"));
67 // Run texhash in user lyx directory
70 //path to texhash through system
72 one.startscript(Systemcall::Wait,"texhash");
76 string const getTexFileList(string const & filename, bool withFullPath)
78 string const file = LibFileSearch("", filename);
82 vector<string> dbase =
83 getVectorFromString(GetFileContents(file), "\n");
85 lyx::eliminate_duplicates(dbase);
86 string const str_out = withFullPath ?
87 getStringFromVector(dbase, "\n") :
88 getStringFromVector(listWithoutPath(dbase), "\n");
93 string const getListOfOptions(string const & classname,
96 string const filename = getTexFileFromList(classname,type);
97 string optionList = string();
98 std::ifstream is(filename.c_str());
102 if (contains(s,"DeclareOption")) {
103 s = s.substr(s.find("DeclareOption"));
104 s = split(s,'{'); // cut front
105 s = token(s,'}',0); // cut end
106 optionList += (s + '\n');
113 string const getTexFileFromList(string const & file,
116 string const file_ = (type == "cls") ? file + ".cls" : file + ".sty";
118 lyxerr << "Search for classfile " << file_ << endl;
120 string const lstfile = (type == "cls") ? "clsFiles.lst" : "styFiles.lst";
121 string const allClasses = GetFileContents(LibFileSearch(string(), lstfile));
123 string classfile = token(allClasses, '\n', entries);
125 while ((!contains(classfile, file) ||
126 (OnlyFilename(classfile) != file)) &&
128 classfile = token(allClasses, '\n', ++entries);
131 // now we have filename with full path
132 lyxerr << "with full path: " << classfile << endl;