]> git.lyx.org Git - lyx.git/blobdiff - src/cursor.h
some fitcursor work
[lyx.git] / src / cursor.h
index e56b7486be926989d465f3e14e0cea34c0ba60a9..a7f981b31e3a8a57fcf53b6163efd86364f9a8ba 100644 (file)
 
 #include "support/types.h"
 
+#include <iosfwd>
 #include <vector>
 
 class BufferView;
-class InsetOld;
+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() : inset_(0), text_(0), idx_(0), par_(0), pos_(0) {}
-public:
+       CursorItem() : inset_(0), par_(0), pos_(0) {}
+       ///
+       explicit CursorItem(UpdatableInset * inset)
+               : inset_(inset), par_(0), pos_(0)
+       {}
        ///
-       InsetOld * inset_;
+       LyXText * text() const;
        ///
-       LyXText * text_;
+       friend std::ostream & operator<<(std::ostream &, CursorItem const &);
+public:
        ///
-       int idx_;
+       UpdatableInset * inset_;
        ///
        int par_;
        ///
@@ -47,21 +53,38 @@ public:
 };
 
 
-class Cursor {
+class LCursor {
 public:
+       /// create 'empty' cursor
+       explicit LCursor(BufferView * bv);
+       /// dispatch from innermost inset upwards
+       DispatchResult dispatch(FuncRequest const & cmd);
        ///
-       Cursor() {}
+       void push(UpdatableInset * inset);
+       /// restrict cursor nesting to given size
+       void pop(int depth);
+       /// pop one level off the cursor
+       void pop();
        ///
-       DispatchResult dispatch(FuncRequest const & cmd);
+       UpdatableInset * innerInset() const;
+       ///
+       UpdatableInset * innerInsetOfType(int code) const;
+       ///
+       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