2 * \file ControlErrorList.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alfredo Braunstein
8 * Full author contact details are available in file CREDITS.
13 #include "ControlErrorList.h"
15 #include "BufferView.h"
19 #include "paragraph.h"
20 #include "pariterator.h"
22 #include "support/lstrings.h"
24 using lyx::support::bformat;
32 ControlErrorList::ControlErrorList(Dialog & d)
33 : Dialog::Controller(d)
37 void ControlErrorList::clearParams()
41 ErrorList const & ControlErrorList::errorList() const
47 bool ControlErrorList::initialiseParams(string const & error_type)
49 Buffer * buf = kernel().bufferview()->buffer();
50 string const title = bformat(_("%1$s Errors (%2$s)"),
51 _(error_type), buf->fileName());
52 errorlist_ = buf->errorList(error_type);
58 string const & ControlErrorList::name()
64 void ControlErrorList::goTo(int item)
66 ErrorItem const & err = errorlist_[item];
71 Buffer & buf = kernel().buffer();
72 ParIterator pit = buf.getParFromID(err.par_id);
74 if (pit == buf.par_iterator_end()) {
75 lyxerr << "par id " << err.par_id << " not found" << endl;
79 // Now make the selection.
80 // This should be implemented using an LFUN. (Angus)
81 // if pos_end is 0, this means it is end-of-paragraph
82 pos_type const end = err.pos_end ? std::min(err.pos_end, pit->size())
84 pos_type const start = std::min(err.pos_start, end);
85 pos_type const range = end - start;
86 DocIterator const dit = makeDocIterator(pit, start);
87 kernel().bufferview()->putSelectionAt(dit, range, false);
88 // If we used an LFUN, we would not need that
89 kernel().bufferview()->update();
92 } // namespace frontend