Logo Search packages:      
Sourcecode: yzis version File versions  Download package

void YView::reindent ( const QPoint  pos  ) 

Reindent given line ( cindent )

Definition at line 201 of file view.cpp.

References YBuffer::action(), YViewCursor::bufferY(), endl(), gotoxy(), mainCursor, YZAction::match(), mBuffer, YZAction::replaceLine(), and YBuffer::textline().

{
    dbg() << "Reindent " << endl;
    QRegExp rx("^(\\t*\\s*\\t*\\s*).*$"); //regexp to get all tabs and spaces
    QString currentLine = mBuffer->textline( pos.y() ).trimmed();
    bool found = false;
    YCursor cur( pos );
    YCursor match = mBuffer->action()->match(this, cur, &found);
    if ( !found ) return ;
    dbg() << "Match found on line " << match.y() << endl;
    QString matchLine = mBuffer->textline( match.y() );
    if ( rx.exactMatch( matchLine ) )
        currentLine.prepend( rx.cap( 1 ) ); //that should have all tabs and spaces from the previous line
    mBuffer->action()->replaceLine( this, YCursor( 0, mainCursor.bufferY() ), currentLine );
    gotoxy( currentLine.length(), mainCursor.bufferY() );
}


Generated by  Doxygen 1.6.0   Back to index