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

wxWidgets folding bugs fixed

(1/1)

Lakmus:
I write in this topic 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();
}

--- End code ---

Thank you.

rickg22:
Hi, can you post that on the project's Patch Requests? (go to the main page, "submit a patch"). Thank you :)

thomas:
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.

Navigation

[0] Message Index

Go to full version