3 * Copyright 1995-2002 the LyX Team
4 * Read the file COPYING
6 * \author Herbert Voss <voss@lyx.org>
11 #include "tex_helpers.h"
16 #include "support/filetools.h"
17 #include "support/lstrings.h"
18 #include "support/systemcall.h"
19 #include "support/path.h"
20 #include "support/lyxalgo.h"
31 extern string user_lyxdir; // home of *Files.lst
35 vector<string> listWithoutPath(vector<string> & dbase)
37 vector<string>::iterator it = dbase.begin();
38 vector<string>::iterator end = dbase.end();
39 for (; it != end; ++it)
40 *it = OnlyFilename(*it);
46 // build filelists of all availabe bst/cls/sty-files. done through
47 // kpsewhich and an external script, saved in *Files.lst
48 void rescanTexStyles()
50 // Run rescan in user lyx directory
53 one.startscript(Systemcall::Wait,
54 LibFileSearch("scripts", "TeXFiles.sh"));
61 // Run texhash in user lyx directory
64 //path to texhash through system
66 one.startscript(Systemcall::Wait,"texhash");
70 string const getTexFileList(string const & filename, bool withFullPath)
72 string const file = LibFileSearch("", filename);
76 vector<string> dbase =
77 getVectorFromString(GetFileContents(file), "\n");
79 lyx::eliminate_duplicates(dbase);
80 string const str_out = withFullPath ?
81 getStringFromVector(dbase, "\n") :
82 getStringFromVector(listWithoutPath(dbase), "\n");
87 string const getListOfOptions(string const & classname,
90 string const filename = getTexFileFromList(classname,type);
91 string optionList = string();
92 std::ifstream is(filename.c_str());
96 if (contains(s,"DeclareOption")) {
97 s = s.substr(s.find("DeclareOption"));
98 s = split(s,'{'); // cut front
99 s = token(s,'}',0); // cut end
100 optionList += (s + '\n');
107 string const getTexFileFromList(string const & file,
110 string const file_ = (type == "cls") ? file + ".cls" : file + ".sty";
112 lyxerr << "Search for classfile " << file_ << endl;
114 string const lstfile = (type == "cls") ? "clsFiles.lst" : "styFiles.lst";
115 string const allClasses = GetFileContents(LibFileSearch(string(), lstfile));
117 string classfile = token(allClasses, '\n', entries);
119 while ((!contains(classfile, file) ||
120 (OnlyFilename(classfile) != file)) &&
122 classfile = token(allClasses, '\n', ++entries);
125 // now we have filename with full path
126 lyxerr << "with full path: " << classfile << endl;