http://forums.codelite.org/viewtopic.php?f=13&t=1966&p=8775#p8775
codelite\LiteEditor> svn diff quickfindbar*.* > quickfindbar.patch
the attached is my patch for quickfindbar. It just simply change the textctrl into combobox.
Index: quickfindbar.cpp
===================================================================
--- quickfindbar.cpp (revision 5950)
+++ quickfindbar.cpp (working copy)
@@ -33,7 +33,11 @@
#include <wx/stc/stc.h>
#include "stringsearcher.h"
#include "quickfindbar.h"
+#include <wx/config.h>
+//to store and load config like find/replacewith
+wxConfig *config = new wxConfig("CodeLite");
+
DEFINE_EVENT_TYPE(QUICKFIND_COMMAND_EVENT)
#define CHECK_FOCUS_WIN() {\
@@ -82,6 +86,16 @@
wxTheApp->Connect(XRCID("find_next_at_caret"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(QuickFindBar::OnFindNextCaret), NULL, this);
wxTheApp->Connect(XRCID("find_previous_at_caret"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(QuickFindBar::OnFindPreviousCaret), NULL, this);
Connect(QUICKFIND_COMMAND_EVENT, wxCommandEventHandler(QuickFindBar::OnQuickFindCommandEvent), NULL, this);
+
+ //load config like find/replace list
+ wxString str;
+ for(int i=0;i<10;i++){
+ if ( config->Read(wxString::Format(wxT("find%i"),i), &str) )
+ m_findWhat->Append(str);
+ if ( config->Read(wxString::Format(wxT("replace%i"),i), &str) )
+ m_replaceWith->Append(str);
+
+ }
}
bool QuickFindBar::Show(bool show)
@@ -160,12 +174,20 @@
void QuickFindBar::OnNext(wxCommandEvent &e)
{
wxUnusedVar(e);
+ int tmppos= m_findWhat->FindString(m_findWhat->GetValue(), false);
+ if ( tmppos != wxNOT_FOUND ) m_findWhat->Delete( tmppos );
+ m_findWhat->Insert(m_findWhat->GetValue(), 0);
+ if (m_findWhat->GetCount()>10) m_findWhat->Delete(10);
DoSearch(true, false);
}
void QuickFindBar::OnPrev(wxCommandEvent &e)
{
wxUnusedVar(e);
+ int tmppos= m_findWhat->FindString(m_findWhat->GetValue(), false);
+ if ( tmppos != wxNOT_FOUND ) m_findWhat->Delete( tmppos );
+ m_findWhat->Insert(m_findWhat->GetValue(), 0);
+ if (m_findWhat->GetCount()>10) m_findWhat->Delete(10);
DoSearch(false, false);
}
@@ -206,7 +228,8 @@
void QuickFindBar::OnCopy(wxCommandEvent& e)
{
- wxTextCtrl *ctrl = GetFocusedControl();
+// wxTextCtrl *ctrl = GetFocusedControl();
+ wxComboBox *ctrl = GetFocusedControl();
if ( !ctrl ) {
e.Skip();
return;
@@ -218,7 +241,8 @@
void QuickFindBar::OnPaste(wxCommandEvent& e)
{
- wxTextCtrl *ctrl = GetFocusedControl();
+// wxTextCtrl *ctrl = GetFocusedControl();
+ wxComboBox *ctrl = GetFocusedControl();
if ( !ctrl ) {
e.Skip();
return;
@@ -230,7 +254,8 @@
void QuickFindBar::OnSelectAll(wxCommandEvent& e)
{
- wxTextCtrl *ctrl = GetFocusedControl();
+// wxTextCtrl *ctrl = GetFocusedControl();
+ wxComboBox *ctrl = GetFocusedControl();
if ( !ctrl ) {
e.Skip();
} else {
@@ -240,7 +265,8 @@
void QuickFindBar::OnEditUI(wxUpdateUIEvent& e)
{
- wxTextCtrl *ctrl = GetFocusedControl();
+// wxTextCtrl *ctrl = GetFocusedControl();
+ wxComboBox *ctrl = GetFocusedControl();
if ( !ctrl ) {
e.Skip();
return;
@@ -272,6 +298,16 @@
wxString find = m_findWhat->GetValue();
wxString replaceWith = m_replaceWith->GetValue();
+ int tmppos= m_findWhat->FindString(m_findWhat->GetValue(), false);
+ if ( tmppos != wxNOT_FOUND ) m_findWhat->Delete( tmppos );
+ m_findWhat->Insert(m_findWhat->GetValue(), 0);
+ if (m_findWhat->GetCount()>10) m_findWhat->Delete(10);
+
+ tmppos= m_replaceWith->FindString(m_replaceWith->GetValue(), false);
+ if ( tmppos != wxNOT_FOUND ) m_replaceWith->Delete( tmppos );
+ m_replaceWith->Insert(m_replaceWith->GetValue(), 0);
+ if (m_replaceWith->GetCount()>10) m_replaceWith->Delete(10);
+
#ifndef __WXMAC__
int re_flags = wxRE_ADVANCED;
#else
@@ -329,7 +365,8 @@
!m_findWhat->GetValue().IsEmpty());
}
-wxTextCtrl* QuickFindBar::GetFocusedControl()
+//wxTextCtrl* QuickFindBar::GetFocusedControl()
+wxComboBox* QuickFindBar::GetFocusedControl()
{
wxWindow *win = wxWindow::FindFocus();
@@ -679,4 +716,12 @@
wxTheApp->Disconnect(XRCID("find_previous"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(QuickFindBar::OnFindPrevious), NULL, this);
wxTheApp->Disconnect(XRCID("find_next_at_caret"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(QuickFindBar::OnFindNextCaret), NULL, this);
wxTheApp->Disconnect(XRCID("find_previous_at_caret"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(QuickFindBar::OnFindPreviousCaret), NULL, this);
+
+ //store config like find/replace list
+ for(int i=0;i<m_findWhat->GetCount();i++){
+ config->Write(wxString::Format(wxT("find%i"),i), m_findWhat->GetString(i) );
+ }
+ for(int i=0;i<m_replaceWith->GetCount();i++){
+ config->Write(wxString::Format(wxT("replace%i"),i), m_replaceWith->GetString(i) );
+ }
}
Index: quickfindbar.h
===================================================================
--- quickfindbar.h (revision 5950)
+++ quickfindbar.h (working copy)
@@ -42,7 +42,8 @@
void DoMarkAll();
wchar_t* DoGetSearchStringPtr();
- wxTextCtrl *GetFocusedControl();
+// wxTextCtrl *GetFocusedControl();
+ wxComboBox *GetFocusedControl();
void DoShowControls();
// General events
Index: quickfindbarbase.cpp
===================================================================
--- quickfindbarbase.cpp (revision 5950)
+++ quickfindbarbase.cpp (working copy)
@@ -71,7 +71,8 @@
m_staticTextFind->Wrap( -1 );
fgSizer1->Add( m_staticTextFind, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2 );
- m_findWhat = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RICH2 );
+// m_findWhat = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RICH2 );
+ m_findWhat = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER|wxCB_DROPDOWN );
m_findWhat->SetToolTip( _("Hit ENTER to search, or Shift + ENTER to search backward") );
fgSizer1->Add( m_findWhat, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 2 );
@@ -92,7 +93,8 @@
m_replaceStaticText->Wrap( -1 );
fgSizer1->Add( m_replaceStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2 );
- m_replaceWith = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RICH2 );
+// m_replaceWith = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RICH2 );
+ m_replaceWith = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER|wxCB_DROPDOWN );
fgSizer1->Add( m_replaceWith, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 2 );
m_toolBarReplace = new clToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE );
Index: quickfindbarbase.h
===================================================================
--- quickfindbarbase.h (revision 5950)
+++ quickfindbarbase.h (working copy)
@@ -25,6 +25,7 @@
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/panel.h>
+#include <wx/combobox.h>
#include "cl_defs.h"
//#ifdef USE_AUI_TOOLBAR
@@ -60,10 +61,12 @@
clToolBar* m_toolBar1;
wxStaticLine* m_staticline3;
wxStaticText* m_staticTextFind;
- wxTextCtrl* m_findWhat;
+// wxTextCtrl* m_findWhat;
+ wxComboBox* m_findWhat;
clToolBar* m_toolBar2;
wxStaticText* m_replaceStaticText;
- wxTextCtrl* m_replaceWith;
+// wxTextCtrl* m_replaceWith;
+ wxComboBox* m_replaceWith;
clToolBar* m_toolBarReplace;
wxStaticLine* m_staticline1;
wxCheckBox* m_checkBoxCase;