2006-01-16 22:02:54 +01:00
|
|
|
// Copyright (c) 2005, Rodrigo Braz Monteiro
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * 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.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2006-01-16 22:02:54 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file dialog_search_replace.cpp
|
|
|
|
/// @brief Find and Search/replace dialogue box and logic
|
|
|
|
/// @ingroup secondary_ui
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
2006-01-16 22:02:54 +01:00
|
|
|
#include <wx/regex.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <wx/string.h>
|
|
|
|
#endif
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
#include "ass_dialogue.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "ass_file.h"
|
2011-07-15 06:25:23 +02:00
|
|
|
#include "command/command.h"
|
|
|
|
#include "compat.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "dialog_search_replace.h"
|
2011-01-16 08:17:36 +01:00
|
|
|
#include "include/aegisub/context.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "frame_main.h"
|
|
|
|
#include "main.h"
|
2010-12-08 04:36:10 +01:00
|
|
|
#include "selection_controller.h"
|
2010-07-20 05:11:11 +02:00
|
|
|
#include "subs_edit_ctrl.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "subs_grid.h"
|
2006-03-14 01:39:33 +01:00
|
|
|
|
2011-01-16 08:17:36 +01:00
|
|
|
// IDs
|
|
|
|
enum {
|
|
|
|
BUTTON_FIND_NEXT,
|
|
|
|
BUTTON_REPLACE_NEXT,
|
|
|
|
BUTTON_REPLACE_ALL,
|
|
|
|
CHECK_MATCH_CASE,
|
|
|
|
CHECK_REGEXP,
|
|
|
|
CHECK_UPDATE_VIDEO
|
|
|
|
};
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Constructor
|
|
|
|
/// @param parent
|
|
|
|
/// @param _hasReplace
|
|
|
|
/// @param name
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
DialogSearchReplace::DialogSearchReplace (wxWindow *parent,bool _hasReplace,wxString name)
|
2011-09-28 21:43:11 +02:00
|
|
|
: wxDialog(parent, -1, name, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, "SearchReplace")
|
2006-01-16 22:02:54 +01:00
|
|
|
{
|
|
|
|
// Setup
|
|
|
|
hasReplace = _hasReplace;
|
|
|
|
|
|
|
|
// Find sizer
|
|
|
|
wxSizer *FindSizer = new wxFlexGridSizer(2,2,5,15);
|
2010-05-21 03:13:36 +02:00
|
|
|
wxArrayString FindHistory = lagi_MRU_wxAS("Find");
|
2011-09-28 21:43:11 +02:00
|
|
|
FindEdit = new wxComboBox(this,-1,"",wxDefaultPosition,wxSize(300,-1),FindHistory,wxCB_DROPDOWN);
|
2006-12-29 23:58:09 +01:00
|
|
|
//if (FindHistory.Count()) FindEdit->SetStringSelection(FindHistory[0]);
|
|
|
|
FindEdit->SetSelection(0);
|
2006-01-16 22:02:54 +01:00
|
|
|
FindSizer->Add(new wxStaticText(this,-1,_("Find what:")),0,wxRIGHT | wxALIGN_CENTER_VERTICAL,0);
|
|
|
|
FindSizer->Add(FindEdit,0,wxRIGHT,0);
|
|
|
|
if (hasReplace) {
|
2010-05-21 03:13:36 +02:00
|
|
|
wxArrayString ReplaceHistory = lagi_MRU_wxAS("Replace");
|
2011-09-28 21:43:11 +02:00
|
|
|
ReplaceEdit = new wxComboBox(this,-1,"",wxDefaultPosition,wxSize(300,-1),ReplaceHistory,wxCB_DROPDOWN);
|
2006-01-16 22:02:54 +01:00
|
|
|
FindSizer->Add(new wxStaticText(this,-1,_("Replace with:")),0,wxRIGHT | wxALIGN_CENTER_VERTICAL,0);
|
|
|
|
FindSizer->Add(ReplaceEdit,0,wxRIGHT,0);
|
|
|
|
ReplaceEdit->SetSelection(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Options sizer
|
|
|
|
wxSizer *OptionsSizer = new wxBoxSizer(wxVERTICAL);
|
2011-11-18 19:49:09 +01:00
|
|
|
CheckMatchCase = new wxCheckBox(this,CHECK_MATCH_CASE,_("&Match case"));
|
|
|
|
CheckRegExp = new wxCheckBox(this,CHECK_MATCH_CASE,_("&Use regular expressions"));
|
|
|
|
CheckUpdateVideo = new wxCheckBox(this,CHECK_UPDATE_VIDEO,_("Update &Video"));
|
2010-05-21 03:13:36 +02:00
|
|
|
CheckMatchCase->SetValue(OPT_GET("Tool/Search Replace/Match Case")->GetBool());
|
|
|
|
CheckRegExp->SetValue(OPT_GET("Tool/Search Replace/RegExp")->GetBool());
|
2006-01-16 22:02:54 +01:00
|
|
|
//CheckRegExp->Enable(false);
|
2010-05-21 03:13:36 +02:00
|
|
|
CheckUpdateVideo->SetValue(OPT_GET("Tool/Search Replace/Video Update")->GetBool());
|
2006-03-05 21:42:38 +01:00
|
|
|
// CheckUpdateVideo->Enable(Search.grid->video->loaded);
|
2006-01-16 22:02:54 +01:00
|
|
|
OptionsSizer->Add(CheckMatchCase,0,wxBOTTOM,5);
|
|
|
|
OptionsSizer->Add(CheckRegExp,0,wxBOTTOM,5);
|
|
|
|
OptionsSizer->Add(CheckUpdateVideo,0,wxBOTTOM,0);
|
|
|
|
|
|
|
|
// Limits sizer
|
|
|
|
wxArrayString field;
|
|
|
|
field.Add(_("Text"));
|
|
|
|
field.Add(_("Style"));
|
|
|
|
field.Add(_("Actor"));
|
2008-06-24 05:22:46 +02:00
|
|
|
field.Add(_("Effect"));
|
2006-01-16 22:02:54 +01:00
|
|
|
wxArrayString affect;
|
|
|
|
affect.Add(_("All rows"));
|
|
|
|
affect.Add(_("Selected rows"));
|
|
|
|
Field = new wxRadioBox(this,-1,_("In Field"),wxDefaultPosition,wxDefaultSize,field);
|
|
|
|
Affect = new wxRadioBox(this,-1,_("Limit to"),wxDefaultPosition,wxDefaultSize,affect);
|
|
|
|
wxSizer *LimitSizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
LimitSizer->Add(Field,1,wxEXPAND | wxRIGHT,5);
|
|
|
|
LimitSizer->Add(Affect,0,wxEXPAND | wxRIGHT,0);
|
2010-05-21 03:13:36 +02:00
|
|
|
Field->SetSelection(OPT_GET("Tool/Search Replace/Field")->GetInt());
|
|
|
|
Affect->SetSelection(OPT_GET("Tool/Search Replace/Affect")->GetInt());
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Left sizer
|
|
|
|
wxSizer *LeftSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
LeftSizer->Add(FindSizer,0,wxBOTTOM,10);
|
|
|
|
LeftSizer->Add(OptionsSizer,0,wxBOTTOM,5);
|
|
|
|
LeftSizer->Add(LimitSizer,0,wxEXPAND | wxBOTTOM,0);
|
|
|
|
|
|
|
|
// Buttons
|
|
|
|
wxSizer *ButtonSizer = new wxBoxSizer(wxVERTICAL);
|
2011-11-18 19:49:09 +01:00
|
|
|
wxButton *FindNext = new wxButton(this,BUTTON_FIND_NEXT,_("&Find next"));
|
2006-01-16 22:02:54 +01:00
|
|
|
FindNext->SetDefault();
|
|
|
|
ButtonSizer->Add(FindNext,0,wxEXPAND | wxBOTTOM,3);
|
|
|
|
if (hasReplace) {
|
2011-11-18 19:49:09 +01:00
|
|
|
ButtonSizer->Add(new wxButton(this,BUTTON_REPLACE_NEXT,_("Replace &next")),0,wxEXPAND | wxBOTTOM,3);
|
|
|
|
ButtonSizer->Add(new wxButton(this,BUTTON_REPLACE_ALL,_("Replace &all")),0,wxEXPAND | wxBOTTOM,3);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
2006-12-30 21:58:24 +01:00
|
|
|
ButtonSizer->Add(new wxButton(this,wxID_CANCEL),0,wxEXPAND | wxBOTTOM,20);
|
2006-03-14 01:39:33 +01:00
|
|
|
//ButtonSizer->Add(new wxButton(this,wxID_HELP),0,wxEXPAND | wxBOTTOM,0);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Main sizer
|
|
|
|
wxSizer *MainSizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
MainSizer->Add(LeftSizer,0,wxEXPAND | wxALL,5);
|
|
|
|
MainSizer->Add(ButtonSizer,0,wxEXPAND | wxALL,5);
|
|
|
|
MainSizer->SetSizeHints(this);
|
|
|
|
SetSizer(MainSizer);
|
|
|
|
CenterOnParent();
|
2006-12-30 21:58:24 +01:00
|
|
|
|
|
|
|
// Open
|
2006-01-16 22:02:54 +01:00
|
|
|
Search.OnDialogOpen();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Destructor
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
DialogSearchReplace::~DialogSearchReplace() {
|
|
|
|
// Save options
|
2006-03-05 21:42:38 +01:00
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Update search
|
|
|
|
///
|
2006-03-05 21:42:38 +01:00
|
|
|
void DialogSearchReplace::UpdateSettings() {
|
|
|
|
Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled();
|
|
|
|
Search.matchCase = CheckMatchCase->IsChecked();
|
|
|
|
Search.updateVideo = CheckUpdateVideo->IsChecked() && CheckUpdateVideo->IsEnabled();
|
2010-05-21 03:13:36 +02:00
|
|
|
OPT_SET("Tool/Search Replace/Match Case")->SetBool(CheckMatchCase->IsChecked());
|
|
|
|
OPT_SET("Tool/Search Replace/RegExp")->SetBool(CheckRegExp->IsChecked());
|
|
|
|
OPT_SET("Tool/Search Replace/Video Update")->SetBool(CheckUpdateVideo->IsChecked());
|
|
|
|
OPT_SET("Tool/Search Replace/Field")->SetInt(Field->GetSelection());
|
|
|
|
OPT_SET("Tool/Search Replace/Affect")->SetInt(Affect->GetSelection());
|
2006-03-05 21:42:38 +01:00
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2006-12-29 23:58:09 +01:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
///////////////
|
|
|
|
// Event table
|
|
|
|
BEGIN_EVENT_TABLE(DialogSearchReplace,wxDialog)
|
2006-12-30 21:58:24 +01:00
|
|
|
EVT_BUTTON(wxID_CANCEL,DialogSearchReplace::OnClose)
|
2006-01-16 22:02:54 +01:00
|
|
|
EVT_BUTTON(BUTTON_FIND_NEXT,DialogSearchReplace::OnFindNext)
|
|
|
|
EVT_BUTTON(BUTTON_REPLACE_NEXT,DialogSearchReplace::OnReplaceNext)
|
|
|
|
EVT_BUTTON(BUTTON_REPLACE_ALL,DialogSearchReplace::OnReplaceAll)
|
2006-03-05 21:42:38 +01:00
|
|
|
EVT_SET_FOCUS(DialogSearchReplace::OnSetFocus)
|
|
|
|
EVT_KILL_FOCUS(DialogSearchReplace::OnKillFocus)
|
2006-01-16 22:02:54 +01:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2006-03-05 21:42:38 +01:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Close
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void DialogSearchReplace::OnClose (wxCommandEvent &event) {
|
2006-03-05 21:42:38 +01:00
|
|
|
Show(false);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Key
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-12-29 23:58:09 +01:00
|
|
|
void DialogSearchReplace::OnKeyDown (wxKeyEvent &event) {
|
|
|
|
//if (event.GetKeyCode() == WXK_ESCAPE) {
|
|
|
|
// Search.OnDialogClose();
|
|
|
|
// // Just hide
|
|
|
|
// Show(false);
|
|
|
|
//}
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Find or replace
|
|
|
|
/// @param mode
|
|
|
|
/// @return
|
|
|
|
///
|
2007-03-28 03:11:52 +02:00
|
|
|
void DialogSearchReplace::FindReplace(int mode) {
|
|
|
|
// Check mode
|
|
|
|
if (mode < 0 || mode > 2) return;
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Variables
|
|
|
|
wxString LookFor = FindEdit->GetValue();
|
|
|
|
if (LookFor.IsEmpty()) return;
|
|
|
|
|
|
|
|
// Setup
|
|
|
|
Search.isReg = CheckRegExp->IsChecked() && CheckRegExp->IsEnabled();
|
|
|
|
Search.matchCase = CheckMatchCase->IsChecked();
|
|
|
|
Search.updateVideo = CheckUpdateVideo->IsChecked() && CheckUpdateVideo->IsEnabled();
|
|
|
|
Search.LookFor = LookFor;
|
|
|
|
Search.CanContinue = true;
|
|
|
|
Search.affect = Affect->GetSelection();
|
|
|
|
Search.field = Field->GetSelection();
|
2007-03-28 03:11:52 +02:00
|
|
|
|
|
|
|
// Find
|
|
|
|
if (mode == 0) {
|
|
|
|
Search.FindNext();
|
|
|
|
if (hasReplace) {
|
|
|
|
wxString ReplaceWith = ReplaceEdit->GetValue();
|
|
|
|
Search.ReplaceWith = ReplaceWith;
|
2010-06-18 04:23:27 +02:00
|
|
|
config::mru->Add("Replace", STD_STR(ReplaceWith));
|
2011-01-16 08:17:36 +01:00
|
|
|
}
|
2007-03-28 03:11:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Replace
|
|
|
|
else {
|
2006-03-05 21:42:38 +01:00
|
|
|
wxString ReplaceWith = ReplaceEdit->GetValue();
|
|
|
|
Search.ReplaceWith = ReplaceWith;
|
2007-03-28 03:11:52 +02:00
|
|
|
if (mode == 1) Search.ReplaceNext();
|
|
|
|
else Search.ReplaceAll();
|
2010-06-18 04:23:27 +02:00
|
|
|
config::mru->Add("Replace", STD_STR(ReplaceWith));
|
2007-03-28 03:11:52 +02:00
|
|
|
}
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Add to history
|
2010-06-18 04:23:27 +02:00
|
|
|
config::mru->Add("Find", STD_STR(LookFor));
|
2006-01-16 22:02:54 +01:00
|
|
|
UpdateDropDowns();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Find next
|
|
|
|
/// @param event
|
|
|
|
///
|
2007-03-28 03:11:52 +02:00
|
|
|
void DialogSearchReplace::OnFindNext (wxCommandEvent &event) {
|
|
|
|
FindReplace(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Replace next
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void DialogSearchReplace::OnReplaceNext (wxCommandEvent &event) {
|
2007-03-28 03:11:52 +02:00
|
|
|
FindReplace(1);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Replace all
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void DialogSearchReplace::OnReplaceAll (wxCommandEvent &event) {
|
2007-03-28 03:11:52 +02:00
|
|
|
FindReplace(2);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Update drop down boxes
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void DialogSearchReplace::UpdateDropDowns() {
|
|
|
|
// Find
|
|
|
|
FindEdit->Freeze();
|
|
|
|
FindEdit->Clear();
|
2010-05-21 03:13:36 +02:00
|
|
|
FindEdit->Append(lagi_MRU_wxAS("Find"));
|
2006-01-16 22:02:54 +01:00
|
|
|
FindEdit->SetSelection(0);
|
|
|
|
FindEdit->Thaw();
|
|
|
|
|
|
|
|
// Replace
|
|
|
|
if (hasReplace) {
|
|
|
|
ReplaceEdit->Freeze();
|
|
|
|
ReplaceEdit->Clear();
|
2010-05-21 03:13:36 +02:00
|
|
|
ReplaceEdit->Append(lagi_MRU_wxAS("Replace"));
|
2006-01-16 22:02:54 +01:00
|
|
|
ReplaceEdit->SetSelection(0);
|
|
|
|
ReplaceEdit->Thaw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-03-05 21:42:38 +01:00
|
|
|
void DialogSearchReplace::OnSetFocus (wxFocusEvent &event) {
|
|
|
|
Search.hasFocus = true;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-03-05 21:42:38 +01:00
|
|
|
void DialogSearchReplace::OnKillFocus (wxFocusEvent &event) {
|
|
|
|
Search.hasFocus = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Constructor SearchReplaceEngine ///////////////////////
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
SearchReplaceEngine::SearchReplaceEngine () {
|
|
|
|
CanContinue = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Find next instance
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void SearchReplaceEngine::FindNext() {
|
|
|
|
ReplaceNext(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Find & Replace next instance
|
|
|
|
/// @param DoReplace
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
|
|
|
|
// Check if it's OK to go on
|
|
|
|
if (!CanContinue) {
|
|
|
|
OpenDialog(DoReplace);
|
|
|
|
return;
|
|
|
|
}
|
2006-03-07 23:38:46 +01:00
|
|
|
|
2011-01-16 08:17:36 +01:00
|
|
|
wxArrayInt sels = context->subsGrid->GetSelection();
|
2008-02-15 22:47:09 +01:00
|
|
|
int firstLine = 0;
|
|
|
|
if (sels.Count() > 0) firstLine = sels[0];
|
2006-03-07 23:38:46 +01:00
|
|
|
// if selection has changed reset values
|
2010-10-15 18:58:50 +02:00
|
|
|
if (firstLine != curLine) {
|
2008-02-15 22:47:09 +01:00
|
|
|
curLine = firstLine;
|
2006-03-07 23:38:46 +01:00
|
|
|
Modified = false;
|
|
|
|
LastWasFind = true;
|
|
|
|
pos = 0;
|
|
|
|
matchLen = 0;
|
|
|
|
replaceLen = 0;
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Setup
|
|
|
|
int start = curLine;
|
2011-01-16 08:17:36 +01:00
|
|
|
int nrows = context->subsGrid->GetRows();
|
2006-01-16 22:02:54 +01:00
|
|
|
bool found = false;
|
2007-01-24 04:54:32 +01:00
|
|
|
wxString *Text = NULL;
|
2006-01-16 22:02:54 +01:00
|
|
|
size_t tempPos;
|
|
|
|
int regFlags = wxRE_ADVANCED;
|
|
|
|
if (!matchCase) {
|
|
|
|
if (isReg) regFlags |= wxRE_ICASE;
|
|
|
|
else LookFor.MakeLower();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search for it
|
|
|
|
while (!found) {
|
|
|
|
Text = GetText(curLine,field);
|
|
|
|
if (DoReplace && LastWasFind) tempPos = pos;
|
|
|
|
else tempPos = pos+replaceLen;
|
|
|
|
|
|
|
|
// RegExp
|
|
|
|
if (isReg) {
|
|
|
|
wxRegEx regex (LookFor,regFlags);
|
|
|
|
if (regex.IsValid()) {
|
|
|
|
if (regex.Matches(Text->Mid(tempPos))) {
|
|
|
|
size_t match_start;
|
|
|
|
regex.GetMatch(&match_start,&matchLen,0);
|
|
|
|
pos = match_start + tempPos;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Normal
|
|
|
|
else {
|
2007-10-18 05:18:39 +02:00
|
|
|
int textPos = tempPos;
|
2006-01-16 22:02:54 +01:00
|
|
|
wxString src = Text->Mid(tempPos);
|
|
|
|
if (!matchCase) src.MakeLower();
|
2007-04-04 22:42:44 +02:00
|
|
|
int tempPos = src.Find(LookFor);
|
|
|
|
if (tempPos != -1) {
|
2007-10-18 05:18:39 +02:00
|
|
|
pos = textPos+tempPos;
|
2006-01-16 22:02:54 +01:00
|
|
|
found = true;
|
|
|
|
matchLen = LookFor.Length();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Didn't find, go to next line
|
|
|
|
if (!found) {
|
|
|
|
curLine++;
|
|
|
|
pos = 0;
|
|
|
|
matchLen = 0;
|
|
|
|
replaceLen = 0;
|
|
|
|
if (curLine == nrows) curLine = 0;
|
|
|
|
if (curLine == start) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Found
|
|
|
|
if (found) {
|
|
|
|
// If replacing
|
|
|
|
if (DoReplace) {
|
|
|
|
// Replace with regular expressions
|
|
|
|
if (isReg) {
|
|
|
|
wxString toReplace = Text->Mid(pos,matchLen);
|
|
|
|
wxRegEx regex(LookFor,regFlags);
|
|
|
|
regex.ReplaceFirst(&toReplace,ReplaceWith);
|
|
|
|
*Text = Text->Left(pos) + toReplace + Text->Mid(pos+matchLen);
|
|
|
|
replaceLen = toReplace.Length();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Normal replace
|
|
|
|
else {
|
|
|
|
*Text = Text->Left(pos) + ReplaceWith + Text->Mid(pos+matchLen);
|
|
|
|
replaceLen = ReplaceWith.Length();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Commit
|
2011-09-15 07:16:32 +02:00
|
|
|
context->ass->Commit(_("replace"), AssFile::COMMIT_DIAG_TEXT);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
replaceLen = matchLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Select
|
2011-01-16 08:17:36 +01:00
|
|
|
context->subsGrid->SelectRow(curLine,false);
|
|
|
|
context->subsGrid->MakeCellVisible(curLine,0);
|
2006-01-16 22:02:54 +01:00
|
|
|
if (field == 0) {
|
2011-01-16 08:17:36 +01:00
|
|
|
context->subsGrid->SetActiveLine(context->subsGrid->GetDialogue(curLine));
|
2011-09-15 07:17:07 +02:00
|
|
|
context->editBox->SetSelectionU(pos,pos+replaceLen);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update video
|
|
|
|
if (updateVideo) {
|
2011-07-15 06:25:23 +02:00
|
|
|
(*cmd::get("video/jump/start"))(context);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
else if (DoReplace) Modified = true;
|
|
|
|
|
|
|
|
// hAx to prevent double match on style/actor
|
|
|
|
if (field != 0) replaceLen = 99999;
|
|
|
|
}
|
|
|
|
LastWasFind = !DoReplace;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Replace all instances
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void SearchReplaceEngine::ReplaceAll() {
|
|
|
|
// Setup
|
|
|
|
wxString *Text;
|
2011-01-16 08:17:36 +01:00
|
|
|
int nrows = context->subsGrid->GetRows();
|
2006-01-16 22:02:54 +01:00
|
|
|
size_t count = 0;
|
|
|
|
int regFlags = wxRE_ADVANCED;
|
|
|
|
if (!matchCase) {
|
|
|
|
if (isReg) regFlags |= wxRE_ICASE;
|
|
|
|
//else LookFor.MakeLower();
|
|
|
|
}
|
|
|
|
bool replaced;
|
2011-01-16 08:17:36 +01:00
|
|
|
context->subsGrid->BeginBatch();
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Selection
|
|
|
|
bool hasSelection = false;
|
2011-01-16 08:17:36 +01:00
|
|
|
wxArrayInt sels = context->subsGrid->GetSelection();
|
2006-01-16 22:02:54 +01:00
|
|
|
if (sels.Count() > 0) hasSelection = true;
|
|
|
|
bool inSel = false;
|
|
|
|
if (affect == 1) inSel = true;
|
|
|
|
|
|
|
|
// Scan
|
|
|
|
for (int i=0;i<nrows;i++) {
|
|
|
|
// Check if row is selected
|
|
|
|
if (inSel && hasSelection && sels.Index(i) == wxNOT_FOUND) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare
|
|
|
|
replaced = false;
|
|
|
|
Text = GetText(i,field);
|
|
|
|
|
|
|
|
// Regular expressions
|
|
|
|
if (isReg) {
|
|
|
|
wxRegEx reg(LookFor,regFlags);
|
|
|
|
if (reg.IsValid()) {
|
2009-06-01 17:44:59 +02:00
|
|
|
size_t reps = reg.Replace(Text,ReplaceWith,1000);
|
2006-01-16 22:02:54 +01:00
|
|
|
if (reps > 0) replaced = true;
|
|
|
|
count += reps;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Normal replace
|
|
|
|
else {
|
2008-03-07 06:34:01 +01:00
|
|
|
if (!Search.matchCase) {
|
2011-09-28 21:43:11 +02:00
|
|
|
wxString Left = "", Right = *Text;
|
2008-06-15 19:56:05 +02:00
|
|
|
int pos = 0;
|
2008-07-23 18:09:27 +02:00
|
|
|
Left.Alloc(Right.Len());
|
2008-06-15 19:56:05 +02:00
|
|
|
while (pos <= (int)(Right.Len() - LookFor.Len())) {
|
|
|
|
if (Right.Mid(pos, LookFor.Len()).CmpNoCase(LookFor) == 0) {
|
|
|
|
Left.Append(Right.Mid(0,pos)).Append(ReplaceWith);
|
|
|
|
Right = Right.Mid(pos+LookFor.Len());
|
|
|
|
count++;
|
|
|
|
replaced = true;
|
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (replaced) {
|
2008-07-23 18:09:27 +02:00
|
|
|
*Text = Left + Right;
|
2008-03-07 06:34:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(Text->Contains(LookFor)) {
|
|
|
|
count += Text->Replace(LookFor, ReplaceWith);
|
|
|
|
replaced = true;
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Commit
|
|
|
|
if (count > 0) {
|
2011-09-15 07:16:32 +02:00
|
|
|
context->ass->Commit(_("replace"), AssFile::COMMIT_DIAG_TEXT);
|
2006-01-16 22:02:54 +01:00
|
|
|
wxMessageBox(wxString::Format(_("%i matches were replaced."),count));
|
|
|
|
}
|
|
|
|
|
|
|
|
// None found
|
|
|
|
else {
|
|
|
|
wxMessageBox(_("No matches found."));
|
|
|
|
}
|
2011-01-16 08:17:36 +01:00
|
|
|
context->subsGrid->EndBatch();
|
2006-01-16 22:02:54 +01:00
|
|
|
LastWasFind = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Search dialog opened
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void SearchReplaceEngine::OnDialogOpen() {
|
|
|
|
// Set curline
|
2011-01-16 08:17:36 +01:00
|
|
|
wxArrayInt sels = context->subsGrid->GetSelection();
|
2006-01-16 22:02:54 +01:00
|
|
|
curLine = 0;
|
|
|
|
if (sels.Count() > 0) curLine = sels[0];
|
|
|
|
|
|
|
|
// Reset values
|
|
|
|
Modified = false;
|
|
|
|
LastWasFind = true;
|
|
|
|
pos = 0;
|
|
|
|
matchLen = 0;
|
|
|
|
replaceLen = 0;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Open dialog
|
|
|
|
/// @param replace
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void SearchReplaceEngine::OpenDialog (bool replace) {
|
2006-03-05 21:42:38 +01:00
|
|
|
static DialogSearchReplace *diag = NULL;
|
|
|
|
wxString title = replace? _("Replace") : _("Find");
|
|
|
|
|
|
|
|
// already opened
|
|
|
|
if (diag) {
|
|
|
|
// it's the right type so give focus
|
|
|
|
if(replace == hasReplace) {
|
2006-12-29 23:58:09 +01:00
|
|
|
diag->FindEdit->SetFocus();
|
2006-03-05 21:42:38 +01:00
|
|
|
diag->Show();
|
2006-03-07 23:38:46 +01:00
|
|
|
OnDialogOpen();
|
2006-03-05 21:42:38 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// wrong type - destroy and create the right one
|
|
|
|
diag->Destroy();
|
|
|
|
}
|
|
|
|
// create new one
|
|
|
|
diag = new DialogSearchReplace(((AegisubApp*)wxTheApp)->frame,replace,title);
|
2006-12-29 23:58:09 +01:00
|
|
|
diag->FindEdit->SetFocus();
|
2006-03-05 21:42:38 +01:00
|
|
|
diag->Show();
|
|
|
|
hasReplace = replace;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get text pointer
|
|
|
|
/// @param n
|
|
|
|
/// @param field
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
wxString *SearchReplaceEngine::GetText(int n,int field) {
|
2011-01-16 08:17:36 +01:00
|
|
|
AssDialogue *cur = context->subsGrid->GetDialogue(n);
|
2006-01-16 22:02:54 +01:00
|
|
|
if (field == 0) return &cur->Text;
|
|
|
|
else if (field == 1) return &cur->Style;
|
|
|
|
else if (field == 2) return &cur->Actor;
|
2008-06-24 05:22:46 +02:00
|
|
|
else if (field == 3) return &cur->Effect;
|
2011-09-28 21:43:11 +02:00
|
|
|
else throw wxString("Invalid field");
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2006-01-16 22:02:54 +01:00
|
|
|
SearchReplaceEngine Search;
|
2009-07-29 07:43:02 +02:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|