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"
17 #include "bufferlist.h"
18 #include "funcrequest.h"
20 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
22 using namespace lyx::support;
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 = kernel().buffer();
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];