]> git.lyx.org Git - lyx.git/blobdiff - src/lyxtext.h
Fix working of the spellchecker dialog with ispell when there are no
[lyx.git] / src / lyxtext.h
index 5d55c9ddff2513d63566f69e0a94bf517cc9691e..3be37e1cfff0300516523e2044fcbe50e2f0dddf 100644 (file)
 #endif
 
 #include "lyxfont.h"
-#include "undo.h"
 #include "lyxcursor.h"
 #include "paragraph.h"
 #include "layout.h"
 #include "lyxrow.h"
 #include "vspace.h"
+#include "Spacing.h"
+#include "LColor.h"
 
 class Buffer;
 class BufferParams;
@@ -38,20 +39,25 @@ public:
        ///
        enum text_status {
                ///
-               UNCHANGED,
+               UNCHANGED = 0,
                ///
-               NEED_MORE_REFRESH,
+               CHANGED_IN_DRAW = 1,
                ///
-               NEED_VERY_LITTLE_REFRESH,
+               NEED_VERY_LITTLE_REFRESH = 2,
                ///
-               CHANGED_IN_DRAW
+               NEED_MORE_REFRESH = 3
        };
        ///
        enum word_location {
-               /// the word around the cursor
+               // the word around the cursor, only if the cursor is
+               //not at a boundary
+               WHOLE_WORD_STRICT,
+               // the word around the cursor
                WHOLE_WORD,
                /// the word begining from the cursor position
                PARTIAL_WORD,
+               /// the word around the cursor or before the cursor
+               PREVIOUS_WORD,
                /// the next word (not yet used)
                NEXT_WORD
        };
@@ -64,7 +70,7 @@ public:
        /// Destructor
        ~LyXText();
 
-       void init(BufferView *);
+       void init(BufferView *, bool reinit = false);
        ///
        mutable int number_of_rows;
        ///
@@ -91,6 +97,10 @@ public:
        LyXFont const getFont(Buffer const *, Paragraph * par,
                        Paragraph::size_type pos) const;
        ///
