News:

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

Main Menu

change Go to Line method.

Started by ollydbg, October 23, 2009, 05:41:23 PM

Previous topic - Next topic

ollydbg

Is it possible to change the function like this


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
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.