LRESULT CFindBar::DoCommand(int id, int msg) { bool bFindPrev = false; switch (id) { case IDC_FINDPREV: bFindPrev = true; // fallthrough case IDC_FINDNEXT: { DoFind(bFindPrev); } break; case IDC_FINDEXIT: { ::SendMessage(m_hParent, COMMITMONITOR_FINDEXIT, 0, 0); } break; case IDC_FINDTEXT: { if (msg == EN_CHANGE) { SendMessage(m_hParent, COMMITMONITOR_FINDRESET, 0, 0); DoFind(false); } } break; } return 1; }
bool ICmdProcTextEntryStc::DoReplaceAll(ICmdParam& cmd) { cmd.param2=1; Target.SetInsertionPoint(0); if(!TestSelection() && !DoFind(cmd)) { Wrapper::MsgsDialog(_hT("no results"),0); return false; } int n=0; Target.BeginUndoAction(); try { while(DoReplace(cmd)) n++; } catch(std::exception&) { } Target.EndUndoAction(); Wrapper::MsgsDialog(String::Format(_hT("%d results replaced"),n),0); return true; }
void FindFrame::FindNext() { if (!DoFind(+1)) m_btnNext->Enable(false); else m_btnPrev->Enable(true); }
void CSPDReaderView::OnViewFind(wxCommandEvent &evt) { if(m_pNotebook->GetCurrentPage()==m_pSplitter1) { CFindDlg dlg(g_theApp->GetMainFrame(),-1,wxT("Find")); dlg.GetFindText()->SetValue(m_strFindText); if(dlg.ShowModal()==wxID_OK) { m_strFindText=dlg.GetFindText()->GetValue(); m_nFindPosition=-1; wxComboBox *pft=(wxComboBox *)g_theApp->GetMainFrame()->FindWindow(ID_FIND_TEXT); if(pft!=NULL) { pft->SetValue(m_strFindText); } DoFind(); } } else { Edit *pEdit=(Edit *)m_pNotebook->GetCurrentPage(); pEdit->OnFind(evt); } }
int TextEditorWX::MatchSel(int flags, const char *text) { if (!InitFind(flags, text, true)) return -1; matchText = edwnd->GetStringSelection(); return DoFind(); }
bool ICmdProcTextEntryStc::DoExecId(ICmdParam& cmd) { switch(cmd.param1) { case CP_DIRTY: Target.MarkDirty(); break; case CP_SAVE_TEMP: return true; case CP_SAVE_FILE: return false; case CP_FIND: if(data.text_old=="") return false; Target.SetSearchFlags(data.flags.val()); return DoFind(cmd); case CP_REPLACE: if(data.text_old=="") return false; Target.SetSearchFlags(data.flags.val()); return DoReplace(cmd); case CP_REPLACEALL: if(data.text_old=="") return false; Target.SetSearchFlags(data.flags.val()); return DoReplaceAll(cmd); default: return basetype::DoExecId(cmd); } return true; }
int TextEditorWX::ReplaceAll(int flags, const char *ftext, const char *rtext, SelectInfo& info) { if (!InitFind(flags, ftext, false)) return -1; int count = 0; findStart = info.startPos; findEnd = info.endPos; if (findStart == findEnd) findEnd = edwnd->GetLastPosition(); wxString repl(rtext); if (findFlags & TXTFIND_REGEXP) { matchText = edwnd->GetRange(findStart, findEnd); count = findRE.ReplaceAll(&matchText, wxString(rtext)); if (count > 0) edwnd->Replace(findStart, findEnd, matchText); } else { long rlen = repl.Len() + 1; do { matchText = edwnd->GetRange(findStart, findEnd); if (!DoFind()) break; count++; edwnd->Replace(matchStart, matchEnd, repl); findStart = matchStart + rlen; } while (findStart < findEnd); } return count; }
bool ICmdProcTextEntryStc::DoReplace(ICmdParam& cmd) { if(!TestSelection()) { return DoFind(cmd); } int pos=Target.GetTargetStart(); int len=Target.ReplaceTarget(str2wx(data.text_new)); Target.SetInsertionPoint(pos+len); Target.SetSelection(pos+len,pos+len); DoFind(cmd); return true; }
wxString wxArchiveFSHandler::FindFirst(const wxString& spec, int flags) { wxString right = GetRightLocation(spec); wxString left = GetLeftLocation(spec); wxString protocol = GetProtocol(spec); wxString key = left + wxT("#") + protocol + wxT(":"); if (!right.empty() && right.Last() == wxT('/')) right.RemoveLast(); if (!m_cache) m_cache = new wxArchiveFSCache; const wxArchiveClassFactory *factory; factory = wxArchiveClassFactory::Find(protocol); if (!factory) return wxEmptyString; m_Archive = m_cache->Get(key); if (!m_Archive) { wxFSFile *leftFile = m_fs.OpenFile(left); if (!leftFile) return wxEmptyString; m_Archive = m_cache->Add(key, *factory, leftFile->DetachStream()); delete leftFile; } m_FindEntry = NULL; switch (flags) { case wxFILE: m_AllowDirs = false, m_AllowFiles = true; break; case wxDIR: m_AllowDirs = true, m_AllowFiles = false; break; default: m_AllowDirs = m_AllowFiles = true; break; } m_ZipFile = key; m_Pattern = right.AfterLast(wxT('/')); m_BaseDir = right.BeforeLast(wxT('/')); if (m_BaseDir.StartsWith(wxT("/"))) m_BaseDir = m_BaseDir.Mid(1); if (m_Archive) { if (m_AllowDirs) { delete m_DirsFound; m_DirsFound = new wxArchiveFilenameHashMap(); if (right.empty()) // allow "/" to match the archive root return spec; } return DoFind(); } return wxEmptyString; }
/** Searches for the next file/directory. This should be used after a successful call to FindWildByPath() or FindWildByDir(), for the next occurrences of the filename in the path or drive list.Using function SetFindMask it is possible to specify a combination of attributes that the drives to be searched must match. Notes: 1. The function sets aDir to NULL, then allocates memory for it before appending entries to the list. Therefore, aDir should have no memory allocated to it before this function is called, otherwise this memory will become orphaned. 2. The caller of the function is responsible for deleting aDir after the function has returned. On error this pointer will be set NULL, thus safe to delete. 3. Calling TFindFile::File() after a successful search, will return the drive letter and the directory containing the file(s). The filenames may be retrieved via the array of TEntry::iName objects contained in aDir. If you want to retrieve the fully qualified path of a file, you will need to parse the path and the filename using the TParse class or derived classes. @param aDir in: a reference to the pointer that will be modified by this method. out: On success a pointer to the internally allocated by this method CDir object, which in turn contains the entries for all files matching aFileName in the first directory in which a match occurred. In this case this API caller is responsible for deleting aDir. If some error occured (including KErrNotFound meaning that nothing found) this pointer will be set to NULL, which is also safe to delete. @return KErrNone if further occurrences were found; KErrNotFound if no more matching files were found. @see TParse @see TEntry::iName @see TFindFile::File @see TFindFile::FindWildByPath @see TFindFile::FindWildByDir @see TFindFile::SetFindMask() */ EXPORT_C TInt TFindFile::FindWild(CDir*& aDir) { iDir=&aDir; *iDir=NULL; return CallSafe(DoFind()); }
void *BucketSet(bucketset_t set, char *name,void *value) { bucket_t *pbucket = DoFind(set, name); if (!pbucket) return NULL; pbucket->nvals = 0; return DoSet(pbucket,value); }
bool ctlSQLBox::Replace(const wxString &find, const wxString &replace, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse) { if (!DoFind(find, replace, true, wholeWord, matchCase, useRegexps, startAtTop, reverse)) { wxWindow *w = wxWindow::FindFocus(); wxMessageBox(_("Reached the end of the document"), _("Replace text"), wxICON_EXCLAMATION | wxOK, w); return false; } return true; }
bool PHPOutlineTree::Select(const wxString& pattern) { wxTreeItemId item = DoFind(pattern, GetRootItem()); if(item.IsOk()) { // select this item EnsureVisible(item); SelectItem(item); return true; } return false; }
void FindWindow::FindAgain(BWindow* window) { if (fFindWindow) { fFindWindow->Lock(); fFindWindow->fFindPanel->Find(); fFindWindow->Unlock(); } else if (sPreviousFind.Length() != 0) DoFind(window, sPreviousFind.String()); else Find(window); }
void *BucketAdd(bucketset_t set, char *name, void *value) { bucket_t *pbucket = DoFind(set, name); if (!pbucket) return NULL; if (pbucket->type == bt_int) return DoSet(pbucket, bint( (*(int *)DoGet(pbucket)) + (*(int *)value))); if (pbucket->type == bt_float) return DoSet(pbucket, bfloat( (*(double *)DoGet(pbucket)) + (*(double *)value))); //else, string -- just concat return BucketConcat(set, name, value); }
void *BucketAvg(bucketset_t set, char *name, void *value) { bucket_t *pbucket = DoFind(set, name); if (!pbucket) return NULL; if (pbucket->type == bt_int) return DoSet(pbucket, bint( AVG((*(int *)DoGet(pbucket)), (*(int *)value), pbucket->nvals))); if (pbucket->type == bt_float) return DoSet(pbucket, bfloat( AVG((*(double *)DoGet(pbucket)), (*(double *)value), pbucket->nvals))); //else, string -- just ignore return DoGet(pbucket); }
wxTreeItemId PHPOutlineTree::DoFind(const wxString& pattern, const wxTreeItemId& parent) { if((GetRootItem() != parent) && FileUtils::FuzzyMatch(pattern, GetItemText(parent))) { return parent; } if(ItemHasChildren(parent)) { wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild(parent, cookie); while(child.IsOk()) { wxTreeItemId match = DoFind(pattern, child); if(match.IsOk()) { return match; } child = GetNextChild(parent, cookie); } } return wxTreeItemId(); }
void ctFindReplaceDialog::OnFind(wxFindDialogEvent& event) { wxString textToFind = event.GetFindString(); bool matchCase = ((event.GetFlags() & wxFR_MATCHCASE) != 0); bool wholeWord = ((event.GetFlags() & wxFR_WHOLEWORD) != 0); wxGetApp().GetSettings().m_matchCase = matchCase; wxGetApp().GetSettings().m_matchWholeWord = wholeWord; if (!DoFind(textToFind, matchCase, wholeWord)) { wxMessageBox(wxT("No more matches."), wxT("Search"), wxOK|wxICON_INFORMATION, this); } }
void *BucketNew(bucketset_t set, char *name, BucketType type, void *initialvalue) { bucket_t bucket; if (set == NULL) set = g_buckets; assert(set); bucket.name = goastrdup(name); bucket.type = type; bucket.vals.sval = NULL; bucket.nvals = 1; DoSet(&bucket, initialvalue); TableEnter(set->buckets,&bucket); return DoGet(DoFind(set, name)); }
void CSPDReaderView::OnViewFindNext(wxCommandEvent &evt) { if(m_pNotebook->GetCurrentPage()==m_pSplitter1) { if(m_strFindText.IsEmpty()) { return; } DoFind(); } else { Edit *pEdit=(Edit *)m_pNotebook->GetCurrentPage(); pEdit->OnFindNext(evt); } }
wxString wxZipFSHandler::FindFirst(const wxString& spec, int flags) { wxString right = GetRightLocation(spec); wxString left = GetLeftLocation(spec); if (!right.empty() && right.Last() == wxT('/')) right.RemoveLast(); if (m_Archive) { delete m_Archive; m_Archive = NULL; } switch (flags) { case wxFILE: m_AllowDirs = false, m_AllowFiles = true; break; case wxDIR: m_AllowDirs = true, m_AllowFiles = false; break; default: m_AllowDirs = m_AllowFiles = true; break; } m_ZipFile = left; wxFSFile *leftFile = wxFileSystem().OpenFile(left); if (leftFile) m_Archive = new wxZipFSInputStream(leftFile); m_Pattern = right.AfterLast(wxT('/')); m_BaseDir = right.BeforeLast(wxT('/')); if (m_BaseDir.StartsWith(wxT("/"))) m_BaseDir = m_BaseDir.Mid(1); if (m_Archive) { if (m_AllowDirs) { delete m_DirsFound; m_DirsFound = new wxZipFilenameHashMap(); if (right.empty()) // allow "/" to match the archive root return spec; } return DoFind(); } return wxEmptyString; }
void *BucketConcat(bucketset_t set, char *name, void *value) { bucket_t *pbucket = DoFind(set, name); char *temp, *s; if (!pbucket) return NULL; assert(pbucket->type == bt_string); s = DoGet(pbucket); temp = (char *)gsimalloc(strlen(s) + strlen(value) + 1); strcpy(temp,s); strcat(temp, value); DoSet(pbucket, temp); gsifree(temp); return DoGet(pbucket); }
bool ctlSQLBox::ReplaceAll(const wxString &find, const wxString &replace, bool wholeWord, bool matchCase, bool useRegexps) { // Use DoFind to repeatedly replace text int count = 0; int initialPos = GetCurrentPos(); GotoPos(0); while(DoFind(find, replace, true, wholeWord, matchCase, useRegexps, false, false)) count++; GotoPos(initialPos); wxString msg; msg.Printf(wxPLURAL("%d replacement made.", "%d replacements made.", count), count); wxMessageBox(msg, _("Replace all"), wxOK | wxICON_INFORMATION); if (count) return true; else return false; }
void CSPDReaderView::OnFindText(wxCommandEvent &evt) { if(m_pNotebook->GetCurrentPage()==m_pSplitter1) { wxComboBox *pft=(wxComboBox *)g_theApp->GetMainFrame()->FindWindow(ID_FIND_TEXT); if(pft==NULL) { return; } wxString strFindText=pft->GetValue(); m_strFindText=strFindText; DoFind(); } else { Edit *pEdit=(Edit *)m_pNotebook->GetCurrentPage(); pEdit->OnFindText(evt); } }
int TextEditorWX::Find(int flags, const char *text) { if (!InitFind(flags, text, false)) return -1; int wrap = 0; while (1) { matchText = edwnd->GetRange(findStart, findEnd); if (DoFind()) { edwnd->SetSelection(matchStart, matchEnd); return wrap; } if (wrap) return -1; findEnd = findStart-1; findStart = 0; wrap = 1; } return -1; }
void FindDialog::OnFindReplaceAllClick( wxCommandEvent& event ) { while( DoFind( true, false ) ); }
void FindDialog::OnFindReplaceClick( wxCommandEvent& event ) { DoFind( true, false ); }
void FindDialog::OnFindSearchClick( wxCommandEvent& event ) { DoFind( false, false ); }
void FindDialog::OnFindReplaceCtrlEnter( wxCommandEvent& event ) { DoFind( true, false ); }
void FindDialog::OnFindSearchCtrlEnter( wxCommandEvent& event ) { DoFind( false, false ); }