| 208 | } |
| 209 | |
| 210 | bool DbgFileView::findString(const char *text) |
| 211 | { |
| 212 | //make sure we have a valid string to find |
| 213 | if (!text || !text[0]) |
| 214 | return false; |
| 215 | |
| 216 | //see which line we start searching from |
| 217 | S32 curLine = 0; |
| 218 | bool searchAgain = false; |
| 219 | if (mFindLineNumber >= 0 && !dStricmp(mFindString, text)) |
| 220 | { |
| 221 | searchAgain = true; |
| 222 | curLine = mFindLineNumber; |
| 223 | } |
| 224 | else |
| 225 | mFindLineNumber = -1; |
| 226 | |
| 227 | //copy the search text |
| 228 | dStrncpy(mFindString, text, 255); |
| 229 | S32 length = dStrlen(mFindString); |
| 230 | |
| 231 | //loop through looking for the next instance |
| 232 | while (curLine < mFileView.size()) |
| 233 | { |
| 234 | char *curText; |
| 235 | if (curLine == mFindLineNumber && mBlockStart >= 0) |
| 236 | curText = &mFileView[curLine].text[mBlockStart + 1]; |
| 237 | else |
| 238 | curText = &mFileView[curLine].text[0]; |
| 239 | |
| 240 | //search for the string (the hard way... - apparently dStrupr is broken... |
| 241 | char *found = NULL; |
| 242 | char *curTextPtr = curText; |
| 243 | while (*curTextPtr != '\0') |
| 244 | { |
| 245 | if (!dStrnicmp(mFindString, curTextPtr, length)) |
| 246 | { |
| 247 | found = curTextPtr; |
| 248 | break; |
| 249 | } |
| 250 | else |
| 251 | curTextPtr++; |
| 252 | } |
| 253 | |
| 254 | //did we find it? |
| 255 | if (found) |
| 256 | { |
| 257 | //scroll first |
| 258 | mFindLineNumber = curLine; |
| 259 | scrollToLine(mFindLineNumber + 1); |
| 260 | |
| 261 | //then hilite |
| 262 | mBlockStart = (S32)(found - &mFileView[curLine].text[0]); |
| 263 | mBlockEnd = mBlockStart + length; |
| 264 | |
| 265 | return true; |
| 266 | } |
| 267 | else |