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