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 vector<string> dbase = getVectorFromString(
70 GetFileContents(LibFileSearch(string(),filename)), "\n");
71 lyx::eliminate_duplicates(dbase);
72 string const str_out = withFullPath ?
73 getStringFromVector(dbase, "\n") :
74 getStringFromVector(listWithoutPath(dbase), "\n");
77 return _("Missing filelist. try Rescan");
82 string const getListOfOptions(string const & classname,
85 string const filename = getTexFileFromList(classname,type);
86 string optionList = string();
87 std::ifstream is(filename.c_str());
91 if (contains(s,"DeclareOption")) {
92 s = s.substr(s.find("DeclareOption"));
93 s = split(s,'{'); // cut front
94 s = token(s,'}',0); // cut end
95 // FIXME: why is this commented out ?
96 // s = s.substr(0, s.find('}')+1); // format entry
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;