2 * \file ControlErrorList.cpp
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 "ParIterator.h"
21 // FIXME: those two headers are needed because of the
22 // WorkArea::redraw() call below.
23 #include "frontends/LyXView.h"
24 #include "frontends/WorkArea.h"
26 #include "support/lstrings.h"
28 using lyx::support::bformat;
36 ControlErrorList::ControlErrorList(Dialog & d)
37 : Dialog::Controller(d)
41 void ControlErrorList::clearParams()
45 ErrorList const & ControlErrorList::errorList() const
47 return kernel().bufferview()->buffer()->errorList(error_type_);
51 bool ControlErrorList::initialiseParams(string const & error_type)
53 error_type_ = error_type;
54 Buffer * buf = kernel().bufferview()->buffer();
56 docstring const title = bformat(_("%1$s Errors (%2$s)"),
58 lyx::from_utf8(buf->fileName()));
59 name_ = lyx::to_utf8(title);
64 string const & ControlErrorList::name()
70 void ControlErrorList::goTo(int item)
72 ErrorItem const & err = errorList()[item];
77 Buffer & buf = kernel().buffer();
78 ParIterator pit = buf.getParFromID(err.par_id);
80 if (pit == buf.par_iterator_end()) {
81 lyxerr << "par id " << err.par_id << " not found" << endl;
85 // Now make the selection.
86 // This should be implemented using an LFUN. (Angus)
87 // if pos_end is 0, this means it is end-of-paragraph
88 pos_type const end = err.pos_end ? std::min(err.pos_end, pit->size())
90 pos_type const start = std::min(err.pos_start, end);
91 pos_type const range = end - start;
92 DocIterator const dit = makeDocIterator(pit, start);
93 kernel().bufferview()->putSelectionAt(dit, range, false);
94 // FIXME: If we used an LFUN, we would not need those two lines:
95 kernel().bufferview()->update();
96 kernel().lyxview().currentWorkArea()->redraw();
99 } // namespace frontend