2001-03-26 13:16:57 +00:00
|
|
|
/* This file is part of
|
2002-03-21 21:21:28 +00:00
|
|
|
* ======================================================
|
2001-03-26 13:16:57 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* \file ControlRef.C
|
|
|
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "ControlRef.h"
|
2001-03-26 13:16:57 +00:00
|
|
|
#include "lyxfunc.h"
|
2001-09-13 09:57:06 +00:00
|
|
|
#include "bufferlist.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
|
|
|
|
2001-03-26 13:16:57 +00:00
|
|
|
ControlRef::ControlRef(LyXView & lv, Dialogs & d)
|
|
|
|
: ControlCommand(lv, d, LFUN_REF_INSERT)
|
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
|
|
|
{
|
2001-09-24 16:55:45 +00:00
|
|
|
Buffer * buffer = bufferlist.getBuffer(MakeAbsPath(name));
|
2001-09-13 09:57:06 +00:00
|
|
|
if (!buffer)
|
|
|
|
buffer = lv_.buffer();
|
|
|
|
return buffer->getLabelList();
|
2001-03-26 13:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlRef::gotoRef(string const & ref) const
|
|
|
|
{
|
2002-07-20 17:27:03 +00:00
|
|
|
lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, "0", false);
|
2001-07-16 15:42:57 +00:00
|
|
|
lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref);
|
2001-03-26 13:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlRef::gotoBookmark() const
|
|
|
|
{
|
2002-07-20 17:27:03 +00:00
|
|
|
lv_.getLyXFunc()->dispatch(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
|
|
|
|
{
|
2002-03-21 21:21:28 +00:00
|
|
|
|
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();
|
|
|
|
string const name = lv_.buffer()->fileName();
|
|
|
|
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];
|
|
|
|
}
|