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

📄 ceditview_command.cpp

📁 日本的开源编辑器源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		nCaretPosX = pcLayout ? pcLayout->GetIndent() : 0;
		nCaretPosY = m_nCaretPosY;
	}
	if( !bLineTopOnly ){
		/* 目的行のデータを取得 */
		/* 改行単位指定で、先頭から空白が1折り返し行以上続いている場合は次の行データを取得 */
		nPosY = nCaretPosY - 1;
		const char*		pLine;
		int				nLineLen;
		const CLayout*	pcLayout;
		do {
			pLine = m_pcEditDoc->m_cLayoutMgr.GetLineStr( ++nPosY, &nLineLen, &pcLayout );
			if( NULL == pLine ){
				return;
			}
			for( nPos = 0; nPos < nLineLen; ++nPos ){
				if( ' ' != pLine[nPos] && '\t' != pLine[nPos] ){
					if( CR == pLine[nPos] || LF == pLine[nPos] ){
						nPos = nLineLen;
					}
					break;
				}
			}
		} while (( lparam & 8 ) && (nPos >= nLineLen) && (m_pcEditDoc->m_cLayoutMgr.GetLineCount() - 1 > nPosY) );
		if( nPos >= nLineLen ){
			nPos = 0;
			nPosY = nCaretPosY;
		}
		/* 指定された行のデータ内の位置に対応する桁の位置を調べる */
		nPos = LineIndexToColmn( pcLayout, nPos );
		if( (m_nCaretPosX != nPos) || (m_nCaretPosY != nPosY) ){
			nCaretPosX = nPos;
			nCaretPosY = nPosY;
		}
	}

	MoveCursor( nCaretPosX, nCaretPosY, TRUE );
	m_nCaretPosX_Prev = nCaretPosX;
	if( bSelect ){
		/* 現在のカーソル位置によって選択範囲を変更 */
		ChangeSelectAreaByCurrentCursor( nCaretPosX, m_nCaretPosY );
	}
}




/* 行末に移動(折り返し単位) */
void CEditView::Command_GOLINEEND( int bSelect, int bIgnoreCurrentSelection )
{
	int				nPosX = 0;
	int				nPosY = m_nCaretPosY;
	const CLayout*	pcLayout;
	if( !bIgnoreCurrentSelection ){
		if( bSelect ){
			if( !IsTextSelected() ){	/* テキストが選択されているか */
				/* 現在のカーソル位置から選択を開始する */
				BeginSelectArea();
			}
		}else{
			if( IsTextSelected() ){	/* テキストが選択されているか */
				/* 現在の選択範囲を非選択状態に戻す */
				DisableSelectArea( TRUE );
			}
		}
	}
	/* 現在行のデータを取得 */
	pcLayout = m_pcEditDoc->m_cLayoutMgr.Search( m_nCaretPosY );
	CMemoryIterator<CLayout> it( pcLayout, m_pcEditDoc->m_cLayoutMgr.GetTabSpace() );
	while( !it.end() ){
		it.scanNext();
		if ( it.getIndex() + it.getIndexDelta() > pcLayout->GetLengthWithoutEOL() ){
			nPosX += it.getColumnDelta();
			break;
		}
		it.addDelta();
	}
	nPosX += it.getColumn() - it.getColumnDelta();
	if( it.getIndex() >= (pcLayout ? pcLayout->GetLengthWithEOL() : 0) ){
		if( m_nCaretPosY + 1 == m_pcEditDoc->m_cLayoutMgr.GetLineCount() ){
			/* 改行で終わっているか */
			if( EOL_NONE != pcLayout->m_cEol ){
			}else{
				nPosX += it.getColumnDelta();
			}
		}
	}
	
	MoveCursor( nPosX, m_nCaretPosY, TRUE );
	m_nCaretPosX_Prev = m_nCaretPosX;
	if( bSelect ){
		/* 現在のカーソル位置によって選択範囲を変更 */
		ChangeSelectAreaByCurrentCursor( nPosX, m_nCaretPosY );
	}
	return;
}




