Пример #1
0
void Display::showResults()   // cat.build should take /s parameter
{
  /*
    s, // recurse into subdirectories
    a, // show all files
    d, // report duplicates
    f, // find text
    q, // query for text at end of execution
    c  // display commandline arguments - used for testing
    h  // show usage
  */
  if (optionEnabled(h))
  {
    showUsage();
  }
  if (optionEnabled(c))
  {
    title("Commandline arguments:");
    showCommandLine();
    std::cout << "\n";
  }
  cat_.showSummary();
  if (optionEnabled(a))
  {
    title("Show all files found:");
    cat_.showFiles();
    std::cout << "\n";
  }
  if (optionEnabled(f))
  {
    title("Show text search results:");
    std::cout << "\n  search text = \"" << searchText() << "\"";
    cat_.showSearchResults(searchText());
    std::cout << "\n";
  }
  if (optionEnabled(d))
  {
    title("Show duplicate files:");
    cat_.showDuplicates();
    std::cout << "\n";
  }
  if (optionEnabled(q))
  {
    title("Text queries:");
    std::string input;
    while (true)
    {
      std::cout << "\n  enter text string (return to quit): ";
      std::getline(std::cin, input);
      if (input.size() == 0)
        break;
      cat_.showSearchResults(input);
    }
  }
}
Пример #2
0
bool opportunityList::setParams(ParameterList &params)
{
  parameterWidget()->appendValue(params);

  if (!searchText().isEmpty())
    params.append("searchpattern", searchText());

  if (!findChild<QCheckBox*>("_showInactive")->isChecked())
    params.append("activeOnly");

  return true;
}
Пример #3
0
TEST_F(TextFinderTest, ScopeTextMatchesWithShadowDOM)
{
    document().body()->setInnerHTML("<b>FOO</b><i>foo</i>", ASSERT_NO_EXCEPTION);
    RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = document().body()->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
    shadowRoot->setInnerHTML("<content select=\"i\"></content><u>Foo</u><content></content>", ASSERT_NO_EXCEPTION);
    Node* textInBElement = document().body()->firstChild()->firstChild();
    Node* textInIElement = document().body()->lastChild()->firstChild();
    Node* textInUElement = shadowRoot->childNodes()->item(1)->firstChild();

    int identifier = 0;
    WebString searchText(String("fOO"));
    WebFindOptions findOptions; // Default.

    textFinder().resetMatchCount();
    textFinder().scopeStringMatches(identifier, searchText, findOptions, true);
    while (textFinder().scopingInProgress())
        runPendingTasks();

    // TextIterator currently returns the matches in the composed tree order,
    // so in this case the matches will be returned in the order of
    // <i> -> <u> -> <b>.
    EXPECT_EQ(3, textFinder().totalMatchCount());
    WebVector<WebFloatRect> matchRects;
    textFinder().findMatchRects(matchRects);
    ASSERT_EQ(3u, matchRects.size());
    EXPECT_EQ(findInPageRect(textInIElement, 0, textInIElement, 3), matchRects[0]);
    EXPECT_EQ(findInPageRect(textInUElement, 0, textInUElement, 3), matchRects[1]);
    EXPECT_EQ(findInPageRect(textInBElement, 0, textInBElement, 3), matchRects[2]);
}
Пример #4
0
SearchToolBar::SearchToolBar(QupZilla* mainClass, QWidget* parent)
    : AnimatedWidget(AnimatedWidget::Up, 300, parent)
    , ui(new Ui::SearchToolbar)
    , p_QupZilla(mainClass)
    , m_findFlags(0)
{
    setAttribute(Qt::WA_DeleteOnClose);
    ui->setupUi(widget());
    ui->closeButton->setIcon(IconProvider::standardIcon(QStyle::SP_DialogCloseButton));

    ui->next->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward));

    ui->previous->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowBack));

    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
    connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(searchText(QString)));
    connect(ui->next, SIGNAL(clicked()), this, SLOT(findNext()));
    connect(ui->previous, SIGNAL(clicked()), this, SLOT(findPrevious()));
    connect(ui->highligh, SIGNAL(clicked()), this, SLOT(refreshFindFlags()));
    connect(ui->caseSensitive, SIGNAL(clicked()), this, SLOT(refreshFindFlags()));
    startAnimation();

    p_QupZilla->actionStop()->setEnabled(false);
    qApp->installEventFilter(this);
}
Пример #5
0
TEST_F(TextFinderTest, FindTextAutosizing)
{
    document().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ", ASSERT_NO_EXCEPTION);

    int identifier = 0;
    WebString searchText(String("FindMe"));
    WebFindOptions findOptions; // Default.
    bool wrapWithinFrame = true;
    WebRect* selectionRect = nullptr;

    // Set viewport scale to 20 in order to simulate zoom-in
    VisualViewport& visualViewport = document().page()->frameHost().visualViewport();
    visualViewport.setScale(20);

    // Enforce autosizing
    document().settings()->setTextAutosizingEnabled(true);
    document().settings()->setTextAutosizingWindowSizeOverride(IntSize(20, 20));
    document().textAutosizer()->updatePageInfo();

    // In case of autosizing, scale _should_ change
    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    ASSERT_TRUE(textFinder().activeMatch());
    ASSERT_EQ(1, visualViewport.scale()); // in this case to 1

    // Disable autosizing and reset scale to 20
    visualViewport.setScale(20);
    document().settings()->setTextAutosizingEnabled(false);
    document().textAutosizer()->updatePageInfo();

    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    ASSERT_TRUE(textFinder().activeMatch());
    ASSERT_EQ(20, visualViewport.scale());
}
Пример #6
0
void SearchToolBar::findNext()
{
    refreshFindFlags();
    m_findFlags += 4;
    searchText(ui->lineEdit->text());

}
Пример #7
0
void SearchToolBar::findPrevious()
{
    m_findFlags = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument;
    updateFindFlags();

    searchText(ui->lineEdit->text());
}
Пример #8
0
/**
 * This should change the Edit text to be appropriate and then begin a search
 * of the dictionaries' entries.
 */
