Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

about bracecompletion

<< < (5/6) > >>

blueshake:
nice to hear that . :D
by the way, what is your idea about reply #18?
this confuse me for several days.

killerbot:
applied and many thanks for the contribution  :P

I have no idea 'm_pControl->DeleteBack();' why this does not work. I should study the class of m_pControl again first.

ollydbg:

--- Quote from: blueshake on August 19, 2009, 10:26:49 am ---hi,
recently,i am going to make a patch,its function is
when you delete a ([{ and the right char is )]} ,so the the relative one will be deleted too.
for example

--- Code: ---int main(|)
--- End code ---
int the "|" position ,you delete "(" and the ")" should be deleted too.
but i face a problem,
it seems that these codes can not work.the caret moved,but the ) didn't be delete.
any one have any idea about this?
these codes seems not be executed .

--- Code: ---m_pControl->DeleteBack();
--- End code ---

here are the codes.

--- Code: ---void cbEditor::OnEditorModified(wxScintillaEvent& event)
{
//    wxString txt = _T("OnEditorModified(): ");
//    int flags = event.GetModificationType();
//    if (flags & wxSCI_MOD_CHANGEMARKER) txt << _T("wxSCI_MOD_CHANGEMARKER, ");
//    if (flags & wxSCI_MOD_INSERTTEXT) txt << _T("wxSCI_MOD_INSERTTEXT, ");
//    if (flags & wxSCI_MOD_DELETETEXT) txt << _T("wxSCI_MOD_DELETETEXT, ");
//    if (flags & wxSCI_MOD_CHANGEFOLD) txt << _T("wxSCI_MOD_CHANGEFOLD, ");
//    if (flags & wxSCI_PERFORMED_USER) txt << _T("wxSCI_PERFORMED_USER, ");
//    if (flags & wxSCI_MOD_BEFOREINSERT) txt << _T("wxSCI_MOD_BEFOREINSERT, ");
//    if (flags & wxSCI_MOD_BEFOREDELETE) txt << _T("wxSCI_MOD_BEFOREDELETE, ");
//    txt << _T("pos=")
//        << wxString::Format(_T("%d"), event.GetPosition())
//        << _T(", line=")
//        << wxString::Format(_T("%d"), event.GetLine())
//        << _T(", linesAdded=")
//        << wxString::Format(_T("%d"), event.GetLinesAdded());
//    Manager::Get()->GetLogManager()->DebugLog(txt);

    // whenever event.GetLinesAdded() != 0, we must re-set breakpoints for lines greater
    // than LineFromPosition(event.GetPosition())
    int linesAdded = event.GetLinesAdded();
    bool isAdd = event.GetModificationType() & wxSCI_MOD_INSERTTEXT;
    bool isDel = event.GetModificationType() & wxSCI_MOD_DELETETEXT;
    if ((isAdd || isDel) && linesAdded != 0)
    {
        // in case of no line numbers to be shown no need to set
        // NOTE : on every modification of the Editor we consult ConfigManager
        //        hopefully not to time consuming, otherwise we make a member out of it
        ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
        if (mgr->ReadBool(_T("/show_line_numbers"), true))
        {
            m_pData->SetLineNumberColWidth();
        }

        // NB: I don't think polling for each debugger every time will slow things down enough
        // to worry about unless there are automated tasks that call this routine regularly
        //
        // well, scintilla events happen regularly
        // although we only reach this part of the code only if a line has been added/removed
        // so, yes, it might not be that bad after all
        PluginsArray arr = Manager::Get()->GetPluginManager()->GetOffersFor(ptDebugger);
        int startline = m_pControl->LineFromPosition(event.GetPosition());
        for(size_t i=0;i<arr.GetCount();i++)
        {
            cbDebuggerPlugin* debugger = (cbDebuggerPlugin*)arr[i];
            debugger->EditorLinesAddedOrRemoved(this, startline, linesAdded);
        }

    }
    if (isDel)
    {
        Manager::Get()->GetLogManager()->DebugLog(event.GetText());
        Manager::Get()->GetLogManager()->DebugLog(F(_T("delete   %d"),event.GetText().size()));
        if (event.GetText().size() == 1)
        {
            const wxString leftBrace(_T("([{"));
            const wxString rightBrace(_T(")]}"));
            int left = leftBrace.find(event.GetText()[0]);
            if (left != wxNOT_FOUND)
            {
                wxChar ch = m_pControl->GetCharAt(event.GetPosition());
                int right = rightBrace.find(ch);
                if (right != wxNOT_FOUND && right == left)
                {
                    m_pControl->GotoPos(event.GetPosition() + 1);
                    m_pControl->DeleteBack();
                 
                }

            }

        }
    }

    OnScintillaEvent(event);
} // end of OnEditorModified
--- End code ---

--- End quote ---

I tested this patch, it seems m_pControl->DeleteBack(); has no effect.
I don't know why...

Jenna:

--- Quote from: ollydbg on August 28, 2009, 01:12:30 pm ---I tested this patch, it seems m_pControl->DeleteBack(); has no effect.
I don't know why...

--- End quote ---

If I see it right, you can not modify the Document from inside the document-modified event (at least not call Document::DeletChars(), did not check this for other modifications).
And I think that's good, because it could lead to infinite loops.

ollydbg:

--- Quote from: jens on August 28, 2009, 02:00:09 pm ---
--- Quote from: ollydbg on August 28, 2009, 01:12:30 pm ---I tested this patch, it seems m_pControl->DeleteBack(); has no effect.
I don't know why...

--- End quote ---

If I see it right, you can not modify the Document from inside the document-modified event (at least not call Document::DeletChars(), did not check this for other modifications).
And I think that's good, because it could lead to infinite loops.


--- End quote ---

Thanks.

It is a reasonable explanation.

Here comes another question:

How can we do such kind of delete?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version