Beispiel #1
0
/*
 * LocateCmd - parse a locate command (format: locate r,c[,len])
 */
vi_rc LocateCmd( const char *data )
{
    char        tmp[MAX_STR];
    linenum     r;
    int         c;
    int         len;

#ifdef __WIN__
    if( BAD_ID( current_window_id ) ) {
        return( ERR_INVALID_LOCATE );
    }
#endif
    data = GetNextWord1( data, tmp );
    if( *tmp == '\0' ) {
        return( ERR_INVALID_LOCATE );
    }
    r = atol( tmp );
    data = GetNextWord1( data, tmp );
    if( *tmp == '\0' ) {
        return( ERR_INVALID_LOCATE );
    }
    c = atoi( tmp );

    // real selection length
    while( isspace( *data ) ) {
        data++;
    }
    len = 0;
    if( *data != 0 ) {
        data = GetNextWord1( data, tmp );
        if( *tmp == '\0' ) {
            return( ERR_INVALID_LOCATE );
        }
        len = atoi( tmp );
    }

    GoToLineNoRelCurs( r );

    c = RealColumnOnCurrentLine( c );
    GoToColumnOnCurrentLine( c + len );

#ifdef __WIN__
    // likely only called by dde, which doesn't use event loop,
    // so must ensure cache ok and set cursor here

    DCInvalidateAllLines();
    DCDisplayAllLines();
    DCUpdate();
    SetWindowCursor();
    SetWindowCursorForReal();
#endif

    if( len > 0 ) {
        SetSelRegionCols( CurrentPos.line, c, c + len - 1 );
    }
    return( ERR_NO_ERR );

} /* LocateCmd */
Beispiel #2
0
/*
 * HilightSearchString - bring a search string into view and hilight it
 */
void HilightSearchString( i_mark *pos, int slen )
{
    if( slen > 0 ) {
        GoToColumnOK( pos->column + slen );
    }
    GoToColumnOK( pos->column + 1 );
    if( slen > 0 ) {
#ifdef __WIN__
        SetSelRegionCols( pos->line, pos->column + 1, pos->column + slen );
        DCUpdate();
#else
        DCUpdate();
        HiliteAColumnRange( pos->line, pos->column, pos->column + slen - 1 );
#endif
    }
    EditFlags.ResetDisplayLine = TRUE;

} /* HilightSearchString */
Beispiel #3
0
/*
 * DoSelectSelection - selected region was selected, invoke aprops script
 */
vi_rc DoSelectSelection( bool doMenu )
{
    linenum     sl, el, tl;
    int         sc, ec, tc;
    vi_rc       rc = ERR_NO_ERR;

    if( SelRgn.selected && doMenu ) {
        sl = SelRgn.start.line;
        el = SelRgn.end.line;
        if( sl > el ) {
            tl = sl;
            sl = el;
            el = tl;
        }
        if( CurrentPos.line >= sl && CurrentPos.line <= el ) {
            if( sl == el && !SelRgn.lines ) {
                sc = SelRgn.start.column;
                ec = SelRgn.end.column;
                if( sc > ec ) {
                    sc--;
                    tc = sc;
                    sc = ec;
                    ec = tc;
                } else if( sc < ec ) {
                    ec--;
                }

                if( CurrentPos.column >= sc && CurrentPos.column <= (ec + 1) ) {
                    rc = InvokeColSelHook( sc, ec );
                }
            } else {
                rc = InvokeLineSelHook( SelRgn.start.line, SelRgn.end.line );
            }
            UnselectRegion();
            return( rc );
        }
        UnselectRegion();
    }
    if( ShiftDown() && LastEvent != '_' ) {
        sc = 1;
        ec = CurrentLine->len;
        SetSelRegionCols( CurrentPos.line, sc, ec );
        if( doMenu ) {
            rc = InvokeLineSelHook( CurrentPos.line, CurrentPos.line );
        }
    } else {
        rc = GimmeCurrentEntireWordDim( &sc, &ec, FALSE );
        if( rc != ERR_NO_ERR ) {
            return( ERR_NO_ERR );
        }
        SetSelRegionCols( CurrentPos.line, sc, ec );
        if( doMenu ) {
            rc = InvokeColSelHook( sc, ec );
        }
    }
    if( doMenu ) {
        UnselectRegion();
    }
    return( rc );

} /* DoSelectSelection */