]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlErrorList.C
Overhaul the branches code.
[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 "buffer.h"
15 #include "BufferView.h"
16 #include "bufferview_funcs.h"
17 #include "debug.h"
18 #include "iterators.h"
19 #include "lyxtext.h"
20 #include "paragraph.h"
21 #include "PosIterator.h"
22
23
24 using std::endl;
25 using std::string;
26
27
28 ControlErrorList::ControlErrorList(Dialog & d)
29         : Dialog::Controller(d)
30 {}
31
32
33 void ControlErrorList::clearParams()
34 {}
35
36
37 ErrorList const & ControlErrorList::errorList() const
38 {
39         return errorlist_;
40 }
41
42
43 bool ControlErrorList::initialiseParams(string const & name)
44 {
45         errorlist_ = kernel().bufferview()->getErrorList();
46         name_ = name;
47         return true;
48 }
49
50
51 string const & ControlErrorList::name()
52 {
53         return name_;
54 }
55
56
57 void ControlErrorList::goTo(int item)
58 {
59         ErrorItem const & err = errorlist_[item];
60
61         if (err.par_id == -1)
62                 return;
63
64         Buffer & buf = kernel().buffer();
65         ParIterator pit = buf.getParFromID(err.par_id);
66
67         if (pit == buf.par_iterator_end()) {
68                 lyxerr << "par id not found" << endl;
69                 return;
70         }
71
72         int const end = std::min(err.pos_end, pit->size());
73         int const start = std::min(err.pos_start, end);
74         int const range = end - start;
75
76         // Now make the selection.
77         PosIterator const pos = pit.asPosIterator(start);
78         bv_funcs::put_selection_at(kernel().bufferview(), pos, range, false);
79 }