-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 2001 The LyX Team.
+/**
+ * \file ControlRef.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * ======================================================
+ * \author Angus Leeming
*
- * \file ControlRef.C
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
#include "ControlRef.h"
-#include "lyxfunc.h"
#include "buffer.h"
#include "bufferlist.h"
#include "funcrequest.h"
#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
using std::vector;
+using std::string;
+
extern BufferList bufferlist;
+namespace lyx {
+
+using support::MakeAbsPath;
+using support::MakeDisplayPath;
-ControlRef::ControlRef(LyXView & lv, Dialogs & d)
- : ControlCommand(lv, d, LFUN_REF_INSERT)
+namespace frontend {
+
+ControlRef::ControlRef(Dialog & d)
+ : ControlCommand(d, "ref")
{}
vector<string> const ControlRef::getLabelList(string const & name) const
{
- Buffer const * buf = bufferlist.getBuffer(MakeAbsPath(name));
- if (!buf)
- buf = buffer();
- return buf->getLabelList();
+ Buffer const & buf = *bufferlist.getBuffer(MakeAbsPath(name));
+ vector<string> list;
+ buf.getLabelList(list);
+ return list;
}
void ControlRef::gotoRef(string const & ref)
{
- lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
- lyxfunc().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
+ kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
+ kernel().dispatch(FuncRequest(LFUN_LABEL_GOTO, ref));
}
void ControlRef::gotoBookmark()
{
- lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
+ kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"));
}
int ControlRef::getBufferNum() const
{
vector<string> buffers = bufferlist.getFileNames();
- string const name = buffer()->fileName();
+ string const name = kernel().buffer().fileName();
vector<string>::const_iterator cit =
find(buffers.begin(), buffers.end(), name);
if (cit == buffers.end())
{
return bufferlist.getFileNames()[num];
}
+
+} // namespace frontend
+} // namespace lyx