| 424 | } |
| 425 | |
| 426 | bool DbgFileView::findMouseOverVariable() |
| 427 | { |
| 428 | GuiCanvas *root = getRoot(); |
| 429 | AssertFatal(root, "Unable to get the root Canvas."); |
| 430 | |
| 431 | Point2I curMouse = root->getCursorPos(); |
| 432 | Point2I pt = globalToLocalCoord(curMouse); |
| 433 | |
| 434 | //find out which cell was hit |
| 435 | Point2I cell((pt.x < 0 ? -1 : pt.x / mCellSize.x), (pt.y < 0 ? -1 : pt.y / mCellSize.y)); |
| 436 | if(cell.x >= 0 && cell.x < mSize.x && cell.y >= 0 && cell.y < mSize.y) |
| 437 | { |
| 438 | S32 stringPosition = pt.x - gFileXOffset; |
| 439 | char tempBuf[256], *varNamePtr = &tempBuf[1]; |
| 440 | dStrcpy(tempBuf, mFileView[cell.y].text, 256); |
| 441 | |
| 442 | //find the current mouse over char |
| 443 | S32 charNum = findMouseOverChar(mFileView[cell.y].text, stringPosition); |
| 444 | if (charNum >= 0) |
| 445 | { |
| 446 | varNamePtr = &tempBuf[charNum]; |
| 447 | } |
| 448 | else |
| 449 | { |
| 450 | mMouseOverVariable[0] = '\0'; |
| 451 | mMouseOverValue[0] = '\0'; |
| 452 | return false; |
| 453 | } |
| 454 | |
| 455 | //now make sure we can go from the current cursor mPosition to the beginning of a var name |
| 456 | bool found = false; |
| 457 | while (varNamePtr >= &tempBuf[0]) |
| 458 | { |
| 459 | if (*varNamePtr == '%' || *varNamePtr == '$') |
| 460 | { |
| 461 | found = true; |
| 462 | break; |
| 463 | } |
| 464 | else if ((dToupper(*varNamePtr) >= 'A' && dToupper(*varNamePtr) <= 'Z') || |
| 465 | (*varNamePtr >= '0' && *varNamePtr <= '9') || *varNamePtr == '_' || *varNamePtr == ':') |
| 466 | { |
| 467 | varNamePtr--; |
| 468 | } |
| 469 | else |
| 470 | { |
| 471 | break; |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | //mouse wasn't over a possible variable name |
| 476 | if (! found) |
| 477 | { |
| 478 | mMouseOverVariable[0] = '\0'; |
| 479 | mMouseOverValue[0] = '\0'; |
| 480 | return false; |
| 481 | } |
| 482 | |
| 483 | //set the var char start positions |
nothing calls this directly
no test coverage detected