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
30 using support::makeAbsPath;
31 using support::makeDisplayPath;
35 ControlRef::ControlRef(Dialog & d)
36 : ControlCommand(d, "ref", "ref")
40 vector<docstring> const ControlRef::getLabelList(string const & name) const
42 Buffer const & buf = *theBufferList().getBuffer(makeAbsPath(name).absFilename());
43 vector<docstring> list;
44 buf.getLabelList(list);
49 void ControlRef::gotoRef(string const & ref)
51 dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
52 dispatch(FuncRequest(LFUN_LABEL_GOTO, ref));
56 void ControlRef::gotoBookmark()
58 dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"));
62 vector<string> const ControlRef::getBufferList() const
64 vector<string> buffers = theBufferList().getFileNames();
65 for (vector<string>::iterator it = buffers.begin();
66 it != buffers.end(); ++it) {
67 *it = lyx::to_utf8(makeDisplayPath(*it));
74 int ControlRef::getBufferNum() const
76 vector<string> buffers = theBufferList().getFileNames();
77 string const name = buffer().fileName();
78 vector<string>::const_iterator cit =
79 find(buffers.begin(), buffers.end(), name);
80 if (cit == buffers.end())
82 return int(cit - buffers.begin());
85 string const ControlRef::getBufferName(int num) const
87 return theBufferList().getFileNames()[num];
90 } // namespace frontend