3 * Read the file COPYING
7 * Full author contact details are available in file CREDITS
13 #pragma implementation
16 #include "tex_helpers.h"
21 #include "support/filetools.h"
22 #include "support/lstrings.h"
23 #include "support/systemcall.h"
24 #include "support/path.h"
25 #include "support/lyxalgo.h"
36 extern string user_lyxdir; // home of *Files.lst
40 vector<string> listWithoutPath(vector<string> & dbase)
42 vector<string>::iterator it = dbase.begin();
43 vector<string>::iterator end = dbase.end();
44 for (; it != end; ++it)
45 *it = OnlyFilename(*it);
51 // build filelists of all availabe bst/cls/sty-files. done through
52 // kpsewhich and an external script, saved in *Files.lst
53 void rescanTexStyles()
55 // Run rescan in user lyx directory
58 one.startscript(Systemcall::Wait,
59 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,
95 string const filename = getTexFileFromList(classname,type);
96 string optionList = string();
97 std::ifstream is(filename.c_str());
101 if (contains(s,"DeclareOption")) {
102 s = s.substr(s.find("DeclareOption"));
103 s = split(s,'{'); // cut front
104 s = token(s,'}',0); // cut end
105 optionList += (s + '\n');
112 string const getTexFileFromList(string const & file,
115 string const file_ = (type == "cls") ? file + ".cls" : file + ".sty";
117 lyxerr << "Search for classfile " << file_ << endl;
119 string const lstfile = (type == "cls") ? "clsFiles.lst" : "styFiles.lst";
120 string const allClasses = GetFileContents(LibFileSearch(string(), lstfile));
122 string classfile = token(allClasses, '\n', entries);
124 while ((!contains(classfile, file) ||
125 (OnlyFilename(classfile) != file)) &&
127 classfile = token(allClasses, '\n', ++entries);
130 // now we have filename with full path
131 lyxerr << "with full path: " << classfile << endl;