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 "Paragraph.h"
20 #include "ParIterator.h"
22 // FIXME: those two headers are needed because of the
23 // WorkArea::redraw() call below.
24 #include "frontends/LyXView.h"
25 #include "frontends/WorkArea.h"
27 #include "support/lstrings.h"
29 using lyx::support::bformat;
37 ControlErrorList::ControlErrorList(Dialog & d)
38 : Dialog::Controller(d)
42 void ControlErrorList::clearParams()
46 ErrorList const & ControlErrorList::errorList() const
48 return kernel().bufferview()->buffer()->errorList(error_type_);
52 bool ControlErrorList::initialiseParams(string const & error_type)
54 error_type_ = error_type;
55 Buffer * buf = kernel().bufferview()->buffer();
57 docstring const title = bformat(_("%1$s Errors (%2$s)"),
59 lyx::from_utf8(buf->fileName()));
60 name_ = lyx::to_utf8(title);
65 string const & ControlErrorList::name()
71 void ControlErrorList::goTo(int item)
73 ErrorItem const & err = errorList()[item];
78 Buffer & buf = kernel().buffer();
79 ParIterator pit = buf.getParFromID(err.par_id);
81 if (pit == buf.par_iterator_end()) {
82 lyxerr << "par id " << err.par_id << " not found" << endl;
86 // Now make the selection.
87 // This should be implemented using an LFUN. (Angus)
88 // if pos_end is 0, this means it is end-of-paragraph
89 pos_type const end = err.pos_end ? std::min(err.pos_end, pit->size())
91 pos_type const start = std::min(err.pos_start, end);
92 pos_type const range = end - start;
93 DocIterator const dit = makeDocIterator(pit, start);
94 kernel().bufferview()->putSelectionAt(dit, range, false);
95 // FIXME: If we used an LFUN, we would not need those two lines:
96 kernel().bufferview()->update();
97 kernel().lyxview().currentWorkArea()->redraw();
100 } // namespace frontend