예제 #1
0
static void FilePos( a_window *wnd, int pos )
{
    unsigned long       range;
    file_window *file = WndFile( wnd );

    if( pos < 0 )
        pos = 0;
    if( file->viewhndl == NULL ) {
        if( pos+WndRows(wnd) > file->eof )
            return;
        WndSetTop( wnd, pos );
        return;
    }
    if( FReadLine( file->viewhndl, pos+WndRows(wnd), 0, TxtBuff, TXT_LEN ) < 0 ) {
        pos = FCurrLine( file->viewhndl ) - WndRows(wnd) - 1;
        if( pos < 0 ) {
            pos = 0;
        }
    }
    WndSetTop( wnd, pos );
    if( pos >= file->rows ) {
        file->rows = pos+1;
        file->rows_offset = FLastOffset( file->viewhndl );
    }
    if( file->rows == 0 )
        file->rows = 1;
    if( file->rows_offset == 0 ) {
        range = file->size;
    } else {
        range = file->size * file->rows / file->rows_offset;
    }
    WndSetVScrollRange( wnd, range );
    WndSetThumbPos( wnd, pos );
}
예제 #2
0
extern int W5Scroll( a_window *wnd, int lines )
{
    int         old_top;
    int         new_top;

    old_top = WndTop( wnd );
    new_top = old_top + lines;
    if( new_top >= NUM_ROWS ) new_top = NUM_ROWS-1;
    if( new_top < 0 ) new_top = 0;
    WndSetTop( wnd, new_top );
    WndSetVScrollRange( wnd, WndRows( wnd ) + NUM_ROWS - 1 );
    WndSetThumbPos( wnd, new_top );
    return( new_top - old_top );
}