1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2001 The LyX Team.
8 * ======================================================
11 * \author Angus Leeming <leeming@lyx.org>
17 #pragma implementation
20 #include "ControlRef.h"
23 #include "bufferlist.h"
24 #include "funcrequest.h"
26 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
30 extern BufferList bufferlist;
33 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
34 : ControlCommand(lv, d, LFUN_REF_INSERT)
38 vector<string> const ControlRef::getLabelList(string const & name) const
40 Buffer const * buf = bufferlist.getBuffer(MakeAbsPath(name));
43 return buf->getLabelList();
47 void ControlRef::gotoRef(string const & ref)
49 lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
50 lyxfunc().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
54 void ControlRef::gotoBookmark()
56 lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
60 vector<string> const ControlRef::getBufferList() const
62 vector<string> buffers = bufferlist.getFileNames();
63 for (vector<string>::iterator it = buffers.begin();
64 it != buffers.end(); ++it) {
65 *it = MakeDisplayPath(*it);
72 int ControlRef::getBufferNum() const
74 vector<string> buffers = bufferlist.getFileNames();
75 string const name = buffer()->fileName();
76 vector<string>::const_iterator cit =
77 find(buffers.begin(), buffers.end(), name);
78 if (cit == buffers.end())
80 return int(cit - buffers.begin());
83 string const ControlRef::getBufferName(int num) const
85 return bufferlist.getFileNames()[num];