void Kiten::searchTextAndRaise( const QString &str )
{
  /* Do the search */
  searchText( str );
  /* get the window as we'd like it */
  raise();
}
Пример #9
0
void SearchToolBar::refreshFindFlags()
{
    m_findFlags = 0;
    if (ui->highligh->isChecked()) {
        m_findFlags += 8;
        searchText(ui->lineEdit->text());
    }
    else {
        m_findFlags += 8;
        searchText("");
        m_findFlags -= 8;
    }
    if (ui->caseSensitive->isChecked()) {
        m_findFlags += 2;
        searchText(ui->lineEdit->text());
    }
}
/** Starts the search with the set modules and the set search text. */
void CSearchDialog::startSearch() {
    QString originalSearchText(m_searchOptionsArea->searchText());
    QString searchText("");

    // first check the search string for errors
    {
        QString TestString(originalSearchText);
        QRegExp ReservedWords("heading:|footnote:|morph:|strong:");
        if (TestString.replace(ReservedWords, "").simplified().isEmpty()) {
            return;
        }
    }

    searchText = prepareSearchText(originalSearchText);

    // Insert search text into history list of combobox
    m_searchOptionsArea->addToHistory(originalSearchText);

    // check that we have the indices we need for searching
    if (!m_searcher.modulesHaveIndices( modules() ) )	{
        int result = util::showQuestion(this, tr("Missing indices"),
                                        tr("One or more works need indexing before they can be searched.\n"
                                           "This could take a long time. Proceed with indexing?"),
                                        QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
        // In SuSE 10.0 the result is the logical or of the button type, just like it is
        // inputed into the QMessageBox.
        if ( (result == (QMessageBox::Yes | QMessageBox::Default)) ||
                (result == QMessageBox::Yes) || (result == QMessageBox::Default) ) {
            CModuleIndexDialog* dlg = CModuleIndexDialog::getInstance();
            dlg->indexUnindexedModules( modules() );
        }
        else {
            return;
        }
    }

    if (m_searchOptionsArea->hasSearchScope()) {
        m_searcher.setSearchScope( m_searchOptionsArea->searchScope() );
    }
    else {
        m_searcher.resetSearchScope();
    }

    m_searcher.setModules( modules() );
    m_searcher.setSearchedText(searchText);


    //Just to be sure that it can't be clicked again, if the search happens to be a bit slow.
    m_searchOptionsArea->searchButton()->setEnabled(false);
    m_searchOptionsArea->m_searchTextCombo->setEnabled(false);

    m_searcher.startSearch();

    m_searchOptionsArea->searchButton()->setEnabled(true);
    m_searchOptionsArea->m_searchTextCombo->setEnabled(true);
    m_searchOptionsArea->m_searchTextCombo->setFocus();
}
Пример #11
0
TEST_F(TextFinderTest, FindTextJavaScriptUpdatesDOM) {
  document().body()->setInnerHTML("<b>XXXXFindMeYYYY</b><i></i>");
  document().updateStyleAndLayout();

  int identifier = 0;
  WebString searchText(String("FindMe"));
  WebFindOptions findOptions;  // Default.
  bool wrapWithinFrame = true;
  bool activeNow;

  textFinder().resetMatchCount();
  textFinder().startScopingStringMatches(identifier, searchText, findOptions);
  while (textFinder().scopingInProgress())
    runPendingTasks();

  findOptions.findNext = true;
  ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions,
                                wrapWithinFrame, &activeNow));
  EXPECT_TRUE(activeNow);
  ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions,
                                wrapWithinFrame, &activeNow));
  EXPECT_TRUE(activeNow);

  // Add new text to DOM and try FindNext.
  Element* iElement = toElement(document().body()->lastChild());
  ASSERT_TRUE(iElement);
  iElement->setInnerHTML("ZZFindMe");
  document().updateStyleAndLayout();

  ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions,
                                wrapWithinFrame, &activeNow));
  Range* activeMatch = textFinder().activeMatch();
  ASSERT_TRUE(activeMatch);
  EXPECT_FALSE(activeNow);
  EXPECT_EQ(2, activeMatch->startOffset());
  EXPECT_EQ(8, activeMatch->endOffset());

  // Restart full search and check that added text is found.
  findOptions.findNext = false;
  textFinder().resetMatchCount();
  textFinder().cancelPendingScopingEffort();
  textFinder().startScopingStringMatches(identifier, searchText, findOptions);
  while (textFinder().scopingInProgress())
    runPendingTasks();
  EXPECT_EQ(2, textFinder().totalMatchCount());

  WebVector<WebFloatRect> matchRects;
  textFinder().findMatchRects(matchRects);
  ASSERT_EQ(2u, matchRects.size());
  Node* textInBElement = document().body()->firstChild()->firstChild();
  Node* textInIElement = document().body()->lastChild()->firstChild();
  EXPECT_EQ(findInPageRect(textInBElement, 4, textInBElement, 10),
            matchRects[0]);
  EXPECT_EQ(findInPageRect(textInIElement, 2, textInIElement, 8),
            matchRects[1]);
}
Пример #12
0
bool WildcardTermEnum::termCompare(const TermPtr& term) {
    if (field == term->field()) {
        String searchText(term->text());
        if (boost::starts_with(searchText, pre)) {
            return wildcardEquals(text, 0, searchText, preLen);
        }
    }
    _endEnum = true;
    return false;
}
Пример #13
0
TEST_F(TextFinderTest, FindTextNotFound) {
  document().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ");
  document().updateStyleAndLayout();

  int identifier = 0;
  WebString searchText(String("Boo"));
  WebFindOptions findOptions;  // Default.
  bool wrapWithinFrame = true;

  EXPECT_FALSE(
      textFinder().find(identifier, searchText, findOptions, wrapWithinFrame));
  EXPECT_FALSE(textFinder().activeMatch());
}
Пример #14
0
TEST_F(TextFinderTest, FindTextNotFound)
{
    document().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ", ASSERT_NO_EXCEPTION);

    int identifier = 0;
    WebString searchText(String("Boo"));
    WebFindOptions findOptions; // Default.
    bool wrapWithinFrame = true;
    WebRect* selectionRect = nullptr;

    EXPECT_FALSE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    EXPECT_FALSE(textFinder().activeMatch());
}
Пример #15
0
	bool FontFilter::filterAcceptsRow(int source_row) {

		QModelIndex sourceIndex = fontsModel()->index(source_row, 0);

		bool search_filter = (searchText().isEmpty()) or (fontsModel()->data(sourceIndex, filterRole()).toString().contains(searchText(), Qt::CaseInsensitive));

		bool selection_filter = (not m_show_only_selected) or (fontsModel()->familySelected(source_row) or fontsModel()->familyMarked(source_row));

		if (search_filter)
			m_search_result_count++;

		return selection_filter and search_filter;

	}
