diff options
author | Ken Moore <moorekou@gmail.com> | 2016-04-21 09:26:39 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-04-21 09:26:39 -0400 |
commit | c62ef0b3e2fd1c047a0d8ed302c35294dc700a3e (patch) | |
tree | 5866745de044374f9ff3be02e679bbab8c4d37d9 /desktop-utilities/lumina-textedit | |
parent | Also make sure the current tab/filename is reflected in the window title for ... (diff) | |
download | lumina-c62ef0b3e2fd1c047a0d8ed302c35294dc700a3e.tar.gz lumina-c62ef0b3e2fd1c047a0d8ed302c35294dc700a3e.tar.bz2 lumina-c62ef0b3e2fd1c047a0d8ed302c35294dc700a3e.zip |
Make the bracket highlighting also check the previous character if nothing found for the next character.
Diffstat (limited to 'desktop-utilities/lumina-textedit')
-rw-r--r-- | desktop-utilities/lumina-textedit/PlainTextEditor.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/desktop-utilities/lumina-textedit/PlainTextEditor.cpp b/desktop-utilities/lumina-textedit/PlainTextEditor.cpp index 3a453b79..fb02f905 100644 --- a/desktop-utilities/lumina-textedit/PlainTextEditor.cpp +++ b/desktop-utilities/lumina-textedit/PlainTextEditor.cpp @@ -216,12 +216,22 @@ void PlainTextEditor::checkMatchChar(){ clearMatchData(); int pos = this->textCursor().position(); QChar ch = this->document()->characterAt(pos); - if(ch==QChar('(')){ highlightMatch(QChar(')'),true, pos); } - else if(ch==QChar(')')){ highlightMatch(QChar('('),false, pos); } - else if(ch==QChar('{')){ highlightMatch(QChar('}'),true, pos); } - else if(ch==QChar('}')){ highlightMatch(QChar('{'),false, pos); } - else if(ch==QChar('[')){ highlightMatch(QChar(']'),true, pos); } - else if(ch==QChar(']')){ highlightMatch(QChar('['),false, pos); } + bool tryback = true; + while(tryback){ + tryback = false; + if(ch==QChar('(')){ highlightMatch(QChar(')'),true, pos); } + else if(ch==QChar(')')){ highlightMatch(QChar('('),false, pos); } + else if(ch==QChar('{')){ highlightMatch(QChar('}'),true, pos); } + else if(ch==QChar('}')){ highlightMatch(QChar('{'),false, pos); } + else if(ch==QChar('[')){ highlightMatch(QChar(']'),true, pos); } + else if(ch==QChar(']')){ highlightMatch(QChar('['),false, pos); } + else if(pos==this->textCursor().position()){ + //Try this one more time - using the previous character instead of the current character + tryback = true; + pos--; + ch = this->document()->characterAt(pos); + } + } //end check for next/previous char } //Functions for notifying the parent widget of changes |