Пример #1
0
void CaretLeft( LPCLASSDATA lpcd )
{
	/*
	 *	Do we have a block marker?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Move to the start of the block.
		 */
		lpcd->ptCaretPos = lpcd->ptSelStart;

		/*
		 *	Clear the marker.
		 */
		ClearMark( lpcd );

		/*
		 *	Update position.
		 */
		UpdateCaret( lpcd );
		return;
	}
	/*
	 *	Move left....
	 */
	MoveLeft( lpcd );
}
Пример #2
0
void CaretRight( LPCLASSDATA lpcd )
{
	/*
	 *	Block marker set?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Move to the end of the marker.
		 */
		lpcd->ptCaretPos = lpcd->ptSelEnd;

		/*
		 *	Clear marker.
		 */
		ClearMark( lpcd );

		/*
		 *	Update position.
		 */
		UpdateCaret( lpcd );
		return;
	}
	/*
	 *	Move the caret right.
	 */
	MoveRight( lpcd );
}
Пример #3
0
LRESULT OnSetFocus( HWND hWnd, WPARAM wParam, LPARAM lParam, LPCLASSDATA lpcd )
{
	/*
	 *	We have the focus.
	 */
	lpcd->bHasFocus = TRUE;

	/*
	 *	Compute view.
	 */
	SetupViewSize( lpcd );

	/*
	 *	Make the caret.
	 */
	CreateTheCaret( lpcd );

	/*
	 *	Send a status message.
	 */
	SendStatusMessage( lpcd );

	/*
	 *	Refresh the view.
	 */
	if ( HasMark( lpcd ))
		InvalidateRect( hWnd, NULL, FALSE );

	/*
	 *	Is the search or replace window active?
	 */
	if ( lpcd->hReplaceWnd && ! IsWindowVisible( lpcd->hReplaceWnd )) ShowWindow( lpcd->hReplaceWnd, SW_SHOW );
	if ( lpcd->hFindWnd && ! IsWindowVisible( lpcd->hFindWnd )) ShowWindow( lpcd->hFindWnd, SW_SHOW );
	return 0;
}
Пример #4
0
static void CaretMoveExtend( LPCLASSDATA lpcd, int nMove )
{
	int	nOldStart, nOldEnd;

	/*
	 *	Marker set?
	 */
	if ( HasMark( lpcd ) == FALSE )
		/*
		 *	Setup starting point.
		 */
		lpcd->ptStartPos = lpcd->ptSelStart = lpcd->ptSelEnd = lpcd->ptCaretPos;

	/*
	 *	Copy old values.
	 */
	nOldStart = lpcd->ptSelStart.y;
	nOldEnd   = lpcd->ptSelEnd.y;

	/*
	 *	Move the caret.
	 */
	( FuncTable[ nMove ] )( lpcd );

	/*
	 *	Where are we?
	 */
	if ( lpcd->ptCaretPos.y < lpcd->ptStartPos.y || lpcd->ptCaretPos.y == lpcd->ptStartPos.y && lpcd->ptCaretPos.x < lpcd->ptStartPos.x )
	{
		/*
		 *	Setup new start position.
		 */
		lpcd->ptSelStart = lpcd->ptCaretPos;
		lpcd->ptSelEnd   = lpcd->ptStartPos;
	}
	else
	{
		lpcd->ptSelStart = lpcd->ptStartPos;
		lpcd->ptSelEnd   = lpcd->ptCaretPos;
	}

	/*
	 *	Update visuals.
	 */
	RenderLines( lpcd, nOldStart, lpcd->ptSelStart.y );
	RenderLines( lpcd, nOldEnd,   lpcd->ptSelEnd.y   );

	/*
	 *	Send status message.
	 */
	SendStatusMessage( lpcd );
}
Пример #5
0
void CopyClipLine( LPCLASSDATA lpcd )
{
	/*
	 *	Mark the line.
	 */
	MarkLine( lpcd );

	/*
	 *	Valid marker?
	 */
	if ( HasMark( lpcd ))
		/*
		 *	Copy the line...
		 */
		 Copy( lpcd );
}
Пример #6
0
void CutLine( LPCLASSDATA lpcd )
{
	/*
	 *	Are we read-only?
	 */
	if ( ISREADONLY )
		return;

	/*
	 *	Mark the line.
	 */
	MarkLine( lpcd );

	/*
	 *	Valid marker?
	 */
	if ( HasMark( lpcd ))
		/*
		 *	Cut the line...
		 */
		 Cut( lpcd );
}
Пример #7
0
void CaretDown( LPCLASSDATA lpcd )
{
	/*
	 *	Do we have a marker?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Move to end marker.
		 */
		lpcd->ptCaretPos = lpcd->ptSelEnd;

		/*
		 *	Clear marker.
		 */
		ClearMark( lpcd );
	}

	/*
	 *	Move down.
	 */
	MoveDown( lpcd );
}
Пример #8
0
void CaretUp( LPCLASSDATA lpcd )
{
	/*
	 *	Do we have a marker?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Move to start marker.
		 */
		lpcd->ptCaretPos = lpcd->ptSelStart;

		/*
		 *	Clear marker.
		 */
		ClearMark( lpcd );
	}

	/*
	 *	Move up.
	 */
	MoveUp( lpcd );
}
Пример #9
0
LRESULT OnKillFocus( HWND hWnd, WPARAM wParam, LPARAM lParam, LPCLASSDATA lpcd )
{
	/*
	 *	Hide tooltip.
	 */
	HideTooltip( lpcd );

	/*
	 *	We no longer have the focus.
	 */
	lpcd->bHasFocus = lpcd->bCaretVisible = FALSE;
	lpcd->cQualifier = 0;
	DestroyCaret();
	if ( HasMark( lpcd ))
		InvalidateRect( hWnd, NULL, FALSE );

	/*
	 *	Is the search or replace window active?
	 */
	if ( lpcd->hReplaceWnd && ! IsChild( lpcd->hReplaceWnd, GetFocus())) ShowWindow( lpcd->hReplaceWnd, SW_HIDE );
	if ( lpcd->hFindWnd && ! IsChild( lpcd->hFindWnd, GetFocus())) ShowWindow( lpcd->hFindWnd, SW_HIDE );
	return 0;
}
Пример #10
0
void Cut( LPCLASSDATA lpcd )
{
	/*
	 *	Read only?
	 */
	if ( ISREADONLY )
		return;

	/*
	 *	Do we have a mark and
	 *	is it valid?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Copy the text.
		 */
		if ( Copy( lpcd ))
			/*
			 *	And delete it.
			 */
			Delete( lpcd );
	}
}
Пример #11
0
BOOL CopyAppend( LPCLASSDATA lpcd )
{
	HGLOBAL		hCombination, hClip;
	LPTSTR		pszSelection, pszClip, pszCombination;

	/*
	 *	Any text?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Open the clipboard.
		 */
		if ( OpenClipboard( lpcd->hWnd ))
		{
			/*
			 *	Get the clip.
			 */
			if (( hClip = GetClipboardData( CF_TEXT )) != NULL )
			{
				/*
				 *	Lock it...
				 */
				if (( pszClip = GlobalLock( hClip )) != NULL )
				{
					/*
					 *	Get the selection.
					 */
					if (( pszSelection = GetText( lpcd, &lpcd->ptSelStart, &lpcd->ptSelEnd )) != NULL )
					{
						/*
						 *	Allocate combination...
						 */
						size_t len = REAL_SIZE( _tcslen( pszClip ) + _tcslen( pszSelection ) + 1 );
						if (( hCombination = GlobalAlloc( GMEM_MOVEABLE | GMEM_DDESHARE, len )) != NULL )
						{
							/*
							 *	Lock the memory..
							 */
							if (( pszCombination = GlobalLock( hCombination )) != NULL )
							{
								/*
								 *	Copy the texts.
								 */
								_tcscpy_s( pszCombination, len, pszClip );
								_tcscat_s( pszCombination, len, pszSelection );

								/*
								 *	Unlock the memory.
								 */
								GlobalUnlock( hCombination );
								GlobalUnlock( hClip );

								/*
								 *	Free the selection.
								 */
								ArrayFreeMem(lpcd->lpUndoRedo, pszSelection );

								/*
								 *	Empty the clipboard and
								 *	set the combination.
								 */
								EmptyClipboard();

								/*
								 *	Unlock the data.
								 */
								GlobalUnlock( hCombination );

								/*
								 *	Put the data on the clipboard.
								 */
								if ( SetClipboardData( CF_TEXT, hCombination ) == hCombination )
									return TRUE;
							}
							GlobalFree( hCombination );
						}
						ArrayFreeMem( lpcd->lpUndoRedo, pszSelection );
					}
					GlobalUnlock( hClip );
				}
			}
			else
			{
				CloseClipboard();
				Copy( lpcd );
				return TRUE;
			}
			CloseClipboard();
		}
	}
	return FALSE;
}
Пример #12
0
BOOL Delete( LPCLASSDATA lpcd )
{
	/*
	 *	Read only?
	 */
	if ( ISREADONLY )
		return TRUE;

	/*
	 *	Do we have a mark and
	 *	is it valid?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Remove the text.
		 */
		DeleteText( lpcd, &lpcd->ptSelStart, &lpcd->ptSelEnd, TRUE );

		/*
		 *	We _must_ have atleast one
		 *	empty line.
		 */
		if ( ArrayGetSize( lpcd->lpLines ) == 0 )
		{
			if ( InsertLine( lpcd, NULL, 0, -1, TRUE ) == FALSE )
				return FALSE;
		}

		/*
		 *	Hide the caret.
		 */
		DisplayCaret( lpcd, FALSE );

		/*
		 *	Move to the start position.
		 */
		lpcd->ptCaretPos = lpcd->ptSelStart;

		/*
		 *	Update column position.
		 */
		lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

		/*
		 *	Invalidate marks.
		 */
		lpcd->ptSelStart.x = lpcd->ptSelStart.y = -1;
		lpcd->ptSelEnd.x   = lpcd->ptSelEnd.y   = -1;

		/*
		 *	Is the caret inside
		 *	the view?
		 */
		if ( CaretInView( lpcd ) == FALSE )
			/*
			 *	No. Move the view to
			 *	make it visible.
			 */
			MakeCaretVisibleNoRedraw( lpcd );

		/*
		 *	Re-render.
		 */
		InvalidateRect( lpcd->hWnd, NULL, FALSE );

		/*
		 *	Setup scrollers.
		 */
		SetupHScroller( lpcd );
		SetupVScroller( lpcd );

		/*
		 *	We are modified.
		 */
		SetModified( lpcd, TRUE );

		/*
		 *	Send status message.
		 */
		SendStatusMessage( lpcd );

		/*
		 *	Show the caret.
		 */
		DisplayCaret( lpcd, TRUE );
	}
	return TRUE;
}
Пример #13
0
BOOL Copy( LPCLASSDATA lpcd )
{
	HANDLE		hData;
	BOOL		bRC = FALSE, bClearMark = FALSE;

	/*
	 *	Do we have a mark and, if so,
	 *	is it valid?
	 */
	if ( HasMark( lpcd ) == FALSE )
	{
		/*
		 *	We have no marker so we simply
		 *	copy the current line to the
		 *	clipboard.
		 */
		if ( ! MarkWholeLine( lpcd, TRUE ))
		{
			/*
			 *	Probably an empty line. Clear the
			 *	clipboard contents.
			 */
			if ( OpenClipboard( lpcd->hWnd ))
			{
				EmptyClipboard();
				CloseClipboard();
			}

			/*
			 *	Update the status.
			 */
			SendStatusMessage( lpcd );
			return FALSE;
		}
		bClearMark = TRUE;
	}

	/*
	 *	Open the clipboard.
	 */
	if ( OpenClipboard( lpcd->hWnd ))
	{
		/*
		 *	Empty the clipboard.
		 */
		EmptyClipboard();

		/*
		 *	Get the marked text.
		 */
		if (( hData = GetTextGlobal( lpcd, &lpcd->ptSelStart, &lpcd->ptSelEnd )) != NULL )
		{
			/*
			 *	Set data to the clipboard.
			 */
			if ( SetClipboardData( CF_TEXT, hData ) == hData )
				bRC = TRUE;
		}
		/*
		 *	Close the clipboard.
		 */
		CloseClipboard();
	}

	/*
	 *	Clear markers?
	 */
	if ( bClearMark )
		ClearMark( lpcd );
	return bRC;
}
Пример #14
0
LRESULT OnReplaceSelection( HWND hWnd, WPARAM wParam, LPARAM lParam, LPCLASSDATA lpcd )
{
	LPCTSTR		lpszText = ( LPCTSTR )lParam;
	BOOL		bDeleted = FALSE;

	/*
	 *	Are we read-only?
	 */
	if ( ISREADONLY )
		return FALSE;

	/*
	 *	Any text?
	 */
	if ( lpszText == NULL || *lpszText == _T( '\0' ))
		return FALSE;

	/*
	 *	Any marks set? If not return FALSE since we need
	 *	to replace a text selection.
	 */
	if ( HasMark( lpcd ) == FALSE )
		return FALSE;

	/*
	 *	Delete the current selection from the text.
	 */
	bDeleted = Delete( lpcd );

	/*
	 *	Hide the caret.
	 */
	DisplayCaret( lpcd, FALSE );

	/*
	 *	Insert the clipboard contents
	 *	into the text.
	 */
	InsertText( lpcd, lpcd->ptCaretPos.y, lpcd->ptCaretPos.x, lpszText, &lpcd->ptCaretPos, ! bDeleted );

	/*
	 *	Update column position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Is the caret inside
	 *	the view?
	 */
	if ( CaretInView( lpcd ) == FALSE )
		/*
		 *	No. Move the view to
		 *	make it visible.
		 */
		MakeCaretVisibleNoRedraw( lpcd );

	/*
	 *	Re-render.
	 */
	InvalidateRect( lpcd->hWnd, NULL, FALSE );

	/*
	 *	Setup scrollers.
	 */
	SetupHScroller( lpcd );
	SetupVScroller( lpcd );

	/*
	 *	We are modified.
	 */
	SetModified( lpcd, TRUE );

	/*
	 *	Show the caret.
	 */
	DisplayCaret( lpcd, TRUE );
	return TRUE;
}
Пример #15
0
LRESULT OnCanCutDelete( HWND hWnd, WPARAM wParam, LPARAM lParam, LPCLASSDATA lpcd )
{
	return ( BOOL )( ! ISREADONLY && HasMark( lpcd ));
}
Пример #16
0
LRESULT OnCanCopy( HWND hWnd, WPARAM wParam, LPARAM lParam, LPCLASSDATA lpcd )
{
	return HasMark( lpcd );
}
Пример #17
0
void Paste( LPCLASSDATA lpcd )
{
	HANDLE		hData;
	LPCTSTR		lpszText;
	BOOL		bDeleted = FALSE;

	/*
	 *	Are we read-only?
	 */
	if ( ISREADONLY )
		return;

	/*
	 *	Valid format on the clipboard?
	 */
	if ( IsClipboardFormatAvailable( CF_TEXT ) == FALSE )
		return;

	/*
	 *	Any marks set?
	 */
	if ( HasMark( lpcd ))
		bDeleted = Delete( lpcd );

	/*
	 *	Hide the caret.
	 */
	DisplayCaret( lpcd, FALSE );

	/*
	 *	Open the clipboard.
	 */
	if ( OpenClipboard( lpcd->hWnd ))
	{
		/*
		 *	Get data handle.
		 */
		if (( hData = GetClipboardData( CF_TEXT )) != NULL )
		{
			/*
			 *	Lock the data.
			 */
			if (( lpszText = GlobalLock( hData )) != NULL )
			{
				/*
				 *	Insert the clipboard contents
				 *	into the text.
				 */
				InsertText( lpcd, lpcd->ptCaretPos.y, lpcd->ptCaretPos.x, lpszText, &lpcd->ptCaretPos, ! bDeleted );

				/*
				 *	Unlock the data handle.
				 */
				GlobalUnlock( hData );
			}
		}
		/*
		 *	Close the clipboard.
		 */
		CloseClipboard();
	}

	/*
	 *	Update column position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Is the caret inside
	 *	the view?
	 */
	if ( CaretInView( lpcd ) == FALSE )
		/*
		 *	No. Move the view to
		 *	make it visible.
		 */
		MakeCaretVisibleNoRedraw( lpcd );

	/*
	 *	Re-render.
	 */
	InvalidateRect( lpcd->hWnd, NULL, FALSE );

	/*
	 *	Setup scrollers.
	 */
	SetupHScroller( lpcd );
	SetupVScroller( lpcd );

	/*
	 *	We are modified.
	 */
	SetModified( lpcd, TRUE );

	/*
	 *	Show the caret.
	 */
	DisplayCaret( lpcd, TRUE );
}