Skip to content

Commit

Permalink
1.2 commit - Added mouse Copy/Paste emulation. Navigation through com…
Browse files Browse the repository at this point in the history
…mand history moves cursor to end of command.
  • Loading branch information
jsm174 committed Feb 7, 2016
1 parent b615a3f commit 591f570
Show file tree
Hide file tree
Showing 14 changed files with 632 additions and 201 deletions.
155 changes: 155 additions & 0 deletions CommandEdit.cpp
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);
}
}
81 changes: 81 additions & 0 deletions CommandEdit.h
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_)
11 changes: 6 additions & 5 deletions Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Added command history clear message
* Added AltGr support
* 11/18/2005: Fixed AltGr support J. Millard
* 12/06/2005: Added mouse Copy/Paste emulation J. Millard
*/

#if !defined(DEFINES_H__INCLUDED_)
Expand All @@ -41,12 +42,12 @@

#define PUTTYCS_WINDOW_CLASS_PUTTY _T( "PuTTY" )

#define PUTTYCS_WINDOW_TITLE_TOOL _T( "PuTTYCS 1.1a - PuTTY Command Sender")
#define PUTTYCS_WINDOW_TITLE_APP _T( "PuTTYCS 1.1a")
#define PUTTYCS_WINDOW_TITLE_TOOL _T( "PuTTYCS 1.2 - PuTTY Command Sender")
#define PUTTYCS_WINDOW_TITLE_APP _T( "PuTTYCS 1.2")

#define PUTTYCS_WINDOW_TITLE_ABOUT _T( "About PuTTYCS 1.1a")
#define PUTTYCS_WINDOW_TITLE_ABOUT _T( "About PuTTYCS 1.2")

#define PUTTYCS_ABOUT_TEXT_LINE1 _T( "PuTTY Command Sender 1.1a" )
#define PUTTYCS_ABOUT_TEXT_LINE1 _T( "PuTTY Command Sender 1.2" )
#define PUTTYCS_ABOUT_TEXT_LINE2 _T( "© 2005 Jason Millard. All rights reserved." )

#define PUTTYCS_WINDOW_TITLE_FILTER_ADD _T( "Add Filter" )
Expand Down Expand Up @@ -92,7 +93,7 @@
#define PUTTYCS_PREF_ARRANGE_ON_STARTUP _T( "arrangeOnStartup" )
#define PUTTYCS_PREF_UNHIDE_ON_EXIT _T( "unhideOnExit" )

#define PUTTYCS_PREF_USE_ALTGR _T( "useAltGr" )
#define PUTTYCS_PREF_EMULATE_COPY_PASTE _T( "emulateCopyPaste" )

#define PUTTYCS_PREF_SEND_CR _T( "sendCR" )

Expand Down
Loading

0 comments on commit 591f570

Please sign in to comment.