2003-05-13 21:15:48 +00:00
|
|
|
/**
|
|
|
|
* \file ControlErrorList.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Alfredo Braunstein
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-05-13 21:15:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "ControlErrorList.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "BufferView.h"
|
2003-05-13 23:12:45 +00:00
|
|
|
#include "debug.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
#include "iterators.h"
|
|
|
|
#include "lyxtext.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
#include "paragraph.h"
|
2003-11-06 10:52:15 +00:00
|
|
|
#include "PosIterator.h"
|
2003-05-13 21:15:48 +00:00
|
|
|
|
|
|
|
|
2003-05-13 23:12:45 +00:00
|
|
|
using std::endl;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
2003-05-13 21:15:48 +00:00
|
|
|
|
2003-05-13 23:12:45 +00:00
|
|
|
|
|
|
|
ControlErrorList::ControlErrorList(Dialog & d)
|
2003-05-20 16:51:31 +00:00
|
|
|
: Dialog::Controller(d)
|
2003-05-13 21:15:48 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2003-05-13 23:12:45 +00:00
|
|
|
void ControlErrorList::clearParams()
|
2003-05-20 16:51:31 +00:00
|
|
|
{}
|
2003-05-13 21:15:48 +00:00
|
|
|
|
|
|
|
|
2003-10-09 10:52:12 +00:00
|
|
|
ErrorList const & ControlErrorList::errorList() const
|
2003-05-13 21:15:48 +00:00
|
|
|
{
|
2003-05-20 16:51:31 +00:00
|
|
|
return errorlist_;
|
2003-05-13 21:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-20 16:51:31 +00:00
|
|
|
bool ControlErrorList::initialiseParams(string const & name)
|
2003-05-13 21:15:48 +00:00
|
|
|
{
|
2003-05-20 16:51:31 +00:00
|
|
|
errorlist_ = kernel().bufferview()->getErrorList();
|
|
|
|
name_ = name;
|
2003-05-13 21:15:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-20 16:51:31 +00:00
|
|
|
string const & ControlErrorList::name()
|
2003-05-13 21:15:48 +00:00
|
|
|
{
|
2003-05-20 16:51:31 +00:00
|
|
|
return name_;
|
2003-05-13 21:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlErrorList::goTo(int item)
|
|
|
|
{
|
2003-05-20 16:51:31 +00:00
|
|
|
ErrorItem const & err = errorlist_[item];
|
2003-05-13 21:15:48 +00:00
|
|
|
|
|
|
|
if (err.par_id == -1)
|
|
|
|
return;
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
Buffer & buf = kernel().buffer();
|
|
|
|
ParIterator pit = buf.getParFromID(err.par_id);
|
2003-05-13 21:15:48 +00:00
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
if (pit == buf.par_iterator_end()) {
|
2003-05-13 23:12:45 +00:00
|
|
|
lyxerr << "par id not found" << endl;
|
2003-05-13 21:15:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-24 17:06:17 +00:00
|
|
|
lyx::pos_type const end = std::min(err.pos_end, pit->size());
|
|
|
|
lyx::pos_type const start = std::min(err.pos_start, end);
|
|
|
|
lyx::pos_type const range = end - start;
|
2003-05-13 21:15:48 +00:00
|
|
|
|
2003-05-13 23:12:45 +00:00
|
|
|
// Now make the selection.
|
2004-01-27 15:14:34 +00:00
|
|
|
PosIterator const pos(pit, start);
|
2004-01-14 17:21:39 +00:00
|
|
|
kernel().bufferview()->putSelectionAt(pos, range, false);
|
2003-05-13 21:15:48 +00:00
|
|
|
}
|