/** * \file ControlRef.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Angus Leeming * * Full author contact details are available in file CREDITS. */ #include #include "ControlRef.h" #include "buffer.h" #include "bufferlist.h" #include "funcrequest.h" #include "frontends/Application.h" #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath using std::vector; using std::string; namespace lyx { using support::makeAbsPath; using support::makeDisplayPath; namespace frontend { ControlRef::ControlRef(Dialog & d) : ControlCommand(d, "ref") {} vector const ControlRef::getLabelList(string const & name) const { Buffer const & buf = *theApp->bufferList().getBuffer(makeAbsPath(name)); vector list; buf.getLabelList(list); return list; } void ControlRef::gotoRef(string const & ref) { kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0")); kernel().dispatch(FuncRequest(LFUN_LABEL_GOTO, ref)); } void ControlRef::gotoBookmark() { kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0")); } vector const ControlRef::getBufferList() const { vector buffers = theApp->bufferList().getFileNames(); for (vector::iterator it = buffers.begin(); it != buffers.end(); ++it) { *it = lyx::to_utf8(makeDisplayPath(*it)); } return buffers; } int ControlRef::getBufferNum() const { vector buffers = theApp->bufferList().getFileNames(); string const name = kernel().buffer().fileName(); vector::const_iterator cit = find(buffers.begin(), buffers.end(), name); if (cit == buffers.end()) return 0; return int(cit - buffers.begin()); } string const ControlRef::getBufferName(int num) const { return theApp->bufferList().getFileNames()[num]; } } // namespace frontend } // namespace lyx