Esempio n. 1
0
void FileListDialog::DoRefSearch(){
	IsSymbolSearch = FALSE;
	FullPathToExe = L".\\plugins\\gtagfornplus\\global.exe";
	getSearchString();
	Parameters = L" -ar ";
	Parameters.append(SearchString);
	getCurrentDir();
	IsDefSearch = FALSE;
	Search();
	if(gtagSearchResult.GetItemCount()==0)
		IsSymbolSearch = TRUE;
	else{
		gtagSearchResult.SetFirstItemSelected();
		OnFileListDoubleClicked();
		return;
	}
	symbol_linenum_list.clear();
	symbol_list.clear();
	symbol_blocks.clear();
	Parameters = L" -axs --result=grep ";
	Parameters.append(SearchString);
	Search();
	if(gtagSearchResult.GetItemCount()!=0){
		gtagSearchResult.SetFirstItemSelected();
		OnFileListDoubleClicked();
	}
}
Esempio n. 2
0
void FileListDialog::DoDeclSearch(){
	IsSymbolSearch = FALSE;
	FullPathToExe = L".\\plugins\\gtagfornplus\\global.exe";
	getSearchString();
	Parameters = L" -a --result=grep ";
	Parameters.append(SearchString);
	getCurrentDir();
	IsDefSearch = TRUE;
	Search();
}
void GenericCodeEditorComponent::findSelection(bool forward)
{
	const String selected = getSearchString();

	if (selected.isNotEmpty())
	{
		if (forward)
		{
			findNext (true, true);
		}
		else
		{
			findNext (false, false);
		}
	}
}
Esempio n. 4
0
QTextCursor FindDialog::find(const QTextCursor &start, const QTextDocument *doc) {
   if (start.isNull())
      return start;

   const QString &searchString = getSearchString();
   
   QTextDocument::FindFlags findFlags = 0;
   if (findBackwards())
      findFlags |= QTextDocument::FindBackward;
   if (caseSensitive())
      findFlags |= QTextDocument::FindCaseSensitively;
   if (wholeWordsOnly())
      findFlags |= QTextDocument::FindWholeWords;
   
   if (regularExpression())
      return doc->find(QRegExp(searchString), start, findFlags);

   // plain-text search
   return doc->find(searchString, start, findFlags);
}
LRESULT AutoSearchFrame::onContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {

	if(reinterpret_cast<HWND>(wParam) == ctrlAutoSearch) {
		POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
		
		asMenu.CreatePopupMenu();

		CRect rc;

		ctrlAutoSearch.GetHeader().GetWindowRect(&rc);
		if (PtInRect(&rc, pt)) {
			return 0;
		}

		if(pt.x == -1 && pt.y == -1) {
			WinUtil::getContextMenuPos(ctrlAutoSearch, pt);
		}

		int enable = ctrlAutoSearch.GetSelectedCount() == 1 ? MFS_ENABLED : MFS_DISABLED;

		if(ctrlAutoSearch.GetSelectedCount() > 1) {
			asMenu.AppendMenu(MF_STRING, IDC_ENABLE, CTSTRING(ENABLE_AUTOSEARCH));
			asMenu.AppendMenu(MF_STRING, IDC_DISABLE, CTSTRING(DISABLE_AUTOSEARCH));
			asMenu.AppendMenu(MF_SEPARATOR);
			//only remove and add is enabled
		} else if(ctrlAutoSearch.GetSelectedCount() == 1) {
			if(ctrlAutoSearch.GetCheckState(ctrlAutoSearch.GetSelectedIndex()) == 1) {
				asMenu.AppendMenu(MF_STRING, IDC_SEARCH, CTSTRING(SEARCH));
				asMenu.AppendMenu(MF_SEPARATOR);
				asMenu.AppendMenu(MF_STRING, IDC_DISABLE, CTSTRING(DISABLE_AUTOSEARCH));
			} else {
				asMenu.AppendMenu(MF_STRING, IDC_ENABLE, CTSTRING(ENABLE_AUTOSEARCH));
			}
			asMenu.AppendMenu(MF_SEPARATOR);
		}
		
		asMenu.AppendMenu(MF_STRING, IDC_ADD, CTSTRING(ADD));
		asMenu.AppendMenu(MF_STRING, IDC_CHANGE, CTSTRING(SETTINGS_CHANGE));
		asMenu.AppendMenu(MF_STRING, IDC_MOVE_UP, CTSTRING(SETTINGS_BTN_MOVEUP));
		asMenu.AppendMenu(MF_STRING, IDC_MOVE_DOWN, CTSTRING(SETTINGS_BTN_MOVEDOWN));
		asMenu.AppendMenu(MF_SEPARATOR);
		asMenu.AppendMenu(MF_STRING, IDC_REMOVE, CTSTRING(REMOVE));

		//asMenu.EnableMenuItem(IDC_REMOVE, enable);
		asMenu.EnableMenuItem(IDC_CHANGE, enable);
		asMenu.EnableMenuItem(IDC_MOVE_UP, enable);
		asMenu.EnableMenuItem(IDC_MOVE_DOWN, enable);
		
		//make a menu title from the search string, its probobly too long to fit but atleast it shows something.
		tstring title;
		if (ctrlAutoSearch.GetSelectedCount() == 1) {
			auto as = AutoSearchManager::getInstance()->getAutoSearch(ctrlAutoSearch.GetSelectedIndex());
			title = Text::toT(as->getSearchString());
			//TCHAR buf[256];
			//ctrlAutoSearch.GetItemText(ctrlAutoSearch.GetSelectedIndex(), buf, 256);
			//title = buf;
		} else {
			title = _T("");
		}
		if (!title.empty())
			asMenu.InsertSeparatorFirst(title);

		
		asMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, m_hWnd);

		if (!title.empty())
			asMenu.RemoveFirstItem();

		return TRUE; 
	}
	
	bHandled = FALSE;
	return FALSE; 
}
Esempio n. 6
0
void FindDialog::replaceAll() {
   TextEditor *current = m_parent->m_activeEditor;
   QTextDocument *doc  = current->getTextDocument();
   QTextCursor start   = current->textCursor();
   QTextCursor result, last;
   int noOccurrences = 0, startPos = -1, endPos = -1;
   m_searching = false;
   
   // search within a selection
   if (start.hasSelection() && searchSelection()) {
      startPos = start.selectionStart();
      endPos = start.selectionEnd();
      
      // get rid of selection
      if (findBackwards())
         start.setPosition(endPos);
      else start.setPosition(startPos);
   } else start.movePosition(QTextCursor::Start);
   
   start.beginEditBlock();
   result = start;
   
   do {
      last   = result;
      result = replace(result, doc, startPos, endPos);
      if (result.isNull())
         break;
      
      // disallow infinite replacements of similar terms ('life' w/ 'LIFE')
      result.setPosition(result.selectionEnd());
      ++noOccurrences;
   } while(true);
   
   start.endEditBlock();
   if (noOccurrences <= 0) {
      STATUS_BAR->showMessage(QString("%1 '%2' not found with the Options given").arg((regularExpression() ? QString("RegExp") : QString("String")), getSearchString()));
   } else {
      current->changeTextCursor(last);
      STATUS_BAR->showMessage(QString("Replaced %1 occurence%2.").arg(QString::number(noOccurrences), (noOccurrences != 1 ? QString("s") : QString(""))));
   }
   
   updateReplace(true);
}
Esempio n. 7
0
void FindDialog::accept() {
   TextEditor *current = m_parent->m_activeEditor;
   QTextDocument *doc  = current->getTextDocument();
   QTextCursor start   = current->textCursor();
   QTextCursor result;
   int startPos = -1, endPos = -1;
   
   // see if we're supposed to search within a selection
   if (start.hasSelection() && searchSelection()) {
      startPos = start.selectionStart();
      endPos = start.selectionEnd();
      
      // get rid of selection
      if (findBackwards())
         start.setPosition(endPos);
      else start.setPosition(startPos);
   } else if (!fromCursor() && !m_searching)
      start.movePosition(QTextCursor::Start);
   
   if (isFind()) {
      result = find(start, doc);
      
      // test if result was outside of selection
      if (!result.isNull() && 
          ((endPos > 0 && result.selectionEnd() > endPos) || 
          (startPos > 0 && result.selectionStart() < startPos)))
         result = QTextCursor(); // null cursor
   } else result = replace(start, doc, endPos);
   
   if (result.isNull()) {
      STATUS_BAR->showMessage(QString("%1 '%2' not found with the Options given").arg((regularExpression() ? QString("RegExp") : QString("String")), getSearchString()));
      
      m_searching = false;
      updateReplace(isReplace());
   } else {
      current->changeTextCursor(result);
      STATUS_BAR->clearMessage();
      
      m_searching = true;
      updateReplace(isReplace());
   }
}