News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

wxWidgets folding bugs fixed

Started by Lakmus, January 19, 2006, 03:43:18 AM

Previous topic - Next topic

Lakmus

I write in this topic http://forums.next.codeblocks.org/index.php?topic=1858 about folding bug, but I find two new bugs.

This code fixed all known folding bugs:


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.

rickg22

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

thomas

#2
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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."