diff options
author | Leandro Melo <leandro.melo@nokia.com> | 2010-11-30 14:14:33 +0100 |
---|---|---|
committer | Leandro Melo <leandro.melo@nokia.com> | 2010-12-01 09:07:15 +0100 |
commit | ea8cb4764be669f72472b5f0b056e54f8075e58f (patch) | |
tree | e603b8fe375a06c9eb72c0d22f84c15b9d98a961 /src/plugins/texteditor/autocompleter.h | |
parent | e117f04fabde000f4c0aae7cc1a82c58da1ba4c3 (diff) |
Editors: Move auto-completion code out of the editor
This is basically a continuation of the commits which
refactor code out of the base text editor. For instance,
36fa1de4c6a15b2c44736b3491679dd6cfbe27ce and
3a684586fabf103b8e09cef31a18ffae1fd9f0c7.
Also removed the doXXXX() forwarding methods.
Diffstat (limited to 'src/plugins/texteditor/autocompleter.h')
-rw-r--r-- | src/plugins/texteditor/autocompleter.h | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/src/plugins/texteditor/autocompleter.h b/src/plugins/texteditor/autocompleter.h index 3b49d499a4..f8ecc1ce49 100644 --- a/src/plugins/texteditor/autocompleter.h +++ b/src/plugins/texteditor/autocompleter.h @@ -47,30 +47,45 @@ public: AutoCompleter(); virtual ~AutoCompleter(); - bool contextAllowsAutoParentheses(const QTextCursor &cursor, - const QString &textToInsert = QString()) const; - bool contextAllowsElectricCharacters(const QTextCursor &cursor) const; + void setAutoParenthesesEnabled(bool b); + bool isAutoParenthesesEnabled() const; + + void setSurroundWithEnabled(bool b); + bool isSurroundWithEnabled() const; + + // Returns the text to complete at the cursor position, or an empty string + virtual QString autoComplete(QTextCursor &cursor, const QString &text) const; + + // Handles backspace. When returning true, backspace processing is stopped + virtual bool autoBackspace(QTextCursor &cursor); + + // Hook to insert special characters on enter. Returns the number of extra blocks inserted. + virtual int paragraphSeparatorAboutToBeInserted(QTextCursor &cursor); + + virtual bool contextAllowsAutoParentheses(const QTextCursor &cursor, + const QString &textToInsert = QString()) const; + virtual bool contextAllowsElectricCharacters(const QTextCursor &cursor) const; // Returns true if the cursor is inside a comment. - bool isInComment(const QTextCursor &cursor) const; + virtual bool isInComment(const QTextCursor &cursor) const; + + virtual QString insertMatchingBrace(const QTextCursor &cursor, const + QString &text, + QChar la, + int *skippedChars) const; - QString insertMatchingBrace(const QTextCursor &cursor, const - QString &text, - QChar la, - int *skippedChars) const; // Returns the text that needs to be inserted - QString insertParagraphSeparator(const QTextCursor &cursor) const; + virtual QString insertParagraphSeparator(const QTextCursor &cursor) const; + +protected: + static void countBracket(QChar open, QChar close, QChar c, int *errors, int *stillopen); + static void countBrackets(QTextCursor cursor, int from, int end, QChar open, QChar close, + int *errors, int *stillopen); private: - virtual bool doContextAllowsAutoParentheses(const QTextCursor &cursor, - const QString &textToInsert = QString()) const; - virtual bool doContextAllowsElectricCharacters(const QTextCursor &cursor) const; - virtual bool doIsInComment(const QTextCursor &cursor) const; - virtual QString doInsertMatchingBrace(const QTextCursor &cursor, - const QString &text, - QChar la, - int *skippedChars) const; - virtual QString doInsertParagraphSeparator(const QTextCursor &cursor) const; + mutable bool m_allowSkippingOfBlockEnd; + bool m_surroundWithEnabled; + bool m_autoParenthesesEnabled; }; } // TextEditor |