Пример #16
0
TEST_F(TextFinderTest, ScopeRepeatPatternTextMatches)
{
    document().body()->setInnerHTML("ab ab ab ab ab", ASSERT_NO_EXCEPTION);
    Node* textNode = document().body()->firstChild();

    int identifier = 0;
    WebString searchText(String("ab ab"));
    WebFindOptions findOptions; // Default.

    textFinder().resetMatchCount();
    textFinder().scopeStringMatches(identifier, searchText, findOptions, true);
    while (textFinder().scopingInProgress())
        runPendingTasks();

    EXPECT_EQ(2, textFinder().totalMatchCount());
    WebVector<WebFloatRect> matchRects;
    textFinder().findMatchRects(matchRects);
    ASSERT_EQ(2u, matchRects.size());
    EXPECT_EQ(findInPageRect(textNode, 0, textNode, 5), matchRects[0]);
    EXPECT_EQ(findInPageRect(textNode, 6, textNode, 11), matchRects[1]);
}
Пример #17
0
TEST_F(TextFinderTest, OverlappingMatches)
{
    document().body()->setInnerHTML("aababaa", ASSERT_NO_EXCEPTION);
    Node* textNode = document().body()->firstChild();

    int identifier = 0;
    WebString searchText(String("aba"));
    WebFindOptions findOptions; // Default.

    textFinder().resetMatchCount();
    textFinder().scopeStringMatches(identifier, searchText, findOptions, true);
    while (textFinder().scopingInProgress())
        runPendingTasks();

    // We shouldn't find overlapped matches.
    EXPECT_EQ(1, textFinder().totalMatchCount());
    WebVector<WebFloatRect> matchRects;
    textFinder().findMatchRects(matchRects);
    ASSERT_EQ(1u, matchRects.size());
    EXPECT_EQ(findInPageRect(textNode, 1, textNode, 4), matchRects[0]);
}
Пример #18
0
TEST_F(TextFinderTest, ScopeTextMatchesSimple) {
  document().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ");
  document().updateStyleAndLayout();

  Node* textNode = document().body()->firstChild();

  int identifier = 0;
  WebString searchText(String("FindMe"));
  WebFindOptions findOptions;  // Default.

  textFinder().resetMatchCount();
  textFinder().startScopingStringMatches(identifier, searchText, findOptions);
  while (textFinder().scopingInProgress())
    runPendingTasks();

  EXPECT_EQ(2, textFinder().totalMatchCount());
  WebVector<WebFloatRect> matchRects;
  textFinder().findMatchRects(matchRects);
  ASSERT_EQ(2u, matchRects.size());
  EXPECT_EQ(findInPageRect(textNode, 4, textNode, 10), matchRects[0]);
  EXPECT_EQ(findInPageRect(textNode, 14, textNode, 20), matchRects[1]);
}
Пример #19
0
// ---------------------------------------------------------------------
void SearchDialog::slotSearch()
{
  accept();
  searchText(PositionBox->isChecked(), 0);
}
Пример #20
0
// -----------------------------------------------------------------------------
// For Devanagari AS
// Checks if @c aItemText matches @c aSearchText.
// @param aItemText list box item text.
// @param aSearchText search text.
// @param aNextChars reference to the next characters for the adaptive search grid
// @return @c ETrue if list box item text matches EFalse otherwise.
// -----------------------------------------------------------------------------
//  
inline TBool IsIndicAdaptiveFindMatch( const TDesC& aItemString, 
	const TDesC& aSearchText, HBufC*& aNextChars, TInt /*aInputLang*/ )
	{	    	
	HBufC16* searchText(NULL);
	TRAPD( error, searchText = HBufC16::NewL( KMatchingBufferLength ) );
	if ( error == KErrNone )
	    {
	    TInt itemStringLength = aItemString.Length();
        TInt searchTextLength = aSearchText.Length();    
        
        if ( searchTextLength < KMatchingBufferLength )
        	{
        	searchText->Des().Append( aSearchText );
        	}
        else
        	{
        	searchText->Des().Append( aSearchText.Left(KMatchingBufferLength-1) );
        	}    
    	
    	TInt indicSyllableCount = -1;
        if( aSearchText.Length()>0 )
    		{
    		//This will replace all placeholder '-' symbols with '*'
     		indicSyllableCount = IndicSyllableCount( searchText, searchTextLength );
    		}
    	    	
    	//Append '*' to the end if not already present.
        if ( (*searchText)[searchText->Length() - 1] != KLitStar)
    		{
    		searchText->Des().Append( KLitStar );
    		}   
    	
    	TInt result = KErrNotFound;
        
        //check if the search string is found in the item string
        for( TInt index = 0; index < itemStringLength; index++ )
            {
            if ( index==0 || IsFindWordSeparator( aItemString[index-1] ) )
                {
                TUint flag = ( TCollationMethod::EFoldCase | TCollationMethod::EIgnoreNone | TCollationMethod::EIgnoreCombining);//TCollationMethod::EIgnoreNone |
        		TCollationMethod collationMethod = *Mem::GetDefaultMatchingTable();
        		collationMethod.iFlags |= flag;
            
           		result = aItemString.Mid(index).MatchC( (*searchText), &collationMethod );
                
                if( result != KErrNotFound ) 
                    {
                    if( index <= (itemStringLength-searchTextLength) )
        	   			{
        	   			//search for the last character in the string
        	   			//We use a TBuf instead of TChar since a special ligature is 
        	   			//represented by 3 characters. Last char would be the '*' wildchar.
	        	   		TBuf<4> lastChar;
	        	   		TInt modifiedStrLength = searchText->Length();
	        	   		if( (*searchText)[modifiedStrLength-1] == KLitStar )
	        	   			{
	        	   			//is this a special ligature?
	        	   			if ( modifiedStrLength > 3 &&
	        	   			        IsSpecialIndicLigature( (*searchText).Mid(modifiedStrLength-4) ) )
	        	   			    {
	        	   			    lastChar = (*searchText).Mid(modifiedStrLength-4);
	        	   			    }
	        	   			else
	        	   			    {
	        	   			    lastChar = (*searchText).Mid(modifiedStrLength-2);
	        	   			    }
	        	   			}
	        	   		else
	        	   			{
	        	   			//No wildchar here
	        	   			lastChar = (*searchText).Mid(modifiedStrLength-1);
	        	   			}
	        	   		
	        	   		lastChar.UpperCase(); //For latin characters as adaptive grid is always in upper case
        	   			TInt charPos = result; //aItemString.Mid(index).MatchC( searchText->Des(), &collationMethod );
        	   			//if found position is not within the substring to be searched, return EFalse.
                        if( charPos == KErrNotFound)
                            {
                            delete searchText;
                            return EFalse;
                            }
                        
        	   			TInt tempPos = charPos;
	        	   		
	        	   		TInt startCount = -1 , endCount = -1;
	        	   		
    	   				//TInt tempIndex(0);
    	   				//Get the position of the next syllable to be checked
    	   				IndicSyllableBoundary(startCount, endCount, indicSyllableCount, aItemString.Mid(index));
    	   				tempPos = aItemString.Mid(index+startCount).MatchC( lastChar, &collationMethod ); 
    	   				
    	   				if (
    	   				//if found position is not within the next syllable to be searched, 
    	   				//return EFalse.
    	   				    ( tempPos != 0 )  
    	   				//Also check if character to be searched is a single unicode while
    	   				//the match is at the start of a special ligature
    	   				   	|| ( !IsSpecialIndicLigature( lastChar ) && 
    	   				            IsSpecialIndicLigature( aItemString.Mid(index+startCount) ) )
    	   				    )
    	   				    {
    	   				    delete searchText;
    	   				    return EFalse;
    	   				    }
	        	   		
	        	   		//else, continue - find the next characters to be displayed on the grid	
	        	   		tempPos = index + endCount + 1;
	        	   		
	        	   		do	{
	        	   		    if(charPos!=KErrNotFound && (tempPos) < itemStringLength )
        	   					{
        	   						TRAP_IGNORE( UpdateNextCharsL( aNextChars, aItemString.Mid(tempPos) ) );
        	   					}
        	   				
        	   				//Is the found next character a consonent/independent-vowel/non-Indic character?
        	   				if ( IsValidNextChars( *aNextChars ) )
        	   					{
        	   					//found a valid character for displaying on the grid - return from here
        	   					delete searchText;
            					return ETrue;
        	   					}
        	   				else //we found an invalid valid character - keep searching
        	   					{
        	   					TPtr ptr = aNextChars->Des();
        	   					ptr.Delete(aNextChars->Length()-1,1);
        	   					//Is this a fallback rendered character?
        	   					if ( IsFallbackRenderedCharacter(aItemString, tempPos) )
        	   					    {
        	   					    //Keep the entry but don't show any more characters from this word
        	   					    delete searchText;
        	   					    return ETrue;
        	   					    }
        	   					}
        	   				}
        	   			//keep looping till we find a valid nextChar or we reach the end of the string
        	   			while(tempPos < itemStringLength ); 
        	   			
        	   			}
        	   			
        	   		} // if( result != KErrNotFound )                                                                  	   	
                } // if (index==0 ..)        
      	    } // for loop	 
	    
  	    if( result != KErrNotFound )
            {
            delete searchText;
            return ETrue;
           	}    
        else 
            {
            delete searchText;
            return EFalse;
            }
        	            		
         } // if (error == KErrNone)   
    delete searchText;                 
    return EFalse;
	}
