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();
51 docstring const title = bformat(_("%1$s Errors (%2$s)"),
53 lyx::from_utf8(buf->fileName()));
54 errorlist_ = buf->errorList(error_type);
55 name_ = lyx::to_utf8(title);
60 string const & ControlErrorList::name()
66 void ControlErrorList::goTo(int item)
68 ErrorItem const & err = errorlist_[item];
73 Buffer & buf = kernel().buffer();
74 ParIterator pit = buf.getParFromID(err.par_id);
76 if (pit == buf.par_iterator_end()) {
77 lyxerr << "par id " << err.par_id << " not found" << endl;
81 // Now make the selection.
82 // This should be implemented using an LFUN. (Angus)
83 // if pos_end is 0, this means it is end-of-paragraph
84 pos_type const end = err.pos_end ? std::min(err.pos_end, pit->size())
86 pos_type const start = std::min(err.pos_start, end);
87 pos_type const range = end - start;
88 DocIterator const dit = makeDocIterator(pit, start);
89 kernel().bufferview()->putSelectionAt(dit, range, false);
90 // If we used an LFUN, we would not need that
91 kernel().bufferview()->update();
94 } // namespace frontend