#ifndef CURSOR_H
#define CURSOR_H
-#include "ParagraphList_fwd.h"
#include "textcursor.h"
#include "support/types.h"
-#include "insets/insetbase.h"
-
+#include <iosfwd>
#include <vector>
+class BufferView;
+class UpdatableInset;
+class DispatchResult;
+class FuncRequest;
class LyXText;
+class InsetTabular;
/**
* The cursor class describes the position of a cursor within a document.
*/
-class CursorItem : public TextCursor {
+class CursorItem {
public:
///
- CursorItem() : text_(0) {}
+ CursorItem() : inset_(0), par_(0), pos_(0) {}
+ ///
+ explicit CursorItem(UpdatableInset * inset)
+ : inset_(inset), par_(0), pos_(0)
+ {}
+ ///
+ LyXText * text() const;
+ ///
+ friend std::ostream & operator<<(std::ostream &, CursorItem const &);
public:
///
- LyXText * text_;
+ UpdatableInset * inset_;
///
- ParagraphList::iterator pit_;
+ int par_;
///
int pos_;
};
-class Cursor {
+class LCursor {
public:
+ /// create 'empty' cursor
+ explicit LCursor(BufferView * bv);
+ /// dispatch from innermost inset upwards
+ DispatchResult dispatch(FuncRequest const & cmd);
+ ///
+ void push(UpdatableInset * inset);
+ /// restrict cursor nesting to given size
+ void pop(int depth);
+ /// pop one level off the cursor
+ void pop();
+ ///
+ UpdatableInset * innerInset() const;
///
- Cursor() {}
+ UpdatableInset * innerInsetOfType(int code) const;
///
- dispatch_result dispatch(FuncRequest const & cmd);
+ InsetTabular * innerInsetTabular() const;
+ ///
+ LyXText * innerText() const;
+ /// returns x,y position
+ void getPos(int & x, int & y) const;
+ ///
+ friend std::ostream & operator<<(std::ostream &, LCursor const &);
public:
- /// mainly used as stack, bnut wee need random access
+ /// mainly used as stack, but wee need random access
std::vector<CursorItem> data_;
+ ///
+ BufferView * bv_;
+private:
+ ///
+ int cached_y_;
};
-/// build cursor from current cursor in view
-void buildCursor(Cursor & cursor, BufferView & bv);
-
-/// build cursor from (x,y) coordinates
-void buildCursor(Cursor & cursor, BufferView & bv, int x, int y);
-
#endif // LYXCURSOR_H