]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlTexinfo.C
fix rbearing
[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 }
50
51 ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
52         : ControlDialogBI(lv, d)
53 {}
54
55
56 // build filelists of all availabe bst/cls/sty-files. done through
57 // kpsewhich and an external script, saved in *Files.lst
58 void ControlTexinfo::rescanStyles() const
59 {
60     rescanTexStyles();
61 }
62
63
64 void ControlTexinfo::runTexhash() const
65 {
66     texhash();
67 }
68
69
70 string const
71 ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const
72 {
73         string list(getFileList(type, withFullPath));
74
75         // initial scan
76         if (list.empty()) {
77                 rescanStyles();
78                 list = getFileList(type, withFullPath);
79         }
80         return list;
81 }
82
83
84 void ControlTexinfo::viewFile(string const filename) const
85 {
86         lv_.getDialogs().showFile(filename);
87 }
88
89
90 string const ControlTexinfo::getClassOptions(string const & filename) const
91 {
92         return getListOfOptions(filename, "cls");
93 }