diff options
author | nyamatongwe <unknown> | 2000-09-04 13:12:01 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2000-09-04 13:12:01 +0000 |
commit | 90e1b590ae736c53fb37e22ea90c8f07064403e0 (patch) | |
tree | 105694b92861b678ee50da068da5501fb33758ae /src/Document.cxx | |
parent | 4438c10faf264c4b7cff5c29acabe94cce37e32f (diff) | |
download | scintilla-mirror-90e1b590ae736c53fb37e22ea90c8f07064403e0.tar.gz |
Added SCFIND_WORDSTART.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r-- | src/Document.cxx | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index f8d349adb..c883dd253 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -717,25 +717,29 @@ int Document::NextWordStart(int pos, int delta) { return pos; } -bool Document::IsWordAt(int start, int end) { - int lengthDoc = Length(); - if (start > 0) { - char ch = CharAt(start - 1); - if (IsWordChar(ch)) - return false; +bool Document::IsWordStartAt(int pos) { + if (pos > 0) { + return !IsWordChar(CharAt(pos - 1)); } - if (end < lengthDoc - 1) { - char ch = CharAt(end); - if (IsWordChar(ch)) - return false; + return true; +} + +bool Document::IsWordEndAt(int pos) { + if (pos < Length() - 1) { + return !IsWordChar(CharAt(pos)); } return true; } +bool Document::IsWordAt(int start, int end) { + return IsWordStartAt(start) && IsWordEndAt(end); +} + // Find text in document, supporting both forward and backward // searches (just pass minPos > maxPos to do a backward search) // Has not been tested with backwards DBCS searches yet. -long Document::FindText(int minPos, int maxPos, const char *s, bool caseSensitive, bool word) { +long Document::FindText(int minPos, int maxPos, const char *s, + bool caseSensitive, bool word, bool wordStart) { bool forward = minPos <= maxPos; int increment = forward ? 1 : -1; @@ -765,8 +769,10 @@ long Document::FindText(int minPos, int maxPos, const char *s, bool caseSensitiv found = false; } if (found) { - if ((!word) || IsWordAt(pos, pos + lengthFind)) - return pos; + if ((!word && !wordStart) || + word && IsWordAt(pos, pos + lengthFind) || + wordStart && IsWordStartAt(pos)) + return pos; } } } else { @@ -778,8 +784,10 @@ long Document::FindText(int minPos, int maxPos, const char *s, bool caseSensitiv found = false; } if (found) { - if ((!word) || IsWordAt(pos, pos + lengthFind)) - return pos; + if (!(word && wordStart) || + word && IsWordAt(pos, pos + lengthFind) || + wordStart && IsWordStartAt(pos)) + return pos; } } } |