From f711887167efe685265056be734b78bc8c97febc Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Fri, 26 Jan 2007 04:11:32 +0000 Subject: [PATCH] Made recombine lines deal with two new cases. Originally committed to SVN as r896. --- aegisub/changelog.txt | 1 + aegisub/subs_grid.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/aegisub/changelog.txt b/aegisub/changelog.txt index be3713ffa..5032e2d3b 100644 --- a/aegisub/changelog.txt +++ b/aegisub/changelog.txt @@ -99,6 +99,7 @@ Please visit http://aegisub.net to download latest version - Fixed Custom Aspect Ratio input. (Dansolo) - Made the video display detachable. (AMZ) - Undo and redo now have descriptions. (Dansolo) +- The three different "Recombine Lines" were merged into one that autodetects needed changes, and also supports two new cases. (AMZ) = 1.10 beta - 2006.08.07 =========================== diff --git a/aegisub/subs_grid.cpp b/aegisub/subs_grid.cpp index 3f112853f..e5ed7e677 100644 --- a/aegisub/subs_grid.cpp +++ b/aegisub/subs_grid.cpp @@ -600,14 +600,25 @@ void SubtitlesGrid::OnRecombine(wxCommandEvent &event) { // Detect type int type = -1; + bool invert = false; if (n1->Text.Right(n2->Text.Length()) == n2->Text) type = 0; + else if (n1->Text.Left(n2->Text.Length()) == n2->Text) { type = 1; invert = true; } else if (n2->Text.Left(n1->Text.Length()) == n1->Text) type = 1; + else if (n2->Text.Right(n1->Text.Length()) == n1->Text) { type = 0; invert = true; } else { // Unknown type parentFrame->StatusTimeout(_T("Unable to recombine: Neither line is a suffix of the other one.")); return; } + // Invert? + if (invert) { + n3 = n1; + n1 = n2; + n2 = n3; + n3 = NULL; + } + // 1+2,2 -> 1,2 if (type == 0) { n1->Text = n1->Text.SubString(0, n1->Text.Length() - n2->Text.Length() - 1).Trim(true).Trim(false); @@ -616,8 +627,8 @@ void SubtitlesGrid::OnRecombine(wxCommandEvent &event) { n2->Start = n1->Start; } - // 1,1+2, -> 1,2 - else { + // 1,1+2 -> 1,2 + else if (type == 1) { n2->Text = n2->Text.Mid(n1->Text.Length()).Trim(true).Trim(false); while (n2->Text.Left(2) == _T("\\N") || n2->Text.Left(2) == _T("\\n")) n2->Text = n2->Text.Mid(2); while (n2->Text.Right(2) == _T("\\N") || n2->Text.Right(2) == _T("\\n")) n2->Text = n2->Text.Mid(0,n2->Text.Length()-2);