Find/Replace functionality, resolves #3
This commit is contained in:
parent
4f649b73a7
commit
b39e63060b
4
Makefile
4
Makefile
@ -19,8 +19,8 @@ WX_RES = $(shell wx-config --rescomp)
|
|||||||
WX_CXXFLAGS = $(shell wx-config --cxxflags)
|
WX_CXXFLAGS = $(shell wx-config --cxxflags)
|
||||||
|
|
||||||
INC_FLAGS = -Iinclude -I. -I/usr/local/include
|
INC_FLAGS = -Iinclude -I. -I/usr/local/include
|
||||||
DEV_CXXFLAGS = -g -Wall -Wextra -DDEBUG $(INC_FLAGS)
|
DEV_CXXFLAGS = -O0 -g -Wall -Wextra -pipe -DDEBUG $(INC_FLAGS)
|
||||||
CXXFLAGS = -Os -DNDEBUG $(INC_FLAGS)
|
CXXFLAGS = -Os -pipe -DNDEBUG $(INC_FLAGS)
|
||||||
|
|
||||||
TEST_SRC = $(wildcard tests/*.cpp)
|
TEST_SRC = $(wildcard tests/*.cpp)
|
||||||
TESTS = $(patsubst %.cpp,%,$(TEST_SRC))
|
TESTS = $(patsubst %.cpp,%,$(TEST_SRC))
|
||||||
|
@ -142,4 +142,5 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set up the main method and event loop
|
||||||
IMPLEMENT_APP(TyroApp);
|
IMPLEMENT_APP(TyroApp);
|
||||||
|
@ -41,6 +41,12 @@ MainFrame::~MainFrame()
|
|||||||
wxLogDebug("Main Frame Destructor Called.");
|
wxLogDebug("Main Frame Destructor Called.");
|
||||||
delete notebook;
|
delete notebook;
|
||||||
delete toolBar;
|
delete toolBar;
|
||||||
|
|
||||||
|
wxDELETE(this->findDlg);
|
||||||
|
wxDELETE(this->findData);
|
||||||
|
wxDELETE(this->replaceDlg);
|
||||||
|
wxDELETE(this->findReplaceData);
|
||||||
|
|
||||||
manager->UnInit();
|
manager->UnInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,17 +431,13 @@ void MainFrame::OnToggleWhitespace(wxCommandEvent& event)
|
|||||||
*/
|
*/
|
||||||
void MainFrame::OnEditFind(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnEditFind(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (this->findDlg != nullptr)
|
if (this->findDlg == nullptr)
|
||||||
{
|
|
||||||
wxDELETE(this->findDlg);
|
|
||||||
wxDELETE(this->findData);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this->findData = new wxFindReplaceData(wxFR_DOWN);
|
this->findData = new wxFindReplaceData(wxFR_DOWN);
|
||||||
this->findDlg = new wxFindReplaceDialog(this, this->findData, "Find");
|
this->findDlg = new wxFindReplaceDialog(this, this->findData, "Find");
|
||||||
this->findDlg->Show(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->findDlg->Show(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -445,19 +447,14 @@ void MainFrame::OnEditFind(wxCommandEvent &WXUNUSED(event))
|
|||||||
*/
|
*/
|
||||||
void MainFrame::OnEditReplace(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnEditReplace(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (this->replaceDlg != nullptr)
|
if (this->replaceDlg == nullptr)
|
||||||
{
|
|
||||||
wxDELETE(this->replaceDlg);
|
|
||||||
wxDELETE(this->findReplaceData);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this->findReplaceData = new wxFindReplaceData(wxFR_DOWN);
|
this->findReplaceData = new wxFindReplaceData(wxFR_DOWN);
|
||||||
this->replaceDlg = new wxFindReplaceDialog(this, this->findReplaceData,
|
this->replaceDlg = new wxFindReplaceDialog(this, this->findReplaceData,
|
||||||
"Find and Replace", wxFR_REPLACEDIALOG);
|
"Find and Replace", wxFR_REPLACEDIALOG);
|
||||||
|
|
||||||
this->replaceDlg->Show(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->replaceDlg->Show(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -538,6 +535,25 @@ void MainFrame::OnFindDialog(wxFindDialogEvent &event)
|
|||||||
else if (type == wxEVT_FIND_REPLACE_ALL)
|
else if (type == wxEVT_FIND_REPLACE_ALL)
|
||||||
{
|
{
|
||||||
wxLogDebug("wxEVT_FIND_REPLACE_ALL");
|
wxLogDebug("wxEVT_FIND_REPLACE_ALL");
|
||||||
|
|
||||||
|
// Freeze editor drawing until replacement is finished
|
||||||
|
editor->Freeze();
|
||||||
|
|
||||||
|
editor->GotoPos(0); // Go to the start of the document
|
||||||
|
editor->SearchAnchor();
|
||||||
|
|
||||||
|
editor->BeginUndoAction();
|
||||||
|
|
||||||
|
while (editor->SearchNext(stc_flags, event.GetFindString()) != -1)
|
||||||
|
{
|
||||||
|
editor->ReplaceSelection(event.GetReplaceString());
|
||||||
|
}
|
||||||
|
|
||||||
|
editor->EndUndoAction();
|
||||||
|
|
||||||
|
editor->ScrollToEnd();
|
||||||
|
|
||||||
|
editor->Thaw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ void TyroMenu::SetupMainMenus()
|
|||||||
//editMenu->Append(wxID_DELETE, "&Delete\tDel");
|
//editMenu->Append(wxID_DELETE, "&Delete\tDel");
|
||||||
editMenu->AppendSeparator();
|
editMenu->AppendSeparator();
|
||||||
editMenu->Append(wxID_FIND, "&Find\tCtrl+F");
|
editMenu->Append(wxID_FIND, "&Find\tCtrl+F");
|
||||||
//editMenu->Append(wxID_REPLACE, "&Replace\tCtrl+R");
|
editMenu->Append(wxID_REPLACE, "&Replace\tCtrl+R");
|
||||||
|
|
||||||
editMenu->AppendSeparator();
|
editMenu->AppendSeparator();
|
||||||
editMenu->Append(wxID_SELECTALL, "Select All\tCtrl+A", "Select all the text in the current document");
|
editMenu->Append(wxID_SELECTALL, "Select All\tCtrl+A", "Select all the text in the current document");
|
||||||
@ -112,7 +112,7 @@ void TyroMenu::EnableEditControls(bool enable)
|
|||||||
this->editMenu->Enable(wxID_PASTE, enable);
|
this->editMenu->Enable(wxID_PASTE, enable);
|
||||||
this->editMenu->Enable(wxID_SELECTALL, enable);
|
this->editMenu->Enable(wxID_SELECTALL, enable);
|
||||||
this->editMenu->Enable(wxID_FIND, enable);
|
this->editMenu->Enable(wxID_FIND, enable);
|
||||||
//this->editMenu->Enable(wxID_REPLACE, enable);
|
this->editMenu->Enable(wxID_REPLACE, enable);
|
||||||
|
|
||||||
// Enable/disable top level menus
|
// Enable/disable top level menus
|
||||||
this->EnableEntireMenu(myVIEW_MENU, this->viewMenu, enable);
|
this->EnableEntireMenu(myVIEW_MENU, this->viewMenu, enable);
|
||||||
|
Loading…
Reference in New Issue
Block a user