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"
24 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
28 extern BufferList bufferlist;
31 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
32 : ControlCommand(lv, d, LFUN_REF_INSERT)
36 vector<string> const ControlRef::getLabelList(string const & name) const
38 Buffer * buffer = bufferlist.getBuffer(MakeAbsPath(name));
40 buffer = lv_.buffer();
41 return buffer->getLabelList();
45 void ControlRef::gotoRef(string const & ref) const
47 lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, string("0"));
48 lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref);
52 void ControlRef::gotoBookmark() const
54 lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, string("0"));
58 vector<string> const ControlRef::getBufferList() const
61 vector<string> buffers = bufferlist.getFileNames();
62 for (vector<string>::iterator it = buffers.begin();
63 it != buffers.end(); ++it) {
64 *it = MakeDisplayPath(*it);
71 int ControlRef::getBufferNum() const
73 vector<string> buffers = bufferlist.getFileNames();
74 string const name = lv_.buffer()->fileName();
75 vector<string>::const_iterator cit =
76 find(buffers.begin(), buffers.end(), name);
77 if (cit == buffers.end())
79 return int(cit - buffers.begin());
82 string const ControlRef::getBufferName(int num) const
84 return bufferlist.getFileNames()[num];