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

Function tabComplete

Engine/source/console/console.cpp:424–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424U32 tabComplete(char* inputBuffer, U32 cursorPos, U32 maxResultLength, bool forwardTab)
425{
426 // Check for null input.
427 if (!inputBuffer[0])
428 {
429 return cursorPos;
430 }
431
432 // Cap the max result length.
433 if (maxResultLength > MaxCompletionBufferSize)
434 {
435 maxResultLength = MaxCompletionBufferSize;
436 }
437
438 // See if this is the same partial text as last checked.
439 if (dStrcmp(tabBuffer, inputBuffer))
440 {
441 // If not...
442 // Save it for checking next time.
443 dStrcpy(tabBuffer, inputBuffer);
444 // Scan backward from the cursor position to find the base to complete from.
445 S32 p = cursorPos;
446 while ((p > 0) && (inputBuffer[p - 1] != ' ') && (inputBuffer[p - 1] != '.') && (inputBuffer[p - 1] != '('))
447 {
448 p--;
449 }
450 completionBaseStart = p;
451 completionBaseLen = cursorPos - p;
452 // Is this function being invoked on an object?
453 if (inputBuffer[p - 1] == '.')
454 {
455 // If so...
456 if (p <= 1)
457 {
458 // Bail if no object identifier.
459 return cursorPos;
460 }
461
462 // Find the object identifier.
463 S32 objLast = --p;
464 while ((p > 0) && (inputBuffer[p - 1] != ' ') && (inputBuffer[p - 1] != '('))
465 {
466 p--;
467 }
468
469 if (objLast == p)
470 {
471 // Bail if no object identifier.
472 return cursorPos;
473 }
474
475 // Look up the object identifier.
476 dStrncpy(completionBuffer, inputBuffer + p, objLast - p);
477 completionBuffer[objLast - p] = 0;
478 tabObject = Sim::findObject(completionBuffer);
479 if (tabObject == NULL)
480 {
481 // Bail if not found.

Callers 3

onKeyDownMethod · 0.85
processMethod · 0.85
processMethod · 0.85

Calls 6

dStrcpyFunction · 0.85
dStrncpyFunction · 0.85
findObjectFunction · 0.70
dStrcmpFunction · 0.50
dStrlenFunction · 0.50
tabCompleteMethod · 0.45

Tested by

no test coverage detected