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
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "ControlErrorList.h"
|
|
|
|
#include "support/lstrings.h" // tostr
|
2003-05-20 16:51:31 +00:00
|
|
|
#include "errorlist.h"
|
2003-05-13 21:15:48 +00:00
|
|
|
#include "buffer.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "lyxtext.h"
|
2003-05-13 23:12:45 +00:00
|
|
|
#include "debug.h"
|
2003-05-13 21:15:48 +00:00
|
|
|
|
|
|
|
|
2003-05-13 23:12:45 +00:00
|
|
|
using std::endl;
|
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-05-20 16:51:31 +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-06-12 11:09:55 +00:00
|
|
|
Buffer * const buf = kernel().buffer();
|
2003-05-22 08:01:41 +00:00
|
|
|
ParIterator pit = buf->getParFromID(err.par_id);
|
2003-05-13 21:15:48 +00:00
|
|
|
|
2003-05-22 08:01:41 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
int range = err.pos_end - err.pos_start;
|
|
|
|
|
2003-06-12 11:09:55 +00:00
|
|
|
if (err.pos_end > pit->size() || range <= 0)
|
|
|
|
range = pit->size() - err.pos_start;
|
2003-05-13 21:15:48 +00:00
|
|
|
|
2003-05-13 23:12:45 +00:00
|
|
|
// Now make the selection.
|
2003-06-12 11:09:55 +00:00
|
|
|
BufferView * const bv = kernel().bufferview();
|
2003-05-13 21:15:48 +00:00
|
|
|
bv->insetUnlock();
|
|
|
|
bv->text->clearSelection();
|
2003-06-12 11:09:55 +00:00
|
|
|
bv->text->setCursor(pit.pit(), err.pos_start);
|
2003-05-13 21:15:48 +00:00
|
|
|
bv->text->setSelectionRange(range);
|
|
|
|
bv->fitCursor();
|
2003-08-04 09:06:35 +00:00
|
|
|
bv->update();
|
2003-05-13 21:15:48 +00:00
|
|
|
}
|