]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlRef.C
Pragmatic pimpl-ing of BufferParams.
[lyx.git] / src / frontends / controllers / ControlRef.C
1 /**
2  * \file ControlRef.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13
14 #include "ControlRef.h"
15 #include "buffer.h"
16 #include "bufferlist.h"
17 #include "funcrequest.h"
18
19 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
20
21 using namespace lyx::support;
22
23 using std::vector;
24
25 extern BufferList bufferlist;
26
27
28 ControlRef::ControlRef(Dialog & d)
29         : ControlCommand(d, "ref")
30 {}
31
32
33 vector<string> const ControlRef::getLabelList(string const & name) const
34 {
35         Buffer const & buf = *bufferlist.getBuffer(MakeAbsPath(name));
36         vector<string> list;
37         buf.getLabelList(list);
38         return list;
39 }
40
41
42 void ControlRef::gotoRef(string const & ref)
43 {
44         kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
45         kernel().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
46 }
47
48
49 void ControlRef::gotoBookmark()
50 {
51         kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
52 }
53
54
55 vector<string> const ControlRef::getBufferList() const
56 {
57         vector<string> buffers = bufferlist.getFileNames();
58         for (vector<string>::iterator it = buffers.begin();
59              it != buffers.end(); ++it) {
60                 *it = MakeDisplayPath(*it);
61         }
62
63         return buffers;
64 }
65
66
67 int ControlRef::getBufferNum() const
68 {
69         vector<string> buffers = bufferlist.getFileNames();
70         string const name = kernel().buffer().fileName();
71         vector<string>::const_iterator cit =
72                 find(buffers.begin(), buffers.end(), name);
73         if (cit == buffers.end())
74                 return 0;
75         return int(cit - buffers.begin());
76 }
77
78 string const ControlRef::getBufferName(int num) const
79 {
80         return bufferlist.getFileNames()[num];
81 }