diff options
Diffstat (limited to 'kjots/kjotsedit.h')
-rw-r--r-- | kjots/kjotsedit.h | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/kjots/kjotsedit.h b/kjots/kjotsedit.h index 6506fab..75012f8 100644 --- a/kjots/kjotsedit.h +++ b/kjots/kjotsedit.h @@ -23,11 +23,16 @@ #ifndef __KJOTSEDIT_H #define __KJOTSEDIT_H -#include <keditcl.h> +#include <ktextedit.h> + +class KFind; +class KFindDialog; +class KReplace; +class KReplaceDialog; class TDEPopupMenu; class KJotsPage; -class KJotsEdit : public KEdit +class KJotsEdit : public KTextEdit { TQ_OBJECT @@ -41,14 +46,62 @@ class KJotsEdit : public KEdit signals: void findSuccessful(); + public slots: + // Create the initial KFindDialog. + void find(); + // Repeat the previous search. + // Creates KFindDialog if needed. + void findNext(); + // Repeat the previous search, but in the opposite direction. + // Creates KFindDialog if needed. + void findPrev(); + // Creates a KReplaceDialog + void replace(); + protected slots: - void openUrl(); + void openUrl(); + void slotFindHighlight(const TQString&, int, int); + void slotReplaceHighlight(const TQString&, int, int); + void slotDoFind(); + void slotDoReplace(); + void slotReplace(const TQString&, int, int, int); + void slotReplaceNext(); protected: virtual void mousePressEvent (TQMouseEvent *e); TDEPopupMenu *web_menu; KJotsPage *m_entry; //!< The entry we are editing. It needs to be kept informed. + + private: + + /* + * Keep track of the current cursor position for find/replace + * functionality, allowing us to increment easily. + */ + struct CursorPosition + { + // Current paragraph. + int paragraph; + // Index from start of current paragraph. + int paragraphIndex; + }; + + KFind *m_find; + KFindDialog *m_findDialog; + KReplace *m_replace; + KReplaceDialog *m_replaceDialog; + + // Maintaining two positions to allow replace while find still active. + CursorPosition m_findCursor{0, 0}; + CursorPosition m_replaceCursor{0, 0}; + + // Start and end position of selection, used to restart search with initial selection. + CursorPosition m_selectionStart{0, 0}; + CursorPosition m_selectionEnd{0, 0}; + + // Setup for m_findCursor/m_replaceCursor with m_find/m_replace + void setupCursor(CursorPosition*, const KFind*); }; #endif // __KJOTSEDIT_H |