]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlTexinfo.C
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / ControlTexinfo.C
1 /**
2  * \file ControlTexinfo.C
3  * See the file COPYING.
4  *
5  * \author Herbert Voss
6  *
7  * Full author contact details are available in file CREDITS
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "ControlTexinfo.h"
17
18 #include "helper_funcs.h"
19 #include "tex_helpers.h"
20
21 #include "frontends/Dialogs.h"
22 #include "frontends/LyXView.h"
23
24 #include "support/filetools.h" // FileSearch
25 #include "support/path.h"
26 #include "support/lstrings.h"
27
28 extern string user_lyxdir; // home of *Files.lst
29
30 namespace {
31
32 string getFileList(ControlTexinfo::texFileSuffix type, bool withFullPath)
33 {
34         switch (type) {
35             case ControlTexinfo::bst: 
36                 return getTexFileList("bstFiles.lst", withFullPath);
37                 break;
38             case ControlTexinfo::cls:
39                 return getTexFileList("clsFiles.lst", withFullPath);
40                 break;
41             case ControlTexinfo::sty:
42                 return getTexFileList("styFiles.lst", withFullPath);
43                 break;
44         }
45         return string();
46 }
47  
48 }
49
50 ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
51         : ControlDialogBI(lv, d)
52 {}
53
54
55 // build filelists of all availabe bst/cls/sty-files. done through
56 // kpsewhich and an external script, saved in *Files.lst
57 void ControlTexinfo::rescanStyles() const
58 {
59     rescanTexStyles();
60 }
61
62
63 void ControlTexinfo::runTexhash() const
64 {
65     texhash();
66 }
67
68
69 string const
70 ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const
71 {
72         string list(getFileList(type, withFullPath));
73
74         // initial scan
75         if (list.empty()) {
76                 rescanStyles();
77                 list = getFileList(type, withFullPath);
78         }
79         return list;
80 }
81
82
83 void ControlTexinfo::viewFile(string const filename) const
84 {
85         lv_.getDialogs().showFile(filename);
86 }
87
88
89 string const ControlTexinfo::getClassOptions(string const & filename) const
90 {
91         return getListOfOptions(filename, "cls");
92 }