| 1 |
// FindEdit.cpp : implementation file |
|---|
| 2 |
// |
|---|
| 3 |
|
|---|
| 4 |
#include "stdafx.h" |
|---|
| 5 |
#include "FindEdit.h" |
|---|
| 6 |
#include "mainfrm.h" |
|---|
| 7 |
|
|---|
| 8 |
#ifdef _DEBUG |
|---|
| 9 |
#define new DEBUG_NEW |
|---|
| 10 |
#undef THIS_FILE |
|---|
| 11 |
static char THIS_FILE[] = __FILE__; |
|---|
| 12 |
#endif |
|---|
| 13 |
|
|---|
| 14 |
///////////////////////////////////////////////////////////////////////////// |
|---|
| 15 |
// CFindEdit |
|---|
| 16 |
|
|---|
| 17 |
CFindEdit::CFindEdit() |
|---|
| 18 |
{ |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
CFindEdit::~CFindEdit() |
|---|
| 22 |
{ |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
BEGIN_MESSAGE_MAP(CFindEdit, CXTFlatEdit) |
|---|
| 27 |
//{{AFX_MSG_MAP(CFindEdit) |
|---|
| 28 |
ON_WM_KEYUP() |
|---|
| 29 |
//}}AFX_MSG_MAP |
|---|
| 30 |
END_MESSAGE_MAP() |
|---|
| 31 |
|
|---|
| 32 |
///////////////////////////////////////////////////////////////////////////// |
|---|
| 33 |
// CFindEdit message handlers |
|---|
| 34 |
|
|---|
| 35 |
void CFindEdit::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) |
|---|
| 36 |
{ |
|---|
| 37 |
char buffer[4096]; |
|---|
| 38 |
GetLine(0,buffer,4096); |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
CString buf(buffer); |
|---|
| 43 |
string _buf(buffer); |
|---|
| 44 |
// if ( nChar == VK_HOME || nChar == VK_END ) { |
|---|
| 45 |
|
|---|
| 46 |
// } |
|---|
| 47 |
if ( nChar == VK_ESCAPE ) { |
|---|
| 48 |
|
|---|
| 49 |
CMainFrame* m = (CMainFrame*)Globals::theApp.m_pMainWnd; |
|---|
| 50 |
if ( m ){ |
|---|
| 51 |
m->ShowControlBar(&(m->m_wndFindToolBar),false,false); |
|---|
| 52 |
CElephantView* v = m->GetActiveView(); |
|---|
| 53 |
if ( v ) |
|---|
| 54 |
{ |
|---|
| 55 |
CScintillaCtrl& rCtrl = v->GetCtrl(); |
|---|
| 56 |
rCtrl.SetFocus(); |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
return; |
|---|
| 60 |
} |
|---|
| 61 |
// MDIActivate( |
|---|
| 62 |
|
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
else if ( nChar == VK_BACK || nChar == VK_DELETE) { |
|---|
| 66 |
|
|---|
| 67 |
CMainFrame* m = (CMainFrame*)Globals::theApp.m_pMainWnd; |
|---|
| 68 |
m->BeginSimpleFind(); |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
else if ( nChar == VK_UP ) { |
|---|
| 74 |
// string find = globals.findHistory.Next(); |
|---|
| 75 |
// if ( find == _buf ) |
|---|
| 76 |
// find = globals.findHistory.Next(); |
|---|
| 77 |
// SetWindowText(find.c_str() ); |
|---|
| 78 |
// nChar = VK_RETURN; |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
else if ( nChar == VK_TAB ) return; |
|---|
| 83 |
|
|---|
| 84 |
else if ( nChar == VK_DOWN ) { |
|---|
| 85 |
// string find = globals.findHistory.Previous(); |
|---|
| 86 |
// if ( find == _buf ) |
|---|
| 87 |
// find = globals.findHistory.Previous(); |
|---|
| 88 |
// SetWindowText(find.c_str() ); |
|---|
| 89 |
// nChar = VK_RETURN; |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
else if ( buf == "" ) return; |
|---|
| 93 |
|
|---|
| 94 |
if ( nChar == VK_RETURN ) { |
|---|
| 95 |
|
|---|
| 96 |
// if ( _buf != m_lastCommand && _buf != "" ) { |
|---|
| 97 |
// globals.findHistory.Add(_buf); |
|---|
| 98 |
// m_lastCommand = _buf; |
|---|
| 99 |
// } |
|---|
| 100 |
|
|---|
| 101 |
CMainFrame* m = (CMainFrame*)Globals::theApp.m_pMainWnd; |
|---|
| 102 |
|
|---|
| 103 |
m->StartFindAtLastPos(); |
|---|
| 104 |
m->m_simpleFindNeedsBegin = false; |
|---|
| 105 |
m->FindSimpleString(buffer); |
|---|
| 106 |
m->m_simpleFindNeedsBegin = true; |
|---|
| 107 |
} |
|---|
| 108 |
else { |
|---|
| 109 |
CMainFrame* m = (CMainFrame*)Globals::theApp.m_pMainWnd; |
|---|
| 110 |
|
|---|
| 111 |
if ( m ) { |
|---|
| 112 |
|
|---|
| 113 |
m->FindSimpleString(buffer); |
|---|
| 114 |
} |
|---|
| 115 |
} |
|---|
| 116 |
CXTFlatEdit::OnKeyUp(nChar, nRepCnt, nFlags); |
|---|
| 117 |
} |
|---|