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
25 extern BufferList bufferlist;
29 using support::MakeAbsPath;
30 using support::MakeDisplayPath;
34 ControlRef::ControlRef(Dialog & d)
35 : ControlCommand(d, "ref")
39 vector<string> const ControlRef::getLabelList(string const & name) const
41 Buffer const & buf = *bufferlist.getBuffer(MakeAbsPath(name));
43 buf.getLabelList(list);
48 void ControlRef::gotoRef(string const & ref)
50 kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
51 kernel().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
55 void ControlRef::gotoBookmark()
57 kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
61 vector<string> const ControlRef::getBufferList() const
63 vector<string> buffers = bufferlist.getFileNames();
64 for (vector<string>::iterator it = buffers.begin();
65 it != buffers.end(); ++it) {
66 *it = MakeDisplayPath(*it);
73 int ControlRef::getBufferNum() const
75 vector<string> buffers = bufferlist.getFileNames();
76 string const name = kernel().buffer().fileName();
77 vector<string>::const_iterator cit =
78 find(buffers.begin(), buffers.end(), name);
79 if (cit == buffers.end())
81 return int(cit - buffers.begin());
84 string const ControlRef::getBufferName(int num) const
86 return bufferlist.getFileNames()[num];
89 } // namespace frontend