Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: Lakmus on January 19, 2006, 03:43:18 am

Title: wxWidgets folding bugs fixed
Post by: Lakmus on January 19, 2006, 03:43:18 am
I write in this topic http://forums.codeblocks.org/index.php?topic=1858 (http://forums.codeblocks.org/index.php?topic=1858) about folding bug, but I find two new bugs.

This code fixed all known folding bugs:

Code
void Code_Editor::OnKeyPressed(wxKeyEvent& event) // Change it for Code::Blocks code editor
{
    long KeyCode = event.GetKeyCode();

    // Fix 'Delete key' folding bug
    if (KeyCode == WXK_DELETE)
    {
        int current_line = GetCurrentLine();

        if (!GetFoldExpanded(current_line))
        {
            ToggleFold(current_line);
        }
    }

    // Fix 'Return key' folding bug
    if (KeyCode == WXK_RETURN)
    {
        int current_line = GetCurrentLine();

        if (!GetFoldExpanded(current_line))
        {
            if (GetColumn(GetCurrentPos()) != 0)
            {
                ToggleFold(current_line);
            }
        }
    }

    // Fix 'Backspace key' folding bug
    if (KeyCode == WXK_BACK)
    {
        if (GetColumn(GetCurrentPos()) == 0)
        {
            int back_line = GetCurrentLine() - 1;

            if (!GetLineVisible(back_line))
            {
                ToggleFold(back_line);
            }
        }
    }

    event.Skip();
}

Thank you.
Title: Re: wxWidgets folding bugs fixed
Post by: rickg22 on January 19, 2006, 07:31:40 pm
Hi, can you post that on the project's Patch Requests? (go to the main page, "submit a patch"). Thank you :)
Title: Re: wxWidgets folding bugs fixed
Post by: thomas on January 19, 2006, 08:18:03 pm
Please don't.

If you want to post a patch, then please do one that works. This one cannot even compile.

EDIT:
To elaborate, you are mixing up editor and scintilla member functions, which prevents it from compiling. Apart from that, I am not sure if it would work, supposed it compiled, because scintilla receives the key events and processes them. Unless scintilla forwards the events (which it should not), the editor will never see any key events.