void SvnConsole::OnReadProcessOutput(wxCommandEvent& event) { ProcessEventData *ped = (ProcessEventData *)event.GetClientData(); if (ped) { m_output.Append(ped->GetData().c_str()); } wxString s (ped->GetData()); s.MakeLower(); if (m_currCmd.printProcessOutput) AppendText( ped->GetData() ); static wxRegEx reUsername("username[ \t]*:", wxRE_DEFAULT|wxRE_ICASE); wxArrayString lines = wxStringTokenize(s, wxT("\n"), wxTOKEN_STRTOK); if( !lines.IsEmpty() && lines.Last().StartsWith(wxT("password for '")) ) { m_output.Clear(); wxString pass = wxGetPasswordFromUser(ped->GetData(), wxT("Subversion")); if(!pass.IsEmpty() && m_process) { m_process->WriteToConsole(pass); } } else if ( !lines.IsEmpty() && reUsername.IsValid() && reUsername.Matches( lines.Last() ) ) { // Prompt the user for "Username:"******"Subversion"); if ( !username.IsEmpty() && m_process ) { m_process->Write(username + "\n"); } } delete ped; }
bool IsBusLabel( const wxString& aLabel ) { wxCHECK_MSG( busLabelRe.IsValid(), false, wxT( "Invalid regular expression in IsBusLabel()." ) ); return busLabelRe.Matches( aLabel ); }
void clTernServer::OnTernOutput(clProcessEvent& event) { static wxRegEx rePort("Listening on port ([0-9]+)"); if(rePort.IsValid() && rePort.Matches(event.GetOutput())) { wxString strPort = rePort.GetMatch(event.GetOutput(), 1); strPort.ToCLong(&m_port); } PrintMessage(event.GetOutput()); }
void OpenResourceDialog::GetLineNumberFromFilter(const wxString& filter, wxString& modFilter, long& lineNumber) { modFilter = filter; lineNumber = -1; static wxRegEx reNumber(":([0-9]+)", wxRE_ADVANCED); if(reNumber.IsValid() && reNumber.Matches(modFilter)) { wxString strLineNumber; strLineNumber = reNumber.GetMatch(modFilter, 1); strLineNumber.ToCLong(&lineNumber); reNumber.Replace(&modFilter, ""); } }
void CPasswordSubset::OnChar( wxKeyEvent& event ) { static wxRegEx charSet("[[:digit:]]|[[:space:]]|,|-|;"); static wxRegEx seps(",|;"); wxASSERT(charSet.IsValid() && seps.IsValid()); wxChar uc = event.GetUnicodeKey(); if (uc != WXK_NONE) { const int N = m_password.length(); if (charSet.Matches(wxString(uc, 1))) { event.Skip(true); // accept // Check against valid pos regexp and update vals accordingly wxString pos_str = m_pos->GetLineText(0); pos_str += uc; // since accepted char will only be added to control later // could have used xwStringTokenizer in following, but this way we also convert to int // and catch bad usage of '-' seps.Replace(&pos_str, wxT(" ")); // replace ';' and ',' with ' ' for stream tokenizing m_vals->Clear(); m_error->SetLabel(wxEmptyString); std::wistringstream is(pos_str.wc_str()); int pos; while (is >> pos) { if (pos > 0 && pos <= N) *m_vals << m_password[pos - 1] << wxT(" "); else if (pos < 0 && pos >= -N) *m_vals << m_password[N + pos] << wxT(" "); else { m_error->SetLabel(_("Invalid position")); } } if (!is.eof()) { m_error->SetLabel(_("Invalid position")); } } else { if (uc == WXK_BACK)
void CMP_LIBRARY::SearchEntryNames( wxArrayString& aNames, const wxRegEx& aRe, bool aSort ) { if( !aRe.IsValid() ) return; LIB_ALIAS_MAP::iterator it; for( it=aliases.begin(); it!=aliases.end(); it++ ) { if( aRe.Matches( (*it).second->GetKeyWords() ) ) aNames.Add( (*it).first ); } if( aSort ) aNames.Sort(); }
bool PHPEditorContextMenu::IsIncludeOrRequireStatement(wxString& includeWhat) { // Do a basic check to see whether this line is include statement or not. // Don't bother in full parsing the file since it can be a quite an expensive operation // (include|require_once|require|include_once)[ \t\\(]*(.*?)[\\) \t)]*; static wxRegEx reInclude(wxT("(include|require_once|require|include_once)[ \t\\(]*(.*?)[\\) \t]*;"), wxRE_ADVANCED); IEditor* editor = m_manager->GetActiveEditor(); if(!editor) return false; wxString line = editor->GetCtrl()->GetLine(editor->GetCurrentLine()); if(reInclude.IsValid() && reInclude.Matches(line)) { includeWhat = reInclude.GetMatch(line, 2); return true; } return false; }
// When a a breakpoint is hit, see if it's got a command-list that needs faking void BreakptMgr::BreakpointHit(int id) { int index = FindBreakpointById(id, m_bps); if ((index == wxNOT_FOUND) || (index >= FIRST_INTERNAL_ID)) { return; } BreakpointInfo bp = m_bps.at(index); if (! bp.commandlist.IsEmpty()) { IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger(); if (dbgr && dbgr->IsRunning()) { // A likely command, presumably at the end of the command-list, is 'continue' or 'cont' // Filter this out and do it separately, otherwise Manager::UpdateLostControl isn't called to blank the indicator static wxRegEx reContinue(wxT("(([[:space:]]|(^))((cont$)|(continue)))")); bool needsCont = false; wxString commands = bp.commandlist; if (reContinue.IsValid() && reContinue.Matches(commands)) { size_t start, len; if (reContinue.GetMatch(&start,&len)) { commands = commands.Left(start); needsCont = true; } } if (! commands.IsEmpty()) { // Just in case someone's _only_ command is 'continue' ! dbgr->ExecuteCmd(commands); } if (needsCont) { dbgr->Continue(); } } } if (bp.bp_type == BP_type_tempbreak) { // If this is a temporary bp, remove it from m_bps now it's been hit // Otherwise it will be treated as a 'Pending' bp, the button will be displayed // and, if clicked, the bp will be resurrected. int index = FindBreakpointById(id, m_bps); if (index != wxNOT_FOUND) { m_bps.erase(m_bps.begin()+index); } } }
wxString TagEntry::FormatComment() { if(m_isCommentForamtted) return m_formattedComment; m_isCommentForamtted = true; m_formattedComment.Clear(); // Send the plugins an event requesting tooltip for this tag if(IsMethod()) { if(IsConstructor()) m_formattedComment << wxT("<b>[Constructor]</b>\n"); else if(IsDestructor()) m_formattedComment << wxT("<b>[Destructor]</b>\n"); TagEntryPtr p(new TagEntry(*this)); m_formattedComment << wxT("<code>") << TagsManagerST::Get()->FormatFunction(p, FunctionFormat_WithVirtual | FunctionFormat_Arg_Per_Line) << wxT("</code>\n"); m_formattedComment.Replace(GetName(), wxT("<b>") + GetName() + wxT("</b>")); } else if(IsClass()) { m_formattedComment << wxT("<b>Kind:</b> "); m_formattedComment << GetKind() << "\n"; if(GetInheritsAsString().IsEmpty() == false) { m_formattedComment << wxT("<b>Inherits:</b> "); m_formattedComment << GetInheritsAsString() << wxT("\n"); } } else if(IsMacro() || IsTypedef() || IsContainer() || GetKind() == wxT("member") || GetKind() == wxT("variable")) { m_formattedComment << wxT("<b>Kind:</b> "); m_formattedComment << GetKind() << "\n"; m_formattedComment << wxT("<b>Match Pattern:</b> "); // Prettify the match pattern wxString matchPattern(GetPattern()); matchPattern.Trim().Trim(false); if(matchPattern.StartsWith(wxT("/^"))) { matchPattern.Replace(wxT("/^"), wxT("")); } if(matchPattern.EndsWith(wxT("$/"))) { matchPattern.Replace(wxT("$/"), wxT("")); } matchPattern.Replace(wxT("\t"), wxT(" ")); while(matchPattern.Replace(wxT(" "), wxT(" "))) { } matchPattern.Trim().Trim(false); // BUG#3082954: limit the size of the 'match pattern' to a reasonable size (200 chars) matchPattern = TagsManagerST::Get()->WrapLines(matchPattern); matchPattern.Replace(GetName(), wxT("<b>") + GetName() + wxT("</b>")); m_formattedComment << wxT("<code>") << matchPattern << wxT("</code>\n"); } // Add comment section wxString tagComment; if(!GetFile().IsEmpty()) { CommentParseResult comments; ::ParseComments(GetFile().mb_str(wxConvUTF8).data(), comments); // search for comment in the current line, the line above it and 2 above it // use the first match we got for(size_t i = 0; i < 3; i++) { wxString comment = comments.getCommentForLine(GetLine()-i); if(!comment.IsEmpty()) { SetComment(comment); break; } } } if(!GetComment().IsEmpty()) { wxString theComment; theComment = GetComment(); theComment = TagsManagerST::Get()->WrapLines(theComment); theComment.Trim(false); wxString tagComment = wxString::Format(wxT("%s\n"), theComment.c_str()); if(m_formattedComment.IsEmpty() == false) { m_formattedComment.Trim().Trim(false); m_formattedComment << wxT("\n<hr>"); } m_formattedComment << tagComment; } // Update all "doxy" comments and surround them with <green> tags static wxRegEx reDoxyParam("([@\\\\]{1}param)[ \t]+([_a-z][a-z0-9_]*)?", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDoxyBrief("([@\\\\]{1}(brief|details))[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDoxyThrow("([@\\\\]{1}(throw|throws))[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDoxyReturn("([@\\\\]{1}(return|retval|returns))[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDoxyToDo("([@\\\\]{1}todo)[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDoxyRemark("([@\\\\]{1}(remarks|remark))[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDate("([@\\\\]{1}date)[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reFN("([@\\\\]{1}fn)[ \t]*", wxRE_DEFAULT | wxRE_ICASE); if(reDoxyParam.IsValid() && reDoxyParam.Matches(m_formattedComment)) { reDoxyParam.ReplaceAll(&m_formattedComment, "\n<b>Parameter</b>\n<i>\\2</i>"); } if(reDoxyBrief.IsValid() && reDoxyBrief.Matches(m_formattedComment)) { reDoxyBrief.ReplaceAll(&m_formattedComment, ""); } if(reDoxyThrow.IsValid() && reDoxyThrow.Matches(m_formattedComment)) { reDoxyThrow.ReplaceAll(&m_formattedComment, "\n<b>Throws</b>\n"); } if(reDoxyReturn.IsValid() && reDoxyReturn.Matches(m_formattedComment)) { reDoxyReturn.ReplaceAll(&m_formattedComment, "\n<b>Returns</b>\n"); } if(reDoxyToDo.IsValid() && reDoxyToDo.Matches(m_formattedComment)) { reDoxyToDo.ReplaceAll(&m_formattedComment, "\n<b>TODO</b>\n"); } if(reDoxyRemark.IsValid() && reDoxyRemark.Matches(m_formattedComment)) { reDoxyRemark.ReplaceAll(&m_formattedComment, "\n "); } if(reDate.IsValid() && reDate.Matches(m_formattedComment)) { reDate.ReplaceAll(&m_formattedComment, "<b>Date</b> "); } if(reFN.IsValid() && reFN.Matches(m_formattedComment)) { size_t fnStart, fnLen, fnEnd; if(reFN.GetMatch(&fnStart, &fnLen)) { fnEnd = m_formattedComment.find('\n', fnStart); if(fnEnd != wxString::npos) { // remove the string from fnStart -> fnEnd (including ther terminating \n) m_formattedComment.Remove(fnStart, (fnEnd - fnStart) + 1); } } } // if nothing to display skip this m_formattedComment.Trim().Trim(false); return m_formattedComment; }
bool ParseCDBWatchValue(cb::shared_ptr<GDBWatch> watch, wxString const &value) { wxArrayString lines = GetArrayFromString(value, wxT('\n')); watch->SetDebugValue(value); watch->MarkChildsAsRemoved(); if (lines.GetCount() == 0) return false; static wxRegEx unexpected_error(wxT("^Unexpected token '.+'$")); static wxRegEx resolve_error(wxT("^Couldn't resolve error at '.+'$")); // search for errors for (unsigned ii = 0; ii < lines.GetCount(); ++ii) { if (unexpected_error.Matches(lines[ii]) || resolve_error.Matches(lines[ii]) || lines[ii] == wxT("No pointer for operator* '<EOL>'")) { watch->SetValue(lines[ii]); return true; } } if (lines.GetCount() == 1) { wxArrayString tokens = GetArrayFromString(lines[0], wxT(' ')); if (tokens.GetCount() < 2) return false; int type_token = 0; if (tokens[0] == wxT("class") || tokens[0] == wxT("struct")) type_token = 1; if (static_cast<int>(tokens.GetCount()) < type_token + 2) return false; int value_start = type_token + 1; if (tokens[type_token + 1] == wxT('*')) { watch->SetType(tokens[type_token] + tokens[type_token + 1]); value_start++; } else watch->SetType(tokens[type_token]); if(value_start >= static_cast<int>(tokens.GetCount())) return false; watch->SetValue(tokens[value_start]); watch->RemoveMarkedChildren(); return true; } else { wxArrayString tokens = GetArrayFromString(lines[0], wxT(' ')); if (tokens.GetCount() < 2) return false; bool set_type = true; if (tokens.GetCount() > 2) { if (tokens[0] == wxT("struct") || tokens[0] == wxT("class")) { if (tokens[2] == wxT('*') || tokens[2].StartsWith(wxT("["))) { watch->SetType(tokens[1] + tokens[2]); set_type = false; } } else { if (tokens[1] == wxT('*') || tokens[1].StartsWith(wxT("["))) { watch->SetType(tokens[0] + tokens[1]); watch->SetValue(lines[1]); return true; } } } if (set_type) watch->SetType(tokens[1]); static wxRegEx class_line(wxT("[ \\t]*\\+(0x[0-9a-f]+)[ \\t]([a-zA-Z0-9_]+)[ \\t]+:[ \\t]+(.+)")); if (!class_line.IsValid()) { int *p = NULL; *p = 0; } else { if (!class_line.Matches(wxT(" +0x000 a : 10"))) { int *p = NULL; *p = 0; } } for (unsigned ii = 1; ii < lines.GetCount(); ++ii) { if (class_line.Matches(lines[ii])) { cb::shared_ptr<GDBWatch> w = AddChild(watch, class_line.GetMatch(lines[ii], 2)); w->SetValue(class_line.GetMatch(lines[ii], 3)); w->SetDebugValue(lines[ii]); } } watch->RemoveMarkedChildren(); return true; } return false; }