ecode: Fix in ProjectSearch.

This commit is contained in:
Martín Lucas Golini
2022-09-19 11:12:20 -03:00
parent aaf9608ea1
commit 2c2d6b03ac
2 changed files with 22 additions and 23 deletions

View File

@@ -28,8 +28,10 @@ static String textLine( const std::string& fileText, const size_t& fromPos, size
if ( stringStartPtr != ptr ) {
while ( stringStartPtr != ptr && *--ptr != '\n' ) {
}
nlStartPtr = ptr + 1;
start = ptr - stringStartPtr + 1;
if ( stringStartPtr != ptr ) {
nlStartPtr = ptr + 1;
start = ptr - stringStartPtr + 1;
}
}
ptr = startPtr;
while ( ++ptr && *ptr != '\0' && *ptr != '\n' ) {

View File

@@ -148,7 +148,7 @@ UIPushButton* UITreeViewCellGlobalSearch::updateText( const std::string& text )
const String& txt = mTextBox->getText();
if ( mSearchStrPos.second < txt.size() ) {
if ( mSearchStrPos.second <= txt.size() ) {
mResultStr = String( txt.toUtf8().substr(
mSearchStrPos.first, mSearchStrPos.second - mSearchStrPos.first ) );
} else {
@@ -191,28 +191,25 @@ static Float getXOffsetCol( Float glyphWidth, Uint32 tabWidth, const String& lin
void UITreeViewCellGlobalSearch::draw() {
UITreeViewCell::draw();
if ( getCurIndex().internalId() != -1 ) {
if ( getCurIndex().internalId() != -1 && mSearchStrPos.first != std::string::npos &&
mSearchStrPos.second > 0 && mSearchStrPos.second <= mTextBox->getText().length() ) {
UITreeViewGlobalSearch* pp = getParent()->getParent()->asType<UITreeViewGlobalSearch>();
if ( mSearchStrPos.first != std::string::npos && mSearchStrPos.second > 0 ) {
auto hspace =
mTextBox->getFont()->getGlyph( L' ', mTextBox->getPixelsFontSize(), false ).advance;
Primitives p;
p.setColor( pp->getColorScheme().getEditorSyntaxStyle( "selection" ).color );
Vector2f screenPos( mScreenPos );
if ( mTextBox->isType( UI_TYPE_CHECKBOX ) ) {
UICheckBox* chk = mTextBox->asType<UICheckBox>();
screenPos.x += chk->getRealAlignOffset().x;
}
if ( mSearchStrPos.second >= mTextBox->getText().length() )
return;
p.drawRectangle( Rectf(
{ screenPos.x + mTextBox->getPixelsPosition().x +
getXOffsetCol( hspace, mTextBox->getTextCache()->getTabWidth(),
mTextBox->getText(), mSearchStrPos.first ),
screenPos.y + mTextBox->getPixelsPosition().y },
Sizef( getTextWidth( hspace, mTextBox->getTextCache()->getTabWidth(), mResultStr ),
mTextBox->getPixelsSize().getHeight() ) ) );
auto hspace =
mTextBox->getFont()->getGlyph( L' ', mTextBox->getPixelsFontSize(), false ).advance;
Primitives p;
p.setColor( pp->getColorScheme().getEditorSyntaxStyle( "selection" ).color );
Vector2f screenPos( mScreenPos );
if ( mTextBox->isType( UI_TYPE_CHECKBOX ) ) {
UICheckBox* chk = mTextBox->asType<UICheckBox>();
screenPos.x += chk->getRealAlignOffset().x;
}
p.drawRectangle( Rectf(
{ screenPos.x + mTextBox->getPixelsPosition().x +
getXOffsetCol( hspace, mTextBox->getTextCache()->getTabWidth(),
mTextBox->getText(), mSearchStrPos.first ),
screenPos.y + mTextBox->getPixelsPosition().y },
Sizef( getTextWidth( hspace, mTextBox->getTextCache()->getTabWidth(), mResultStr ),
mTextBox->getPixelsSize().getHeight() ) ) );
}
}