void Candidate::ComputeWordBoundaryChars() { const CharacterSequence &characters = Characters(); auto character_pos = characters.begin(); if ( character_pos == characters.end() ) { return; } const auto &first_character = *character_pos; if ( !first_character->IsPunctuation() ) { word_boundary_chars_.push_back( first_character ); } auto previous_character_pos = characters.begin(); ++character_pos; for ( ; character_pos != characters.end(); ++previous_character_pos, ++character_pos ) { const auto &previous_character = *previous_character_pos; const auto &character = *character_pos; if ( ( !previous_character->IsUppercase() && character->IsUppercase() ) || ( previous_character->IsPunctuation() && character->IsLetter() ) ) { word_boundary_chars_.push_back( character ); } } }
charinfo * get_charinfo (internal_font_number f, integer c) { sa_tree_item glyph; charinfo *ci; if (proper_char_index(c)) { glyph = get_sa_item(Characters(f), c); if (!glyph) { /* this could be optimized using controlled growth */ font_bytes += sizeof(charinfo); glyph = ++font_tables[f]->charinfo_count; do_realloc(font_tables[f]->charinfo, (glyph+1), charinfo); memset (&(font_tables[f]->charinfo[glyph]),0,sizeof(charinfo)); font_tables[f]->charinfo[glyph].ef = 1000; /* init */ font_tables[f]->charinfo_size = glyph; set_sa_item(font_tables[f]->characters, c, glyph, 1); /* 1= global */ } return &(font_tables[f]->charinfo[glyph]); } else if (c == left_boundarychar) { if (left_boundary(f)==NULL) { ci = xcalloc(1,sizeof(charinfo)); font_bytes += sizeof(charinfo); set_left_boundary(f,ci); } return left_boundary(f); } else if (c == right_boundarychar) { if (right_boundary(f)==NULL) { ci = xcalloc(1,sizeof(charinfo)); font_bytes += sizeof(charinfo); set_right_boundary(f,ci); } return right_boundary(f); } return &(font_tables[f]->charinfo[0]); }
void SelectHeroMenu::Update() { std::vector<int> pressedKeys = KeyHandler::GetKeys(); if(!chosen){ for(int i = 0; i < pressedKeys.size(); i++) { switch(pressedKeys[i]) { case VK_DOWN: { if(selected<menuEntities.size() - 1) { dynamic_cast<MenuEntity*>(menuEntities[selected])->UnSelect(); selected++; dynamic_cast<MenuEntity*>(menuEntities[selected])->Select(); } } break; case VK_UP: { if(selected > 1) { dynamic_cast<MenuEntity*>(menuEntities[selected])->UnSelect(); selected--; dynamic_cast<MenuEntity*>(menuEntities[selected])->Select(); } } break; case VK_RETURN: { if(!firstTime) { if(selected < menuEntities.size() - 1) { if(UnlockedHeroesLevels::isHeroUnlocked(Characters(selected - 1))) { selectedMenuOption = 0; chosen = true; EndMenuAnimation(); } }else { selectedMenuOption = 6; } }else { firstTime = false; } } break; } } }else { if(counter>15){ selectedMenuOption = selected; } counter++; } }
void Candidate::ComputeTextIsLowercase() { for ( const auto &character : Characters() ) { if ( character->IsUppercase() ) { text_is_lowercase_ = false; return; } } text_is_lowercase_ = true; }
Result Candidate::QueryMatchResult( const Word &query ) const { // Check if the query is a subsequence of the candidate and return a result // accordingly. This is done by simultaneously going through the characters of // the query and the candidate. If both characters match, we move to the next // character in the query and the candidate. Otherwise, we only move to the // next character in the candidate. The matching is a combination of smart // base matching and smart case matching. If there is no character left in the // query, the query is not a subsequence and we return an empty result. If // there is no character left in the candidate, the query is a subsequence and // we return a result with the query, the candidate, the sum of indexes of the // candidate where characters matched, and a boolean that is true if the query // is a prefix of the candidate. if ( query.IsEmpty() ) { return Result( this, &query, 0, false ); } if ( Length() < query.Length() ) { return Result(); } size_t query_index = 0; size_t candidate_index = 0; size_t index_sum = 0; const CharacterSequence &query_characters = query.Characters(); const CharacterSequence &candidate_characters = Characters(); auto query_character_pos = query_characters.begin(); auto candidate_character_pos = candidate_characters.begin(); for ( ; candidate_character_pos != candidate_characters.end(); ++candidate_character_pos, ++candidate_index ) { const auto &candidate_character = *candidate_character_pos; const auto &query_character = *query_character_pos; if ( query_character->MatchesSmart( *candidate_character ) ) { index_sum += candidate_index; ++query_character_pos; if ( query_character_pos == query_characters.end() ) { return Result( this, &query, index_sum, candidate_index == query_index ); } ++query_index; } } return Result(); }
void set_charinfo (internal_font_number f, integer c, charinfo *ci) { sa_tree_item glyph; if (proper_char_index(c)) { glyph = get_sa_item(Characters(f), c); if (glyph) { font_tables[f]->charinfo[glyph] = *ci; } else { pdftex_fail("font: %s","character insertion failed"); } } else if (c == left_boundarychar) { set_left_boundary(f,ci); } else if (c == right_boundarychar) { set_right_boundary(f,ci); } }
void Candidate::ComputeCaseSwappedText() { for ( const auto &character : Characters() ) { case_swapped_text_.append( character->SwappedCase() ); } }