/* ファイルの先頭に移動 */
void CEditView::Command_GOFILETOP( int bSelect )
{
	if( bSelect ){
		if( !IsTextSelected() ){	/* テキストが選択されているか */
			/* 現在のカーソル位置から選択を開始する */
			BeginSelectArea();
		}
		/* 現在のカーソル位置によって選択範囲を変更 */
		ChangeSelectAreaByCurrentCursor( m_nCaretPosX, 0 );
	}else{
		if( IsTextSelected() ){	/* テキストが選択されているか */
			/* 現在の選択範囲を非選択状態に戻す */
			DisableSelectArea( TRUE );
		}
	}
	/* 先頭へカーソルを移動 */
	//	Sep. 8, 2000 genta
	AddCurrentLineToHistory();

	if ( !m_bBeginBoxSelect )	m_nCaretPosX = 0;	//	通常は、(0, 0)へ移動。ボックス選択中は、(m_nCaretPosX, 0)へ移動

	MoveCursor( m_nCaretPosX, 0, TRUE );
	m_nCaretPosX_Prev = m_nCaretPosX;

	//	Feb. 21, 2004 gis_dur 選択しながら文書先頭へ移動すると
	//	選択範囲が変になる
	if( bSelect ){
		/* 現在のカーソル位置によって選択範囲を変更 */
		ChangeSelectAreaByCurrentCursor( m_nCaretPosX, 0 );
	}
	return;
}




/* ファイルの最後に移動 */
void CEditView::Command_GOFILEEND( int bSelect )
{
// 2001.12.13 hor BOX選択中にファイルの最後にジャンプすると[EOF]の行が反転したままになるの修正
	if( !bSelect && IsTextSelected() ) DisableSelectArea( TRUE );	// 2001.12.21 hor Add
	AddCurrentLineToHistory();
	Cursor_UPDOWN( m_pcEditDoc->m_cLayoutMgr.GetLineCount() , bSelect );
	Command_DOWN( bSelect, TRUE );
	if ( !m_bBeginBoxSelect ){							// 2002/04/18 YAZAKI
		/*	2004.04.19 fotomo
			改行のない最終行で選択肢ながら文書末へ移動した場合に
			選択範囲が正しくない場合がある問題に対応
		*/
		Command_GOLINEEND( bSelect, FALSE );				// 2001.12.21 hor Add
	}
	MoveCursor( m_nCaretPosX, m_nCaretPosY, TRUE );	// 2001.12.21 hor Add
	// 2002.02.16 hor 矩形選択中を除き直前のカーソル位置をリセット
	if( !(IsTextSelected() && m_bBeginBoxSelect) ) m_nCaretPosX_Prev = m_nCaretPosX;
	return;
// 2001.12.13 hor 以下をコメント (////はもともとコメント)
//	HDC			hdc;
//	PAINTSTRUCT	ps;
//	int bIsFreeCursorMode_old = m_pShareData->m_Common.m_bIsFreeCursorMode;
//	int	nLastLine;
//	if( 0 == m_pcEditDoc->m_cLayoutMgr.GetLineCount() ){
//		return;
//	}
//	m_pShareData->m_Common.m_bIsFreeCursorMode = FALSE;
//	if( bSelect ){
//		if( !IsTextSelected() ){	/* テキストが選択されているか */
//			/* 現在のカーソル位置から選択を開始する */
//			BeginSelectArea();
//		}
////		/* 現在のカーソル位置によって選択範囲を変更 */
////		ChangeSelectAreaByCurrentCursor( 0, 0 );
//	}else{
//		if( IsTextSelected() ){	/* テキストが選択されているか */
//			/* 現在の選択範囲を非選択状態に戻す */
//			DisableSelectArea( TRUE );
//		}
//	}
//	nLastLine = m_pcEditDoc->m_cLayoutMgr.GetLineCount() - 1;
//	//	Sep. 8, 2000 genta
//	AddCurrentLineToHistory();
//	MoveCursor( 0, nLastLine, TRUE );
//	if( bSelect ){
//		m_nSelectLineTo = m_nCaretPosY;		/* 範囲選択終了行 */
//	}
//	Command_DOWN( bSelect, TRUE );
//	Command_GOLINEEND( bSelect, TRUE );
//	Command_RIGHT( bSelect, TRUE, FALSE );
////やめた	m_nCaretPosX_Prev = m_nCaretPosX;
//	m_pShareData->m_Common.m_bIsFreeCursorMode = bIsFreeCursorMode_old;
//	/* 再描画 */
//	hdc = ::GetDC( m_hWnd );
//	ps.rcPaint.left = 0;
//	ps.rcPaint.right = m_nViewAlignLeft + m_nViewCx;
//	ps.rcPaint.top = m_nViewAlignTop;
//	ps.rcPaint.bottom = m_nViewAlignTop + m_nViewCy;
//	OnKillFocus();
//	OnPaint( hdc, &ps, TRUE );	/* メモリDCを使用してちらつきのない再描画 */
//	OnSetFocus();
//	::ReleaseDC( m_hWnd, hdc );
//	return;
}




