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 namespace lyx::support;
25 extern BufferList bufferlist;
28 ControlRef::ControlRef(Dialog & d)
29 : ControlCommand(d, "ref")
33 vector<string> const ControlRef::getLabelList(string const & name) const
35 Buffer const & buf = *bufferlist.getBuffer(MakeAbsPath(name));
37 buf.getLabelList(list);
42 void ControlRef::gotoRef(string const & ref)
44 kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
45 kernel().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
49 void ControlRef::gotoBookmark()
51 kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
55 vector<string> const ControlRef::getBufferList() const
57 vector<string> buffers = bufferlist.getFileNames();
58 for (vector<string>::iterator it = buffers.begin();
59 it != buffers.end(); ++it) {
60 *it = MakeDisplayPath(*it);
67 int ControlRef::getBufferNum() const
69 vector<string> buffers = bufferlist.getFileNames();
70 string const name = kernel().buffer().fileName();
71 vector<string>::const_iterator cit =
72 find(buffers.begin(), buffers.end(), name);
73 if (cit == buffers.end())
75 return int(cit - buffers.begin());
78 string const ControlRef::getBufferName(int num) const
80 return bufferlist.getFileNames()[num];