Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: ollydbg on October 23, 2009, 05:41:23 pm

Title: change Go to Line method.
Post by: ollydbg on October 23, 2009, 05:41:23 pm
Is it possible to change the function like this

Code
void cbEditor::GotoLine(int line, bool centerOnScreen)
{
    cbStyledTextCtrl* control = GetControl();

    // Make sure the line is not folded. This is done before moving to that
    // line because folding may change the lines layout.
    control->EnsureVisible(line);

    // If the line or the following is a fold point it will be unfolded, in this way
    // when the line is a function declaration (or only contains the opening brace of it [yes, that happens sometimes] )
    // the body is shown.
    DoFoldLine(line,0);
    DoFoldLine(line+1,0);

    if (centerOnScreen)
    {
        int onScreen = control->LinesOnScreen() >> 1;
        int firstVisibleLine = control->GetFirstVisibleLine();
        if(line<firstVisibleLine||line>(firstVisibleLine+2*onScreen))
        {
            control->GotoLine(line - onScreen);
            control->GotoLine(line + onScreen);
        }

    }
    control->GotoLine(line);
}

I think this can avoid some screen flash(for me, it is annoying), which means when we just do a small jump, we don't need to center the cursor. :D

Any comments?!? :D