]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlRef.C
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / ControlRef.C
1 /**
2  * \file ControlRef.C
3  * See the file COPYING.
4  *
5  * \author Angus Leeming
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 "ControlRef.h"
17 #include "lyxfunc.h"
18 #include "buffer.h"
19 #include "bufferlist.h"
20 #include "funcrequest.h"
21
22 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
23
24 using std::vector;
25
26 extern BufferList bufferlist;
27
28
29 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
30         : ControlCommand(lv, d, LFUN_REF_INSERT)
31 {}
32
33
34 vector<string> const ControlRef::getLabelList(string const & name) const
35 {
36         Buffer const * buf = bufferlist.getBuffer(MakeAbsPath(name));
37         if (!buf)
38                 buf = buffer();
39         return buf->getLabelList();
40 }
41
42
43 void ControlRef::gotoRef(string const & ref)
44 {
45         lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
46         lyxfunc().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
47 }
48
49
50 void ControlRef::gotoBookmark()
51 {
52         lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
53 }
54
55
56 vector<string> const ControlRef::getBufferList() const
57 {
58         vector<string> buffers = bufferlist.getFileNames();
59         for (vector<string>::iterator it = buffers.begin();
60              it != buffers.end(); ++it) {
61                 *it = MakeDisplayPath(*it);
62         }
63
64         return buffers;
65 }
66
67
68 int ControlRef::getBufferNum() const
69 {
70         vector<string> buffers = bufferlist.getFileNames();
71         string const name = buffer()->fileName();
72         vector<string>::const_iterator cit =
73                 find(buffers.begin(), buffers.end(), name);
74         if (cit == buffers.end())
75                 return 0;
76         return int(cit - buffers.begin());
77 }
78
79 string const ControlRef::getBufferName(int num) const
80 {
81         return bufferlist.getFileNames()[num];
82 }