/* 単語の左端に移動 */
void CEditView::Command_WORDLEFT( int bSelect )
{
	int				nIdx;
	int				nLineNew;
	int				nColmNew;
	BOOL			bIsFreeCursorModeOld;
	if( bSelect ){
		if( !IsTextSelected() ){	/* テキストが選択されているか */
			/* 現在のカーソル位置から選択を開始する */
			BeginSelectArea();
		}
	}else{
		if( IsTextSelected() ){		/* テキストが選択されているか */
			/* 現在の選択範囲を非選択状態に戻す */
			DisableSelectArea( TRUE );
		}
	}

	const CLayout* pcLayout;
	pcLayout = m_pcEditDoc->m_cLayoutMgr.Search( m_nCaretPosY );
	if( NULL == pcLayout ){
		bIsFreeCursorModeOld = m_pShareData->m_Common.m_bIsFreeCursorMode;	/* フリーカーソルモードか */
		m_pShareData->m_Common.m_bIsFreeCursorMode = FALSE;
		/* カーソル左移動 */
		Command_LEFT( bSelect, FALSE );
		m_pShareData->m_Common.m_bIsFreeCursorMode = bIsFreeCursorModeOld;	/* フリーカーソルモードか */
		return;
	}
	/* 指定された桁に対応する行のデータ内の位置を調べる */
	nIdx = LineColmnToIndex( pcLayout, m_nCaretPosX );
	/* 現在位置の左の単語の先頭位置を調べる */
	if( m_pcEditDoc->m_cLayoutMgr.PrevWord( m_nCaretPosY, nIdx, &nLineNew, &nColmNew, m_pShareData->m_Common.m_bStopsBothEndsWhenSearchWord ) ){
		/* 行が変わった */
		if( nLineNew != m_nCaretPosY ){
			pcLayout = m_pcEditDoc->m_cLayoutMgr.Search( nLineNew );
			if( NULL == pcLayout ){
				return;
			}
		}
		/* 指定された行のデータ内の位置に対応する桁の位置を調べる */
		nColmNew = LineIndexToColmn( pcLayout, nColmNew );
		/* カーソル移動 */
		MoveCursor( nColmNew, nLineNew, TRUE );
		m_nCaretPosX_Prev = m_nCaretPosX;
		if( bSelect ){
			/* 現在のカーソル位置によって選択範囲を変更 */
			ChangeSelectAreaByCurrentCursor( nColmNew, nLineNew );
		}
	}else{
		bIsFreeCursorModeOld = m_pShareData->m_Common.m_bIsFreeCursorMode;	/* フリーカーソルモードか */
		m_pShareData->m_Common.m_bIsFreeCursorMode = FALSE;
		/* カーソル左移動 */
		Command_LEFT( bSelect, FALSE );
//		if( 0 < m_nCaretPosY ){
//			/* 行末に移動 */
//			Command_GOLINEEND( bSelect, FALSE );
//		}
		m_pShareData->m_Common.m_bIsFreeCursorMode = bIsFreeCursorModeOld;	/* フリーカーソルモードか */
	}
	return;
}




/* 単語の右端に移動 */
void CEditView::Command_WORDRIGHT( int bSelect )
{
	int			nIdx;
	int			nCurLine;
	int			nLineNew;
	int			nColmNew;
	int			bTryAgain;
	BOOL		bIsFreeCursorModeOld;
	if( bSelect ){
		if( !IsTextSelected() ){	/* テキストが選択されているか */
			/* 現在のカーソル位置から選択を開始する */
			BeginSelectArea();
		}
	}else{
		if( IsTextSelected() ){	/* テキストが選択されているか */
			/* 現在の選択範囲を非選択状態に戻す */
			DisableSelectArea( TRUE );
		}
	}
	bTryAgain = FALSE;
try_again:;
	nCurLine = m_nCaretPosY;
	const CLayout* pcLayout;
	pcLayout = m_pcEditDoc->m_cLayoutMgr.Search( nCurLine );
	if( NULL == pcLayout ){
		return;
	}
	if(

⌨️ 快捷键说明

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