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 "lyxtext.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
#include "paragraph.h"
|
2004-03-28 22:00:22 +00:00
|
|
|
#include "pariterator.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
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
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;
|
|
|
|
}
|
|
|
|
|
2003-05-13 23:12:45 +00:00
|
|
|
// Now make the selection.
|
2005-01-11 13:22:42 +00:00
|
|
|
// This should be implemented using an LFUN. (Angus)
|
2004-07-25 00:04:42 +00:00
|
|
|
pos_type const end = std::min(err.pos_end, pit->size());
|
|
|
|
pos_type const start = std::min(err.pos_start, end);
|
|
|
|
pos_type const range = end - start;
|
2005-01-11 13:22:42 +00:00
|
|
|
DocIterator const dit = makeDocIterator(pit, start);
|
|
|
|
kernel().bufferview()->putSelectionAt(dit, range, false);
|
|
|
|
// If we used an LFUN, we would not need that
|
|
|
|
kernel().bufferview()->update();
|
2003-05-13 21:15:48 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|