From defaf3a5acee494ec41ebbc3fc191955a22c13ed Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Wed, 1 Feb 2006 02:16:57 +0000 Subject: [PATCH] From changelog: - Drag-and-drop files onto the program no longer causes the subs to be unloaded every time, even if no subs were dropped (jfs) - Recombining lines (1,1+2 and 1+2,2) where the lone line is a substring of the line only appearing combined no longer causes incorrect results (as a side-effect, more strict prefix/suffix-checking has also been implemented) (jfs) Originally committed to SVN as r54. --- core/changelog.txt | 2 ++ core/frame_main.cpp | 4 ++- core/frame_main.h | 2 +- core/subs_grid.cpp | 72 +++++++++++++++++++++++++++------------------ 4 files changed, 50 insertions(+), 30 deletions(-) diff --git a/core/changelog.txt b/core/changelog.txt index 83856504e..7370f57e0 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -17,6 +17,8 @@ Please visit http://aegisub.net to download latest version o When editing karaoke-timing for a line and not splitting/joining, all tags are kept intact, so only the \k tag timings are changed - Fixed bug where \t tags (among others?) would lose their parameters when being rebuilt (happens with Framerate Transport export filter, Automation and during the karaoke timing improvements listed above, among other places) (jfs) - Implemented FexTracker, for automatically tracking positions on the video and placing text accordingly (Tentacle) +- Drag-and-drop files onto the program no longer causes the subs to be unloaded every time, even if no subs were dropped (jfs) +- Recombining lines (1,1+2 and 1+2,2) where the lone line is a substring of the line only appearing combined no longer causes incorrect results (as a side-effect, more strict prefix/suffix-checking has also been implemented) (jfs) = 1.09 beta - 2006.01.16 =========================== diff --git a/core/frame_main.cpp b/core/frame_main.cpp index 14fe51baa..13725be34 100644 --- a/core/frame_main.cpp +++ b/core/frame_main.cpp @@ -1088,7 +1088,9 @@ bool FrameMain::LoadList(wxArrayString list) { blockVideoLoad = (video != _T("")); // Load files - LoadSubtitles(subs); + if (subs != _T("")) { + LoadSubtitles(subs); + } if (blockVideoLoad) { blockVideoLoad = false; LoadVideo(video); diff --git a/core/frame_main.h b/core/frame_main.h index 7e18e85ea..26980ebfa 100644 --- a/core/frame_main.h +++ b/core/frame_main.h @@ -207,7 +207,6 @@ private: bool SaveSubtitles(bool saveas=false,bool withCharset=false); int TryToCloseSubs(bool enableCancel=true); void SetDisplayMode(int mode); - void StatusTimeout(wxString text,int ms=10000); void AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help,wxBitmap bmp); wxMenuItem *RebuildMenuItem(wxMenu *menu,int id,wxBitmap bmp1,wxBitmap bmp2,bool state); @@ -229,6 +228,7 @@ public: static wxArrayString GetEncodings(); void UpdateTitle(); void SetSelectionFlag (bool HasSelection); + void StatusTimeout(wxString text,int ms=10000); void SetAccelerators(); void InitMenu(); diff --git a/core/subs_grid.cpp b/core/subs_grid.cpp index e77faa0d4..dbdf74651 100644 --- a/core/subs_grid.cpp +++ b/core/subs_grid.cpp @@ -823,21 +823,29 @@ void SubtitlesGrid::On122Recombine(wxCommandEvent &event) { AssDialogue *n1,*n2; n1 = GetDialogue(n); n2 = GetDialogue(n+1); - n1->Text.Replace(n2->Text,_T("")); - n1->Text.Trim(true); - n1->Text.Trim(false); - if (n1->Text.Left(2) == _T("\\N") || n1->Text.Left(2) == _T("\\n")) n1->Text = n1->Text.Mid(2); - if (n1->Text.Right(2) == _T("\\N") || n1->Text.Right(2) == _T("\\n")) n1->Text = n1->Text.Mid(0,n1->Text.Length()-2); - n2->Start = n1->Start; - n1->ParseASSTags(); - n1->UpdateData(); - n2->UpdateData(); + n1->Text.Trim(true).Trim(false); + n2->Text.Trim(true).Trim(false); - // Commit - SetRowToLine(n,n1); - SetRowToLine(n+1,n2); - ass->FlagAsModified(); - CommitChanges(); + // Check if n2 is a suffix of n1 + if (n1->Text.Right(n2->Text.Length()) == n2->Text) { + n1->Text = n1->Text.SubString(0, n1->Text.Length() - n2->Text.Length() - 1).Trim(true).Trim(false); + while (n1->Text.Left(2) == _T("\\N") || n1->Text.Left(2) == _T("\\n")) + n1->Text = n1->Text.Mid(2); + while (n1->Text.Right(2) == _T("\\N") || n1->Text.Right(2) == _T("\\n")) + n1->Text = n1->Text.Mid(0,n1->Text.Length()-2); + n2->Start = n1->Start; + n1->ParseASSTags(); + n1->UpdateData(); + n2->UpdateData(); + + // Commit + SetRowToLine(n,n1); + SetRowToLine(n+1,n2); + ass->FlagAsModified(); + CommitChanges(); + } else { + parentFrame->StatusTimeout(_T("Unable to recombine: Second line is not a suffix of first one.")); + } } @@ -854,21 +862,29 @@ void SubtitlesGrid::On112Recombine(wxCommandEvent &event) { AssDialogue *n1,*n2; n1 = GetDialogue(n); n2 = GetDialogue(n+1); - n2->Text.Replace(n1->Text,_T("")); - n2->Text.Trim(true); - n2->Text.Trim(false); - if (n2->Text.Left(2) == _T("\\N") || n2->Text.Left(2) == _T("\\n")) n2->Text = n2->Text.Mid(2); - if (n2->Text.Right(2) == _T("\\N") || n2->Text.Right(2) == _T("\\n")) n2->Text = n2->Text.Mid(0,n2->Text.Length()-2); - n1->End = n2->End; - n2->ParseASSTags(); - n1->UpdateData(); - n2->UpdateData(); + n1->Text.Trim(true).Trim(false); + n2->Text.Trim(true).Trim(false); - // Commit - SetRowToLine(n,n1); - SetRowToLine(n+1,n2); - ass->FlagAsModified(); - CommitChanges(); + // Check if n1 is a prefix of n2 and recombine + if (n2->Text.Left(n1->Text.Length()) == n1->Text) { + 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); + n1->End = n2->End; + n2->ParseASSTags(); + n1->UpdateData(); + n2->UpdateData(); + + // Commit + SetRowToLine(n,n1); + SetRowToLine(n+1,n2); + ass->FlagAsModified(); + CommitChanges(); + } else { + parentFrame->StatusTimeout(_T("Unable to recombine: First line is not a prefix of second one.")); + } }