Bug fix in ProjectSearch (ecode).

Minor fxi in UITreeViewGlobalSearch results.
Fix in the UITextInput text input.
This commit is contained in:
Martín Lucas Golini
2020-09-02 00:40:57 -03:00
parent 763683a818
commit 9178fc168a
8 changed files with 47 additions and 39 deletions

View File

@@ -723,6 +723,9 @@ void App::showGlobalSearch() {
mEditorSplitter->getCurEditor()->getDocument().getSelectedText() );
}
mGlobalSearchInput->getDocument().selectAll();
auto* loader = mGlobalSearchTree->getParent()->find( "loader" );
if ( loader )
loader->setVisible( true );
updateGlobalSearchBar();
}
@@ -742,6 +745,9 @@ void App::updateGlobalSearchBar() {
void App::hideGlobalSearchBar() {
mGlobalSearchBarLayout->setEnabled( false )->setVisible( false );
mGlobalSearchTree->setVisible( false );
auto* loader = mGlobalSearchTree->getParent()->find( "loader" );
if ( loader )
loader->setVisible( false );
}
void App::initGlobalSearchBar() {
@@ -759,7 +765,7 @@ void App::initGlobalSearchBar() {
mGlobalSearchBarLayout->addCommand( "search-in-files", [&, caseSensitiveChk] {
if ( mDirTree && mDirTree->getFilesCount() > 0 && !mGlobalSearchInput->getText().empty() ) {
UILoader* loader = UILoader::New();
loader->setId( "loader " );
loader->setId( "loader" );
loader->setRadius( 48 );
loader->setOutlineThickness( 6 );
loader->setFillColor( Color::Red );

View File

@@ -5,10 +5,12 @@ static int countNewLines( const std::string& text, const size_t& start, const si
const char* startPtr = text.c_str() + start;
const char* endPtr = text.c_str() + end;
size_t count = 0;
do {
if ( '\n' == *startPtr )
count++;
} while ( ++startPtr && startPtr != endPtr );
if ( startPtr != endPtr ) {
while ( ++startPtr && startPtr != endPtr ) {
if ( '\n' == *startPtr )
count++;
} ;
}
return count;
}
@@ -23,7 +25,7 @@ static std::string textLine( const std::string& fileText, const size_t& fromPos,
const char* nlStartPtr = ptr + 1;
start = ptr - stringStartPtr + 1;
ptr = startPtr;
while ( ++ptr && *ptr != '\n' ) {
while ( ++ptr && *ptr != '\0' && *ptr != '\n' ) {
}
end = ptr - stringStartPtr;
relCol = startPtr - nlStartPtr;

View File

@@ -21,13 +21,13 @@ UIPushButton* UITreeViewCellGlobalSearch::setText( const String& text ) {
if ( text != mTextBox->getText() ) {
mTextBox->setVisible( !text.empty() );
mTextBox->setText( text );
updateText( text );
updateText( text + '\n' );
updateLayout();
}
return this;
}
UIPushButton* UITreeViewCellGlobalSearch::updateText( const String& text ) {
UIPushButton* UITreeViewCellGlobalSearch::updateText( const std::string& text ) {
if ( getCurIndex().internalId() != -1 ) {
UITreeViewGlobalSearch* pp = getParent()->getParent()->asType<UITreeViewGlobalSearch>();
@@ -35,20 +35,22 @@ UIPushButton* UITreeViewCellGlobalSearch::updateText( const String& text ) {
auto styleDef = SyntaxDefinitionManager::instance()->getStyleByExtension( res->file );
auto tokens =
SyntaxTokenizer::tokenize( styleDef, text, SYNTAX_TOKENIZER_STATE_NONE ).first;
Uint32 from = text.find_first_not_of( ' ' );
Uint32 to = from;
if ( from != String::InvalidPos ) {
to = text.find_first_of( ' ', from );
mTextBox->setFontFillColor( pp->getLineNumColor(), from, to );
}
size_t start = 0;
auto tokens =
SyntaxTokenizer::tokenize( styleDef, text, SYNTAX_TOKENIZER_STATE_NONE, to ).first;
size_t start = to;
for ( auto& token : tokens ) {
mTextBox->setFontFillColor( pp->getColorScheme().getSyntaxStyle( token.type ).color,
start, start + token.text.size() );
start += token.text.size();
}
Uint32 from = text.find_first_not_of( ' ' );
if ( from != String::InvalidPos )
mTextBox->setFontFillColor( pp->getLineNumColor(), from,
text.find_first_of( ' ', from ) );
}
return this;
}

View File

@@ -16,7 +16,7 @@ class UITreeViewCellGlobalSearch : public UITreeViewCell {
UIPushButton* setText( const String& text );
UIPushButton* updateText( const String& text );
UIPushButton* updateText( const std::string& text );
};
class UITreeViewGlobalSearch : public UITreeView {