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

bool YView::drawNextCol (  ) 

go to next col

Definition at line 1184 of file view.cpp.

References adjust, YViewCursor::bColIncrement, YViewCursor::bLineIncrement, YViewCursor::bufferX(), drawMode, YViewCursor::lastCharWasTab, YViewCursor::sColIncrement, YViewCursor::screenX(), sCurLine, sCurLineLength, YViewCursor::setBufferX(), YViewCursor::setScreenX(), YViewCursor::spaceFill, tablength, workCursor, YViewCursor::wrapNextLine, and YViewCursor::wrapTab.

Referenced by gotody(), and guiPaintEvent().

{
    bool ret = false;

    int curx = workCursor.bufferX();
    bool lastCharWasTab = workCursor.lastCharWasTab;

    int nextLength = ( drawMode ? 0 : 1 );

    workCursor.sColIncrement = 1;
    workCursor.wrapNextLine = false;
    workCursor.lastCharWasTab = false;

    if ( curx < sCurLineLength ) {
        int lenToTest;
        lastChar = sCurLine.at( curx );
        mFillChar = ' ';
        if ( lastChar != tabChar ) {
            listChar = drawMode && opt_list && lastChar == ' ';
            if ( listChar ) {
                if ( stringHasOnlySpaces(sCurLine.mid(curx) ) && opt_listchars[ "trail" ].length() > 0 ) {
                    lastChar = opt_listchars["trail"][0];
                } else if ( opt_listchars["space"].length() > 0 ) {
                    lastChar = opt_listchars["space"][0];
                }
            }
            workCursor.sColIncrement = 1;
            lenToTest = workCursor.sColIncrement;
        } else {
            workCursor.lastCharWasTab = true;
            lastChar = ' ';
            listChar = drawMode && opt_list;
            if ( listChar ) {
                if ( opt_listchars["tab"].length() > 0 ) {
                    lastChar = opt_listchars["tab"][0];
                    if ( opt_listchars["tab"].length() > 1 )
                        mFillChar = opt_listchars["tab"][1];
                    if ( workCursor.wrapTab )
                        lastChar = mFillChar;
                }
            }
            if ( workCursor.screenX( ) == scrollCursor.bufferX() )
                workCursor.sColIncrement = ( workCursor.spaceFill ? workCursor.spaceFill : tablength );
            else {
                // calculate tab position
                int mySpaceFill = ( scrollCursor.bufferX() == 0 ? workCursor.spaceFill : 0 ); // do not care about rSpaceFill if we arent't in wrapped mode
                if ( workCursor.screenX() >= mySpaceFill )
                    workCursor.sColIncrement = ( ( workCursor.screenX() - mySpaceFill ) / tablength + 1 ) * tablength + mySpaceFill - workCursor.screenX();
                else
                    workCursor.sColIncrement = mySpaceFill + 1 - workCursor.screenX();
            }
            if ( drawMode ) lenToTest = 1;
            else lenToTest = workCursor.sColIncrement;
        }

        // will our new char appear in the area ?
        ret = adjust || workCursor.screenX() + lenToTest - scrollCursor.screenX() <= mColumnsVis - nextLength;

        if ( ret || ! drawMode ) {
            // moving cursors
            workCursor.setScreenX( workCursor.screenX() + workCursor.sColIncrement );
            workCursor.setBufferX( workCursor.bufferX() + workCursor.bColIncrement );
            // update HL
            if ( drawMode ) rHLa += workCursor.bColIncrement;
        }
    } else if ( sCurLineLength == 0 && drawMode && curx == 0 ) { // empty line
        ret = true;
        lastChar = ' ';
        workCursor.setScreenX( 1 );
        workCursor.setBufferX( 1 );
    }

    if ( wrap ) {
        // screen pos
        int sx = workCursor.screenX() + nextLength + ( (ret || !drawMode) ? 0 : workCursor.sColIncrement );
        // buff pos
        int bx = curx + ( drawMode ? 0 : workCursor.bColIncrement );
        workCursor.wrapNextLine = sx > mColumnsVis;
        if ( bx == sCurLineLength ) { // wrap a tab at EOL
            workCursor.wrapNextLine &= ( drawMode ? lastCharWasTab : workCursor.lastCharWasTab );
        } else {
            workCursor.wrapNextLine &= bx < sCurLineLength;
        }
    }

    // only remember of case where wrapNextLine is true ( => we will wrap a tab next drawNextCol )
    workCursor.lastCharWasTab &= workCursor.wrapNextLine;

    // wrapNextLine is true, we are out of area ( ret is false ), last char was a tab => we are wrapping a tab
    workCursor.wrapTab = false;
    if ( workCursor.wrapNextLine ) {
        if ( drawMode ) {
            workCursor.wrapTab = ! ret && lastCharWasTab;
        } else {
            workCursor.wrapTab = workCursor.lastCharWasTab && workCursor.screenX() > mColumnsVis;
        }
    }
    // do not increment line buffer if we are wrapping a line
    workCursor.bLineIncrement = workCursor.wrapNextLine ? 0 : 1;

    /* if ( !drawMode && (workCursor.bufferY() == 12 || workCursor.bufferY() == 13 ) ) {
      workCursor.debug();
      dbg() << ret << endl;
     }
    */ 
    return ret;
}


Generated by  Doxygen 1.6.0   Back to index