Example #1
0
/*
 * SetCurrentColumn - set CurrentPos.column, positioning LeftTopPos.column nicely
 */
vi_rc SetCurrentColumn( int newcol )
{
    long        oldpos;
    int         text_cols;

    oldpos = CurrentPos.column - LeftTopPos.column;
    if( newcol <= 0 ) {
        newcol = 1;
    }

    text_cols = WindowAuxInfo( current_window_id, WIND_INFO_TEXT_COLS );
    if( oldpos < 0 || oldpos >= text_cols ) {
        LeftTopPos.column = newcol - SCROLL_HLINE - 1;
    } else {
        LeftTopPos.column = newcol - oldpos - 1;
    }
    if( LeftTopPos.column < 0 ) {
        LeftTopPos.column = 0;
    }

    CurrentPos.column = newcol;

    CheckCurrentColumn();
    UpdateCursorDrag();
    VarAddRandC();

    PositionHorizontalScrollThumb( current_window_id, LeftTopPos.column );
    UpdateStatusWindow();
    SetWindowCursor();
    DCDisplayAllLines();
    return( ERR_NO_ERR );

} /* SetCurrentColumn */
Example #2
0
/*
 * startSelectedRegion - start selection region area from keyboard
 */
int startSelectedRegion( bool line_based )
{
    if( ShiftDown() && SelRgn.selected ) {
        EditFlags.Dragging = TRUE;
        UpdateCursorDrag();
    } else {
        if( SelRgn.selected ) {
            UnselectRegion();
            return( ERR_NO_ERR );
        }
        EditFlags.Dragging = TRUE;
        InitSelectedRegion();
        SelRgn.lines = line_based;
        SelRgn.selected = TRUE;
        updateRegion();
    }
    return( ERR_NO_ERR );

} /* startSelectedRegion */
Example #3
0
void SetCurrentLineNumber( linenum l )
{
    long        last;
    long        height;

    CurrentPos.line = l;
    UpdateCursorDrag();
    VarAddRandC();

    if( CurrentFile != NULL ) {
        height = WindowAuxInfo( current_window_id, WIND_INFO_TEXT_LINES );
        last = CurrentFile->fcbs.tail->end_line - height + 1;
        if ( LeftTopPos.line > last ){
             last = LeftTopPos.line;
        }
    } else {
        last = 1;
    }
    PositionVerticalScrollThumb( current_window_id, LeftTopPos.line, last );
}
Example #4
0
/*
 * GoToColumn - go to a specified column
 */
vi_rc GoToColumn( int colno, int maxcol )
{
    int vc;

    if( CurrentFile == NULL ) {
        return( ERR_NO_FILE );
    }

    if( maxcol == 0 ) {
        maxcol = 1;
    }
    if( colno == 0 ) {
        colno = 1;
    }
    if( colno < 1 || colno > maxcol ) {
        return( ERR_NO_SUCH_COLUMN );
    }

    /*
     * compute new location, and re-display text if needed
     */
    VirtualColumnDesired = VirtualColumnOnCurrentLine( colno );
    CurrentPos.column = colno;
    if( !CheckLeftColumn() ) {
        DCDisplayAllLines();
        PositionHorizontalScrollThumb( current_window_id, LeftTopPos.column );
    }

    SetWindowCursor();
    vc = VirtualColumnOnCurrentLine( CurrentPos.column );
    UpdateStatusWindow();
    VarAddGlobalLong( "C", (long) vc );
    UpdateCursorDrag();
    return( ERR_NO_ERR );

} /* GoToColumn */