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"
22 ControlErrorList::ErrorItem::ErrorItem(string const & error,
23 string const & description,
24 int par_id, int pos_start, int pos_end)
25 : error(error), description(description), par_id(par_id),
26 pos_start(pos_start), pos_end(pos_end)
29 ControlErrorList::ControlErrorList(Dialog & d)
30 : Dialog::Controller(d), current_(0)
34 void ControlErrorList::clearParams()
41 std::vector<ControlErrorList::ErrorItem> const &
42 ControlErrorList::ErrorList() const
48 int ControlErrorList::currentItem() const
54 bool ControlErrorList::initialiseParams(string const &)
56 logfilename_ = kernel().buffer()->getLogName().second;
64 void ControlErrorList::clearErrors()
71 void ControlErrorList::fillErrors()
73 LaTeX latex("", logfilename_, "");
75 latex.scanLogFile(terr);
77 Buffer * const buf = kernel().buffer();
79 TeXErrors::Errors::const_iterator cit = terr.begin();
80 TeXErrors::Errors::const_iterator end = terr.end();
82 for (; cit != end; ++cit) {
85 int const errorrow = cit->error_in_line;
86 buf->texrow.getIdFromRow(errorrow, par_id, posstart);
88 buf->texrow.getIdFromRow(errorrow + 1, par_id, posend);
89 ErrorList_.push_back(ErrorItem(cit->error_desc,
91 par_id, posstart, posend));
96 string const & ControlErrorList::docName()
98 return kernel().buffer()->fileName();
102 void ControlErrorList::goTo(int item)
104 BufferView * const bv = kernel().bufferview();
105 Buffer * const buf = kernel().buffer();
109 ControlErrorList::ErrorItem const & err = ErrorList_[item];
112 if (err.par_id == -1)
115 ParagraphList::iterator pit = buf->getParFromID(err.par_id);
117 if (pit == bv->text->ownerParagraphs().end()) {
118 cout << "par id not found" << endl;
122 int range = err.pos_end - err.pos_start;
124 if (err.pos_end > pit->size() || range <= 0)
125 range = pit->size() - err.pos_start;
127 //now make the selection
129 bv->toggleSelection();
130 bv->text->clearSelection();
131 bv->text->setCursor(pit, err.pos_start);
132 bv->text->setSelectionRange(range);
133 bv->toggleSelection(false);
135 bv->update(bv->text, BufferView::SELECT);