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 "bufferlist.h"
23 #include "funcrequest.h"
25 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
29 extern BufferList bufferlist;
32 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
33 : ControlCommand(lv, d, LFUN_REF_INSERT)
37 vector<string> const ControlRef::getLabelList(string const & name) const
39 Buffer * buffer = bufferlist.getBuffer(MakeAbsPath(name));
41 buffer = lv_.buffer();
42 return buffer->getLabelList();
46 void ControlRef::gotoRef(string const & ref) const
48 lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
49 lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_REF_GOTO, ref));
53 void ControlRef::gotoBookmark() const
55 lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
59 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 = lv_.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];