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"
14 #include "support/lstrings.h" // tostr
17 #include "BufferView.h"
25 ControlErrorList::ErrorItem::ErrorItem(string const & error,
26 string const & description,
27 int par_id, int pos_start, int pos_end)
28 : error(error), description(description), par_id(par_id),
29 pos_start(pos_start), pos_end(pos_end)
33 ControlErrorList::ControlErrorList(Dialog & d)
34 : Dialog::Controller(d), current_(0)
38 void ControlErrorList::clearParams()
45 std::vector<ControlErrorList::ErrorItem> const &
46 ControlErrorList::ErrorList() const
52 int ControlErrorList::currentItem() const
58 bool ControlErrorList::initialiseParams(string const &)
60 logfilename_ = kernel().buffer()->getLogName().second;
68 void ControlErrorList::clearErrors()
75 void ControlErrorList::fillErrors()
77 LaTeX latex("", logfilename_, "");
79 latex.scanLogFile(terr);
81 Buffer * const buf = kernel().buffer();
83 TeXErrors::Errors::const_iterator cit = terr.begin();
84 TeXErrors::Errors::const_iterator end = terr.end();
86 for (; cit != end; ++cit) {
89 int const errorrow = cit->error_in_line;
90 buf->texrow.getIdFromRow(errorrow, par_id, posstart);
92 buf->texrow.getIdFromRow(errorrow + 1, par_id, posend);
93 ErrorList_.push_back(ErrorItem(cit->error_desc,
95 par_id, posstart, posend));
100 string const & ControlErrorList::docName()
102 return kernel().buffer()->fileName();
106 void ControlErrorList::goTo(int item)
108 BufferView * const bv = kernel().bufferview();
109 Buffer * const buf = kernel().buffer();
113 ControlErrorList::ErrorItem const & err = ErrorList_[item];
116 if (err.par_id == -1)
119 ParagraphList::iterator pit = buf->getParFromID(err.par_id);
121 if (pit == bv->text->ownerParagraphs().end()) {
122 lyxerr << "par id not found" << endl;
126 int range = err.pos_end - err.pos_start;
128 if (err.pos_end > pit->size() || range <= 0)
129 range = pit->size() - err.pos_start;
131 // Now make the selection.
133 bv->toggleSelection();
134 bv->text->clearSelection();
135 bv->text->setCursor(pit, err.pos_start);
136 bv->text->setSelectionRange(range);
137 bv->toggleSelection(false);
139 bv->update(bv->text, BufferView::SELECT);