| 411 | } |
| 412 | |
| 413 | void CodeEntry::RenderOverlay() |
| 414 | { |
| 415 | if (IKeyboardFocusListener::GetActiveKeyboardFocus() != this) |
| 416 | return; |
| 417 | |
| 418 | if (!IsAutocompleteShowing()) |
| 419 | return; |
| 420 | |
| 421 | ofVec2f caretPos = ofVec2f(mAutocompleteCaretCoords.x * mCharWidth + mX + 1.5f - mScroll.x, mAutocompleteCaretCoords.y * mCharHeight + mY + 2 - mScroll.y); |
| 422 | |
| 423 | ofFill(); |
| 424 | |
| 425 | for (size_t i = 0; i < mAutocompletes.size(); ++i) |
| 426 | { |
| 427 | if (mAutocompletes[i].valid) |
| 428 | { |
| 429 | int charactersLeft = (int)mAutocompletes[i].autocompleteFull.length() - (int)mAutocompletes[i].autocompleteRest.length(); |
| 430 | float x = caretPos.x - charactersLeft * mCharWidth; |
| 431 | float y = caretPos.y + mCharHeight * (i + 2) - 2; |
| 432 | if (i == mAutocompleteHighlightIndex) |
| 433 | ofSetColor(jediIndexBg); |
| 434 | else |
| 435 | ofSetColor(jediBg); |
| 436 | ofRect(x, y - mCharHeight + 2, gFontFixedWidth.GetStringWidth(mAutocompletes[i].autocompleteFull, mFontSize), mCharHeight); |
| 437 | |
| 438 | ofSetColor(jediAutoComplete); |
| 439 | gFontFixedWidth.DrawString(mAutocompletes[i].autocompleteFull, mFontSize, x, y); |
| 440 | ofSetColor(jediAutoCompleteRest); |
| 441 | std::string prefix = ""; |
| 442 | for (size_t j = 0; j < charactersLeft; ++j) |
| 443 | prefix += " "; |
| 444 | gFontFixedWidth.DrawString(prefix + mAutocompletes[i].autocompleteRest, mFontSize, x, y); |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | for (size_t i = 0; i < mAutocompleteSignatures.size(); ++i) |
| 449 | { |
| 450 | if (mAutocompleteSignatures[i].valid && mAutocompleteSignatures[i].params.size() > 0) |
| 451 | { |
| 452 | std::string params = "("; |
| 453 | std::string highlightParamString = " "; |
| 454 | for (size_t j = 0; j < mAutocompleteSignatures[i].params.size(); ++j) |
| 455 | { |
| 456 | std::string param = mAutocompleteSignatures[i].params[j]; |
| 457 | std::string placeholder = ""; |
| 458 | for (size_t k = 0; k < param.length(); ++k) |
| 459 | placeholder += " "; |
| 460 | if (j == mAutocompleteSignatures[i].entryIndex) |
| 461 | { |
| 462 | params += placeholder; |
| 463 | highlightParamString += mAutocompleteSignatures[i].params[j]; |
| 464 | } |
| 465 | else |
| 466 | { |
| 467 | params += mAutocompleteSignatures[i].params[j]; |
| 468 | highlightParamString += placeholder; |
| 469 | } |
| 470 |
no test coverage detected