From a1ad0fa5855eeb60907e24d8160234e5f121e88b Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 26 Jan 2012 22:13:39 +0000 Subject: [PATCH] Use Scintilla's logic for deciding when to coalesce edit box changes Scintilla's modification notifications don't expose enough information to do a very good job of deciding when to group changes with previous ones, but it does expose when Scintilla thinks undo groups should end, so just use that. This should significantly improve the behavior of undo when editing lines in the edit box. Originally committed to SVN as r6370. --- aegisub/src/subs_edit_box.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/aegisub/src/subs_edit_box.cpp b/aegisub/src/subs_edit_box.cpp index c7856f5aa..b534d201a 100644 --- a/aegisub/src/subs_edit_box.cpp +++ b/aegisub/src/subs_edit_box.cpp @@ -207,7 +207,6 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) // Text editor TextEdit = new SubsTextEditCtrl(this, wxSize(300,50), wxBORDER_SUNKEN, c); TextEdit->Bind(wxEVT_KEY_DOWN, &SubsEditBox::OnKeyDown, this); - TextEdit->SetUndoCollection(false); BottomSizer = new wxBoxSizer(wxHORIZONTAL); BottomSizer->Add(TextEdit,1,wxEXPAND,0); @@ -221,7 +220,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) SetSizerAndFit(MainSizer); TextEdit->Bind(wxEVT_STC_MODIFIED, &SubsEditBox::OnChange, this); - TextEdit->SetModEventMask(wxSTC_MOD_INSERTTEXT | wxSTC_MOD_DELETETEXT); + TextEdit->SetModEventMask(wxSTC_MOD_INSERTTEXT | wxSTC_MOD_DELETETEXT | wxSTC_STARTACTION); Bind(wxEVT_COMMAND_TEXT_UPDATED, &SubsEditBox::OnLayerEnter, this, Layer->GetId()); Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &SubsEditBox::OnLayerChange, this, Layer->GetId()); @@ -406,12 +405,9 @@ void SubsEditBox::OnKeyDown(wxKeyEvent &event) { void SubsEditBox::OnChange(wxStyledTextEvent &event) { if (line && TextEdit->GetText() != line->Text) { - if (event.GetModificationType() & wxSTC_MOD_INSERTTEXT) { - CommitText(_("insert text")); - } - else { - CommitText(_("delete text")); - } + if (event.GetModificationType() & wxSTC_STARTACTION) + commitId = -1; + CommitText(_("modify text")); } }