本文整理汇总了C++中CBuffer::GetLineLength方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::GetLineLength方法的具体用法?C++ CBuffer::GetLineLength怎么用?C++ CBuffer::GetLineLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::GetLineLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnforceSelBounds
BOOL CSelection::EnforceSelBounds()
{
CBuffer *pBuffer = m_pCtrl->GetBuffer();
BOOL bFixup = FALSE;
if ( m_nEndRow < pBuffer->GetLineCount() )
{
int nLastChar = pBuffer->GetLineLength( m_nEndRow );
if ( m_nEndCol > nLastChar )
{
m_nEndCol = nLastChar;
bFixup = TRUE;
}
}
else
{
m_nEndCol = 0;
bFixup = TRUE;
}
return bFixup;
}
示例2: EnforceSelBounds
BOOL CSelection::EnforceSelBounds()
{
ASSERT( BoundSelection() ); // don't call this unless it's neccessary
CBuffer *pBuffer = m_pCtrl->GetBuffer();
BOOL bFixup = FALSE;
if ( m_nEndRow < pBuffer->GetLineCount() )
{
int nLastChar = pBuffer->GetLineLength( m_nEndRow );
if ( m_nEndCol > nLastChar )
{
m_nEndCol = nLastChar;
bFixup = TRUE;
}
}
else
{
m_nEndCol = 0;
bFixup = TRUE;
}
return bFixup;
}
示例3: Extend
void CSelection::Extend( Direction eDirection, Amount eAmount, BOOL bScrollIfNeccessary, BOOL bDamage, BOOL bAllowPastEndOfLine )
{
CBuffer *pBuffer = m_pCtrl->GetBuffer();
int nLineCount = pBuffer->GetLineCount();
BOOL bEnforceSelBounds = BoundSelection();
int nSaveEndRow = m_nEndRow;
int nSaveEndCol = m_nEndCol;
BOOL bUsePreferredCol = FALSE;
if ( nLineCount )
{
int nOldEndRow = m_nEndRow;
int nOldStartRow = m_nStartRow;
LPCTSTR pszEndLineStart = pBuffer->GetLineText( m_nEndRow );
int nEndLineLen = pBuffer->GetLineLength( m_nEndRow );
BOOL bStartRowChanged = FALSE;
switch ( eDirection )
{
case eUp:
{
switch ( eAmount )
{
case eChar:
{
m_nEndRow--;
bUsePreferredCol = TRUE;
break;
}
case ePage:
{
m_nEndRow -= ( m_pView->GetBottomIndex( FALSE ) - m_pView->GetTopIndex() );
break;
}
case eSmartAll:
case eAll:
{
m_nEndRow = 0;
break;
}
}
break;
}
case eDown:
{
switch ( eAmount )
{
case eChar:
{
m_nEndRow++;
bUsePreferredCol = TRUE;
break;
}
case ePage:
{
int nTemp = m_nEndRow + ( m_pView->GetBottomIndex( FALSE ) - m_pView->GetTopIndex() );
m_nEndRow = min( nLineCount, nTemp );
break;
}
case eAll:
case eSmartAll:
{
m_nEndRow = nLineCount - 1;
break;
}
}
break;
}
case eLeft:
{
switch ( eAmount )
{
case eChar:
{
if ( m_nEndCol == 0 || m_nEndCol > nEndLineLen )
m_nEndCol--;
else
m_nEndCol -= _tclen_prev( pszEndLineStart, pszEndLineStart + m_nEndCol );
if ( m_nEndCol < 0 )
{
if ( bAllowPastEndOfLine && m_nEndRow > 0 )
{
m_nEndRow--;
m_nEndCol = pBuffer->GetLineLength( m_nEndRow );
bEnforceSelBounds = FALSE; // already enforced by previous statement!
}
else
{
m_nEndCol = 0;
}
}
break;
}
case ePage:
{
m_nEndCol -= ( m_pView->GetRightIndex( FALSE ) - m_pView->GetLeftIndex() );
break;
}
case eAll:
//.........这里部分代码省略.........
示例4: SetSelectionFromPoint
void CSelection::SetSelectionFromPoint( CEditView *pView, int x, int y, BOOL bEmpty, BOOL bAllowLineSel )
{
if ( m_pView != pView )
{
CEditView *pLastView = m_pView;
m_pView = pView;
if ( !IsEmpty() )
{
// switching views -- erase the selection in the other view
pLastView->DamageView( min( m_nEndRow, m_nStartRow ), max( m_nEndRow, m_nStartRow ) );
}
}
int nCol, nRow;
RECT rcChar;
m_pView->GetCharPosFromPoint( x, y, nCol, nRow, &rcChar );
RECT rcView;
m_pView->GetViewRect( &rcView );
CBuffer *pBuffer = m_pCtrl->GetBuffer();
int nLineCount = pBuffer->GetLineCount();
if ( !bEmpty && bAllowLineSel && ( x > rcView.left && x < ( rcView.left + m_pView->GetLeftMargin( TRUE ) ) ) )
{
// line selecting
nCol = 0;
if ( nRow < m_nStartRow )
{
m_nStartCol = CEditView::MAXCOL;
}
else
{
m_nStartCol = 0;
nRow++;
}
nRow = min( nRow, nLineCount - 1 );
nRow = max( 0, nRow );
// selecting the last line should just go to the end of the line since
// there is no line below nRow.
if ( nLineCount && ( nRow == nLineCount - 1 ) )
{
nCol = pBuffer->GetLineLength( nRow );
}
}
else
{
nRow = min( nRow, nLineCount - 1 );
nRow = max( 0, nRow );
nCol = pBuffer->ConvertViewColToBufferCol( nRow, nCol );
}
// since the column might have changed above, let's refetch the
// char rect.
m_pView->GetCharBoundingRect( nCol, nRow, &rcChar );
if ( !IsRectEmpty( &rcChar ) && ( x > ( ( rcChar.left + rcChar.right ) / 2 ) ) )
{
// cursor is closer to the next char
nCol += pBuffer->GetCharSize( nRow, nCol );
}
if ( bEmpty )
{
SetEmptySelection( nCol, nRow );
}
else
{
if ( nCol != m_nEndCol || nRow != m_nEndRow )
{
ExtendTo( nCol, nRow );
}
}
}