Example #1
0
CELL * p_findAll(CELL * params)
{
CELL * key;
CELL * space;

key = evaluateExpression(params);
params = getEvalDefault(params->next, &space);

if(key->type == CELL_STRING && space->type == CELL_STRING)
	return(findAllString((char *)key->contents, 
			(char *)space->contents,  (size_t) space->aux - 1, params));

if(!isList(space->type))
	return(errorProcExt(ERR_LIST_EXPECTED, space));

return(findAllList(key, (CELL *)space->contents, params));
}
Example #2
0
void wxSTEditorNotebook::OnFindDialog(wxFindDialogEvent &event)
{
    wxSTERecursionGuard guard(m_rGuard_OnFindDialog);
    if (guard.IsInside()) return;

    // currently opened page is where the search starts
    wxSTEditor *editor = GetEditor();

    if (!editor)
        return;

    // just search the given page by letting the editor handle it
    if (!STE_HASBIT(event.GetFlags(), STE_FR_ALLDOCS))
    {
        editor->HandleFindDialogEvent(event);
        return;
    }

    wxEventType eventType = event.GetEventType();
    wxString findString   = event.GetFindString();
    long flags            = event.GetFlags();

    editor->SetFindString(findString, true);
    editor->SetFindFlags(flags, true);

    STE_TextPos pos = editor->GetCurrentPos();
    if ((eventType == wxEVT_COMMAND_FIND) && STE_HASBIT(flags, STE_FR_WHOLEDOC))
        pos = -1;

    // we have to move cursor to start of word if last backwards search suceeded
    //   note cmp is ok since regexp doesn't handle searching backwards
    if ((eventType == wxEVT_COMMAND_FIND_NEXT) && !STE_HASBIT(flags, wxFR_DOWN))
    {
        if ((labs(editor->GetSelectionEnd() - editor->GetSelectionStart()) == long(findString.Length()))
            && (editor->GetFindReplaceData()->StringCmp(findString, editor->GetSelectedText(), flags)))
                pos -= (STE_TextPos)findString.Length() + 1; // doesn't matter if it matches or not, skip it
    }


    if (eventType == wxEVT_STEFIND_GOTO)
    {
        wxString findAllString(event.GetString());

        wxString fileName;
        int line_number      = 0;
        int line_start_pos   = 0;
        int string_start_pos = 0;
        int string_length    = 0;
        wxString lineText;

        bool ok = wxSTEditorFindReplaceData::ParseFindAllString(findAllString,
                                                                fileName,
                                                                line_number, line_start_pos,
                                                                string_start_pos, string_length,
                                                                lineText);
        int page = wxNOT_FOUND;

        if (ok)
            page = FindEditorPageByFileName(fileName);

        if (page != wxNOT_FOUND)
        {
            SetSelection(page);
            GetEditor(page)->HandleFindDialogEvent(event);
        }
    }
    else if ((eventType == wxEVT_COMMAND_FIND) || (eventType == wxEVT_COMMAND_FIND_NEXT))
    {
        if (STE_HASBIT(flags, STE_FR_FINDALL|STE_FR_BOOKMARKALL))
        {
            // sum up all of the find strings in all editors
            int n, count = (int)GetPageCount();

            for (n = 0; n < count; n++)
            {
                wxSTEditor* e = GetEditor(n);
                if (e)
                    e->HandleFindDialogEvent(event);
            }
        }
        else
        {
            if ((eventType == wxEVT_COMMAND_FIND) && STE_HASBIT(flags, STE_FR_WHOLEDOC))
                pos = 0;

            pos = FindString(findString, pos, flags, STE_FINDSTRING_SELECT|STE_FINDSTRING_GOTO);

            if (pos >= 0)
            {
                //editor->SetFocus();
            }
            else
            {
                wxBell(); // bell ok to signify no more occurances?
            }
        }
    }
    else if (eventType == wxEVT_COMMAND_FIND_REPLACE)
    {
        if (!editor->GetFindReplaceData()->StringCmp(findString, editor->GetSelectedText(), flags))
        {
            wxBell();
            return;
        }

        STE_TextPos pos = editor->GetSelectionStart();
        wxString replaceString(event.GetReplaceString());
        editor->ReplaceSelection(replaceString);
        editor->EnsureCaretVisible();
        editor->SetSelection(pos, pos + (STE_TextPos)replaceString.Length());
        editor->UpdateCanDo(true);
        //editor->SetFocus();
    }
    else if (eventType == wxEVT_COMMAND_FIND_REPLACE_ALL)
    {
        wxString replaceString(event.GetReplaceString());
        if (editor->GetFindReplaceData()->StringCmp(findString, replaceString, flags))
            return;

        wxBusyCursor busy;

        int pages = 0;
        int count = ReplaceAllStrings(findString, replaceString, flags, &pages);

        wxString msg( wxString::Format(_("Replaced %d occurances of\n'%s' with '%s'\nin %d documents."),
                                       count, findString.wx_str(), replaceString.wx_str(), pages) );

        wxMessageBox( msg, _("Finished replacing"),
                      wxOK|wxICON_INFORMATION|wxSTAY_ON_TOP,
                      wxGetTopLevelParent(this) ); // make it be on top in GTK
                      //wxDynamicCast(event.GetEventObject(), wxDialog));
    }
    else if (eventType == wxEVT_COMMAND_FIND_CLOSE)
    {
        //if (wxDynamicCast(event.GetEventObject(), wxDialog))
        //    ((wxDialog*)event.GetEventObject())->Destroy();
    }
}