commands.cc
/*
** scroll_down_half_window - try to scroll listing down half a window.
**                           If `freshen\' is true, which is the default,
**                           the screen is refreshed.  It is important
**                           to note that we may not be able to scroll
**                           down a complete half window, since we
**                           always anchor the head of the listing to
**                           the first line in the screen.  This routine
**                           is only called when the head\(\) of the
**                           listing isn\'t being displayed.
*/
try to scroll listing down half a window.
If `freshen\' is true, which is the default,
the screen is refreshed.  It is important
to note that we may not be able to scroll
down a complete half window, since we
always anchor the head of the listing to
the first line in the screen.  This routine
is only called when the head\(\) of the
listing isn\'t being displayed.
try to scroll listing down half a window . If ` freshen \ ' is true which is the default the screen is refreshed . It is important to note that we may not be able to scroll down a complete half window since we always anchor the head of the listing to the first line in the screen . This routine is only called when the head \ ( \ ) of the listing isn \ ' t being displayed .
static void scroll_down_half_window(DirList *dl, int y, int freshen = 1)
{
    if (dl->firstLine() != dl->head())
    {
         We can scroll down.  Try to leave the cursor on the file
         it started out on.  Otherwise, leave it on the
         \(rows\(\)-2\)/2 line, which was the previous firstLine\(\).
        DirLine *ln = dl->firstLine();
        for (int i = 0; i < (rows()-2)/2 && ln->prev(); i++, ln = ln->prev()) ;
        dl->setFirst(ln);
        if (dl->currLine()->length() > columns()) rightshift_current_line(dl);
        if (CS || AL || ALN || SR)
        {
            if (CS)
                scroll_listing_down_N(i);
            else
            {
                clear_modeline();
                scroll_screen_down_N(i);
                update_modeline();
                clear_message_line();
            }
            cursor_home();
            for (int j = 0; j < i; j++, ln = ln->next())
                display_string(ln->line(), ln->length());
            ln = dl->firstLine();
            for (int i = 0; i < rows()-2 && ln->next(); i++, ln = ln->next()) ;
            dl->setLast(ln);
        }
        else
        {
            cursor_home();
            for (int i = 0; i < rows()-2 && ln->next(); i++, ln = ln->next())
            {
                clear_to_end_of_line();
                display_string(ln->line(), ln->length());
            }
            if (i != rows() - 2)
            {
                 We hit last line before outputing all that we could.
                 Must output lastLine\(\) == tail\(\).
                display_string(ln->line(), ln->length());
                dl->setLast(ln);
                i++;   so we know how many lines have been written
            }
            else
                dl->setLast(ln->prev());
             now clear any remaining rows on the screen
            int tmp = i;
            move_cursor(i, 0);
            for (; i < rows()-2; i++)
            {
                clear_to_end_of_line();
                cursor_down();
            }
            i = tmp;   because we use `i\' below
        }
        int pos = i + y;
        if (pos > rows() - 3)
        {
            pos = rows() - 3;
            dl->setCurrLine(dl->lastLine());
        }
        dl->saveYXPos(pos, goal_column(dl));
        if (dl->currLine()->length() > columns())
            leftshift_current_line(dl);
        else
            move_cursor(pos, dl->savedXPos());
        if (freshen) synch_display();
    }
}
static void scroll_down_half_window ( DirList * dl , int y , int freshen = 1 ) { if ( dl -> firstLine ( ) != dl -> head ( ) ) { DirLine * ln = dl -> firstLine ( ) ; for ( int i = 0 ; i < ( rows ( ) - 2 ) / 2 && ln -> prev ( ) ; i ++ , ln = ln -> prev ( ) ) ; dl -> setFirst ( ln ) ; if ( dl -> currLine ( ) -> length ( ) > columns ( ) ) rightshift_current_line ( dl ) ; if ( CS || AL || ALN || SR ) { if ( CS ) scroll_listing_down_N ( i ) ; else { clear_modeline ( ) ; scroll_screen_down_N ( i ) ; update_modeline ( ) ; clear_message_line ( ) ; } cursor_home ( ) ; for ( int j = 0 ; j < i ; j ++ , ln = ln -> next ( ) ) display_string ( ln -> line ( ) , ln -> length ( ) ) ; ln = dl -> firstLine ( ) ; for ( int i = 0 ; i < rows ( ) - 2 && ln -> next ( ) ; i ++ , ln = ln -> next ( ) ) ; dl -> setLast ( ln ) ; } else { cursor_home ( ) ; for ( int i = 0 ; i < rows ( ) - 2 && ln -> next ( ) ; i ++ , ln = ln -> next ( ) ) { clear_to_end_of_line ( ) ; display_string ( ln -> line ( ) , ln -> length ( ) ) ; } if ( i != rows ( ) - 2 ) { display_string ( ln -> line ( ) , ln -> length ( ) ) ; dl -> setLast ( ln ) ; i ++ ; } else dl -> setLast ( ln -> prev ( ) ) ; int tmp = i ; move_cursor ( i , 0 ) ; for ( ; i < rows ( ) - 2 ; i ++ ) { clear_to_end_of_line ( ) ; cursor_down ( ) ; } i = tmp ; } int pos = i + y ; if ( pos > rows ( ) - 3 ) { pos = rows ( ) - 3 ; dl -> setCurrLine ( dl -> lastLine ( ) ) ; } dl -> saveYXPos ( pos , goal_column ( dl ) ) ; if ( dl -> currLine ( ) -> length ( ) > columns ( ) ) leftshift_current_line ( dl ) ; else move_cursor ( pos , dl -> savedXPos ( ) ) ; if ( freshen ) synch_display ( ) ; } }
scroll_down_half_window - try to scroll listing down half a window.
scroll_down_half_window - try to scroll listing down half a window .
// // We can scroll down.  Try to leave the cursor on the file // it started out on.  Otherwise, leave it on the // \(rows\(\)-2\)/2 line, which was the previous firstLine\(\). // // // We hit last line before outputing all that we could. // Must output lastLine\(\) == tail\(\). // // so we know how many lines have been written // now clear any remaining rows on the screen // because we use `i\' below