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.
13 #include "ControlRef.h"
16 #include "BufferList.h"
17 #include "FuncRequest.h"
19 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
21 #include <boost/filesystem/operations.hpp>
31 using support::makeAbsPath;
32 using support::makeDisplayPath;
36 ControlRef::ControlRef(Dialog & d)
37 : ControlCommand(d, "ref")
41 vector<docstring> const ControlRef::getLabelList(string const & name) const
43 Buffer const & buf = *theBufferList().getBuffer(makeAbsPath(name).absFilename());
44 vector<docstring> list;
45 buf.getLabelList(list);
50 void ControlRef::gotoRef(string const & ref)
52 dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
53 dispatch(FuncRequest(LFUN_LABEL_GOTO, ref));
57 void ControlRef::gotoBookmark()
59 dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"));
63 vector<string> const ControlRef::getBufferList() const
65 vector<string> buffers = theBufferList().getFileNames();
66 for (vector<string>::iterator it = buffers.begin();
67 it != buffers.end(); ++it) {
68 *it = lyx::to_utf8(makeDisplayPath(*it));
75 int ControlRef::getBufferNum() const
77 vector<string> buffers = theBufferList().getFileNames();
78 string const name = buffer().fileName();
79 vector<string>::const_iterator cit =
80 find(buffers.begin(), buffers.end(), name);
81 if (cit == buffers.end())
83 return int(cit - buffers.begin());
86 string const ControlRef::getBufferName(int num) const
88 return theBufferList().getFileNames()[num];
91 } // namespace frontend