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