3 * Copyright 1995-2002 the LyX Team
4 * Read the file COPYING
6 * \author Herbert Voss <voss@lyx.org>
16 #include "tex_helpers.h"
17 #include "support/filetools.h"
19 #include "support/lstrings.h"
20 #include "support/systemcall.h"
21 #include "support/path.h"
22 #include "support/lyxalgo.h"
28 extern string user_lyxdir; // home of *Files.lst
32 vector<string> listWithoutPath(vector<string> & dbase)
34 vector<string>::iterator it = dbase.begin();
35 vector<string>::iterator end = dbase.end();
36 for (; it != end; ++it)
37 *it = OnlyFilename(*it);
43 // build filelists of all availabe bst/cls/sty-files. done through
44 // kpsewhich and an external script, saved in *Files.lst
45 void rescanTexStyles()
47 // Run rescan in user lyx directory
50 one.startscript(Systemcall::Wait,
51 LibFileSearch("scripts", "TeXFiles.sh"));
58 // Run texhash in user lyx directory
61 //path to texhash through system
63 one.startscript(Systemcall::Wait,"texhash");
67 string const getTexFileList(string const & filename, bool withFullPath)
69 string const file = LibFileSearch("", filename);
73 vector<string> dbase =
74 getVectorFromString(GetFileContents(file), "\n");
76 lyx::eliminate_duplicates(dbase);
77 string const str_out = withFullPath ?
78 getStringFromVector(dbase, "\n") :
79 getStringFromVector(listWithoutPath(dbase), "\n");
84 string const getListOfOptions(string const & classname,
87 string const filename = getTexFileFromList(classname,type);
88 string optionList = string();
89 std::ifstream is(filename.c_str());
93 if (contains(s,"DeclareOption")) {
94 s = s.substr(s.find("DeclareOption"));
95 s = split(s,'{'); // cut front
96 s = token(s,'}',0); // cut end
97 optionList += (s + '\n');
104 string const getTexFileFromList(string const & file,
107 string const file_ = (type == "cls") ? file + ".cls" : file + ".sty";
109 lyxerr << "Search for classfile " << file_ << endl;
111 string const lstfile = (type == "cls") ? "clsFiles.lst" : "styFiles.lst";
112 string const allClasses = GetFileContents(LibFileSearch(string(), lstfile));
114 string classfile = token(allClasses, '\n', entries);
116 while ((!contains(classfile, file) ||
117 (OnlyFilename(classfile) != file)) &&
119 classfile = token(allClasses, '\n', ++entries);
122 // now we have filename with full path
123 lyxerr << "with full path: " << classfile << endl;