News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Patch add event for editor split and unsplit

Started by arthurzmj, May 23, 2014, 02:36:14 PM

Previous topic - Next topic

arthurzmj

I've create a ticket on https://sourceforge.net/p/codeblocks/tickets/2/
I think it's useful sometimes.
Declare here for developer's attention.

oBFusCATed

Examples?
You've mentioned the KeyBinder plugin, but I don't see changes in it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

arthurzmj

#2
Quote from: oBFusCATed on May 23, 2014, 11:55:44 PM
Examples?
You've mentioned the KeyBinder plugin, but I don't see changes in it.

I found such codes in KeyBinder
// ----------------------------------------------------------------------------
void cbKeyBinder::OnWindowCreateEvent(wxEvent& event)
// ----------------------------------------------------------------------------
{
    // wxEVT_CREATE entry
    // Have to do this for split windows since CodeBlocks does not have
    // events when opening/closing split windows

    // Attach a split window (or any other window)
    if ( m_bBound )
    {
        wxWindow* pWindow = (wxWindow*)(event.GetEventObject());
        cbEditor* ed = 0;
        //cbStyledTextCtrl* p_cbStyledTextCtrl = 0;
        //cbStyledTextCtrl* pLeftSplitWin = 0;
        cbStyledTextCtrl* pRightSplitWin = 0;
        ed  = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
        if (ed)
        {   //p_cbStyledTextCtrl = ed->GetControl();
            //pLeftSplitWin = ed->GetLeftSplitViewControl();
            pRightSplitWin = ed->GetRightSplitViewControl();
            //Has this window been split?
            //**This is a temporary hack until some cbEvents are defined**
            if ( pWindow && (pRightSplitWin == 0) )
            {
                //-if (pRightSplitWin eq pWindow)
                //-{    Attach(pRightSplitWin);
                if (pWindow->GetParent() == ed)
                {   LOGIT( _T("OnWindowCreateEvent Attaching:%p"), pWindow );
                    AttachEditor(pWindow);
                }
            }
        }
    }//if m_bBound...

    event.Skip();
}//OnWindowCreateEvent


Although The plugin can find the split window in such way, the window relationship has not been built yet in such event.
That means the plugin can not find this window by Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor()->GetRightSplitViewControl()
What's more, the window's parent is going to be changed to a wxSplitterWindow after the window was created. In my cbVike plugin, It's important to get this wxSplitterWindow, but there is no way to do this without the split and unsplit event. You can refer to https://github.com/zmj64351508/cbvike . It's very similar to keyBinder in structure.

Edit: Another example is if the plugin want to do something like change the caret style in WindowCreateEvent, it may crash the app because the wxScintilla is not initialized when this event occurs.

oBFusCATed

Are you willing to provide a patch for keybinder, too?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

arthurzmj

OK. But the patch for keyBinder may come a few days later since I'm a little busy this week.

arthurzmj

Quote from: oBFusCATed on May 25, 2014, 12:50:52 PM
Are you willing to provide a patch for keybinder, too?
This is the patch for keybinder and along with a little change of split event from previous patch. Please use this patch instead of the previous one.