]> git.lyx.org Git - lyx.git/blob - src/cursor.C
11070ca67f0d6b0b7f9a78cdd9b6223a11ebe08a
[lyx.git] / src / cursor.C
1 /**
2  * \file cursor.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Jürgen Vigna
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "buffer.h"
14 #include "BufferView.h"
15 #include "cursor.h"
16 #include "debug.h"
17 #include "iterators.h"
18 #include "lyxtext.h"
19 #include "paragraph.h"
20
21 #include "insets/updatableinset.h"
22
23 using std::vector;
24
25
26 DispatchResult Cursor::dispatch(FuncRequest const &)
27 {
28         for (int i = data_.size() - 1; i >= 0; --i) {
29                 lyxerr << "trying to dispatch to " << data_[i].text_ << std::endl;
30         }
31         return UNDISPATCHED;
32 }
33
34
35 void buildCursor(Cursor & cursor, BufferView & bv)
36 {
37         UpdatableInset * inset = bv.theLockingInset();
38         lyxerr << "\nbuildCursor: " << inset << std::endl;
39         if (!inset)
40                 return;
41         
42         inset = inset->getLockingInset();
43
44         bool ok = false;
45         ParIterator pit = bv.buffer()->par_iterator_begin();
46         ParIterator end = bv.buffer()->par_iterator_end();
47         for ( ; pit != end && !ok; ++pit) {
48                 InsetList::iterator     it = pit->insetlist.begin();
49                 InsetList::iterator     iend = pit->insetlist.end();
50                 for ( ; it != iend && !ok; ++it) 
51                         if (it->inset == inset || it->inset == inset->owner())
52                                 ok = true;
53         }
54
55         if (!ok) {
56                 lyxerr << " tli not found! inset: " << inset << std::endl;
57                 return;
58         }
59
60         vector<ParagraphList::iterator> pits; 
61         vector<ParagraphList const *>   plists;
62         vector<LyXText *>               texts;
63 /*
64         pit.getPits(pits, plists, texts);
65
66         cursor.data_.resize(pits.size());
67         for (size_t i = 0, n = pits.size(); i != n; ++i) {
68                 cursor.data_[i].text_ = texts[i];
69                 cursor.data_[i].pit_  = pits[i];
70                 //cursor.data_[i].pos_ = texts[i]->cursor.pos();
71                 cursor.data_[i].pos_ = 0;
72                 lyxerr << " text: " << cursor.data_[i].text_
73                        << " pit: " << cursor.data_[i].pit_->id()
74                        << " pos: " << cursor.data_[i].pos_
75                        << std::endl;
76         }
77 */
78 }