📄 ceditview_new.cpp
字号:
HDC hdc,
const CLayout* pcLayout,
int& nLineNum,
int x,
int& y,
BOOL bDispBkBitmap,
int nLineTo,
BOOL bSelected
)
{
MY_RUNNINGTIMER( cRunningTimer, "CEditView::DispLineNew" );
// May 9, 2000 genta
Types *TypeDataPtr = &(m_pcEditDoc->GetDocumentAttribute());
int nLineNumOrg = nLineNum;
const char* pLine; //@@@ 2002.09.22 YAZAKI
int nLineLen;
int nX;
int nLineBgn;
int nBgn;
int nPos;
int nCharChars;
int nCharChars_2;
int nCOMMENTMODE;
int nCOMMENTMODE_OLD;
int nCOMMENTEND;
int nCOMMENTEND_OLD;
RECT rcClip;
RECT rcClip2;
int nLineHeight = m_nCharHeight + TypeDataPtr->m_nLineSpace;
int nCharWidth = m_nCharWidth + TypeDataPtr->m_nColmSpace;
// テキスト描画モード
UINT fuOptions = ETO_CLIPPED | ETO_OPAQUE;
//@@@ 2001.12.21 YAZAKI
// HPEN hPen;
// HPEN hPenOld;
HBRUSH hBrush;
COLORREF colTextColorOld;
COLORREF colBkColorOld;
//#ifndef COMPILE_TAB_VIEW //@@@ 2001.03.16 by MIK
// // static char* pszTAB = "> ";
// // static char* pszTAB = ">???????";
// static char* pszTAB = "^ ";
//#endif
static char* pszSPACES = " ";
static char* pszZENSPACE = "□";
static char* pszWRAP = "<";
int nPosX;
int nPosY;
int bEOF = FALSE;
int nCount;
int nLineCols;
const CLayout* pcLayout2;
int i, j;
int nIdx;
int nUrlLen;
BOOL bSearchStringMode;
BOOL bSearchFlg; // 2002.02.08 hor
int nSearchStart; // 2002.02.08 hor
int nSearchEnd;
int nColorIdx;
bool bKeyWordTop = true; // Keyword Top
// const CDocLine* pCDocLine;
//@@@ 2001.11.17 add start MIK
int nMatchLen;
int nMatchColor;
//@@@ 2001.11.17 add end MIK
bSearchStringMode = FALSE;
bSearchFlg = TRUE; // 2002.02.08 hor
nSearchStart= -1; // 2002.02.08 hor
nSearchEnd = -1; // 2002.02.08 hor
/* 論理行データの取得 */
if( NULL != pcLayout ){
// 2002/2/10 aroka CMemory変更
nLineLen = pcLayout->m_pCDocLine->m_pLine->GetLength() - pcLayout->m_nOffset;
pLine = pcLayout->m_pCDocLine->m_pLine->GetPtr() + pcLayout->m_nOffset;
nCOMMENTMODE = pcLayout->m_nTypePrev; /* タイプ 0=通常 1=行コメント 2=ブロックコメント 3=シングルクォーテーション文字列 4=ダブルクォーテーション文字列 */
nCOMMENTEND = 0;
pcLayout2 = pcLayout;
}else{
pLine = NULL;
nLineLen = 0;
nCOMMENTMODE = COLORIDX_TEXT; // 2002/03/13 novice
nCOMMENTEND = 0;
pcLayout2 = NULL;
}
/* 現在の色を指定 */
// SetCurrentColor( hdc, 0 );
SetCurrentColor( hdc, nCOMMENTMODE );
nBgn = 0;
nPos = 0;
nLineBgn = 0;
nX = 0;
nCharChars = 0;
// my_icmpの利用によりlocaleに依存しない 2002/11/30 Moca
// setlocale ( LC_ALL, "C" ); // Oct. 29, 2001 genta 検索文字列のハイライトに関係する
if( NULL != pLine ){
//@@@ 2001.11.17 add start MIK
if( TypeDataPtr->m_bUseRegexKeyword )
{
m_cRegexKeyword->RegexKeyLineStart();
}
//@@@ 2001.11.17 add end MIK
y -= nLineHeight;
nLineNum--;
// MYTRACE( "\n\n=======================================" );
while( nPos < nLineLen ){
// MYTRACE( "nLineNum = %d\n", nLineNum );
y += nLineHeight;
nLineNum++;
if( m_nViewTopLine + m_nViewRowNum < nLineNum ){
nLineNum = nLineTo + 1;
goto end_of_func;
}
if( nLineTo < nLineNum ){
goto end_of_func;
}
pcLayout2 = m_pcEditDoc->m_cLayoutMgr.Search( nLineNum );
if( y/* + nLineHeight*/ >= m_nViewAlignTop ){
/* 行番号表示 */
DispLineNumber( hdc, pcLayout2, nLineNum, y );
}
nBgn = nPos;
nLineBgn = nBgn;
nX = 0;
// 行頭背景
if (pcLayout2 && pcLayout2->GetIndent()){
rcClip.left = x;
rcClip.right = x + pcLayout2->GetIndent() * ( nCharWidth );
rcClip.top = y;
rcClip.bottom = y + nLineHeight;
if( rcClip.left < m_nViewAlignLeft ){
rcClip.left = m_nViewAlignLeft;
}
if( rcClip.left < rcClip.right &&
rcClip.left < m_nViewAlignLeft + m_nViewCx && rcClip.right > m_nViewAlignLeft ){
hBrush = ::CreateSolidBrush( TypeDataPtr->m_ColorInfoArr[COLORIDX_TEXT].m_colBACK );
::FillRect( hdc, &rcClip, hBrush );
::DeleteObject( hBrush );
}
nX += pcLayout2->GetIndent();
}
while( nPos - nLineBgn < pcLayout2->m_nLength ){
/* 検索文字列の色分け */
if( TRUE == m_bCurSrchKeyMark /* 検索文字列のマーク */
&& TypeDataPtr->m_ColorInfoArr[COLORIDX_SEARCH].m_bDisp ){
searchnext:;
// 2002.02.08 hor 正規表現の検索文字列マークを少し高速化
if(!bSearchStringMode && (!m_bCurSrchRegularExp || (bSearchFlg && nSearchStart < nPos))){
bSearchFlg=IsSearchString( pLine, nLineLen, nPos, &nSearchStart, &nSearchEnd );
}
if( !bSearchStringMode && bSearchFlg && nSearchStart==nPos
){
if( y/* + nLineHeight*/ >= m_nViewAlignTop ){
/* テキスト表示 */
nX += DispText( hdc, x + nX * ( nCharWidth ), y, &pLine[nBgn], nPos - nBgn );
}
nBgn = nPos;
bSearchStringMode = TRUE;
// nCOMMENTMODE = 90;
// nCOMMENTMODE_OLD_2 = nCOMMENTMODE;
// nCOMMENTEND_OLD_2 = nCOMMENTEND;
/* 現在の色を指定 */
// SetCurrentColor( hdc, nCOMMENTMODE );
SetCurrentColor( hdc, COLORIDX_SEARCH ); // 2002/03/13 novice
}else
if( bSearchStringMode
&& nSearchEnd <= nPos //+ == では行頭文字の場合、nSearchEndも0であるために文字色の解除ができないバグを修正 2003.05.03 かろと
){
// 検索した文字列の終わりまできたら、文字色を標準に戻す処理
if( y/* + nLineHeight*/ >= m_nViewAlignTop ){
// SetCurrentColor( hdc, 90 );
/* テキスト表示 */
nX += DispText( hdc, x + nX * ( nCharWidth ), y, &pLine[nBgn], nPos - nBgn );
}
nBgn = nPos;
/* 現在の色を指定 */
// nCOMMENTMODE = nCOMMENTMODE_OLD_2;
// nCOMMENTEND = nCOMMENTEND_OLD_2;
SetCurrentColor( hdc, nCOMMENTMODE );
bSearchStringMode = FALSE;
goto searchnext;
}
}
if( nPos >= nLineLen - pcLayout2->m_cEol.GetLen() ){
if( y/* + nLineHeight*/ >= m_nViewAlignTop ){
/* テキスト表示 */
nX += DispText( hdc, x + nX * ( nCharWidth ), y, &pLine[nBgn], nPos - nBgn );
nBgn = nPos + 1;
/* 行末背景描画 */
rcClip.left = x + nX * ( nCharWidth );
rcClip.right = m_nViewAlignLeft + m_nViewCx;
rcClip.top = y;
rcClip.bottom = y + nLineHeight;
if( rcClip.left < m_nViewAlignLeft ){
rcClip.left = m_nViewAlignLeft;
}
if( rcClip.left < rcClip.right &&
rcClip.left < m_nViewAlignLeft + m_nViewCx && rcClip.right > m_nViewAlignLeft ){
hBrush = ::CreateSolidBrush( TypeDataPtr->m_ColorInfoArr[COLORIDX_TEXT].m_colBACK );
::FillRect( hdc, &rcClip, hBrush );
::DeleteObject( hBrush );
}
/* 改行記号の表示 */
if( bSearchStringMode ){
nColorIdx = COLORIDX_SEARCH;
}else{
nColorIdx = COLORIDX_CRLF;
}
HFONT hFontOld;
/* フォントを選ぶ */
hFontOld = (HFONT)::SelectObject( hdc,
ChooseFontHandle(
TypeDataPtr->m_ColorInfoArr[nColorIdx].m_bFatFont,
TypeDataPtr->m_ColorInfoArr[nColorIdx].m_bUnderLine
)
);
colTextColorOld = ::SetTextColor( hdc, TypeDataPtr->m_ColorInfoArr[nColorIdx].m_colTEXT ); /* TAB文字の色 */
colBkColorOld = ::SetBkColor( hdc, TypeDataPtr->m_ColorInfoArr[nColorIdx].m_colBACK ); /* TAB文字背景の色 */
rcClip2.left = x + nX * ( nCharWidth );
// Jul. 20, 2003 ryoji 横スクロール時に改行コードが欠けないように
rcClip2.right = rcClip2.left + ( nCharWidth ) * ( 2 );
if( rcClip2.left < m_nViewAlignLeft ){
rcClip2.left = m_nViewAlignLeft;
}
if( rcClip2.left < rcClip2.right &&
rcClip2.left < m_nViewAlignLeft + m_nViewCx && rcClip2.right > m_nViewAlignLeft ){
rcClip2.top = y;
rcClip2.bottom = y + nLineHeight;
colBkColorOld = ::SetBkColor( hdc, TypeDataPtr->m_ColorInfoArr[nColorIdx].m_colBACK ); /* CRLF背景の色 */
// 2003.08.17 ryoji 改行文字が欠けないように
::ExtTextOut( hdc, x + nX * ( nCharWidth ), y, fuOptions,
&rcClip2, (const char *)" ", 2, m_pnDx );
::SetBkColor( hdc, colBkColorOld );
/* 改行記号の表示 */
if( TypeDataPtr->m_ColorInfoArr[COLORIDX_CRLF].m_bDisp ){
nPosX = x + nX * ( nCharWidth );
nPosY = y;
// From Here 2003.08.17 ryoji 改行文字が欠けないように
HRGN hRgn;
hRgn = ::CreateRectRgnIndirect(&rcClip2);
::SelectClipRgn(hdc, hRgn);
//@@@ 2001.12.21 YAZAKI
DrawEOL(hdc, nPosX + 1, nPosY, m_nCharWidth, m_nCharHeight,
pcLayout2->m_cEol, TypeDataPtr->m_ColorInfoArr[nColorIdx].m_bFatFont,
TypeDataPtr->m_ColorInfoArr[nColorIdx].m_colTEXT );
::SelectClipRgn(hdc, NULL);
::DeleteObject(hRgn);
// To Here 2003.08.17 ryoji 改行文字が欠けないように
}
}
::SelectObject( hdc, hFontOld );
::SetTextColor( hdc, colTextColorOld );
::SetBkColor( hdc, colBkColorOld );
nX++;
if( bSelected ){
/* テキスト反転 */
DispTextSelected( hdc, nLineNum, x, y, nX );
}
}
goto end_of_line;
}
SEARCH_START:;
switch( nCOMMENTMODE ){
case COLORIDX_TEXT: // 2002/03/13 novice
//@@@ 2001.11.17 add start MIK
//正規表現キーワード
if( TypeDataPtr->m_bUseRegexKeyword
&& m_cRegexKeyword->RegexIsKeyword( pLine, nPos, nLineLen, &nMatchLen, &nMatchColor )
/*&& TypeDataPtr->m_ColorInfoArr[nMatchColor].m_bDisp*/ )
{
if( y/* + nLineHeight*/ >= m_nViewAlignTop )
{
/* テキスト表示 */
nX += DispText( hdc, x + nX * ( nCharWidth ), y, &pLine[nBgn], nPos - nBgn );
}
/* 現在の色を指定 */
nBgn = nPos;
//nCOMMENTMODE = 1000; /* 色指定 */
nCOMMENTMODE = 1000 + nMatchColor; /* 色指定 */ //@@@ 2002.01.04 upd
nCOMMENTEND = nPos + nMatchLen; /* キーワード文字列の終端をセットする */
if( !bSearchStringMode ){
SetCurrentColor( hdc, nCOMMENTMODE ); //@@@ 2002.01.04
//SetCurrentColor( hdc, nCOMMENTMODE + nMatchColor ); //@@@ 2002.01.04
}
}
else
//@@@ 2001.11.17 add end MIK
// Mar. 15, 2000 genta
if( TypeDataPtr->m_ColorInfoArr[COLORIDX_COMMENT].m_bDisp &&
TypeDataPtr->m_cLineComment.Match( nPos, nLineLen, pLine ) //@@@ 2002.09.22 YAZAKI
){
if( y/* + nLineHeight*/ >= m_nViewAlignTop ){
/* テキスト表示 */
nX += DispText( hdc, x + nX * ( nCharWidth ), y, &pLine[nBgn], nPos - nBgn );
}
nBgn = nPos;
nCOMMENTMODE = COLORIDX_COMMENT; /* 行コメントである */ // 2002/03/13 novice
// if( TypeDataPtr->m_bDispCOMMENT ){ /* コメントを表示する */
/* 現在の色を指定 */
if( !bSearchStringMode ){
SetCurrentColor( hdc, nCOMMENTMODE );
}
// }
}else
// Mar. 15, 2000 genta
if( TypeDataPtr->m_ColorInfoArr[COLORIDX_COMMENT].m_bDisp &&
TypeDataPtr->m_cBlockComment.Match_CommentFrom( 0, nPos, nLineLen, pLine ) //@@@ 2002.09.22 YAZAKI
){
if( y/* + nLineHeight*/ >= m_nViewAlignTop ){
/* テキスト表示 */
nX += DispText( hdc, x + nX * ( nCharWidth ), y, &pLine[nBgn], nPos - nBgn );
}
nBgn = nPos;
nCOMMENTMODE = COLORIDX_BLOCK1; /* ブロックコメント1である */ // 2002/03/13 novice
// if( TypeDataPtr->m_bDispCOMMENT ){ /* コメントを表示する */
/* 現在の色を指定 */
if( !bSearchStringMode ){
SetCurrentColor( hdc, nCOMMENTMODE );
}
// }
/* この物理行にブロックコメントの終端があるか */
nCOMMENTEND = TypeDataPtr->m_cBlockComment.Match_CommentTo( 0, nPos + (int)lstrlen( TypeDataPtr->m_cBlockComment.getBlockCommentFrom(0) ), nLineLen, pLine ); //@@@ 2002.09.22 YAZAKI
//#ifdef COMPILE_BLOCK_COMMENT2 //@@@ 2001.03.10 by MIK
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -