commands.cc
/*
** scroll_up_half_window - scroll listing up half a window.  This routine
**                         is only called when the tail\(\) of the listing
**                         isn\'t being displayed.  We try to leave the
**                         cursor on the file it was on previously,
**                         otherwise it is left on the first file in
**                         the screen.
*/
scroll listing up half a window.  This routine
is only called when the tail\(\) of the listing
isn\'t being displayed.  We try to leave the
cursor on the file it was on previously,
otherwise it is left on the first file in
the screen.
scroll listing up half a window . This routine is only called when the tail \ ( \ ) of the listing isn \ ' t being displayed . We try to leave the cursor on the file it was on previously otherwise it is left on the first file in the screen .
static void scroll_up_half_window(DirList *dl, int y)
{
    if (dl->currLine()->length() > columns()) rightshift_current_line(dl);
    DirLine *ln = dl->firstLine();
    for (int i = 0; i < (rows() - 2)/2; i++, ln = ln->next()) ;
    dl->setFirst(ln);
    if (CS || DL || SF || DLN)
    {
        if (CS)
            scroll_listing_up_N((rows()-2)/2);
        else
        {
            clear_modeline();
            scroll_screen_up_N((rows()-2)/2);
            update_modeline();
        }
        move_cursor(rows() - 2 -((rows()-2)/2), 0);
        ln = dl->lastLine()->next();
        for (i = 0; i < (rows() - 2)/2 && ln; i++, ln = ln->next())
            display_string(ln->line(), ln->length());
        ln ? dl->setLast(ln->prev()) : dl->setLast(dl->tail());
    }
    else
    {
        cursor_home();
        for (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
        move_cursor(i, 0);
        for (; i < rows() - 2; i++)
        {
            clear_to_end_of_line();
            cursor_down();
        }
    }
    int pos = y - (rows()-2)/2;
    if (pos < 0)
    {
        pos = 0;
        dl->setCurrLine(dl->firstLine());
    }
    dl->saveYXPos(pos, goal_column(dl));
    if (dl->currLine()->length() > columns())
        leftshift_current_line(dl);
    else
        move_cursor(pos, dl->savedXPos());
    synch_display();
}
static void scroll_up_half_window ( DirList * dl , int y ) { if ( dl -> currLine ( ) -> length ( ) > columns ( ) ) rightshift_current_line ( dl ) ; DirLine * ln = dl -> firstLine ( ) ; for ( int i = 0 ; i < ( rows ( ) - 2 ) / 2 ; i ++ , ln = ln -> next ( ) ) ; dl -> setFirst ( ln ) ; if ( CS || DL || SF || DLN ) { if ( CS ) scroll_listing_up_N ( ( rows ( ) - 2 ) / 2 ) ; else { clear_modeline ( ) ; scroll_screen_up_N ( ( rows ( ) - 2 ) / 2 ) ; update_modeline ( ) ; } move_cursor ( rows ( ) - 2 - ( ( rows ( ) - 2 ) / 2 ) , 0 ) ; ln = dl -> lastLine ( ) -> next ( ) ; for ( i = 0 ; i < ( rows ( ) - 2 ) / 2 && ln ; i ++ , ln = ln -> next ( ) ) display_string ( ln -> line ( ) , ln -> length ( ) ) ; ln ? dl -> setLast ( ln -> prev ( ) ) : dl -> setLast ( dl -> tail ( ) ) ; } else { cursor_home ( ) ; for ( 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 ( ) ) ; move_cursor ( i , 0 ) ; for ( ; i < rows ( ) - 2 ; i ++ ) { clear_to_end_of_line ( ) ; cursor_down ( ) ; } } int pos = y - ( rows ( ) - 2 ) / 2 ; if ( pos < 0 ) { pos = 0 ; dl -> setCurrLine ( dl -> firstLine ( ) ) ; } dl -> saveYXPos ( pos , goal_column ( dl ) ) ; if ( dl -> currLine ( ) -> length ( ) > columns ( ) ) leftshift_current_line ( dl ) ; else move_cursor ( pos , dl -> savedXPos ( ) ) ; synch_display ( ) ; }
scroll_up_half_window - scroll listing up half a window.
scroll_up_half_window - scroll listing up half a window .
// // 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