X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCursor.h;h=fc4daeb93b7a7f3b0619fd4a2573e20f565a3c3a;hb=af5257b6c3b24c00b18c601b77033cf7e60ce211;hp=6c5e5e67838bf51709bdbd0a5f7392021f9a10c2;hpb=02028c0b12ba94093e4e77494e7158a58f1631e5;p=lyx.git diff --git a/src/Cursor.h b/src/Cursor.h index 6c5e5e6783..fc4daeb93b 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -47,8 +47,7 @@ global. deriving from DocIterator * A Cursor is a descendant of CursorData that contains interesting - display-related information, in particular targetX(), the horizontal - position of the cursor in pixels. + display-related information, in particular the BufferView that owns it. */ #ifndef LCURSOR_H @@ -130,6 +129,12 @@ public: void setSelection(DocIterator const & where, int n); /// void clearSelection(); + /// check whether selection contains specific type of inset + /// returns 0 if no selection was made + bool insetInSelection(InsetCode const & inset); + /// count occurences of specific inset type in the selection + /// returns 0 if no selection was made + int countInsetsInSelection(InsetCode const & inset); /// access to normalized selection anchor CursorSlice normalAnchor() const; @@ -138,7 +143,6 @@ public: DocIterator & realAnchor() { return anchor_; } /// sets anchor to cursor position void resetAnchor(); - /// access to owning BufferView /// access start of selection CursorSlice selBegin() const; @@ -150,32 +154,24 @@ public: DocIterator selectionEnd() const; /// - docstring selectionAsString(bool with_label) const; + docstring selectionAsString(bool const with_label, + bool const skipdelete = false) const; /// get some interesting description of top position void info(odocstream & os, bool devel_mode) const; /// docstring currentState(bool devel_mode) const; - /// auto-correct mode - bool autocorrect() const { return autocorrect_; } - /// auto-correct mode - bool & autocorrect() { return autocorrect_; } - /// fix cursor in circumstances that should never happen. /// \retval true if a fix occurred. bool fixIfBroken(); /// Repopulate the slices insets from bottom to top. Useful /// for stable iterators or Undo data. void sanitize(); - /// - bool isInside(Inset const *) const; - /// make sure we are outside of given inset - void leaveInset(Inset const & inset); /// - bool textUndo(); + bool undoAction(); /// - bool textRedo(); + bool redoAction(); /// makes sure the next operation will be stored void finishUndo() const; @@ -183,6 +179,8 @@ public: void beginUndoGroup() const; /// end the current undo group void endUndoGroup() const; + /// end abruptly the current group and create a new one wih the same nesting level + void splitUndoGroup() const; /// The general case: prepare undo for an arbitrary range. void recordUndo(pit_type from, pit_type to) const; @@ -192,7 +190,7 @@ public: /// containing the cursor void recordUndo(UndoKind kind = ATOMIC_UNDO) const; /// Convenience: prepare undo for the inset containing the cursor - void recordUndoInset(Inset const * inset = 0) const; + void recordUndoInset(Inset const * inset = nullptr) const; /// Convenience: prepare undo for the whole buffer void recordUndoFullBuffer() const; /// Convenience: prepare undo for buffer parameters @@ -216,7 +214,7 @@ public: /// one inset in the selection has confirmDeletion. bool confirmDeletion(bool before = false) const; -protected: +private: /// validate the "new born word" position void checkNewWordPosition(); /// clear the "new born word" position @@ -231,22 +229,19 @@ protected: /// are we in word-selection mode? This is set when double clicking. bool word_selection_; -// FIXME: make them protected. -public: - /// the current font settings - Font current_font; - /// the current font - Font real_current_font; - -protected: - /// the start of the new born word DocIterator new_word_; // // math specific stuff that could be promoted to "global" later // - /// do we allow autocorrection - bool autocorrect_; + + // FIXME: make them private +public: + /// The current font settings. This holds the settings for output. + Font current_font; + /// The current display font. This holds the settings of the text + /// in the workarea. + Font real_current_font; }; @@ -261,6 +256,10 @@ public: void push(Inset & inset); /// add a new cursor slice, place cursor at front (move backwards) void pushBackward(Inset & inset); + /// try to put cursor in inset before it in entry cell, or next one + /// if it is not empty, or exit the slice if there is no next one. + void editInsertedInset(); + /// pop one level off the cursor void pop(); /// pop one slice off the cursor stack and go backwards @@ -281,7 +280,13 @@ public: /// get the resut of the last dispatch DispatchResult const & result() const; - /// + /// Set the cursor language from current input method language + /* Considers first exact math with the codes used in the document, + * then approximate match among the same list, and finally exact + * or partial match with the whole list of languages. + */ + void setLanguageFromInput(); + /// Set the current font of the cursor from its location. void setCurrentFont(); /** @@ -380,6 +385,7 @@ public: /// distance between actual and targeted position during last up/down in text int textTargetOffset() const; + /// access to owning BufferView BufferView & bv() const; /// reset cursor bottom to the beginning of the top inset // (sort of 'chroot' environment...) @@ -397,16 +403,11 @@ public: void undispatched() const; /// the event was already dispatched void dispatched() const; - /// Set which screen update should be done + + /// Describe the screen update that should be done void screenUpdateFlags(Update::flags f) const; - /// Forces an updateBuffer() call - void forceBufferUpdate() const; - /// Removes any pending updateBuffer() call - void clearBufferUpdate() const; - /// Do we need to call updateBuffer()? - bool needBufferUpdate() const; /** - * don't call update() when done + * Reset update flags to Update::None. * * Should only be called by an inset's doDispatch() method. It means: * I handled that request and I can reassure you that the screen does @@ -417,6 +418,13 @@ public: */ void noScreenUpdate() const; + /// Forces an updateBuffer() call + void forceBufferUpdate() const; + /// Removes any pending updateBuffer() call + void clearBufferUpdate() const; + /// Do we need to call updateBuffer()? + bool needBufferUpdate() const; + /// Repopulate the slices insets from bottom to top. Useful /// for stable iterators or Undo data. void sanitize(); @@ -504,9 +512,9 @@ public: /// void plainInsert(MathAtom const & at); - /// interpret name of a macro. Returns true if something got - /// inserted. - bool macroModeClose(); + /// interpret name of a macro or ditch it if \c cancel is true. + /// Returns true if something got inserted. + bool macroModeClose(bool cancel = false); /// are we currently typing the name of a macro? bool inMacroMode() const; /// get access to the macro we are currently typing @@ -516,10 +524,9 @@ public: /// the name of the macro we are currently inputting docstring macroName(); - /// replace selected stuff with at, placing the former - // selection in given cell of atom - void handleNest(MathAtom const & at, int cell = 0); + // selection in entry cell of atom + void handleNest(MathAtom const & at); /// make sure cursor position is valid /// FIXME: It does a subset of fixIfBroken. Maybe merge them? @@ -549,4 +556,4 @@ bool notifyCursorLeavesOrEnters(Cursor const & old, Cursor & cur); } // namespace lyx -#endif // LYXLCURSOR_H +#endif // LCURSOR_H