Пример #21
0
int main()
{
    //Performance Calculation Variables
    clock_t begin, end;
    double processTime;
    /////////////////////////

    hashTable* hTable = NULL;
    wList* wordList = NULL;

	int i=0;
    char** fileNames = getCWDtxtFiles();
    FILE* file[NumOftxtFiles];

	for(i=0;i<NumOftxtFiles;++i)
    {
        file[i] = fopen(fileNames[i], "r");
    }

	FILE* out = fopen("Analysis/output.txt", "a");
    char lol[50] = {'\0'};

    begin = clock();

	for(i=0;i<NumOftxtFiles;++i)
    {
        while(!feof(file[i]))
        {
            fscanf(file[i], "%s", lol);
            trimWord(lol);
            if(lol[0] == '\0')
                continue;
            wordList = addWordToList(wordList, lol, i+1);
        }
    }
	storeBST();
	//Performance Calculation--
    end  = clock();
    processTime = (double)(end-begin)/CLOCKS_PER_SEC;
    //Performance Calculation--

	int numWords = countWords(wordList);
    hTable = createHashTable(numWords);
    addToTableFromList(hTable, wordList);

    //printHashTable(hTable);
    //printHashTableToFile(hTable, out);
    fclose(out);
	fclose(out);

	for(i=0;i<2;++i)
    {
        fclose(file[i]);
    }

	FILE* record = fopen("Analysis/record.txt", "a");
    int emptyCount = countEmpty(hTable);
	fprintf(record, "WordCount : %d Empty : %d ProcessTime : %f s\n", numWords, emptyCount, processTime);

	fclose(record);

    printf("\nNo in list = %d %d", countWords(wordList), numWords);
    int c = 0;
    for(i=0;i<numWords;i++){
        bucket* b = hTable->table[i];
        while(b != NULL){
            ++c;
            b = b->next;
        }
    }

	//Driver Loop
	char ans = 'y';
    while(ans == 'y'){
        printBannner(processTime);
        printf("\n\t"); printf("__________________________________________________________\n\n");
        printf("\t"); printf("                        Enter the Query                              \n\n");
        printf("\t\t\t\t"); scanf("%s",lol);
        printf("\t"); printf("__________________________________________________________\n");
        if(lol[strlen(lol)-1] == '*'){
            makeList(wordList, lol);
            char* word = NULL;
            while((word = getNextWord())!= NULL){
                printf("\n\t\t");printf("%s : \n", word);
                searchText(word, hTable, fileNames, NumOftxtFiles);
            }
        }
        else{
            trimWord(lol);
        	char* word = getCorrectWord(lol);
        	if(strcmp(word, lol) != 0)
        	{
				printf("\n\t\t\t");printf("Corrected Word : %s\n", word);
            	searchText(word, hTable, fileNames, NumOftxtFiles);
            	printf("\n\t\t\t");printf("Do you want to search for original word? y/n : ");
				char a = 'y';
				while(getchar() != '\n');
				scanf("%c", &a);
				if(a == 'y')
					searchText(lol, hTable, fileNames, NumOftxtFiles);
        	}
        	else
        		searchText(lol, hTable, fileNames, NumOftxtFiles);
        }

        printf("\n\n\t\t\t");printf("Search Again? y/n : ");
        while(getchar() != '\n');
        scanf("%c", &ans);
    }

    return 0;
}
Пример #22
0
TEST_F(TextFinderTest, FindTextInShadowDOM)
{
    document().body()->setInnerHTML("<b>FOO</b><i>foo</i>", ASSERT_NO_EXCEPTION);
    RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = document().body()->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
    shadowRoot->setInnerHTML("<content select=\"i\"></content><u>Foo</u><content></content>", ASSERT_NO_EXCEPTION);
    Node* textInBElement = document().body()->firstChild()->firstChild();
    Node* textInIElement = document().body()->lastChild()->firstChild();
    Node* textInUElement = shadowRoot->childNodes()->item(1)->firstChild();

    int identifier = 0;
    WebString searchText(String("foo"));
    WebFindOptions findOptions; // Default.
    bool wrapWithinFrame = true;
    WebRect* selectionRect = nullptr;

    // TextIterator currently returns the matches in the composed treeorder, so
    // in this case the matches will be returned in the order of
    // <i> -> <u> -> <b>.
    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    Range* activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textInIElement, activeMatch->startContainer());
    EXPECT_EQ(0, activeMatch->startOffset());
    EXPECT_EQ(textInIElement, activeMatch->endContainer());
    EXPECT_EQ(3, activeMatch->endOffset());

    findOptions.findNext = true;
    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textInUElement, activeMatch->startContainer());
    EXPECT_EQ(0, activeMatch->startOffset());
    EXPECT_EQ(textInUElement, activeMatch->endContainer());
    EXPECT_EQ(3, activeMatch->endOffset());

    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textInBElement, activeMatch->startContainer());
    EXPECT_EQ(0, activeMatch->startOffset());
    EXPECT_EQ(textInBElement, activeMatch->endContainer());
    EXPECT_EQ(3, activeMatch->endOffset());

    // Should wrap to the first match.
    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textInIElement, activeMatch->startContainer());
    EXPECT_EQ(0, activeMatch->startOffset());
    EXPECT_EQ(textInIElement, activeMatch->endContainer());
    EXPECT_EQ(3, activeMatch->endOffset());

    // Fresh search in the reverse order.
    identifier = 1;
    findOptions = WebFindOptions();
    findOptions.forward = false;

    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textInBElement, activeMatch->startContainer());
    EXPECT_EQ(0, activeMatch->startOffset());
    EXPECT_EQ(textInBElement, activeMatch->endContainer());
    EXPECT_EQ(3, activeMatch->endOffset());

    findOptions.findNext = true;
    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textInUElement, activeMatch->startContainer());
    EXPECT_EQ(0, activeMatch->startOffset());
    EXPECT_EQ(textInUElement, activeMatch->endContainer());
    EXPECT_EQ(3, activeMatch->endOffset());

    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textInIElement, activeMatch->startContainer());
    EXPECT_EQ(0, activeMatch->startOffset());
    EXPECT_EQ(textInIElement, activeMatch->endContainer());
    EXPECT_EQ(3, activeMatch->endOffset());

    // And wrap.
    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textInBElement, activeMatch->startContainer());
    EXPECT_EQ(0, activeMatch->startOffset());
    EXPECT_EQ(textInBElement, activeMatch->endContainer());
    EXPECT_EQ(3, activeMatch->endOffset());
}
Пример #23
0
void SearchToolBar::caseSensitivityChanged()
{
    updateFindFlags();

    searchText(ui->lineEdit->text());
}
Пример #24
0
static void activateEntry(GtkWidget* entry, gpointer* gdata) {
	WebKitWebView* webView = g_object_get_data(G_OBJECT(entry), "webView");
	const gchar* entry_str = gtk_entry_get_text(GTK_ENTRY(entry));
	WebKitWebSettings* settings = webkit_web_view_get_settings(
			WEBKIT_WEB_VIEW(webView));
	gfloat current_zoom = webkit_web_view_get_zoom_level(webView);
	gboolean fz = webkit_web_view_get_full_content_zoom(webView);
	if (entry_str[0] != 0) {
		if (strncmp(entry_str, "?", 1) == 0) {
			gchar* s = g_strdup(entry_str);
			s++;
			gtk_entry_set_text(GTK_ENTRY(entry),
					g_strjoin(NULL, search_str, s, NULL));
			if ((startpage == TRUE) && (fz == TRUE) && (current_zoom != 1.0)) {
				fz = FALSE;
				webkit_web_view_set_full_content_zoom(webView, fz);
				GtkWidget* window = g_object_get_data(G_OBJECT(entry),
						"window");
				setZbutton(window, fz);
			}
		} else if (strncmp(entry_str, "=", 1) == 0) {
			gchar* s = g_strdup(entry_str);
			s++;
			searchText(webView, s);
			return;
		} else if (strncmp(entry_str, "#", 1) == 0) {
			int r = 0;
			r = fork();
			if (r == 0) {
				execl("/usr/local/bin/kwebhelper.py", "kwebhelper.py", "cmd",
						entry_str, NULL);
			}
			return;
		} else if (strncmp(entry_str, "!", 1) == 0) {
			gchar* s = g_strdup(entry_str);
			s++;
			if (strlen(s) > 1) {
				g_object_set(G_OBJECT(settings), "spell-checking-languages", s,
						NULL);
				gtk_entry_set_text(GTK_ENTRY(entry),
						g_strjoin(NULL,
								"Spell checking language has been set to: ", s,
								NULL));
			}
			return;
		}

		else if (strncmp(entry_str, "&", 1) == 0) {
			gchar* s = g_strdup(entry_str);
			s++;
			g_object_set(G_OBJECT(settings), "user-stylesheet-uri", s, NULL);
			gtk_entry_set_text(GTK_ENTRY(entry),
					g_strjoin(NULL, "User style sheet: ", s, NULL));
			return;
		} else if (strncmp(entry_str, "$", 1) == 0) {
			gchar* s = g_strdup(entry_str);
			s++;
			g_object_set(G_OBJECT(settings), "user-agent", s, NULL);
			const gchar* t = webkit_web_settings_get_user_agent(settings);
			gtk_entry_set_text(GTK_ENTRY(entry),
					g_strjoin(NULL, "User agent: ", t, NULL));
			return;
		}

		else if (strcmp(entry_str, ":c") == 0) {
			gtk_entry_set_text(GTK_ENTRY(entry),
					g_strjoin(NULL, "file://", homedir, "/kweb_about_c.html",
							NULL));
		} else if (strncmp(entry_str, ":", 1) == 0) {
			gchar* s = g_strdup(entry_str);
			s++;
			gchar* fname = g_strjoin(NULL, "/usr/local/share/kweb/kweb_about_",
					s, ".html", NULL);

			struct stat stbc;
			if (stat(fname, &stbc) == 0) {
				gtk_entry_set_text(GTK_ENTRY(entry),
						g_strjoin(NULL, "file://", fname, NULL));
			} else {
				gtk_entry_set_text(GTK_ENTRY(entry),
						g_strjoin(NULL,
								"file:///usr/local/share/kweb/kweb_about_e.html",
								NULL));
			}
		} else if (strstr(entry_str, "://") == NULL) {
			if (strncmp(entry_str, "/", 1) == 0) {
				gtk_entry_set_text(GTK_ENTRY(entry),
						g_strjoin(NULL, "file://", entry_str, NULL));
			} else {
				gtk_entry_set_text(GTK_ENTRY(entry),
						g_strjoin(NULL, "http://", entry_str, NULL));
			}
		}
		const gchar* uri = gtk_entry_get_text(GTK_ENTRY(entry));
		webkit_web_view_stop_loading(webView);
		webkit_web_view_load_uri(webView, uri);
		gtk_widget_grab_focus(GTK_WIDGET(webView));
	}
}
Пример #25
0
TEST_F(TextFinderTest, FindTextSimple)
{
    document().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ", ASSERT_NO_EXCEPTION);
    Node* textNode = document().body()->firstChild();

    int identifier = 0;
    WebString searchText(String("FindMe"));
    WebFindOptions findOptions; // Default.
    bool wrapWithinFrame = true;
    WebRect* selectionRect = nullptr;

    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    Range* activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textNode, activeMatch->startContainer());
    EXPECT_EQ(4, activeMatch->startOffset());
    EXPECT_EQ(textNode, activeMatch->endContainer());
    EXPECT_EQ(10, activeMatch->endOffset());

    findOptions.findNext = true;
    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textNode, activeMatch->startContainer());
    EXPECT_EQ(14, activeMatch->startOffset());
    EXPECT_EQ(textNode, activeMatch->endContainer());
    EXPECT_EQ(20, activeMatch->endOffset());

    // Should wrap to the first match.
    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textNode, activeMatch->startContainer());
    EXPECT_EQ(4, activeMatch->startOffset());
    EXPECT_EQ(textNode, activeMatch->endContainer());
    EXPECT_EQ(10, activeMatch->endOffset());

    // Search in the reverse order.
    identifier = 1;
    findOptions = WebFindOptions();
    findOptions.forward = false;

    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textNode, activeMatch->startContainer());
    EXPECT_EQ(14, activeMatch->startOffset());
    EXPECT_EQ(textNode, activeMatch->endContainer());
    EXPECT_EQ(20, activeMatch->endOffset());

    findOptions.findNext = true;
    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textNode, activeMatch->startContainer());
    EXPECT_EQ(4, activeMatch->startOffset());
    EXPECT_EQ(textNode, activeMatch->endContainer());
    EXPECT_EQ(10, activeMatch->endOffset());

    // Wrap to the first match (last occurence in the document).
    ASSERT_TRUE(textFinder().find(identifier, searchText, findOptions, wrapWithinFrame, selectionRect));
    activeMatch = textFinder().activeMatch();
    ASSERT_TRUE(activeMatch);
    EXPECT_EQ(textNode, activeMatch->startContainer());
    EXPECT_EQ(14, activeMatch->startOffset());
    EXPECT_EQ(textNode, activeMatch->endContainer());
    EXPECT_EQ(20, activeMatch->endOffset());
}