Logo Search packages:      
Sourcecode: yzis version File versions  Download package

void YView::alignViewBufferVertically ( int  line  ) 

align view vertically on the given buffer

  • line

Definition at line 356 of file view.cpp.

References YViewCursor::bufferY(), getCurrentTop(), getCursor(), getLinesVisible(), gotodxdy(), gotodxy(), gotoxy(), mLinesVis, YViewCursor::reset(), YViewCursor::screenX(), YViewCursor::screenY(), sendRefreshEvent(), YViewCursor::setBufferY(), YViewCursor::setScreenY(), and updateCursor().

{
    // dbg() << "YView::alignViewBufferVertically " << line << endl;
    int newcurrent = line;
    int old_dCurrentTop = scrollCursor.screenY();
    if ( newcurrent > 0 ) {
        if ( wrap ) {
            gotodxy( &scrollCursor, scrollCursor.screenX(), newcurrent );
        } else {
            scrollCursor.setBufferY( newcurrent );
            scrollCursor.setScreenY( newcurrent );
        }
    } else {
        scrollCursor.reset();
    }
    if ( old_dCurrentTop == scrollCursor.screenY() ) {
        /* nothing has changed */
        return ;
    } else if ( qAbs(old_dCurrentTop - scrollCursor.screenY()) < mLinesVis ) {
        /* optimization: we can scroll */
        internalScroll( 0, old_dCurrentTop - scrollCursor.screenY() );
    } else {
        sendRefreshEvent();
    }

    // find the last visible line in the buffer
    int lastBufferLineVisible = getCurrentTop() + getLinesVisible() - 1;

    if ( wrap ) {
        YViewCursor temp = scrollCursor;
        gotodxdy( &temp, getCursor().x(), getDrawCurrentTop() + getLinesVisible() - 1 );
        lastBufferLineVisible = temp.bufferY();
    }

    // move cursor if it scrolled off the screen
    if (getCursor().y() < getCurrentTop())
        gotoxy(getCursor().x(), getCurrentTop());
    else if (getCursor().y() > lastBufferLineVisible)
        gotoxy( getCursor().x(), lastBufferLineVisible );

    updateCursor();
}


Generated by  Doxygen 1.6.0   Back to index