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;
28 extern BufferList bufferlist;
31 ControlRef::ControlRef(Dialog & d)
32 : ControlCommand(d, "ref")
36 vector<string> const ControlRef::getLabelList(string const & name) const
38 Buffer const & buf = *bufferlist.getBuffer(MakeAbsPath(name));
40 buf.getLabelList(list);
45 void ControlRef::gotoRef(string const & ref)
47 kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
48 kernel().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
52 void ControlRef::gotoBookmark()
54 kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
58 vector<string> const ControlRef::getBufferList() const
60 vector<string> buffers = bufferlist.getFileNames();
61 for (vector<string>::iterator it = buffers.begin();
62 it != buffers.end(); ++it) {
63 *it = MakeDisplayPath(*it);
70 int ControlRef::getBufferNum() const
72 vector<string> buffers = bufferlist.getFileNames();
73 string const name = kernel().buffer().fileName();
74 vector<string>::const_iterator cit =
75 find(buffers.begin(), buffers.end(), name);
76 if (cit == buffers.end())
78 return int(cit - buffers.begin());
81 string const ControlRef::getBufferName(int num) const
83 return bufferlist.getFileNames()[num];