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 #pragma implementation
17 #include "ControlRef.h"
20 #include "bufferlist.h"
21 #include "funcrequest.h"
23 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
27 extern BufferList bufferlist;
30 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
31 : ControlCommand(lv, d, LFUN_REF_INSERT)
35 vector<string> const ControlRef::getLabelList(string const & name) const
37 Buffer const * buf = bufferlist.getBuffer(MakeAbsPath(name));
40 return buf->getLabelList();
44 void ControlRef::gotoRef(string const & ref)
46 lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
47 lyxfunc().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
51 void ControlRef::gotoBookmark()
53 lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
57 vector<string> const ControlRef::getBufferList() const
59 vector<string> buffers = bufferlist.getFileNames();
60 for (vector<string>::iterator it = buffers.begin();
61 it != buffers.end(); ++it) {
62 *it = MakeDisplayPath(*it);
69 int ControlRef::getBufferNum() const
71 vector<string> buffers = bufferlist.getFileNames();
72 string const name = buffer()->fileName();
73 vector<string>::const_iterator cit =
74 find(buffers.begin(), buffers.end(), name);
75 if (cit == buffers.end())
77 return int(cit - buffers.begin());
80 string const ControlRef::getBufferName(int num) const
82 return bufferlist.getFileNames()[num];