⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ceditview_new2.cpp

📁 日本的开源编辑器源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			break;
		}
		// 02/09/19 ai End

		//	次の行へ
		--PosY;
		ci = ci->m_pPrev;	//	次のアイテム
		if( ci == NULL )
			break;	//	終わりに達した

		cline = ci->m_pLine->GetPtr( &len );
		cPos = cline + len;
	}while( cline != NULL );

	return false;
}

//@@@ 2001.02.03 Start by MIK:
/*!
	@brief 全角対括弧の検索:順方向

	@author MIK

	@param PosX [in] 検索開始点の物理座標X
	@param PosY [in] 検索開始点の物理座標Y
	@param NewX [out] 移動先のレイアウト座標X
	@param NewY [out] 移動先のレイアウト座標Y
	@param upChar [in] 括弧の始まりの文字へのポインタ
	@param dnChar [in] 括弧を閉じる文字列へのポインタ
	@param mode [in] bit0(in)  : 表示領域外を調べるか? 0:調べない  1:調べる (このbitを参照)
					 bit1(in)  : 前方文字を調べるか?   0:調べない  1:調べる
					 bit2(out) : 見つかった位置         0:後ろ      1:前

	@retval true 成功
	@retval false 失敗
*/
bool CEditView::SearchBracketForward2(  int		PosX,	int		PosY,
										int*	NewX,	int*	NewY,
										char*	upChar,	char*	dnChar,
										int*	mode )
{
	CDocLine* ci;

	int len;
	const char *cPos, *nPos;
	char *cline, *lineend;
	int level = 0;
	int			nCol, nLine, nSearchNum;	// 02/09/19 ai

	//	初期位置の設定
	m_pcEditDoc->m_cLayoutMgr.CaretPos_Phys2Log( PosX, PosY, &nCol, &nLine );	// 02/09/19 ai
	nSearchNum = ( m_nViewTopLine + m_nViewRowNum ) - nLine;					// 02/09/19 ai
	ci = m_pcEditDoc->m_cDocLineMgr.GetLineInfo( PosY );
	cline = ci->m_pLine->GetPtr( &len );
	lineend = cline + len;
	cPos = cline + PosX;

	do {
		while( cPos < lineend ){
			nPos = CMemory::MemCharNext( cline, len, cPos );
			if( nPos - cPos != 2 ){
				//	skip
				cPos = nPos;
				continue;
			}
			if( strncmp(upChar, cPos, 2) == 0 ){
				++level;
			}
			else if( strncmp(dnChar, cPos, 2) == 0 ){
				--level;
			}

			if( level == 0 ){	//	見つかった!
				PosX = cPos - cline;
				m_pcEditDoc->m_cLayoutMgr.CaretPos_Phys2Log( PosX, PosY, NewX, NewY );
				return true;
			}
			cPos = nPos;	//	次の文字へ
		}

		// 02/09/19 ai Start
		nSearchNum--;
		if( ( 0 > nSearchNum ) && ( 0 == (*mode & 1 ) ) )
		{	// 表示領域外を調べないモードで表示領域の終端の場合
			//SendStatusMessage( "対括弧の検索を中断しました" );
			break;
		}
		// 02/09/19 ai End

		//	次の行へ
		++PosY;
		ci = ci->m_pNext;	//	次のアイテム
		if( ci == NULL )
			break;	//	終わりに達した

		cline = ci->m_pLine->GetPtr( &len );
		cPos = cline;
		lineend = cline + len;
	}while( cline != NULL );

	return false;
}
//@@@ 2001.02.03 End

