From da331e26ddb4c6081430dd9a35e612318a6ebd5c Mon Sep 17 00:00:00 2001 From: Waldi Ravens Date: Mon, 20 Apr 2020 06:57:32 +0200 Subject: [PATCH] Formatting (whitespace only) --- libse/ContinuationUtilities.cs | 22 ++++++------- .../FixCommonErrors/FixContinuationStyle.cs | 14 ++++---- libse/LanguageStructure.cs | 4 +-- libse/SubtitleFormats/UnknownSubtitle94.cs | 2 +- libse/SubtitleFormats/UnknownSubtitle95.cs | 6 ++-- src/Forms/SettingsProfile.cs | 2 +- src/Logic/Ocr/Binary/BinaryOcrDb.cs | 2 +- .../Tesseract/TesseractMultiThreadRunner.cs | 2 +- src/Logic/UiUtil.cs | 4 --- src/Test/Logic/ContinuationUtilitiesTest.cs | 32 +++++++++---------- src/UpdateLanguageFiles/Program.cs | 2 +- 11 files changed, 44 insertions(+), 48 deletions(-) diff --git a/libse/ContinuationUtilities.cs b/libse/ContinuationUtilities.cs index 1cbc3783a..170f253b6 100644 --- a/libse/ContinuationUtilities.cs +++ b/libse/ContinuationUtilities.cs @@ -162,7 +162,7 @@ namespace Nikse.SubtitleEdit.Core checkString = checkString.Trim(); // Remove string elevation - if (checkString.EndsWith("\n_", StringComparison.Ordinal) || checkString.EndsWith("\n.", StringComparison.Ordinal) + if (checkString.EndsWith("\n_", StringComparison.Ordinal) || checkString.EndsWith("\n.", StringComparison.Ordinal) || checkString.EndsWith("\n _", StringComparison.Ordinal) || checkString.EndsWith("\n .", StringComparison.Ordinal) || checkString.EndsWith("\n _", StringComparison.Ordinal) || checkString.EndsWith("\n .", StringComparison.Ordinal) /* Alt+255 */) { @@ -226,7 +226,7 @@ namespace Nikse.SubtitleEdit.Core return firstWord; } - + public static string GetLastWord(string input) { // Return if empty string @@ -283,7 +283,7 @@ namespace Nikse.SubtitleEdit.Core { return originalText; } - + // Return if only suffix/prefix if (IsOnlySuffix(text, profile) || IsOnlyPrefix(text, profile)) { @@ -299,7 +299,7 @@ namespace Nikse.SubtitleEdit.Core // Make new last word string gapAddEnd = (profile.GapSuffixAddSpace ? " " : "") + profile.GapSuffix; - if (gapAddEnd.Length == 0 || !newLastWord.EndsWith(gapAddEnd)) { + if (gapAddEnd.Length == 0 || !newLastWord.EndsWith(gapAddEnd)) { newLastWord = newLastWord.TrimEnd(',') + ((lastWord.EndsWith(",") || addComma) && !profile.GapSuffixReplaceComma ? "," : "") + gapAddEnd; } } @@ -308,7 +308,7 @@ namespace Nikse.SubtitleEdit.Core // Make new last word string addEnd = (profile.SuffixAddSpace ? " " : "") + profile.Suffix; - if (addEnd.Length == 0 || !newLastWord.EndsWith(addEnd)) { + if (addEnd.Length == 0 || !newLastWord.EndsWith(addEnd)) { newLastWord = newLastWord.TrimEnd(',') + ((lastWord.EndsWith(",") || addComma) && !profile.SuffixReplaceComma ? "," : "") + addEnd; } } @@ -319,8 +319,8 @@ namespace Nikse.SubtitleEdit.Core if (wordIndex >= 0 && wordIndex < originalText.Length - 3) { int currentIndex = wordIndex + lastWord.TrimEnd(',').Length; - if (((currentIndex < originalText.Length && originalText[currentIndex] == '<') - || (currentIndex + 1 < originalText.Length && originalText[currentIndex + 1] == ',' && originalText[currentIndex] == '<')) + if (((currentIndex < originalText.Length && originalText[currentIndex] == '<') + || (currentIndex + 1 < originalText.Length && originalText[currentIndex + 1] == ',' && originalText[currentIndex] == '<')) && !IsFullLineTag(originalText, currentIndex)) { if (currentIndex < originalText.Length && originalText[currentIndex] == ',') @@ -404,7 +404,7 @@ namespace Nikse.SubtitleEdit.Core removeDashesDuringSanitization = false; } } - + string text = removeDashesDuringSanitization ? textWithoutDash : textWithDash; // Return if empty string @@ -626,7 +626,7 @@ namespace Nikse.SubtitleEdit.Core var prefix = firstWord.Replace(newFirstWord, ""); result = ReplaceFirstOccurrence(originalText, prefix, ""); } - + // Return original if empty string if (string.IsNullOrEmpty(result)) { @@ -794,7 +794,7 @@ namespace Nikse.SubtitleEdit.Core return true; } - + public static bool IsFullLineTag(string input, int position) { input = ExtractParagraphOnly(input); @@ -1250,4 +1250,4 @@ namespace Nikse.SubtitleEdit.Core public bool GapPrefixAddSpace { get; set; } } } -} \ No newline at end of file +} diff --git a/libse/Forms/FixCommonErrors/FixContinuationStyle.cs b/libse/Forms/FixCommonErrors/FixContinuationStyle.cs index 84538c2b7..c876fef40 100644 --- a/libse/Forms/FixCommonErrors/FixContinuationStyle.cs +++ b/libse/Forms/FixCommonErrors/FixContinuationStyle.cs @@ -24,7 +24,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors { this.SetContinuationProfile(Configuration.Settings.General.ContinuationStyle); } - + int minGapMs = ContinuationUtilities.GetMinimumGapMs(); bool inSentence = false; @@ -57,7 +57,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors } } - // ...and italic lyrics + // ...and italic lyrics if (Configuration.Settings.General.FixContinuationStyleUncheckInsertsItalic) { if (ContinuationUtilities.IsItalic(oldText) && !ContinuationUtilities.IsNewSentence(text, true) && inItalicSentence == false) @@ -85,10 +85,10 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors var oldTextNextWithoutPrefix = ContinuationUtilities.RemovePrefix(oldTextNext, _continuationProfile, true, gap); var textNextWithoutPrefix = ContinuationUtilities.SanitizeString(oldTextNextWithoutPrefix, true); - // Get last word of this paragraph + // Get last word of this paragraph string lastWord = ContinuationUtilities.GetLastWord(text); - + // If ends with dots (possible interruptions), or nothing, check if next sentence is new sentence, otherwise don't check by default if (text.EndsWith("..") || text.EndsWith("…") || ContinuationUtilities.EndsWithNothing(text, _continuationProfile)) { @@ -110,7 +110,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors } } } - + if (shouldProcess) { // First paragraph... @@ -125,7 +125,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors // Make new last word var newText = ContinuationUtilities.AddSuffixIfNeeded(oldTextWithoutSuffix, _continuationProfile, gap, addComma); - + // Commit if changed if (oldText != newText && callbacks.AllowFix(p, fixAction)) { @@ -211,7 +211,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors { return ContinuationUtilities.HasSuffix(input, this._continuationProfile); } - + private bool StartsWithName(string input, string language) { if (this._names == null) diff --git a/libse/LanguageStructure.cs b/libse/LanguageStructure.cs index c7943ea7c..744fcf9e8 100644 --- a/libse/LanguageStructure.cs +++ b/libse/LanguageStructure.cs @@ -2236,7 +2236,7 @@ public string GoToStartCurrent { get; set; } public string ToggleStartEndCurrent { get; set; } public string PlayCurrent { get; set; } - + public string WaveformGoToPrevSubtitle { get; set; } public string WaveformGoToNextSubtitle { get; set; } public string WaveformSelectNextSubtitle { get; set; } @@ -2327,7 +2327,7 @@ public string UncheckInsertsAllCaps { get; set; } public string UncheckInsertsItalic { get; set; } public string UncheckInsertsLowercase { get; set; } - public string HideContinuationCandidatesWithoutName { get; set; } + public string HideContinuationCandidatesWithoutName { get; set; } public string IgnoreLyrics { get; set; } } diff --git a/libse/SubtitleFormats/UnknownSubtitle94.cs b/libse/SubtitleFormats/UnknownSubtitle94.cs index 6d4b1a3c2..1381eaffc 100644 --- a/libse/SubtitleFormats/UnknownSubtitle94.cs +++ b/libse/SubtitleFormats/UnknownSubtitle94.cs @@ -19,7 +19,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats var sb = new StringBuilder(); foreach (var p in subtitle.Paragraphs) { - //0:13 0:14 I'm from Londrina, Paraná, Brasil. + //0:130:14I'm from Londrina, Paraná, Brasil. sb.AppendLine($"{EncodeTimeCode(p.StartTime)}\t{EncodeTimeCode(p.EndTime)}\t{HtmlUtil.RemoveHtmlTags(p.Text, true).Replace(Environment.NewLine, " ")}"); } return sb.ToString(); diff --git a/libse/SubtitleFormats/UnknownSubtitle95.cs b/libse/SubtitleFormats/UnknownSubtitle95.cs index 10d6baefc..bf74ee2a8 100644 --- a/libse/SubtitleFormats/UnknownSubtitle95.cs +++ b/libse/SubtitleFormats/UnknownSubtitle95.cs @@ -15,13 +15,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats public override string ToText(Subtitle subtitle, string title) { - //001 10:00:00.22 10:00:04.22 00:00:04.00 #F CC00000D0 #C + //00110:00:00.2210:00:04.2200:00:04.00#F CC00000D0#C //Studio presents - //002 10:00:13.02 10:00:15.22 00:00:02.20 #F CC00000D0 #C + //002 10:00:13.02 10:00:15.22 00:00:02.20#F CC00000D0#C //What does my stuff //mean to me ? - const string writeFormat = "{0:000} {1} {2} {3} #F CC00000D0 #C{4}{5}"; + const string writeFormat = "{0:000} {1} {2} {3}\t#F CC00000D0\t#C{4}{5}"; var sb = new StringBuilder(); for (var index = 0; index < subtitle.Paragraphs.Count; index++) { diff --git a/src/Forms/SettingsProfile.cs b/src/Forms/SettingsProfile.cs index 6044b0483..12a855c96 100644 --- a/src/Forms/SettingsProfile.cs +++ b/src/Forms/SettingsProfile.cs @@ -295,7 +295,7 @@ namespace Nikse.SubtitleEdit.Forms comboBoxContinuationStyle.SelectedIndex = 0; toolTipContinuationPreview.RemoveAll(); toolTipContinuationPreview.SetToolTip(comboBoxContinuationStyle, ContinuationUtilities.GetContinuationStylePreview(RulesProfiles[idx].ContinuationStyle)); - comboBoxContinuationStyle.SelectedIndex = ContinuationUtilities.GetIndexFromContinuationStyle(RulesProfiles[idx].ContinuationStyle); + comboBoxContinuationStyle.SelectedIndex = ContinuationUtilities.GetIndexFromContinuationStyle(RulesProfiles[idx].ContinuationStyle); _editOn = oldEditOn; } diff --git a/src/Logic/Ocr/Binary/BinaryOcrDb.cs b/src/Logic/Ocr/Binary/BinaryOcrDb.cs index 6b9543040..581f284c6 100644 --- a/src/Logic/Ocr/Binary/BinaryOcrDb.cs +++ b/src/Logic/Ocr/Binary/BinaryOcrDb.cs @@ -248,7 +248,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr.Binary string s = Path.GetFileNameWithoutExtension(dir); list.Add(s); } - return list.OrderBy(p=>p).ToList(); + return list.OrderBy(p => p).ToList(); } } diff --git a/src/Logic/Ocr/Tesseract/TesseractMultiThreadRunner.cs b/src/Logic/Ocr/Tesseract/TesseractMultiThreadRunner.cs index 47a9e7535..88b10e5b8 100644 --- a/src/Logic/Ocr/Tesseract/TesseractMultiThreadRunner.cs +++ b/src/Logic/Ocr/Tesseract/TesseractMultiThreadRunner.cs @@ -33,7 +33,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr.Tesseract var jobs = (List)j; var job = jobs.First(); - var results = _tesseractRunner.Run(job.LanguageCode, job.PsmMode, job.EngineMode, jobs.Select(p=>p.FileName).ToList(), job.Run302); + var results = _tesseractRunner.Run(job.LanguageCode, job.PsmMode, job.EngineMode, jobs.Select(p => p.FileName).ToList(), job.Run302); lock (QueueLock) { diff --git a/src/Logic/UiUtil.cs b/src/Logic/UiUtil.cs index f2cfd829b..96ce629aa 100644 --- a/src/Logic/UiUtil.cs +++ b/src/Logic/UiUtil.cs @@ -445,7 +445,6 @@ namespace Nikse.SubtitleEdit.Logic } } - private static Font _defaultSystemFont; private static Font DefaultSystemFont { @@ -593,9 +592,6 @@ namespace Nikse.SubtitleEdit.Logic c.Font = GetDefaultFont(); } - - - foreach (Control inner in c.Controls) { FixFontsInner(inner, iterations - 1); diff --git a/src/Test/Logic/ContinuationUtilitiesTest.cs b/src/Test/Logic/ContinuationUtilitiesTest.cs index d3d3b7aa8..9f11d266a 100644 --- a/src/Test/Logic/ContinuationUtilitiesTest.cs +++ b/src/Test/Logic/ContinuationUtilitiesTest.cs @@ -89,7 +89,7 @@ namespace Test.Logic string line1Expected = "...this is a test." + Environment.NewLine + "- Another test..."; Assert.AreEqual(line1Expected, line1Actual); } - + [TestMethod] public void SanitizeString8() { @@ -361,7 +361,7 @@ namespace Test.Logic string line1Expected = "This is a test..."; Assert.AreEqual(line1Expected, line1Actual); } - + [TestMethod] public void AddSuffixIfNeeded9() { @@ -481,7 +481,7 @@ namespace Test.Logic string line1Expected = "..."; Assert.AreEqual(line1Expected, line1Actual); } - + [TestMethod] public void AddSuffixIfNeeded15() { @@ -491,7 +491,7 @@ namespace Test.Logic string line1Expected = "妈..."; Assert.AreEqual(line1Expected, line1Actual); } - + [TestMethod] public void AddSuffixIfNeeded16() { @@ -601,7 +601,7 @@ namespace Test.Logic string line1Expected = "- this is a test." + Environment.NewLine + "-A what do you say?"; Assert.AreEqual(line1Expected, line1Actual); } - + [TestMethod] public void AddPrefixIfNeeded8() { @@ -641,7 +641,7 @@ namespace Test.Logic string line1Expected = "- ...this is a test." + Environment.NewLine + "- Okay."; Assert.AreEqual(line1Expected, line1Actual); } - + [TestMethod] public void AddPrefixIfNeeded10() { @@ -741,7 +741,7 @@ namespace Test.Logic string line1Expected = "This is a test" + Environment.NewLine + " " + Environment.NewLine + "_"; Assert.AreEqual(line1Expected, line1Actual); } - + [TestMethod] public void RemoveSuffix2() { @@ -861,7 +861,7 @@ namespace Test.Logic string line1Expected = "this is a test." + Environment.NewLine + " " + Environment.NewLine + "_"; Assert.AreEqual(line1Expected, line1Actual); } - + [TestMethod] public void RemovePrefix4() { @@ -945,7 +945,7 @@ namespace Test.Logic bool line1Actual = ContinuationUtilities.IsNewSentence(line1); Assert.IsTrue(line1Actual); } - + [TestMethod] public void IsNewSentence4() { @@ -1009,7 +1009,7 @@ namespace Test.Logic bool line1Actual = ContinuationUtilities.IsEndOfSentence(line1); Assert.IsTrue(line1Actual); } - + [TestMethod] public void IsEndOfSentence3() { @@ -1025,7 +1025,7 @@ namespace Test.Logic bool line1Actual = ContinuationUtilities.IsEndOfSentence(line1); Assert.IsTrue(line1Actual); } - + [TestMethod] public void IsEndOfSentence5() { @@ -1049,7 +1049,7 @@ namespace Test.Logic bool line1Actual = ContinuationUtilities.IsEndOfSentence(line1); Assert.IsFalse(line1Actual); } - + [TestMethod] public void IsEndOfSentence8() { @@ -1114,7 +1114,7 @@ namespace Test.Logic bool line1Actual = ContinuationUtilities.EndsWithNothing(line1, profile); Assert.IsTrue(line1Actual); } - + [TestMethod] public void EndsWithNothing2() { @@ -1627,7 +1627,7 @@ namespace Test.Logic bool line1Actual = ContinuationUtilities.HasSuffix(line1, profile); Assert.IsFalse(line1Actual); } - + [TestMethod] public void IsOnlySuffix1() { @@ -1645,7 +1645,7 @@ namespace Test.Logic bool line1Actual = ContinuationUtilities.IsOnlySuffix(line1, profile); Assert.IsTrue(line1Actual); } - + [TestMethod] public void IsOnlySuffix3() { @@ -1771,7 +1771,7 @@ namespace Test.Logic Assert.AreEqual(line1Expected, line1Actual); Assert.AreEqual(line2Expected, line2Actual); } - + [TestMethod] public void MergeHelper2() { diff --git a/src/UpdateLanguageFiles/Program.cs b/src/UpdateLanguageFiles/Program.cs index a5d66bb86..198f6c7b0 100644 --- a/src/UpdateLanguageFiles/Program.cs +++ b/src/UpdateLanguageFiles/Program.cs @@ -70,7 +70,7 @@ namespace UpdateLanguageFiles { File.WriteAllText(args[1], languageDeserializerContent, Encoding.UTF8); } - catch + catch { System.Threading.Thread.Sleep(100); File.WriteAllText(args[1], languageDeserializerContent, Encoding.UTF8);