]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlTexinfo.C
Move the external dialog to the new scheme.
[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
14 #include "ControlTexinfo.h"
15
16 #include "helper_funcs.h"
17 #include "tex_helpers.h"
18
19 #include "frontends/Dialogs.h"
20 #include "frontends/LyXView.h"
21
22 #include "support/filetools.h" // FileSearch
23 #include "support/path.h"
24 #include "support/lstrings.h"
25
26 extern string user_lyxdir; // home of *Files.lst
27
28 namespace {
29
30 string getFileList(ControlTexinfo::texFileSuffix type, bool withFullPath)
31 {
32         switch (type) {
33             case ControlTexinfo::bst:
34                 return getTexFileList("bstFiles.lst", withFullPath);
35                 break;
36             case ControlTexinfo::cls:
37                 return getTexFileList("clsFiles.lst", withFullPath);
38                 break;
39             case ControlTexinfo::sty:
40                 return getTexFileList("styFiles.lst", withFullPath);
41                 break;
42         }
43         return string();
44 }
45
46 } // namespace anon
47
48
49 ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
50         : ControlDialogBI(lv, d)
51 {}
52
53
54 // build filelists of all availabe bst/cls/sty-files. done through
55 // kpsewhich and an external script, saved in *Files.lst
56 void ControlTexinfo::rescanStyles() const
57 {
58     rescanTexStyles();
59 }
60
61
62 void ControlTexinfo::runTexhash() const
63 {
64     texhash();
65 }
66
67
68 string const
69 ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const
70 {
71         string list(getFileList(type, withFullPath));
72
73         // initial scan
74         if (list.empty()) {
75                 rescanStyles();
76                 list = getFileList(type, withFullPath);
77         }
78         return list;
79 }
80
81
82 void ControlTexinfo::viewFile(string const filename) const
83 {
84         lv_.getDialogs().showFile(filename);
85 }
86
87
88 string const ControlTexinfo::getClassOptions(string const & filename) const
89 {
90         return getListOfOptions(filename, "cls");
91 }