3 * Copyright 1995-2002 the LyX Team
4 * Read the file COPYING
6 * \author Herbert Voss <voss@lyx.org>
12 #pragma implementation
15 #include "tex_helpers.h"
20 #include "support/filetools.h"
21 #include "support/lstrings.h"
22 #include "support/systemcall.h"
23 #include "support/path.h"
24 #include "support/lyxalgo.h"
35 extern string user_lyxdir; // home of *Files.lst
39 vector<string> listWithoutPath(vector<string> & dbase)
41 vector<string>::iterator it = dbase.begin();
42 vector<string>::iterator end = dbase.end();
43 for (; it != end; ++it)
44 *it = OnlyFilename(*it);
50 // build filelists of all availabe bst/cls/sty-files. done through
51 // kpsewhich and an external script, saved in *Files.lst
52 void rescanTexStyles()
54 // Run rescan in user lyx directory
57 one.startscript(Systemcall::Wait,
58 LibFileSearch("scripts", "TeXFiles.sh"));
65 // Run texhash in user lyx directory
68 //path to texhash through system
70 one.startscript(Systemcall::Wait,"texhash");
74 string const getTexFileList(string const & filename, bool withFullPath)
76 string const file = LibFileSearch("", filename);
80 vector<string> dbase =
81 getVectorFromString(GetFileContents(file), "\n");
83 lyx::eliminate_duplicates(dbase);
84 string const str_out = withFullPath ?
85 getStringFromVector(dbase, "\n") :
86 getStringFromVector(listWithoutPath(dbase), "\n");
91 string const getListOfOptions(string const & classname,
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 = (type == "cls") ? "clsFiles.lst" : "styFiles.lst";
119 string const allClasses = GetFileContents(LibFileSearch(string(), lstfile));
121 string classfile = token(allClasses, '\n', entries);
123 while ((!contains(classfile, file) ||
124 (OnlyFilename(classfile) != file)) &&
126 classfile = token(allClasses, '\n', ++entries);
129 // now we have filename with full path
130 lyxerr << "with full path: " << classfile << endl;