Hi,
Attached is a patch for incremental search that does the following:
1) Searching for "" finds the search-anchor, not the EOF (this also
affects FindText()).
2) Add a search flag SCFIND_WRAP, that causes the search to wrap to the
start if the document end is reached (and vice-versa for reverse searches).
--
Snow
diff -r -u scin-base/include/Scintilla.h scin-search/include/Scintilla.h
--- scin-base/include/Scintilla.h 2006-02-25 23:58:22.000000000 +0000
+++ scin-search/include/Scintilla.h 2006-04-09 18:53:36.000000000 +0100
@@ -300,6 +300,7 @@
#define SCI_GETPRINTCOLOURMODE 2149
#define SCFIND_WHOLEWORD 2
#define SCFIND_MATCHCASE 4
+#define SCFIND_WRAP 8
#define SCFIND_WORDSTART 0x00100000
#define SCFIND_REGEXP 0x00200000
#define SCFIND_POSIX 0x00400000
diff -r -u scin-base/include/Scintilla.iface scin-search/include/Scintilla.iface
--- scin-base/include/Scintilla.iface 2006-04-09 17:12:48.000000000 +0100
+++ scin-search/include/Scintilla.iface 2006-04-09 18:54:04.000000000 +0100
@@ -730,6 +730,7 @@
enu FindOption=SCFIND_
val SCFIND_WHOLEWORD=2
val SCFIND_MATCHCASE=4
+val SCFIND_WRAP=8
val SCFIND_WORDSTART=0x00100000
val SCFIND_REGEXP=0x00200000
val SCFIND_POSIX=0x00400000
diff -r -u scin-base/src/Document.cxx scin-search/src/Document.cxx
--- scin-base/src/Document.cxx 2006-02-25 01:43:02.000000000 +0000
+++ scin-search/src/Document.cxx 2006-04-09 18:55:54.000000000 +0100
@@ -1110,6 +1110,8 @@
}
//Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos,
ft->lpstrText, lengthFind);
char firstChar = s[0];
+ if (firstChar == '\0')
+ return startPos;
if (!caseSensitive)
firstChar = static_cast<char>(MakeUpperCase(firstChar));
int pos = forward ? startPos : (startPos - 1);
diff -r -u scin-base/src/Editor.cxx scin-search/src/Editor.cxx
--- scin-base/src/Editor.cxx 2006-03-14 10:11:08.000000000 +0000
+++ scin-search/src/Editor.cxx 2006-04-09 18:58:40.000000000 +0100
@@ -4724,6 +4724,7 @@
const char *txt = reinterpret_cast<char *>(lParam);
int pos;
int lengthFound = istrlen(txt);
+ int patternLength = lengthFound;
if (iMessage == SCI_SEARCHNEXT) {
pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
(wParam & SCFIND_MATCHCASE) != 0,
@@ -4732,14 +4733,40 @@
(wParam & SCFIND_REGEXP) != 0,
(wParam & SCFIND_POSIX) != 0,
&lengthFound);
+ if (pos == -1 && searchAnchor != 0 && (wParam & SCFIND_WRAP) !=
0) {
+ int wrapEnd = searchAnchor + patternLength;
+ if (wrapEnd > pdoc->Length()) {
+ wrapEnd = pdoc->Length();
+ }
+ pos = pdoc->FindText(0, wrapEnd, txt,
+
(wParam & SCFIND_MATCHCASE) != 0,
+
(wParam & SCFIND_WHOLEWORD) != 0,
+
(wParam & SCFIND_WORDSTART) != 0,
+
(wParam & SCFIND_REGEXP) != 0,
+
(wParam & SCFIND_POSIX) != 0,
+
&lengthFound);
+ }
} else {
pos = pdoc->FindText(searchAnchor, 0, txt,
- (wParam & SCFIND_MATCHCASE) != 0,
- (wParam & SCFIND_WHOLEWORD) != 0,
- (wParam & SCFIND_WORDSTART) != 0,
- (wParam & SCFIND_REGEXP) != 0,
- (wParam & SCFIND_POSIX) != 0,
- &lengthFound);
+
(wParam & SCFIND_MATCHCASE) != 0,
+
(wParam & SCFIND_WHOLEWORD) != 0,
+
(wParam & SCFIND_WORDSTART) != 0,
+
(wParam & SCFIND_REGEXP) != 0,
+
(wParam & SCFIND_POSIX) != 0,
+
&lengthFound);
+ if (pos == -1 && searchAnchor != pdoc->Length() && (wParam &
SCFIND_WRAP) != 0) {
+ int wrapEnd = searchAnchor - patternLength;
+ if (wrapEnd < 0) {
+ wrapEnd = 0;
+ }
+ pos = pdoc->FindText(pdoc->Length(), wrapEnd, txt,
+
(wParam & SCFIND_MATCHCASE) != 0,
+
(wParam & SCFIND_WHOLEWORD) != 0,
+
(wParam & SCFIND_WORDSTART) != 0,
+
(wParam & SCFIND_REGEXP) != 0,
+
(wParam & SCFIND_POSIX) != 0,
+
&lengthFound);
+ }
}
if (pos != -1) {
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest