]> git.lyx.org Git - lyx.git/blobdiff - src/cursor.h
fix tabular crashs
[lyx.git] / src / cursor.h
index 68c257c793479496c2291ff2c8b9ec7b351a58f0..91e169f5f142a4464bdd4d6fcdc22da6bc675ce4 100644 (file)
@@ -13,6 +13,7 @@
 #define CURSOR_H
 
 #include "cursor_slice.h"
+#include "dispatchresult.h"
 
 #include <iosfwd>
 #include <vector>
@@ -25,14 +26,23 @@ class FuncRequest;
 class InsetTabular;
 class LyXText;
 class Paragraph;
+class Row;
 
 
 // these should go
 class MathHullInset;
-class PainterInfo;
 class MathUnknownInset;
 class MathGridInset;
 
+
+// only needed for gcc 2.95, remove when support terminated
+template <typename A, typename B>
+bool ptr_cmp(A const * a, B const * b)
+{
+       return a == b;
+}
+
+
 // this is used for traversing math insets
 typedef std::vector<CursorSlice> CursorBase;
 /// move on one step
@@ -82,6 +92,8 @@ public:
        CursorSlice const & current() const;
        /// how many nested insets do we have?
        size_t depth() const { return cursor_.size(); }
+       /// depth of current slice
+       int currentDepth() const { return current_; }
 
        //
        // selection
@@ -131,30 +143,41 @@ public:
        void selClear();
        /// clears or deletes selection depending on lyxrc setting
        void selClearOrDel();
+       //
+       std::string selectionAsString(bool label) const;
        ///
        void paste(std::string const & data);
+       ///
+       std::string currentState();
 
        //
        // access to the 'current' cursor slice
        //
-       /// the current inset
+       /// the containing inset
        InsetBase * inset() const { return current().inset(); }
        /// return the cell of the inset this cursor is in
        idx_type idx() const { return current().idx(); }
        /// return the cell of the inset this cursor is in
        idx_type & idx() { return current().idx(); }
        /// return the last possible cell in this inset
-       idx_type lastidx() const { return current().lastidx(); }
+       idx_type lastidx() const;
        /// return the paragraph this cursor is in
        par_type par() const { return current().par(); }
        /// return the paragraph this cursor is in
        par_type & par() { return current().par(); }
+       /// return the last possible paragraph in this inset
+       par_type lastpar() const;
        /// return the position within the paragraph
        pos_type pos() const { return current().pos(); }
        /// return the position within the paragraph
        pos_type & pos() { return current().pos(); }
        /// return the last position within the paragraph
        pos_type lastpos() const;
+       /// return the display row of the cursor with in the current par
+       row_type crow() const;
+       /// return the display row of the cursor with in the current par
+       row_type lastcrow() const;
+
        /// return the number of embedded cells
        size_t nargs() const;
        /// return the number of embedded cells
@@ -165,6 +188,12 @@ public:
        row_type row() const;
        /// return the grid row of the current cell
        col_type col() const;
+       /// the inset just behind the cursor
+       InsetBase * nextInset();
+       /// the inset just in front of the cursor
+       InsetBase * prevInset();
+       /// the inset just in front of the cursor
+       InsetBase const * prevInset() const;
 
        //
        // math-specific part
@@ -192,14 +221,18 @@ public:
 
        //
        // text-specific part
-       ///
+       /// see comment for boundary_ below
        bool boundary() const { return current().boundary(); }
-       ///
+       /// see comment for boundary_ below
        bool & boundary() { return current().boundary(); }
-       ///
+       /// the paragraph we're in
        Paragraph & paragraph();
-       ///
+       /// the paragraph we're in
        Paragraph const & paragraph() const;
+       /// the row in the paragraph we're in
+       Row & textRow();
+       /// the row in the paragraph we're in
+       Row const & textRow() const;
        ///
        LyXText * text() const;
        ///
@@ -223,6 +256,13 @@ public:
        /// move one step to the right
        bool posRight();
 
+       /// insert an inset
+       void insert(InsetBase *);
+       /// insert a single char
+       void insert(char c);
+       /// insert a string
+       void insert(std::string const & str);
+
        /// write acess to target x position of cursor
        int & x_target();
        /// return target x position of cursor
@@ -241,11 +281,19 @@ public:
        /// access to owning BufferView
        BufferView & bv() const; 
        /// get some interesting description of current position
-       void info(std::ostream & os);
+       void info(std::ostream & os) const;
        /// are we in math mode (2), text mode (1) or unsure (0)?
        int currentMode();
        /// reset cursor
        void reset();
+       /// for spellchecking
+       void replaceWord(std::string const & replacestring);
+       /// update our view
+       void update();
+       ///
+       void dispatched(dispatch_result_t res);
+       void notdispatched();
+       void noupdate();
 
        /// output
        friend std::ostream & operator<<(std::ostream & os, LCursor const & cur);
@@ -255,6 +303,9 @@ public:
        std::vector<CursorSlice> cursor_;
        /// the anchor position
        std::vector<CursorSlice> anchor_;
+       
+       /// 
+       DispatchResult disp_;
 
 private:
        ///
@@ -303,8 +354,6 @@ public:
        void insert(MathAtom const &);
        ///
        void insert(MathArray const &);
-       ///
-       void insert2(std::string const &);
        /// return false for empty math insets
        bool erase();
        /// return false for empty math insets
@@ -354,8 +403,6 @@ public:
        /// are we currently typing '#1' or '#2' or...?
        bool inMacroArgMode() const;
 
-       /// draws light-blue selection background
-       void drawSelection(PainterInfo & pi);
        /// replace selected stuff with at, placing the former
        // selection in given cell of atom
        void handleNest(MathAtom const & at, int cell = 0);
@@ -376,10 +423,6 @@ public:
        /// returns the normalized anchor of the selection
        CursorSlice normalAnchor();
 
-       ///
-       void insert(char c);
-       ///
-       void insert(std::string const & str);
        /// lock/unlock inset
        void lockToggle();
 
@@ -391,9 +434,17 @@ public:
        /// split font inset etc
        void handleFont(std::string const & font);
 
-       void releaseMathCursor();
-
+       /// are we in mathed?
        bool inMathed() const;
+       /// are we in texted?
+       bool inTexted() const;
+
+       /// display a message
+       void message(std::string const & msg) const;
+       /// display an error message
+       void errorMessage(std::string const & msg) const;
+       ///
+       std::string getPossibleLabel();
 
 private:
        /// moves cursor index one cell to the left