]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlErrorList.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[lyx.git] / src / frontends / controllers / ControlErrorList.C
1 /**
2  * \file ControlErrorList.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alfredo Braunstein
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #include "ControlErrorList.h"
14 #include "support/lstrings.h" // tostr
15 #include "errorlist.h"
16 #include "buffer.h"
17 #include "BufferView.h"
18 #include "lyxtext.h"
19 #include "debug.h"
20
21
22 using std::endl;
23
24
25 ControlErrorList::ControlErrorList(Dialog & d)
26         : Dialog::Controller(d)
27 {}
28
29
30 void ControlErrorList::clearParams()
31 {}
32
33
34 ErrorList const &
35 ControlErrorList::errorList() const
36 {
37         return errorlist_;
38 }
39
40
41 bool ControlErrorList::initialiseParams(string const & name)
42 {
43         errorlist_ = kernel().bufferview()->getErrorList();
44         name_ = name;
45         return true;
46 }
47
48
49 string const & ControlErrorList::name()
50 {
51         return name_;
52 }
53
54
55 void ControlErrorList::goTo(int item)
56 {
57         ErrorItem const & err = errorlist_[item];
58
59         if (err.par_id == -1)
60                 return;
61
62         Buffer * const buf = kernel().buffer();
63         ParIterator pit = buf->getParFromID(err.par_id);
64
65         if (pit == buf->par_iterator_end()) {
66                 lyxerr << "par id not found" << endl;
67                 return;
68         }
69
70         int range = err.pos_end - err.pos_start;
71
72         if (err.pos_end > pit->size() || range <= 0)
73                 range = pit->size() - err.pos_start;
74
75         // Now make the selection.
76         BufferView * const bv = kernel().bufferview();
77         bv->insetUnlock();
78         bv->toggleSelection();
79         bv->text->clearSelection();
80         bv->text->setCursor(pit.pit(), err.pos_start);
81         bv->text->setSelectionRange(range);
82         bv->toggleSelection(false);
83         bv->fitCursor();
84         bv->update(bv->text, BufferView::SELECT);
85 }