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"
|
2006-08-13 16:16:43 +00:00
|
|
|
#include "gettext.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
|
|
|
|
2007-01-07 22:01:50 +00:00
|
|
|
// FIXME: those two headers are needed because of the
|
|
|
|
// WorkArea::redraw() call below.
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
#include "frontends/WorkArea.h"
|
|
|
|
|
2006-08-13 16:16:43 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
using lyx::support::bformat;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-13 16:16:43 +00:00
|
|
|
bool ControlErrorList::initialiseParams(string const & error_type)
|
2003-05-13 21:15:48 +00:00
|
|
|
{
|
2006-08-13 16:16:43 +00:00
|
|
|
Buffer * buf = kernel().bufferview()->buffer();
|
2006-09-09 15:27:44 +00:00
|
|
|
// FIXME UNICODE
|
2006-09-11 08:54:10 +00:00
|
|
|
docstring const title = bformat(_("%1$s Errors (%2$s)"),
|
|
|
|
_(error_type),
|
|
|
|
lyx::from_utf8(buf->fileName()));
|
2006-08-13 16:16:43 +00:00
|
|
|
errorlist_ = buf->errorList(error_type);
|
2006-09-11 08:54:10 +00:00
|
|
|
name_ = lyx::to_utf8(title);
|
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()) {
|
2005-11-30 10:51:02 +00:00
|
|
|
lyxerr << "par id " << err.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)
|
2005-06-03 08:48:04 +00:00
|
|
|
// if pos_end is 0, this means it is end-of-paragraph
|
|
|
|
pos_type const end = err.pos_end ? std::min(err.pos_end, pit->size())
|
2006-04-05 23:56:29 +00:00
|
|
|
: pit->size();
|
2004-07-25 00:04:42 +00:00
|
|
|
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);
|
2007-01-07 22:01:50 +00:00
|
|
|
// FIXME: If we used an LFUN, we would not need those two lines:
|
2005-01-11 13:22:42 +00:00
|
|
|
kernel().bufferview()->update();
|
2007-01-07 22:01:50 +00:00
|
|
|
kernel().lyxview().currentWorkArea()->redraw();
|
2003-05-13 21:15:48 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|