MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / FindNext

Method FindNext

editor/ScriptStudio.cpp:445–512  ·  view source on GitHub ↗

This will look for the next series of charaters (given by the null terminated w) If it finds the string, it will highlight/select it and move the caret to the beginning of the word returns true if it found the string else false

Source from the content-addressed store, hash-verified

443// returns true if it found the string
444// else false
445bool CScriptStudio::FindNext(char *w) {
446 int index, max;
447 bool word_found;
448 bool new_word;
449 static int start = 0;
450
451 word_found = false;
452
453 // See if this is a new word to look for (as compared to the last searched word)
454 if (m_LastWord != w) {
455 m_LastWord = w;
456 start = 0;
457 new_word = true;
458 } else
459 new_word = false;
460
461 // This will update the m_sScript string so it has the current script in it
462 UpdateEditText();
463
464 // Make a copy of the script to work with
465 char *text;
466 text = (char *)mem_malloc(m_EditText.GetLength() + 1);
467 if (!text)
468 Int3();
469 strcpy(text, (LPCSTR)m_EditText);
470 max = m_EditText.GetLength();
471
472 // Make sure we aren't gonna try to go past the end of the buffer, start at 0 if we are
473 if (start + (signed)strlen(w) >= max - 1)
474 start = 0;
475
476 // Here we begin the search
477 for (index = start; index < max; index++) {
478 // check the character it's at in the buffer to the first character of the find string, if they are the same
479 // it's a possibility, so Check the word
480 if (toupper(text[index]) == toupper(w[0]))
481 if (CheckWord(index, text, w)) {
482 // We got a match, so move the caret, and select the word
483 SetCurrentIndex(index);
484 SetSelection(index, strlen(w));
485 word_found = true;
486 // adjust start so on the next FindNext() it will start from the next character
487 start = index + 1;
488 index = max;
489 }
490 }
491
492 if (text)
493 mem_free(text);
494
495 if (!word_found) {
496 // This can mean 2 things. We searched to the end of the file and either never found a word, or we did at one time
497
498 // either way, start back at the beginning next time
499 start = 0;
500
501 // if it was a new word then we never found it
502 if (new_word) {

Callers

nothing calls this directly

Calls 3

SetCurrentIndexFunction · 0.85
OutrageMessageBoxFunction · 0.85
GetLengthMethod · 0.80

Tested by

no test coverage detected