2002-09-05 14:10:50 +00:00
|
|
|
/**
|
|
|
|
* \file ControlRef.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-26 13:16:57 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Angus Leeming
|
2001-03-26 13:16:57 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-26 13:16:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "ControlRef.h"
|
2001-03-26 13:16:57 +00:00
|
|
|
#include "lyxfunc.h"
|
2002-08-12 20:17:41 +00:00
|
|
|
#include "buffer.h"
|
2001-09-13 09:57:06 +00:00
|
|
|
#include "bufferlist.h"
|
2002-08-07 08:11:41 +00:00
|
|
|
#include "funcrequest.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
|
|
|
#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
|
|
|
|
|
2001-09-13 09:57:06 +00:00
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
extern BufferList bufferlist;
|
2001-03-26 13:16:57 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
ControlRef::ControlRef(Dialog & d)
|
2003-02-27 13:26:07 +00:00
|
|
|
: ControlCommand(d, "ref")
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2001-03-26 13:16:57 +00:00
|
|
|
|
|
|
|
|
2001-09-13 09:57:06 +00:00
|
|
|
vector<string> const ControlRef::getLabelList(string const & name) const
|
2001-03-26 13:16:57 +00:00
|
|
|
{
|
2002-08-12 20:17:41 +00:00
|
|
|
Buffer const * buf = bufferlist.getBuffer(MakeAbsPath(name));
|
|
|
|
if (!buf)
|
2003-02-25 14:51:38 +00:00
|
|
|
buf = kernel().buffer();
|
2002-08-12 20:17:41 +00:00
|
|
|
return buf->getLabelList();
|
2001-03-26 13:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
void ControlRef::gotoRef(string const & ref)
|
2001-03-26 13:16:57 +00:00
|
|
|
{
|
2003-02-25 14:51:38 +00:00
|
|
|
kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
|
|
|
|
kernel().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
|
2001-03-26 13:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
void ControlRef::gotoBookmark()
|
2001-03-26 13:16:57 +00:00
|
|
|
{
|
2003-02-25 14:51:38 +00:00
|
|
|
kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
|
2001-03-26 13:16:57 +00:00
|
|
|
}
|
|
|
|
|
2001-09-13 09:57:06 +00:00
|
|
|
|
|
|
|
vector<string> const ControlRef::getBufferList() const
|
|
|
|
{
|
2001-09-24 16:55:45 +00:00
|
|
|
vector<string> buffers = bufferlist.getFileNames();
|
|
|
|
for (vector<string>::iterator it = buffers.begin();
|
|
|
|
it != buffers.end(); ++it) {
|
|
|
|
*it = MakeDisplayPath(*it);
|
|
|
|
}
|
|
|
|
|
|
|
|
return buffers;
|
2001-09-13 09:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ControlRef::getBufferNum() const
|
|
|
|
{
|
|
|
|
vector<string> buffers = bufferlist.getFileNames();
|
2003-02-25 14:51:38 +00:00
|
|
|
string const name = kernel().buffer()->fileName();
|
2001-09-13 09:57:06 +00:00
|
|
|
vector<string>::const_iterator cit =
|
|
|
|
find(buffers.begin(), buffers.end(), name);
|
|
|
|
if (cit == buffers.end())
|
|
|
|
return 0;
|
2002-03-26 12:12:29 +00:00
|
|
|
return int(cit - buffers.begin());
|
2001-09-13 09:57:06 +00:00
|
|
|
}
|
2002-02-06 15:12:40 +00:00
|
|
|
|
|
|
|
string const ControlRef::getBufferName(int num) const
|
|
|
|
{
|
|
|
|
return bufferlist.getFileNames()[num];
|
|
|
|
}
|