mirror of https://github.com/odrling/Aegisub
Add an optional argument to AssFile::Commit which indicates that only a single line was changed. Currently used only to cut down on file copies when coalescing.
Originally committed to SVN as r5614.
This commit is contained in:
parent
c936306593
commit
67ab06e830
|
@ -760,12 +760,23 @@ wxString AssFile::GetWildcardList(int mode) {
|
||||||
else return "";
|
else return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int AssFile::Commit(wxString desc, int type, int amendId) {
|
int AssFile::Commit(wxString desc, int type, int amendId, AssEntry *single_line) {
|
||||||
++commitId;
|
++commitId;
|
||||||
// Allow coalescing only if it's the last change and the file has not been
|
// Allow coalescing only if it's the last change and the file has not been
|
||||||
// saved since the last change
|
// saved since the last change
|
||||||
if (commitId == amendId+1 && RedoStack.empty() && savedCommitId != commitId) {
|
if (commitId == amendId+1 && RedoStack.empty() && savedCommitId != commitId) {
|
||||||
|
// If only one line changed just modify it instead of copying the file
|
||||||
|
if (single_line) {
|
||||||
|
entryIter this_it = Line.begin(), undo_it = UndoStack.back().Line.begin();
|
||||||
|
while (*this_it != single_line) {
|
||||||
|
++this_it;
|
||||||
|
++undo_it;
|
||||||
|
}
|
||||||
|
**undo_it = *single_line;
|
||||||
|
}
|
||||||
|
else {
|
||||||
UndoStack.back() = *this;
|
UndoStack.back() = *this;
|
||||||
|
}
|
||||||
AnnounceCommit(type);
|
AnnounceCommit(type);
|
||||||
return commitId;
|
return commitId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,11 +197,12 @@ public:
|
||||||
DEFINE_SIGNAL_ADDERS(FileSave, AddFileSaveListener)
|
DEFINE_SIGNAL_ADDERS(FileSave, AddFileSaveListener)
|
||||||
|
|
||||||
/// @brief Flag the file as modified and push a copy onto the undo stack
|
/// @brief Flag the file as modified and push a copy onto the undo stack
|
||||||
/// @param desc Undo description
|
/// @param desc Undo description
|
||||||
/// @param type Type of changes made to the file in this commit
|
/// @param type Type of changes made to the file in this commit
|
||||||
/// @param commitId Commit to amend rather than pushing a new commit
|
/// @param commitId Commit to amend rather than pushing a new commit
|
||||||
|
/// @param single_line Line which was changed, if only one line was
|
||||||
/// @return Unique identifier for the new undo group
|
/// @return Unique identifier for the new undo group
|
||||||
int Commit(wxString desc, int type, int commitId = -1);
|
int Commit(wxString desc, int type, int commitId = -1, AssEntry *single_line = 0);
|
||||||
/// @brief Undo the last set of changes to the file
|
/// @brief Undo the last set of changes to the file
|
||||||
void Undo();
|
void Undo();
|
||||||
/// @brief Redo the last undone changes
|
/// @brief Redo the last undone changes
|
||||||
|
|
|
@ -392,7 +392,7 @@ void AudioTimingControllerDialogue::Commit()
|
||||||
commit_id = -1; // never coalesce with a manually triggered commit
|
commit_id = -1; // never coalesce with a manually triggered commit
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
commit_id = ass->Commit(_("timing"), AssFile::COMMIT_DIAG_TIME, commit_id);
|
commit_id = context->ass->Commit(_("timing"), AssFile::COMMIT_DIAG_TIME, commit_id, selection_controller->GetActiveLine());
|
||||||
|
|
||||||
commit_slot.Unblock();
|
commit_slot.Unblock();
|
||||||
timing_modified = false;
|
timing_modified = false;
|
||||||
|
|
|
@ -226,7 +226,7 @@ void AudioTimingControllerKaraoke::GetMarkers(SampleRange const& range, AudioMar
|
||||||
void AudioTimingControllerKaraoke::DoCommit() {
|
void AudioTimingControllerKaraoke::DoCommit() {
|
||||||
active_line->Text = kara->GetText();
|
active_line->Text = kara->GetText();
|
||||||
file_changed_slot.Block();
|
file_changed_slot.Block();
|
||||||
commit_id = c->ass->Commit(_("karaoke timing"), AssFile::COMMIT_TEXT, commit_id);
|
commit_id = c->ass->Commit(_("karaoke timing"), AssFile::COMMIT_DIAG_TEXT, commit_id, active_line);
|
||||||
file_changed_slot.Unblock();
|
file_changed_slot.Unblock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -485,7 +485,7 @@ void SubsEditBox::SetSelectedRows(setter set, T value, wxString desc, int type,
|
||||||
|
|
||||||
for_each(sel.begin(), sel.end(), std::tr1::bind(set, _1, value));
|
for_each(sel.begin(), sel.end(), std::tr1::bind(set, _1, value));
|
||||||
|
|
||||||
commitId = c->ass->Commit(desc, type, (amend && desc == lastCommitType) ? commitId : -1);
|
commitId = c->ass->Commit(desc, type, (amend && desc == lastCommitType) ? commitId : -1, sel.size() == 1 ? *sel.begin() : 0);
|
||||||
lastCommitType = desc;
|
lastCommitType = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,7 +518,7 @@ void SubsEditBox::CommitTimes(TimeField field) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timeCommitId[field] = c->ass->Commit(_("modify times"), AssFile::COMMIT_DIAG_TIME, timeCommitId[field]);
|
timeCommitId[field] = c->ass->Commit(_("modify times"), AssFile::COMMIT_DIAG_TIME, timeCommitId[field], sel.size() == 1 ? *sel.begin() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsEditBox::OnSize(wxSizeEvent &evt) {
|
void SubsEditBox::OnSize(wxSizeEvent &evt) {
|
||||||
|
|
Loading…
Reference in New Issue