1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2001 The LyX Team.
8 * ======================================================
11 * \author Angus Leeming <a.leeming@ic.ac.uk>
17 #pragma implementation
20 #include "ControlRef.h"
22 #include "ButtonControllerBase.h"
26 #include "bufferlist.h"
29 #include "frontends/LyXView.h"
31 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
33 #include <boost/bind.hpp>
40 extern BufferList bufferlist;
42 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
43 : ControlCommand(lv, d, LFUN_REF_INSERT)
45 d_.showRef = boost::bind(&ControlRef::showInset, this, _1);
46 d_.createRef = boost::bind(&ControlRef::createInset, this, _1);
50 vector<string> const ControlRef::getLabelList(string const & name) const
52 Buffer * buffer = bufferlist.getBuffer(MakeAbsPath(name));
54 buffer = lv_.buffer();
55 return buffer->getLabelList();
59 void ControlRef::gotoRef(string const & ref) const
61 lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, "0");
62 lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref);
66 void ControlRef::gotoBookmark() const
68 lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, "0");
72 vector<string> const ControlRef::getBufferList() const
75 vector<string> buffers = bufferlist.getFileNames();
76 for (vector<string>::iterator it = buffers.begin();
77 it != buffers.end(); ++it) {
78 *it = MakeDisplayPath(*it);
85 int ControlRef::getBufferNum() const
87 vector<string> buffers = bufferlist.getFileNames();
88 string const name = lv_.buffer()->fileName();
89 vector<string>::const_iterator cit =
90 find(buffers.begin(), buffers.end(), name);
91 if (cit == buffers.end())
93 return int(cit - buffers.begin());
96 string const ControlRef::getBufferName(int num) const
98 return bufferlist.getFileNames()[num];