+       LyXFont const getLayoutFont(Buffer const *, Paragraph * par) const;
+       ///
+       LyXFont const getLabelFont(Buffer const *, Paragraph * par) const;
+       ///
        void setCharFont(Buffer const *, Paragraph * par,
                         Paragraph::size_type pos, LyXFont const & font);
        void setCharFont(BufferView *, Paragraph * par,
@@ -145,6 +155,9 @@ public:
        
        ///
        void toggleFree(BufferView *, LyXFont const &, bool toggleall = false);
+
+       ///
+       string getStringToIndex(BufferView *);
        
        /** recalculates the heights of all previous rows of the
            specified paragraph.  needed, if the last characters font
@@ -166,10 +179,10 @@ public:
    
        /** Completes the insertion with a full rebreak.
            Returns true if something was broken. */
-        bool fullRebreak(BufferView *);
+       bool fullRebreak(BufferView *);
 
        ///
-       Row * need_break_row;
+       mutable Row * need_break_row;
        ///
        mutable int refresh_y;
        ///
@@ -182,12 +195,19 @@ public:
        mutable Row * refresh_row;
        ///
        int refresh_pos;
-       
+
+       /// give and set the LyXText status
+       text_status status() const;
+       ///
+       void status(BufferView *, text_status) const;
+
+private:       
        /** wether the screen needs a refresh,
           starting with refresh_y
           */
-       mutable text_status status;
+       mutable text_status status_;
        
+public:
        /** returns a pointer to the row near the specified y-coordinate
          (relative to the whole text). y is set to the real beginning
          of this row
@@ -219,10 +239,13 @@ public:
          Since the LyXText now has been moved from Buffer to BufferView
          it should not be absolutely needed to move the cursor...
          */
-       mutable LyXCursor cursor;
+       mutable LyXCursor cursor; // actual cursor position
 
-       /** The structrue that keeps track of the selections set. */
+       /** The structure that keeps track of the selections set. */
        struct Selection {
+               Selection() 
+                       : set_(false), mark_(false)
+                       {}
                bool set() const {
                        return set_;
                }
@@ -235,9 +258,10 @@ public:
                void mark(bool m) {
                        mark_ = m;
                }
-               LyXCursor cursor;
-               LyXCursor start;
-               LyXCursor end;
+               LyXCursor cursor; // temporary cursor to hold a cursor position
+                                 // until setSelection is called!
+               LyXCursor start;  // start of a REAL selection
+               LyXCursor end;    // end of a REAL selection
        private:
                bool set_; // former selection
                bool mark_; // former mark_set
@@ -245,31 +269,34 @@ public:
        };
        mutable Selection selection;
 
-       /// needed for the toggling
-       LyXCursor last_sel_cursor;
-       ///
-       LyXCursor toggle_cursor;
-       ///
-       LyXCursor toggle_end_cursor;
+       /// needed for the toggling (cursor position on last selection made)
+       mutable LyXCursor last_sel_cursor; 
+       /// needed for toggling the selection in screen.C
+       mutable LyXCursor toggle_cursor;
+       /// needed for toggling the selection in screen.C
+       mutable LyXCursor toggle_end_cursor;
    
        /// need the selection cursor:
        void setSelection(BufferView *);
        ///
-       void clearSelection(BufferView *) const;
+       void clearSelection() const;
        ///
-       string const selectionAsString(Buffer const *) const;
+       string const selectionAsString(Buffer const *, bool label) const;
        
        /// select the word we need depending on word_location
-       void getWord(LyXCursor & from, LyXCursor & to, word_location) const;
+       void getWord(LyXCursor & from, LyXCursor & to, 
+                    word_location const) const;
        /// just selects the word the cursor is in
-       void selectWord(BufferView *);
+       void selectWord(BufferView *, word_location const);
+       /// returns the inset at cursor (if it exists), 0 otherwise
+       Inset * getInset() const;
 
        /** 'selects" the next word, where the cursor is not in 
         and returns this word as string. THe cursor will be moved 
         to the beginning of this word. 
         With SelectSelectedWord can this be highlighted really
         */ 
-       string const selectNextWord(BufferView *, float & value) const;
+       string const selectNextWordToSpellcheck(BufferView *, float & value) const;
        ///
        void selectSelectedWord(BufferView *);
        ///
@@ -341,7 +368,8 @@ public:
        ///
        void deleteLineForward(BufferView *);
        ///
-       bool selectWordWhenUnderCursor(BufferView *);
+       bool selectWordWhenUnderCursor(BufferView *, 
+                                      word_location const);
        ///
        enum TextCase {
                ///
@@ -354,7 +382,12 @@ public:
        /// Change the case of the word at cursor position.
        void changeCase(BufferView *, TextCase action);
        ///
-       void transposeChars(BufferView const &);
+       void changeRegionCase(BufferView * bview,
+                                      LyXCursor const & from,
+                                      LyXCursor const & to,
+                                      LyXText::TextCase action);
+       ///
+       void transposeChars(BufferView &);
        
        /** returns a printed row in a pixmap. The y value is needed to
          decide, wether it is selected text or not. This is a strange
@@ -363,8 +396,10 @@ public:
        void getVisibleRow(BufferView *, int y_offset, int x_offset,
                           Row * row_ptr, int y, bool cleared=false);
 
+       /// 
+       void toggleInset(BufferView *);
        ///
-       void cutSelection(BufferView *, bool = true);
+       void cutSelection(BufferView *, bool doclear = true, bool realcut = true);
        ///
        void copySelection(BufferView *);
        ///
@@ -373,14 +408,6 @@ public:
        void copyEnvironmentType();
        ///
        void pasteEnvironmentType(BufferView *);
-       ///
-       void insertFootnote();
-       ///
-       void insertMarginpar();
-       ///
-       void insertFigure();
-       ///
-       void insertTabular();
 
        /** the DTP switches for paragraphs. LyX will store the top settings
         always in the first physical paragraph, the bottom settings in the
@@ -393,6 +420,7 @@ public:
                          bool pagebreak_top, bool pagebreak_bottom,
                          VSpace const & space_top,
                          VSpace const & space_bottom,
+                         Spacing const & spacing,
                          LyXAlignment align, 
                          string labelwidthstring,
                          bool noindent);
@@ -430,40 +458,6 @@ public:
        int numberOfCell(Paragraph * par,
                         Paragraph::size_type pos) const;
        ///
-       Paragraph * getParFromID(int id);
-
-       // undo functions
-       /// returns false if no undo possible
-       bool textUndo(BufferView *);
-       /// returns false if no redo possible
-       bool textRedo(BufferView *);
-       /// used by TextUndo/TextRedo
-       bool textHandleUndo(BufferView *, Undo * undo);
-       /// makes sure the next operation will be stored
-       void finishUndo();
-       /// this is dangerous and for internal use only
-       void freezeUndo();
-       /// this is dangerous and for internal use only
-       void unFreezeUndo();
-       /// the flag used by FinishUndo();
-       mutable bool undo_finished;
-       /// a flag
-       bool undo_frozen;
-       ///
-       void setUndo(Buffer *, Undo::undo_kind kind,
-                    Paragraph const * before,
-                    Paragraph const * end) const;
-       ///
-       void setRedo(Buffer *, Undo::undo_kind kind,
-                    Paragraph const * before,
-                    Paragraph const * end);
-       ///
-       Undo * createUndo(Buffer *, Undo::undo_kind kind,
-                         Paragraph const * before,
-                         Paragraph const * end) const;
-       /// for external use in lyx_cb.C
-       void setCursorParUndo(Buffer *);
-       ///
        void removeTableRow(LyXCursor & cursor) const;
        ///
        bool isEmptyTableCell() const;
@@ -506,8 +500,6 @@ public:
                        (bidi_start <= pos && pos <= bidi_end);
        }
 private:
-       ///
-       void init();
        ///
        mutable Row * firstrow;
        ///
@@ -552,13 +544,21 @@ private:
                            float & fill_label_hfill,
                            bool bidi = true) const;
 
+       // fix the cursor `cur' after a characters has been deleted at `where'
+       // position. Called by deleteEmptyParagraphMechanism
+       void fixCursorAfterDelete(BufferView * bview,
+                                 LyXCursor & cur,
+                                 LyXCursor const & where) const;
+       
        ///
        void deleteEmptyParagraphMechanism(BufferView *,
                                           LyXCursor const & old_cursor) const;
 
+public:
        /** Updates all counters starting BEHIND the row. Changed paragraphs
         * with a dynamic left margin will be rebroken. */ 
        void updateCounters(BufferView *, Row * row) const;
+private:
        ///
        void setCounter(Buffer const *, Paragraph * par) const;
    
@@ -621,6 +621,8 @@ private:
          */
        bool hfillExpansion(Buffer const *, Row const * row_ptr,
                            Paragraph::size_type pos) const;
+       /// 
+       LColor::color backgroundColor();
 
 
        ///
@@ -654,12 +656,15 @@ private:
 
        ///
        void charInserted();
+public:
        //
        // special owner functions
        ///
        Paragraph * ownerParagraph() const;
        //
        Paragraph * ownerParagraph(Paragraph *) const;
+       // set it searching first for the right owner using the paragraph id
+       Paragraph * ownerParagraph(int id, Paragraph *) const;
 };