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