lyx_mirror/src/frontends/controllers/ControlErrorList.C

86 lines
1.8 KiB
C++
Raw Normal View History

/**
* \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 "buffer.h"
#include "BufferView.h"
#include "debug.h"
#include "lyxtext.h"
#include "paragraph.h"
#include "pariterator.h"
using std::endl;
using std::string;
namespace lyx {
namespace frontend {
ControlErrorList::ControlErrorList(Dialog & d)
: Dialog::Controller(d)
{}
void ControlErrorList::clearParams()
{}
ErrorList const & ControlErrorList::errorList() const
{
return errorlist_;
}
bool ControlErrorList::initialiseParams(string const & name)
{
This commit transfer the ErrorList handling from LyXView to Buffer. It also removes the need for the error signal and simplify the kerbel <-> frontend communication. I think it should speed-up _significantly_ the latex compilation for example in case of problematic files. TODO 1: All occurrences of "LyXView::showErrorList()" in the "kernel" should be replaced by a boost signal emission (Buffer::errors()). This signal is already connected to this showErrorList() slot. TODO 2: The ErrorList mechanism is used wrongly in a number of place, most notably in "Converter.C". Instead of replacing the ErrorList in the "Buffer" class, the "Converter" class should maintain its own list instead and connect directly to the LyXView::showErrorList() slot. Buffer: * errorList_: new private member and associated access methods. * setErrorList(): new accessor method. * addError(): apend an error to the errorList_. * error(): deleted. * errors(): new boost signal, unused for now. Shall be used instead of LyXView::showErrorList(). LyXView: * getErrorList(), addError(), errorlist_, errorConnection_: deleted. * errorsConnection_: new boost connection for the Buffer::errors() signal. lyx_main.C: * LyX::exec2(): manually print all errors. BufferView.h: remove unneeded ErrorList forward declaration. BufferView::pimpl::menuInsertLyXFile(): delete Buffer::error() connection and add a FIXME comment text.C: Use Buffer::addError() instead of Buffer::error() signal emission. ControlErrorList.C: get the ErrorList from the Buffer instead of LyXView git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14467 a592a061-630c-0410-9148-cb99ea01b6c8
2006-07-15 22:43:37 +00:00
errorlist_ = kernel().bufferview()->buffer()->getErrorList();
name_ = name;
return true;
}
string const & ControlErrorList::name()
{
return name_;
}
void ControlErrorList::goTo(int item)
{
ErrorItem const & err = errorlist_[item];
if (err.par_id == -1)
return;
Buffer & buf = kernel().buffer();
ParIterator pit = buf.getParFromID(err.par_id);
if (pit == buf.par_iterator_end()) {
lyxerr << "par id " << err.par_id << " not found" << endl;
return;
}
// Now make the selection.
// This should be implemented using an LFUN. (Angus)
// 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())
: pit->size();
pos_type const start = std::min(err.pos_start, end);
pos_type const range = end - start;
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();
}
} // namespace frontend
} // namespace lyx