3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
14 #include "ControlRef.h"
16 #include "bufferlist.h"
17 #include "funcrequest.h"
19 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
21 using lyx::support::MakeAbsPath;
22 using lyx::support::MakeDisplayPath;
26 extern BufferList bufferlist;
29 ControlRef::ControlRef(Dialog & d)
30 : ControlCommand(d, "ref")
34 vector<string> const ControlRef::getLabelList(string const & name) const
36 Buffer const & buf = *bufferlist.getBuffer(MakeAbsPath(name));
38 buf.getLabelList(list);
43 void ControlRef::gotoRef(string const & ref)
45 kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
46 kernel().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
50 void ControlRef::gotoBookmark()
52 kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
56 vector<string> const ControlRef::getBufferList() const
58 vector<string> buffers = bufferlist.getFileNames();
59 for (vector<string>::iterator it = buffers.begin();
60 it != buffers.end(); ++it) {
61 *it = MakeDisplayPath(*it);
68 int ControlRef::getBufferNum() const
70 vector<string> buffers = bufferlist.getFileNames();
71 string const name = kernel().buffer().fileName();
72 vector<string>::const_iterator cit =
73 find(buffers.begin(), buffers.end(), name);
74 if (cit == buffers.end())
76 return int(cit - buffers.begin());
79 string const ControlRef::getBufferName(int num) const
81 return bufferlist.getFileNames()[num];