]> git.lyx.org Git - lyx.git/blobdiff - src/lyxtext.h
fix some C++ parsing bugs
[lyx.git] / src / lyxtext.h
index e880d878c4510135eae0ad8f5441969f4f5dc721..5a4f8efc51c26cf05d9b648de8698465b2df4f38 100644 (file)
@@ -17,6 +17,7 @@
 #include "layout.h"
 #include "LColor.h"
 #include "insets/inset.h"
+#include "RowList.h"
 
 class Buffer;
 class BufferParams;
@@ -37,18 +38,13 @@ class ParagraphList;
 class LyXText {
 public:
        /// what repainting is needed
-       enum text_status {
+       enum refresh_status {
                /// no repaint is needed
-               UNCHANGED = 0,
-               /**
-                * A paint has caused a change in some rows
-                * and rebreaking is needed.
-                */
-               CHANGED_IN_DRAW = 1,
+               REFRESH_NONE = 0,
                /// the refresh_row needs repainting
-               NEED_VERY_LITTLE_REFRESH = 2,
+               REFRESH_ROW = 1,
                /// everything from refresh_y downwards needs repainting
-               NEED_MORE_REFRESH = 3
+               REFRESH_AREA = 2
        };
 
        ///
@@ -71,9 +67,6 @@ public:
        /// sets inset as owner
        LyXText(BufferView *, InsetText *);
 
-       /// Destructor
-       ~LyXText();
-
        void init(BufferView *, bool reinit = false);
        ///
        int height;
@@ -84,17 +77,20 @@ public:
        /// the current font
        LyXFont real_current_font;
 private:
-       /** the first visible row on screen
+       /** the 'anchor' row: the position of this row remains constant
+        *  with respect to the top of the screen
         */
-       Row * top_row_;
+       Row * anchor_row_;
        /** the pixel offset with respect to this row of top_y
         */
-       int top_row_offset_;
+       int anchor_row_offset_;
 public:
        /// get the y coord. of the top of the screen (relative to doc start)
        int top_y() const;
-       /// set it
+       /// set the y coord. of the top of the screen (relative to doc start)
        void top_y(int newy);
+       /// set the anchoring row. top_y will be computed relative to this
+       void anchor_row(Row * row);
        ///
        InsetText * inset_owner;
        ///
@@ -115,8 +111,6 @@ public:
        void setCharFont(Paragraph * par,
                         lyx::pos_type pos, LyXFont const & font, bool toggleall);
 
-       /// return true if the row changed
-       void markChangeInDraw(Row * row, Row * next);
        ///
        void breakAgainOneRow(Row * row);
        /// what you expect when pressing <enter> at cursor position
@@ -188,9 +182,6 @@ public:
        /// clear any pending paints
        void clearPaint();
 
-       /// post notice that we changed during a draw
-       void postChangedInDraw();
-
        /**
         * Mark position y as the starting point for a repaint
         */
@@ -214,26 +205,25 @@ public:
         * Return the status. This represents what repaints are
         * pending after some operation (e.g. inserting a char).
         */
-       text_status status() const;
+       refresh_status refreshStatus() const;
 
 private:
        /**
         * The pixel y position from which to repaint the screen.
         * The position is absolute along the height of outermost
-        * lyxtext (I think). NEED_MORE_REFRESH and NEED_LITTLE_REFRESH
+        * lyxtext (I think). REFRESH_AREA and REFRESH_ROW
         * repaints both use this as a starting point (if it's within
         * the viewable portion of the lyxtext).
         */
        int refresh_y;
        /**
         * The row from which to repaint the screen, used by screen.c.
-        * This must be set if the pending update is NEED_LITTLE_REFRESH.
-        * It doesn't make any difference for NEED_MORE_REFRESH.
+        * This must be set if the pending update is REFRESH_ROW.
+        * It doesn't make any difference for REFRESH_AREA.
         */
        Row * refresh_row;
 
-       /// refresh status
-       text_status status_;
+       refresh_status refresh_status_;
 
        /// only the top-level LyXText has this non-zero
        BufferView * bv_owner;
@@ -259,8 +249,8 @@ public:
            IMO it's stupid to have to allocate a dummy y all the time I need
            the first row
        */
-       Row * firstRow() const { return firstrow; }
-
+       Row * firstRow() const { return &*rowlist_.begin(); }
+       Row * lastRow() const { return &const_cast<LyXText*>(this)->rowlist_.back(); }
        /** The cursor.
          Later this variable has to be removed. There should be now internal
          cursor in a text (and thus not in a buffer). By keeping this it is
@@ -484,46 +474,20 @@ public:
        int workWidth() const;
        ///
        int workWidth(Inset * inset) const;
+
        ///
        void computeBidiTables(Buffer const *, Row * row) const;
-
        /// Maps positions in the visual string to positions in logical string.
-       inline
-       lyx::pos_type log2vis(lyx::pos_type pos) const {
-               if (bidi_start == -1)
-                       return pos;
-               else
-                       return log2vis_list[pos-bidi_start];
-       }
-
+       lyx::pos_type log2vis(lyx::pos_type pos) const;
        /// Maps positions in the logical string to positions in visual string.
-       inline
-       lyx::pos_type vis2log(lyx::pos_type pos) const {
-               if (bidi_start == -1)
-                       return pos;
-               else
-                       return vis2log_list[pos-bidi_start];
-       }
-       ///
-       inline
-       lyx::pos_type bidi_level(lyx::pos_type pos) const {
-               if (bidi_start == -1)
-                       return 0;
-               else
-                       return bidi_levels[pos-bidi_start];
-       }
-       ///
-       inline
-       bool bidi_InRange(lyx::pos_type pos) const {
-               return bidi_start == -1 ||
-                       (bidi_start <= pos && pos <= bidi_end);
-       }
-private:
+       lyx::pos_type vis2log(lyx::pos_type pos) const;
        ///
-       Row * firstrow;
+       lyx::pos_type bidi_level(lyx::pos_type pos) const;
        ///
-       Row * lastrow;
-
+       bool bidi_InRange(lyx::pos_type pos) const;
+private:
+       ///
+       RowList rowlist_;
        ///
        void cursorLeftOneWord(LyXCursor &);
 
@@ -547,6 +511,7 @@ private:
        /** inserts a new row behind the specified row, increments
            the touched counters */
        void insertRow(Row * row, Paragraph * par, lyx::pos_type pos);
+
        /// removes the row and reset the touched counters
        void removeRow(Row * row);
 
@@ -578,7 +543,7 @@ public:
         * with a dynamic left margin will be rebroken. */
        void updateCounters();
        ///
-       void update(bool changed = true);
+       void update();
        /**
         * Returns an inset if inset was hit, or 0 if not.
         * If hit, the coordinates are changed relative to the inset.
@@ -652,16 +617,12 @@ private:
 
        ///
        mutable std::vector<lyx::pos_type> log2vis_list;
-
        ///
        mutable std::vector<lyx::pos_type> vis2log_list;
-
        ///
        mutable std::vector<lyx::pos_type> bidi_levels;
-
        ///
        mutable lyx::pos_type bidi_start;
-
        ///
        mutable lyx::pos_type bidi_end;