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"));
66 // Run texhash in user lyx directory
69 //path to texhash through system
71 one.startscript(Systemcall::Wait,"texhash");
75 string const getTexFileList(string const & filename, bool withFullPath)
77 string const file = LibFileSearch("", filename);
81 vector<string> dbase =
82 getVectorFromString(GetFileContents(file), "\n");
84 lyx::eliminate_duplicates(dbase);
85 string const str_out = withFullPath ?
86 getStringFromVector(dbase, "\n") :
87 getStringFromVector(listWithoutPath(dbase), "\n");
92 string const getListOfOptions(string const & classname, string const & type)
94 string const filename = getTexFileFromList(classname,type);
95 string optionList = string();
96 std::ifstream is(filename.c_str());
100 if (contains(s,"DeclareOption")) {
101 s = s.substr(s.find("DeclareOption"));
102 s = split(s,'{'); // cut front
103 s = token(s,'}',0); // cut end
104 optionList += (s + '\n');
111 string const getTexFileFromList(string const & file,
114 string const file_ = (type == "cls") ? file + ".cls" : file + ".sty";
116 lyxerr << "Search for classfile " << file_ << endl;
118 string const lstfile =
119 ((type == "cls") ? "clsFiles.lst" : "styFiles.lst");
120 string const allClasses = GetFileContents(LibFileSearch(string(),
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;