//@@@ 2001.02.03 Start by MIK:
/*!
	@brief 全角対括弧の検索:逆方向

	@author MIK

	@param PosX [in] 検索開始点の物理座標X
	@param PosY [in] 検索開始点の物理座標Y
	@param NewX [out] 移動先のレイアウト座標X
	@param NewY [out] 移動先のレイアウト座標Y
	@param upChar [in] 括弧の始まりの文字へのポインタ
	@param dnChar [in] 括弧を閉じる文字列へのポインタ
	@param mode [in] bit0(in)  : 表示領域外を調べるか? 0:調べない  1:調べる (このbitを参照)
					 bit1(in)  : 前方文字を調べるか?   0:調べない  1:調べる
					 bit2(out) : 見つかった位置         0:後ろ      1:前

	@retval true 成功
	@retval false 失敗
*/
bool CEditView::SearchBracketBackward2( int   PosX,   int   PosY,
									    int*  NewX,   int*  NewY,
									    char* dnChar, char* upChar,
										int*  mode )
{
	CDocLine* ci;

	int len;
	const char *cPos, *pPos;
	char *cline, *lineend;
	int level = 1;
	int	nCol, nLine, nSearchNum;	// 02/09/19 ai

	//	初期位置の設定
	m_pcEditDoc->m_cLayoutMgr.CaretPos_Phys2Log( PosX, PosY, &nCol, &nLine );	// 02/09/19 ai
	nSearchNum = nLine - m_nViewTopLine;										// 02/09/19 ai
	ci = m_pcEditDoc->m_cDocLineMgr.GetLineInfo( PosY );
	cline = ci->m_pLine->GetPtr( &len );
	lineend = cline + len;
	cPos = cline + PosX;

	do {
		while( cPos > cline ){
			pPos = CMemory::MemCharPrev( cline, len, cPos );
			if( cPos - pPos != 2 ){
				//	skip
				cPos = pPos;
				continue;
			}
			if( strncmp(upChar, pPos, 2) == 0 ){
				++level;
			}
			else if( strncmp(dnChar, pPos, 2) == 0 ){
				--level;
			}

			if( level == 0 ){	//	見つかった!
				PosX = pPos - cline;
				m_pcEditDoc->m_cLayoutMgr.CaretPos_Phys2Log( PosX, PosY, NewX, NewY );
				return true;
			}
			cPos = pPos;	//	次の文字へ
		}

		// 02/09/19 ai Start
		nSearchNum--;
		if( ( 0 > nSearchNum ) && ( 0 == (*mode & 1 ) ) )
		{	// 表示領域外を調べないモードで表示領域の先頭の場合
			//SendStatusMessage( "対括弧の検索を中断しました" );
			break;
		}
		// 02/09/19 ai End

		//	次の行へ
		--PosY;
		ci = ci->m_pPrev;	//	次のアイテム
		if( ci == NULL )
			break;	//	終わりに達した

		cline = ci->m_pLine->GetPtr( &len );
		cPos = cline + len;
	}while( cline != NULL );

	return false;
}
//@@@ 2001.02.03 End

//@@@ 2003.01.09 Start by ai:
/*!
	@brief 括弧判定

	@author ai

	@param pLine [in] 
	@param x
	@param size

	@retval true 括弧
	@retval false 非括弧
*/
bool CEditView::IsBracket( const char *pLine, int x, int size )
{
	int	i;
	if( size == 1 ){
		const struct HANKAKKO_T *p;
		p = hankakkoarr;
		for( i = 0; p->sStr != NULL; i++, p++ )
		{
			if( strncmp( p->sStr, &pLine[x], 1 ) == 0 )
			{
				return true;
			}
			else if( strncmp( p->eStr, &pLine[x], 1 ) == 0 )
			{
				return true;
			}
		}
	}
	else if( size == 2 ) {
		const struct ZENKAKKO_T *p;
		p = zenkakkoarr;
		for( i = 0; p->sStr != NULL; i++, p++ )
		{
			if( strncmp( p->sStr, &pLine[x], 2 ) == 0 )
			{
				return true;
			}
			else if( strncmp( p->eStr, &pLine[x], 2 ) == 0 )
			{
				return true;
			}
		}
	}

	return false;
}
//@@@ 2003.01.09 End

//!	現在のカーソル行位置を履歴に登録する
void CEditView::AddCurrentLineToHistory( void )
{
	int PosX, PosY;	//	物理位置(改行単位の計算)

	m_pcEditDoc->m_cLayoutMgr.CaretPos_Log2Phys( m_nCaretPosX, m_nCaretPosY, &PosX, &PosY );

	CMarkMgr::CMark m( PosX, PosY );
	m_cHistory->Add( m );

}


