Пример #1
0
vi_rc DeleteLines( void )
{
    range       r;

    GetLineRange( &r, GetRepeatCount(), CurrentPos.line );
    return( Delete( &r ) );

} /* DeleteLines */
Пример #2
0
vi_rc YankLines( void )
{
    range       r;

    GetLineRange( &r, GetRepeatCount(), CurrentPos.line );
    return( Yank( &r ) );

} /* YankLines */
Пример #3
0
/*
 * doOperator - process an operator event
 */
static vi_rc doOperator( event *ev )
{
    event       *next;
    vi_rc       rc;
    long        count;
    range       range;
    int         next_type;
    bool        is_op_alias;

    rc = ERR_INVALID_OP;
    defaultRange( &range );
    count = GetRepeatCount();
    is_op_alias = ev->b.is_op_alias;
    if( is_op_alias ) {
        ev->rtn.alias( &ev, &next );
    } else {
        next = nextEvent();
        // a count is the only thing allowed to interfere between an op and
        // its argument so we just keep chewing...
        if( next != &EventList['0'] ) {
            while( next->b.is_number ) {
                if( EditFlags.Modeless ) {
                    next->alt_rtn.old();
                } else {
                    next->rtn.old();
                }
                next = nextEvent();
            }
        }
        count *= GetRepeatCount();
    }
    KillRepeatWindow();
    if( EditFlags.Modeless ) {
        range.fix_range = next->alt_b.fix_range;
        next_type = next->alt_b.type;
    } else {
        range.fix_range = next->b.fix_range;
        next_type = next->b.type;
    }
    EditFlags.OperatorWantsMove = true; // was: if( count==1 )
    if( next_type == EVENT_OP ) {
        // op/op only valid when ops are equal
        if( next == ev ) {
            rc = GetLineRange( &range, count, CurrentPos.line );
        }
    } else {
        // it had better be a move operation
        if( next_type == EVENT_REL_MOVE || next_type == EVENT_ABS_MOVE ) {
            /*
             * Kluge! want 'ce' instead of 'cw' - this sucks.
             *
             * - even better kludge: if we are currently on white
             *   space, then treat 'cw' as 'cw'. arrrrr. cge.
             */
            if( ( ev == &EventList['c'] || ev == &EventList[VI_KEY( ALT_F1 )] ) &&
                        LastEvent == 'w' ) {
                EditFlags.IsChangeWord = true;
                if( CurrentLine != NULL ) {
                    if( !isspace( CurrentLine->data[CurrentPos.column - 1] ) ) {
                        next = &EventList['e'];
                        range.fix_range = false;
                    }
                }
            }
            if( EditFlags.Modeless ) {
                rc = next->alt_rtn.move( &range, count );
            } else {
                rc = next->rtn.move( &range, count );
            }
            EditFlags.IsChangeWord = false;
        } else {
            /*
             * Kluge! treat 'r' as a movement command.
             */
            if( LastEvent == 'r' ) {
                rc = GetSelectedRegion( &range );
            } else if( LastEvent == '0' ) {
                rc = MoveLineBegin( &range, 1 );
            } else if( LastEvent == VI_KEY( ESC ) ) {
                rc = RANGE_REQUEST_CANCELLED;
            }
        }
    }
    EditFlags.OperatorWantsMove = false;
    if( rc == ERR_NO_ERR ) {
        if( ev->b.modifies ) {
            rc = ModificationTest();
        }
        if( rc == ERR_NO_ERR ) {
            NormalizeRange( &range );
            if( EditFlags.Modeless ) {
                rc = ev->alt_rtn.op( &range );
            } else {
                rc = ev->rtn.op( &range );
            }
        }
    }
    return( rc );

} /* doOperator */