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