//	2001/06/18 Start by asa-o: 補完ウィンドウ用のキーワードヘルプ表示
bool  CEditView::ShowKeywordHelp( POINT po, LPCTSTR pszHelp, LPRECT prcHokanWin)
{
	CMemory		cmemCurText;
	CMemory*	pcmemRefText;
	LPSTR		pszWork;
	RECT		rcTipWin,
				rcDesktop;

	if( m_pcEditDoc->GetDocumentAttribute().m_bUseKeyWordHelp ){ /* キーワードヘルプを使用する */
		if( m_bInMenuLoop == FALSE	&&	/* メニュー モーダル ループに入っていない */
			0 != m_dwTipTimer			/* 辞書Tipを表示していない */
		){
			cmemCurText.SetDataSz( pszHelp );

			/* 既に検索済みか */
			if( CMemory::IsEqual( cmemCurText, m_cTipWnd.m_cKey ) ){
				/* 該当するキーがなかった */
				if( !m_cTipWnd.m_KeyWasHit ){
					return false;
				}
			}else{
				m_cTipWnd.m_cKey = cmemCurText;
				/* 検索実行 */
				if( m_cDicMgr.Search( cmemCurText.GetPtr(), &pcmemRefText, m_pcEditDoc->GetDocumentAttribute().m_szKeyWordHelpFile ) ){
					/* 該当するキーがある */
					m_cTipWnd.m_KeyWasHit = TRUE;
					pszWork = pcmemRefText->GetPtr();
//								m_cTipWnd.m_cInfo.SetData( pszWork, lstrlen( pszWork ) );
					m_cTipWnd.m_cInfo.SetDataSz( pszWork );
					delete pcmemRefText;
				}else{
					/* 該当するキーがなかった */
					m_cTipWnd.m_KeyWasHit = FALSE;
					return false;
				}
			}
			m_dwTipTimer = 0;	/* 辞書Tipを表示している */

		// 2001/06/19 Start by asa-o: 辞書Tipの表示位置調整
			// 辞書Tipのサイズを取得
			m_cTipWnd.GetWindowSize(&rcTipWin);

			//	May 01, 2004 genta マルチモニタ対応
			::GetMonitorWorkRect( m_cTipWnd.m_hWnd, &rcDesktop );

			// 右に入る
			if(prcHokanWin->right + rcTipWin.right < rcDesktop.right){
				// そのまま
			}else
			// 左に入る
			if(rcDesktop.left < prcHokanWin->left - rcTipWin.right ){
				// 左に表示
				po.x = prcHokanWin->left - (rcTipWin.right + 8);
			}else
			// どちらもスペースが無いとき広いほうに表示
			if(rcDesktop.right - prcHokanWin->right > prcHokanWin->left ){
				// 右に表示 そのまま
			}else{
				// 左に表示
				po.x = prcHokanWin->left - (rcTipWin.right + 8);
			}
		// 2001/06/19 End

			/* 辞書Tipを表示 */
			m_cTipWnd.Show( po.x, po.y , NULL , &rcTipWin);
			return true;
		}
	}
	return false;
}
//	2001/06/18 End

#if 0
/*!	コントロールコードを "^@" 表示する。
	0x00 - 0x1f は "^@" - "^_" で表示する。
	0x7f は "^?" で表示する。
	その他は "?" で表示する。
*/
int CEditView::DispCtrlCode( HDC hdc, int x, int y, const unsigned char* pData, int nLength )
{
	int		i, x1, y1;
	unsigned char	c;
	HPEN	hPen, hPenOld;

	x1 = m_nCharWidth / 3;
	y1 = m_nCharHeight / 5;

	hPen = ::CreatePen( PS_SOLID, 0, m_pcEditDoc->GetDocumentAttribute().m_ColorInfoArr[COLORIDX_CTRLCODE].m_colTEXT );
	hPenOld = (HPEN)::SelectObject( hdc, hPen );

	for( i = 0; i < nLength; i++, pData++ )
	{
		if     ( (*pData) <= 0x1f ) c = '@' + (*pData);
		else if( (*pData) == 0x7f ) c = '?';
		else                        c = '?';

		//文字を表示する
		DispText( hdc, x, y, &c, 1 );

		//制御文字を示す記号を描画する
		::MoveToEx( hdc, x, y + y1, NULL );
		::LineTo( hdc, x + x1, y );
		::LineTo( hdc, x + x1 * 2, y + y1 );

		x += m_nCharWidth;
	}

	::SelectObject( hdc, hPenOld );
	::DeleteObject( hPen );

	return nLength;
}
#endif


/*[EOF]*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -