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
24 extern BufferList bufferlist;
27 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
28 : ControlCommand(lv, d, LFUN_REF_INSERT)
32 vector<string> const ControlRef::getLabelList(string const & name) const
34 Buffer const * buf = bufferlist.getBuffer(MakeAbsPath(name));
37 return buf->getLabelList();
41 void ControlRef::gotoRef(string const & ref)
43 lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
44 lyxfunc().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
48 void ControlRef::gotoBookmark()
50 lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
54 vector<string> const ControlRef::getBufferList() const
56 vector<string> buffers = bufferlist.getFileNames();
57 for (vector<string>::iterator it = buffers.begin();
58 it != buffers.end(); ++it) {
59 *it = MakeDisplayPath(*it);
66 int ControlRef::getBufferNum() const
68 vector<string> buffers = bufferlist.getFileNames();
69 string const name = buffer()->fileName();
70 vector<string>::const_iterator cit =
71 find(buffers.begin(), buffers.end(), name);
72 if (cit == buffers.end())
74 return int(cit - buffers.begin());
77 string const ControlRef::getBufferName(int num) const
79 return bufferlist.getFileNames()[num];