Author Topic: wxWidgets folding bugs fixed  (Read 3022 times)

Offline Lakmus

  • Single posting newcomer
  • *
  • Posts: 8
    • Lakmus soft
wxWidgets folding bugs fixed
« on: January 19, 2006, 03:43:18 am »
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: [Select]
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.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: wxWidgets folding bugs fixed
« Reply #1 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 :)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: wxWidgets folding bugs fixed
« Reply #2 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.
« Last Edit: January 19, 2006, 08:23:14 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."