MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / findString

Method findString

Engine/source/gui/editor/guiDebugger.cpp:204–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

DbgFileViewFindFunction · 0.80
DbgFileViewFindFunction · 0.80
guiDebugger.cppFile · 0.80

Calls 6

dStricmpFunction · 0.85
dStrncpyFunction · 0.85
dStrnicmpFunction · 0.85
dStrlenFunction · 0.50
Point2IClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected