-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.2 commit - Added mouse Copy/Paste emulation. Navigation through com…
…mand history moves cursor to end of command.
- Loading branch information
Showing
14 changed files
with
632 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/** | ||
* CommandEdit.cpp - Command CEdit Control | ||
* | ||
* Copyright (c) 2005 Jason Millard ([email protected]) | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
* | ||
* REVISION HISTORY: | ||
* | ||
* 12/06/2005: Initial version J. Millard | ||
*/ | ||
|
||
#include "stdafx.h" | ||
#include "puttycs.h" | ||
#include "CommandEdit.h" | ||
|
||
#ifdef _DEBUG | ||
#define new DEBUG_NEW | ||
#undef THIS_FILE | ||
static char THIS_FILE[] = __FILE__; | ||
#endif | ||
|
||
/** | ||
* CCommandEdit::CCommandEdit() | ||
*/ | ||
|
||
CCommandEdit::CCommandEdit() | ||
{ | ||
m_iEmulateCopyPaste = 0; | ||
} | ||
|
||
/** | ||
* CCommandEdit::~CCommandEdit() | ||
*/ | ||
|
||
CCommandEdit::~CCommandEdit() | ||
{ | ||
} | ||
|
||
BEGIN_MESSAGE_MAP(CCommandEdit, CEdit) | ||
//{{AFX_MSG_MAP(CCommandEdit) | ||
ON_WM_LBUTTONUP() | ||
ON_WM_RBUTTONUP() | ||
//}}AFX_MSG_MAP | ||
END_MESSAGE_MAP() | ||
|
||
/** | ||
* CCommandEdit::SetText() | ||
*/ | ||
|
||
void CCommandEdit::SetText( CString csText ) | ||
{ | ||
SetWindowText( csText ); | ||
|
||
SetSel( csText.GetLength(), -1 ); | ||
} | ||
|
||
/** | ||
* CCommandEdit::setEmulateCopyPaste() | ||
*/ | ||
|
||
void CCommandEdit::SetEmulateCopyPaste( int iEmulateCopyPaste ) | ||
{ | ||
m_iEmulateCopyPaste = iEmulateCopyPaste; | ||
} | ||
|
||
/** | ||
* CCommandEdit::OnLButtonUp() | ||
*/ | ||
|
||
void CCommandEdit::OnLButtonUp(UINT nFlags, CPoint point) | ||
{ | ||
CEdit::OnLButtonUp(nFlags, point); | ||
|
||
if ( m_iEmulateCopyPaste ) | ||
{ | ||
int iStart; | ||
int iEnd; | ||
|
||
GetSel( iStart, iEnd ); | ||
|
||
if ( iStart != iEnd ) | ||
{ | ||
if ( OpenClipboard() ) | ||
{ | ||
CString csText; | ||
GetWindowText(csText); | ||
|
||
CString csCommand = | ||
csText.Mid( iStart, (iEnd - iStart) ); | ||
|
||
EmptyClipboard(); | ||
|
||
HGLOBAL hglbCopy = | ||
GlobalAlloc( GMEM_MOVEABLE, | ||
((csCommand.GetLength() + 1) * sizeof(TCHAR)) ); | ||
|
||
if ( hglbCopy != NULL ) | ||
{ | ||
LPTSTR lptstrCopy = | ||
(TCHAR*) GlobalLock( hglbCopy ); | ||
|
||
_tcscpy( lptstrCopy, csCommand ); | ||
|
||
GlobalUnlock( hglbCopy ); | ||
|
||
#ifdef UNICODE | ||
SetClipboardData( CF_UNICODETEXT, hglbCopy ); | ||
#else | ||
SetClipboardData( CF_TEXT, hglbCopy ); | ||
#endif | ||
} | ||
|
||
CloseClipboard(); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
/** | ||
* CCommandEdit::OnRButtonUp() | ||
*/ | ||
|
||
void CCommandEdit::OnRButtonUp(UINT nFlags, CPoint point) | ||
{ | ||
if ( m_iEmulateCopyPaste ) | ||
{ | ||
Paste(); | ||
} | ||
else | ||
{ | ||
CEdit::OnRButtonUp(nFlags, point); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* CommandEdit.h - Command CEdit Control header | ||
* | ||
* Copyright (c) 2005 Jason Millard ([email protected]) | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
* | ||
* REVISION HISTORY: | ||
* | ||
* 12/06/2005: Initial version J. Millard | ||
*/ | ||
|
||
#if !defined(AFX_COMMANDEDIT_H__309531A0_E385_4512_83CF_2A230314E589__INCLUDED_) | ||
#define AFX_COMMANDEDIT_H__309531A0_E385_4512_83CF_2A230314E589__INCLUDED_ | ||
|
||
#if _MSC_VER > 1000 | ||
#pragma once | ||
#endif // _MSC_VER > 1000 | ||
|
||
class CCommandEdit : public CEdit | ||
{ | ||
// Construction | ||
public: | ||
CCommandEdit(); | ||
|
||
void SetText( CString csText ); | ||
void SetEmulateCopyPaste( int iEmulateCopyPaste ); | ||
|
||
// Attributes | ||
public: | ||
|
||
// Operations | ||
public: | ||
|
||
// Overrides | ||
// ClassWizard generated virtual function overrides | ||
//{{AFX_VIRTUAL(CCommandEdit) | ||
//}}AFX_VIRTUAL | ||
|
||
// Implementation | ||
public: | ||
virtual ~CCommandEdit(); | ||
|
||
// Generated message map functions | ||
protected: | ||
//{{AFX_MSG(CCommandEdit) | ||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point); | ||
afx_msg void OnRButtonUp(UINT nFlags, CPoint point); | ||
//}}AFX_MSG | ||
|
||
int m_iEmulateCopyPaste; | ||
|
||
DECLARE_MESSAGE_MAP() | ||
}; | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
//{{AFX_INSERT_LOCATION}} | ||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. | ||
|
||
#endif // !defined(AFX_COMMANDEDIT_H__309531A0_E385_4512_83CF_2A230314E589__INCLUDED_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.