]> git.lyx.org Git - lyx.git/blobdiff - src/lyxtext.h
Fix loop when opening TOC widget in an empty document, basically by Richard Heck.
[lyx.git] / src / lyxtext.h
index cfa42e1d94d20a3ff01e1fe5bad51860d4cdd64f..49a4c97a3ec1557c289ce07390ef4d18eed5e2b9 100644 (file)
@@ -37,7 +37,6 @@ class FuncStatus;
 class InsetBase;
 class LColor_color;
 class LCursor;
-class LyXTextClass;
 class PainterInfo;
 class Row;
 class RowMetrics;
@@ -63,11 +62,8 @@ public:
        ///
        void setCharFont(Buffer const & buffer, pit_type pit, pos_type pos,
                LyXFont const & font);
-       ///
-       void setCharFont(Buffer const & buffer, pit_type pit, pos_type pos,
-               LyXFont const & font, bool toggleall);
 
-       /// what you expect when pressing <enter> at cursor position
+       /// what you expect when pressing \<enter\> at cursor position
        void breakParagraph(LCursor & cur, bool keep_layout = false);
 
        /// set layout over selection
@@ -94,11 +90,6 @@ public:
        /// FIXME: replace LCursor with DocIterator.
        void setFont(LCursor & cur, LyXFont const &, bool toggleall = false);
 
-       /// returns pos in given par at given x coord.
-       /// FIXME: move to TextMetrics.
-       pos_type x2pos(BufferView const &, pit_type pit, int row, int x) const;
-       int pos2x(pit_type pit, pos_type pos) const;
-
        ///
        void toggleFree(LCursor & cur, LyXFont const &, bool toggleall = false);
 
@@ -144,10 +135,9 @@ public:
        /// This method uses the BufferView CoordCache to locate the
        /// paragraph. The y-coodinate is allowed to be off-screen and
        /// the CoordCache will be automatically updated if needed. This is
-       /// the reason why we need a non const BufferView and why this
-       /// method is non-const.
+       /// the reason why we need a non const BufferView.
        /// FIXME: move to TextMetrics.
-       pit_type getPitNearY(BufferView & bv, int y);
+       pit_type getPitNearY(BufferView & bv, int y) const;
 
        /** Find the word under \c from in the relative location
         *  defined by \c word_location.
@@ -158,10 +148,17 @@ public:
        /// just selects the word the cursor is in
        void selectWord(LCursor & cur, word_location loc);
 
-       /// accept selected change
-       void acceptChange(LCursor & cur);
-       /// reject selected change
-       void rejectChange(LCursor & cur);
+       /// what type of change operation to make 
+       enum ChangeOp {
+               ACCEPT,
+               REJECT
+       };
+       /// accept or reject the selected change
+       void acceptOrRejectChanges(LCursor & cur, ChangeOp op);
+       /// accept the changes within the complete LyXText
+       void acceptChanges(BufferParams const & bparams);
+       /// reject the changes within the complete LyXText
+       void rejectChanges(BufferParams const & bparams);
 
        /// returns true if par was empty and was removed
        bool setCursor(LCursor & cur, pit_type par, pos_type pos,
@@ -190,6 +187,8 @@ public:
        \retval inset is non-null if the cursor is positionned inside
        */
        /// FIXME: move to TextMetrics.
+       /// FIXME: cleanup to use BufferView::getCoveringInset() and
+       /// setCursorFromCoordinates() instead of checkInsetHit().
        InsetBase * editXY(LCursor & cur, int x, int y);
        
        /// Move cursor one line up.
@@ -282,6 +281,9 @@ public:
        void insertStringAsParagraphs(LCursor & cur, docstring const & str);
 
        /// Returns an inset if inset was hit, or 0 if not.
+       /// \warning This method is not recursive! It will return the
+       /// outermost inset within this LyXText.
+       /// \sa BufferView::getCoveringInset() to get the innermost inset.
        InsetBase * checkInsetHit(BufferView &, int x, int y);
 
        ///
@@ -343,12 +345,17 @@ public:
        int cursorY(BufferView const & bv, CursorSlice const & cursor,
                bool boundary) const;
 
-       /// delete double space or empty paragraphs around old cursor
+       /// delete double spaces, leading spaces, and empty paragraphs around old cursor.
+       /// \retval true if a change has happened and we need a redraw.
        /// FIXME: replace LCursor with DocIterator. This is not possible right
        /// now because recordUndo() is called which needs a LCursor.
-       bool deleteEmptyParagraphMechanism(LCursor & cur,
+       static bool deleteEmptyParagraphMechanism(LCursor & cur,
                LCursor & old, bool & need_anchor_change);
 
+       /// delete double spaces, leading spaces, and empty paragraphs
+       /// from \first to \last paragraph
+       void deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges);
+
 public:
        /// the current font settings
        LyXFont current_font;
@@ -375,7 +382,7 @@ private:
 
        // fix the cursor `cur' after a characters has been deleted at `where'
        // position. Called by deleteEmptyParagraphMechanism
-       void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where);
+       static void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where);
 
        // At cursor position 0, try to merge the paragraph with the one before it.
        // Ignore change tracking, i.e., physically remove the end-of-par character
@@ -391,6 +398,12 @@ private:
        void charInserted();
        /// set 'number' font property
        void number(LCursor & cur);
+
+       /// paste plain text at current cursor.
+       /// \param str string to paste
+       /// \param asParagraphs whether to paste as paragraphs or as lines
+       void pasteString(LCursor & cur, docstring const & str,
+                       bool asParagraphs);
 };
 
 } // namespace lyx