void wxCodeCompletionBoxManager::OnStcModified(wxStyledTextEvent& event)
{
    event.Skip();
    if(m_box && m_box->IsShown() && m_box->m_stc == event.GetEventObject()) {
        m_box->StcModified(event);
    }
}
void t4p::PhpCallTipProviderClass::OnCallTipClick(wxStyledTextEvent& evt) {
    wxStyledTextCtrl* ctrl = wxDynamicCast(evt.GetEventObject(), wxStyledTextCtrl);

    if (!CurrentCallTipResources.empty()) {
        size_t resourcesSize = CurrentCallTipResources.size();
        int position = evt.GetPosition();
        wxString callTip;

        // up arrow. if already at the first choice, then loop around
        // looping around looks better than hiding arrows; because hiding arrows changes the
        // rendering position and make the call tip jump around when clicking up/down
        if (1 == position) {
            CurrentCallTipIndex = ((CurrentCallTipIndex >= 1) && (CurrentCallTipIndex - 1) < resourcesSize) ? CurrentCallTipIndex - 1 : resourcesSize - 1;
            callTip =  PhpCallTipSignature(CurrentCallTipIndex, CurrentCallTipResources);
        } else if (2 == position) {
            // down arrow
            CurrentCallTipIndex = ((CurrentCallTipIndex + 1) < resourcesSize) ? CurrentCallTipIndex + 1 : 0;
            callTip = PhpCallTipSignature(CurrentCallTipIndex, CurrentCallTipResources);
        }
        if (!callTip.IsEmpty()) {
            ctrl->CallTipCancel();
            ctrl->CallTipShow(ctrl->GetCurrentPos(), callTip);
        }
    }
    evt.Skip();
}
Пример #3
0
void wxSTEditorFindReplacePanel::OnMarginClick( wxStyledTextEvent &event )
{
    if (!m_resultEditor) return; // set after editor is fully created

    if (event.GetEventType() == wxEVT_STE_MARGINDCLICK)
        return;

    wxSTEditor *editor = (wxSTEditor*)event.GetEventObject();
    int pos = event.GetPosition();

    if (event.GetEventType() == wxEVT_STC_DOUBLECLICK) // event pos not set correctly
        pos = editor->GetCurrentPos();

    int line = editor->LineFromPosition(pos);

    if (editor->GetLine(line).Strip(wxString::both).IsEmpty())
        return;

    wxArrayString* findAllStrings = m_findReplaceData->GetFindAllStrings();

    if ((line < 0) || (line >= (int)findAllStrings->GetCount()))
        return;

    editor->MarkerDeleteAll(STE_MARKER_BOOKMARK);
    editor->MarkerAdd(line, STE_MARKER_BOOKMARK);

    wxFindDialogEvent fEvent(wxEVT_COMMAND_FIND_NEXT, GetId());
    fEvent.SetEventObject(this);
    fEvent.SetFindString(m_findCombo->GetValue());
    fEvent.SetFlags(GetFindFlags());
    fEvent.SetExtraLong(line);
    Send(fEvent);
}
void t4p::PhpCodeCompletionProviderClass::OnAutoCompletionSelected(wxStyledTextEvent& event) {
    wxStyledTextCtrl* txtCtrl = wxDynamicCast(event.GetEventObject(), wxStyledTextCtrl);
    if (!txtCtrl) {
        return;
    }
    t4p::CodeControlClass* ctrl = (t4p::CodeControlClass*)txtCtrl;

    if (!AutoCompletionResourceMatches.empty()) {
        UnicodeString selected = t4p::WxToIcu(event.GetText());

        bool handled = false;
        for (size_t i = 0; i < AutoCompletionResourceMatches.size(); ++i) {
            t4p::PhpTagClass res = AutoCompletionResourceMatches[i];
            if (res.Identifier == selected) {
                // user had selected  a function /method name; let's add the
                // parenthesis and show the call tip
                ctrl->AutoCompCancel();
                wxString selected = event.GetText();
                int startPos = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
                ctrl->SetSelection(startPos, ctrl->GetCurrentPos());
                wxString status;
                if ((t4p::PhpTagClass::FUNCTION == res.Type || t4p::PhpTagClass::METHOD == res.Type) && !res.HasParameters()) {
                    ctrl->ReplaceSelection(selected + wxT("()"));
                    ctrl->HandleCallTip(0, true);
                } else if (t4p::PhpTagClass::FUNCTION == res.Type || t4p::PhpTagClass::METHOD == res.Type) {
                    ctrl->ReplaceSelection(selected + wxT("("));
                    ctrl->HandleCallTip(0, true);
                } else {
                    ctrl->ReplaceSelection(selected);
                }
                handled = true;
                break;
            }
        }
        if (!handled) {
            // complete the PHP alternative syntax for control structures
            // ie endif endwhile endfor endforeach endswitch
            // Scintilla cannot handle semicolons in keywords; we will add the semicolon here
            if (selected.caseCompare(UNICODE_STRING_SIMPLE("endif"), 0) == 0 ||
                    selected.caseCompare(UNICODE_STRING_SIMPLE("endwhile"), 0) == 0 ||
                    selected.caseCompare(UNICODE_STRING_SIMPLE("endfor"), 0) == 0 ||
                    selected.caseCompare(UNICODE_STRING_SIMPLE("endforeach"), 0) == 0 ||
                    selected.caseCompare(UNICODE_STRING_SIMPLE("endswitch"), 0) == 0) {
                ctrl->AutoCompCancel();
                wxString selected = event.GetText();
                int startPos = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
                ctrl->SetSelection(startPos, ctrl->GetCurrentPos());
                ctrl->ReplaceSelection(selected + wxT(";"));
            }
        }
    }
}
Пример #5
0
void TextFrame::onUpdateUI(wxStyledTextEvent& event)
{
    if(event.GetUpdated()==wxSTC_UPDATE_SELECTION)
    {
        onSelectionChanged();
        wxObject *obj = event.GetEventObject();
        if(obj)
        {
          wxStyledTextCtrl* txt = dynamic_cast<wxStyledTextCtrl*>(obj);
          if(txt)
            updateBraceHilight(txt);
        }
    }
    else if(event.GetUpdated()==wxSTC_UPDATE_V_SCROLL)
    {
        UpdateMarkerPages();
    }
}
Пример #6
0
void wxSTEditorFrame::OnSTCUpdateUI(wxStyledTextEvent &event)
{
    event.Skip();
    if (!GetStatusBar()) // nothing to do
        return;

    wxStyledTextCtrl* editor = wxStaticCast(event.GetEventObject(), wxStyledTextCtrl);
    STE_TextPos pos = editor->GetCurrentPos();
    int line        = editor->GetCurrentLine() + 1; // start at 1
    int lines       = editor->GetLineCount();
    int col         = editor->GetColumn(pos) + 1;   // start at 1
    int chars       = editor->GetLength();

    wxString txt = wxString::Format("Line %6d of %6d, Col %4d, Chars %6d  ", line, lines, col, chars);
    txt += editor->GetOvertype() ? "[OVR]" : "[INS]";

    if (txt != GetStatusBar()->GetStatusText()) // minor flicker reduction
        SetStatusText(txt, 0);
}
Пример #7
0
void FindResultsTab::OnStyleNeeded(wxStyledTextEvent& e)
{
    wxStyledTextCtrl* ctrl = dynamic_cast<wxStyledTextCtrl*>(e.GetEventObject());
    if(!ctrl) return;
    StyleText(ctrl, e);
}
Пример #8
0
void FindUsageTab::OnStyleNeeded(wxStyledTextEvent& e)
{
    wxStyledTextCtrl* ctrl = dynamic_cast<wxStyledTextCtrl*>(e.GetEventObject());
    if(!ctrl) return;
    m_styler->StyleText(ctrl, e, true);
}