First shot at search

This commit is contained in:
Tim Warren 2015-06-01 16:51:00 -04:00
parent 289d52489b
commit bc0f97dd0b
2 changed files with 34 additions and 16 deletions

View File

@ -475,7 +475,6 @@ void MainFrame::OnFindDialog(wxFindDialogEvent &event)
// Position after search
int new_pos = 0;
int new_line = 1;
// Send find flags to editor control
editor->SetSearchFlags(stc_flags);
@ -484,27 +483,44 @@ void MainFrame::OnFindDialog(wxFindDialogEvent &event)
{
wxLogDebug("wxEVT_FIND");
editor->SetAnchor(0);
/*if (editor->GetCurrentPos() < 1)
{
editor->GotoPos(1);
}*/
editor->SearchAnchor();
}
if (type == wxEVT_FIND_NEXT || type == wxEVT_FIND)
{
if ((fr_flags & wxFR_DOWN) != 0)
{
if (type == wxEVT_FIND_NEXT)
{
new_pos = editor->SearchNext(stc_flags, event.GetFindString());
}
else
{
new_pos = editor->SearchPrev(stc_flags, event.GetFindString());
wxLogDebug("wxEVT_FIND_NEXT");
}
new_pos = ((fr_flags & wxFR_DOWN) != 0)
? editor->SearchNext(stc_flags, event.GetFindString())
: editor->SearchPrev(stc_flags, event.GetFindString());
int sel_start = editor->GetSelectionStart();
int sel_end = editor->GetSelectionEnd();
if (new_pos > 0)
{
new_line = editor->LineFromPosition(new_pos);
editor->ScrollToLine(new_line);
//editor->SetAnchor(new_pos);
{
if ((fr_flags & wxFR_DOWN) != 0)
{
editor->GotoPos(sel_end + 1);
}
else
{
((sel_start - 1) > 0)
? editor->GotoPos(sel_start - 1)
: editor->GotoPos(sel_start);
}
editor->SearchAnchor();
editor->SetSelectionStart(sel_start);
editor->SetSelectionEnd(sel_end);
}
return;

View File

@ -61,11 +61,11 @@ void TyroMenu::SetupMainMenus()
editMenu->Append(wxID_COPY, "&Copy\tCtrl+C", "Copy selected text");
editMenu->Append(wxID_PASTE, "&Paste\tCtrl+V", "Paste contents of clipboard");
//editMenu->Append(wxID_DELETE, "&Delete\tDel");
//editMenu->AppendSeparator();
//editMenu->Append(wxID_FIND, "&Find\tCtrl+F");
editMenu->AppendSeparator();
editMenu->Append(wxID_FIND, "&Find\tCtrl+F");
//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->AppendSeparator();
editMenu->Append(wxID_PREFERENCES, "&Preferences\tCtrl+P");
@ -111,6 +111,8 @@ void TyroMenu::EnableEditControls(bool enable)
this->editMenu->Enable(wxID_COPY, enable);
this->editMenu->Enable(wxID_PASTE, enable);
this->editMenu->Enable(wxID_SELECTALL, enable);
this->editMenu->Enable(wxID_FIND, enable);
//this->editMenu->Enable(wxID_REPLACE, enable);
// Enable/disable top level menus
this->EnableEntireMenu(myVIEW_MENU, this->viewMenu, enable);