2020-04-15 13:03:48 +02:00
|
|
|
|
using Nikse.SubtitleEdit.Core.Enums;
|
|
|
|
|
using System;
|
2020-02-16 08:08:19 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Nikse.SubtitleEdit.Core
|
|
|
|
|
{
|
|
|
|
|
public class DialogSplitMerge
|
|
|
|
|
{
|
|
|
|
|
public DialogType DialogStyle { get; set; }
|
2020-04-01 19:27:20 +02:00
|
|
|
|
public ContinuationStyle ContinuationStyle { get; set; }
|
2020-04-17 09:12:20 +02:00
|
|
|
|
public string TwoLetterLanguageCode { get; set; }
|
2020-04-17 09:17:30 +02:00
|
|
|
|
public bool SkipLineEndingCheck { get; set; }
|
2020-04-17 09:12:20 +02:00
|
|
|
|
|
|
|
|
|
private static char GetDashChar() => '-';
|
|
|
|
|
private static char GetAlternateDashChar() => '‐'; // Unicode En Dash (\u2010)
|
2020-02-16 08:08:19 +01:00
|
|
|
|
|
|
|
|
|
public string FixDashesAndSpaces(string input)
|
|
|
|
|
{
|
|
|
|
|
return FixSpaces(FixDashes(input));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string FixSpaces(string input)
|
|
|
|
|
{
|
|
|
|
|
var lines = input.SplitToLines();
|
|
|
|
|
if (!IsDialog(lines))
|
|
|
|
|
{
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < lines.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var l = lines[i];
|
|
|
|
|
var pre = GetStartTags(l);
|
|
|
|
|
l = l.Remove(0, pre.Length);
|
|
|
|
|
switch (DialogStyle)
|
|
|
|
|
{
|
|
|
|
|
case DialogType.DashBothLinesWithSpace:
|
|
|
|
|
if (l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
|
|
|
|
var rest = l.Remove(0, l.IndexOf(GetDashChar()) + 1);
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + rest.TrimStart());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DialogType.DashSecondLineWithSpace:
|
|
|
|
|
if (i > 0 && l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
|
|
|
|
var rest = l.Remove(0, l.IndexOf(GetDashChar()) + 1);
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + rest.TrimStart());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DialogType.DashBothLinesWithoutSpace:
|
|
|
|
|
if (l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
|
|
|
|
var rest = l.Remove(0, l.IndexOf(GetDashChar()) + 1);
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + rest.TrimStart());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DialogType.DashSecondLineWithoutSpace:
|
|
|
|
|
if (i > 0 && l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
|
|
|
|
var rest = l.Remove(0, l.IndexOf(GetDashChar()) + 1);
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + rest.TrimStart());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2020-02-16 13:03:01 +01:00
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sb.ToString().TrimEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string AddSpaces(string input)
|
|
|
|
|
{
|
|
|
|
|
var lines = input.SplitToLines();
|
|
|
|
|
if (!IsDialog(lines))
|
|
|
|
|
{
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < lines.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var l = lines[i];
|
|
|
|
|
var pre = GetStartTags(l);
|
|
|
|
|
l = l.Remove(0, pre.Length);
|
|
|
|
|
switch (DialogStyle)
|
|
|
|
|
{
|
|
|
|
|
case DialogType.DashBothLinesWithSpace:
|
|
|
|
|
if (l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
|
|
|
|
var rest = l.Remove(0, l.IndexOf(GetDashChar()) + 1);
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + rest.TrimStart());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DialogType.DashSecondLineWithSpace:
|
|
|
|
|
if (i > 0 && l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
|
|
|
|
var rest = l.Remove(0, l.IndexOf(GetDashChar()) + 1);
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + rest.TrimStart());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sb.ToString().TrimEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string RemoveSpaces(string input)
|
|
|
|
|
{
|
|
|
|
|
var lines = input.SplitToLines();
|
|
|
|
|
if (!IsDialog(lines))
|
|
|
|
|
{
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < lines.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var l = lines[i];
|
|
|
|
|
var pre = GetStartTags(l);
|
|
|
|
|
l = l.Remove(0, pre.Length);
|
|
|
|
|
switch (DialogStyle)
|
|
|
|
|
{
|
|
|
|
|
case DialogType.DashBothLinesWithSpace:
|
|
|
|
|
case DialogType.DashSecondLineWithSpace:
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
break;
|
|
|
|
|
case DialogType.DashBothLinesWithoutSpace:
|
|
|
|
|
if (l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
|
|
|
|
var rest = l.Remove(0, l.IndexOf(GetDashChar()) + 1);
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + rest.TrimStart());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DialogType.DashSecondLineWithoutSpace:
|
|
|
|
|
if (i > 0 && l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
|
|
|
|
var rest = l.Remove(0, l.IndexOf(GetDashChar()) + 1);
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + rest.TrimStart());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2020-02-16 14:10:31 +01:00
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sb.ToString().TrimEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string FixDashes(string input)
|
|
|
|
|
{
|
|
|
|
|
var lines = input.SplitToLines();
|
|
|
|
|
if (!IsDialog(lines))
|
|
|
|
|
{
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-07 17:17:25 +01:00
|
|
|
|
var isDialogThreeLinesTwoOne = lines.Count == 3 && IsDialogThreeLinesTwoOne(lines[0], lines[1], lines[2]);
|
|
|
|
|
var isDialogThreeLinesOneTwo = lines.Count == 3 && IsDialogThreeLinesOneTwo(lines[0], lines[1], lines[2]);
|
|
|
|
|
|
2020-02-16 08:08:19 +01:00
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < lines.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var l = lines[i];
|
|
|
|
|
var pre = GetStartTags(l);
|
|
|
|
|
l = l.Remove(0, pre.Length);
|
|
|
|
|
switch (DialogStyle)
|
|
|
|
|
{
|
|
|
|
|
case DialogType.DashBothLinesWithSpace:
|
2020-03-07 17:17:25 +01:00
|
|
|
|
if (isDialogThreeLinesTwoOne && i == 1 || isDialogThreeLinesOneTwo && i == 2)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
else if (!l.TrimStart().StartsWith(GetDashChar()))
|
2020-02-16 08:08:19 +01:00
|
|
|
|
{
|
2020-02-16 15:54:45 +01:00
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + l.TrimStart().TrimStart(GetAlternateDashChar()));
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DialogType.DashSecondLineWithSpace:
|
|
|
|
|
if (i > 0 && !l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
2020-03-07 17:31:28 +01:00
|
|
|
|
if (isDialogThreeLinesTwoOne && i == 1 || isDialogThreeLinesOneTwo && i == 2)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + l.TrimStart().TrimStart(GetAlternateDashChar()));
|
|
|
|
|
}
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
else if (i == 0 && l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + l.Remove(0, l.IndexOf(GetDashChar()) + 1).TrimStart());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DialogType.DashBothLinesWithoutSpace:
|
2020-03-07 17:31:28 +01:00
|
|
|
|
if (isDialogThreeLinesTwoOne && i == 1 || isDialogThreeLinesOneTwo && i == 2)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
else if (!l.TrimStart().StartsWith(GetDashChar()))
|
2020-02-16 08:08:19 +01:00
|
|
|
|
{
|
2020-02-16 15:54:45 +01:00
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + l.TrimStart().TrimStart(GetAlternateDashChar()));
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DialogType.DashSecondLineWithoutSpace:
|
|
|
|
|
if (i > 0 && !l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
2020-03-07 17:31:28 +01:00
|
|
|
|
if (isDialogThreeLinesTwoOne && i == 1 || isDialogThreeLinesOneTwo && i == 2)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + l.TrimStart().TrimStart(GetAlternateDashChar()));
|
|
|
|
|
}
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
else if (i == 0 && l.TrimStart().StartsWith(GetDashChar()))
|
|
|
|
|
{
|
2020-02-16 15:54:45 +01:00
|
|
|
|
sb.AppendLine(pre + GetLineStartFromDashStyle(i) + l.Remove(0, l.IndexOf(GetDashChar()) + 1).TrimStart().TrimStart(GetAlternateDashChar()));
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(pre + l);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2020-02-16 09:15:33 +01:00
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sb.ToString().TrimEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string InsertStartDash(string input, int lineIndex)
|
|
|
|
|
{
|
|
|
|
|
var pre = GetStartTags(input);
|
|
|
|
|
var s = input.Remove(0, pre.Length);
|
|
|
|
|
|
2020-02-16 21:07:56 +01:00
|
|
|
|
if (string.IsNullOrEmpty(s))
|
|
|
|
|
{
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-16 08:08:19 +01:00
|
|
|
|
if (s.StartsWith(GetDashChar()))
|
|
|
|
|
{
|
|
|
|
|
s = s.TrimStart(GetDashChar());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pre + GetLineStartFromDashStyle(lineIndex) + s.TrimStart();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string RemoveStartDash(string input)
|
|
|
|
|
{
|
|
|
|
|
var pre = GetStartTags(input);
|
|
|
|
|
var s = input.Remove(0, pre.Length);
|
|
|
|
|
|
2020-02-18 18:29:48 +01:00
|
|
|
|
if (!s.TrimStart().StartsWith(GetDashChar()) && !s.TrimStart().StartsWith(GetAlternateDashChar()))
|
2020-02-16 08:08:19 +01:00
|
|
|
|
{
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-16 15:54:45 +01:00
|
|
|
|
return pre + s.TrimStart().TrimStart(GetDashChar(), GetAlternateDashChar()).TrimStart();
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 21:41:35 +01:00
|
|
|
|
public static DialogType GetDialogStyleFromIndex(int index)
|
|
|
|
|
{
|
|
|
|
|
switch (index)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
return DialogType.DashBothLinesWithoutSpace;
|
|
|
|
|
case 2:
|
|
|
|
|
return DialogType.DashSecondLineWithSpace;
|
|
|
|
|
case 3:
|
|
|
|
|
return DialogType.DashSecondLineWithoutSpace;
|
|
|
|
|
default:
|
|
|
|
|
return DialogType.DashBothLinesWithSpace;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-15 13:03:48 +02:00
|
|
|
|
|
2020-02-16 08:08:19 +01:00
|
|
|
|
private static string GetStartTags(string input)
|
|
|
|
|
{
|
2020-02-16 13:03:01 +01:00
|
|
|
|
var pre = new StringBuilder();
|
2020-02-16 08:08:19 +01:00
|
|
|
|
var s = input;
|
|
|
|
|
if (s.StartsWith("{\\") && s.Contains('}'))
|
|
|
|
|
{
|
2020-02-16 13:03:01 +01:00
|
|
|
|
pre.Append(s.Substring(0, s.IndexOf('}') + 1));
|
2020-02-16 08:08:19 +01:00
|
|
|
|
s = s.Remove(0, pre.Length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (s.StartsWith("<") && s.Contains('>'))
|
|
|
|
|
{
|
|
|
|
|
var htmlPre = s.Substring(0, s.IndexOf('>') + 1);
|
|
|
|
|
s = s.Remove(0, htmlPre.Length);
|
2020-02-16 13:03:01 +01:00
|
|
|
|
pre.Append(htmlPre);
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-16 13:03:01 +01:00
|
|
|
|
return pre.ToString();
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-24 09:23:23 +01:00
|
|
|
|
public bool IsDialog(List<string> lines)
|
2020-02-16 08:08:19 +01:00
|
|
|
|
{
|
|
|
|
|
if (lines.Count < 2 || lines.Count > 3)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-16 15:54:45 +01:00
|
|
|
|
var l0 = HtmlUtil.RemoveHtmlTags(lines[0]);
|
2020-02-16 08:08:19 +01:00
|
|
|
|
var l1 = HtmlUtil.RemoveHtmlTags(lines[1], true);
|
2020-04-17 09:17:30 +02:00
|
|
|
|
var noLineEnding = SkipLineEndingCheck || LanguageAutoDetect.IsLanguageWithoutPeriods(TwoLetterLanguageCode);
|
2020-02-16 08:08:19 +01:00
|
|
|
|
|
2020-04-17 09:12:20 +02:00
|
|
|
|
if (lines.Count == 2 && (l0.HasSentenceEnding(TwoLetterLanguageCode) || noLineEnding) && (l1.TrimStart().StartsWith(GetDashChar()) || l1.TrimStart().StartsWith(GetAlternateDashChar())))
|
2020-02-16 08:08:19 +01:00
|
|
|
|
{
|
2020-04-15 13:03:48 +02:00
|
|
|
|
return true;
|
2020-02-16 08:08:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lines.Count == 3)
|
|
|
|
|
{
|
|
|
|
|
var l2 = HtmlUtil.RemoveHtmlTags(lines[2], true);
|
|
|
|
|
|
|
|
|
|
// - I'm fine today, but I would have
|
|
|
|
|
// been better if I had a some candy.
|
|
|
|
|
// - How are you?
|
2020-03-07 17:17:25 +01:00
|
|
|
|
if (IsDialogThreeLinesTwoOne(l0, l1, l2))
|
2020-02-16 08:08:19 +01:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// - How are you?
|
|
|
|
|
// - I'm fine today, but I would have
|
|
|
|
|
// been better if I had a some candy.
|
2020-03-07 17:17:25 +01:00
|
|
|
|
if (IsDialogThreeLinesOneTwo(l0, l1, l2))
|
2020-02-16 21:07:56 +01:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-17 09:12:20 +02:00
|
|
|
|
if ((l0.HasSentenceEnding(TwoLetterLanguageCode) || noLineEnding) &&
|
2020-02-16 21:07:56 +01:00
|
|
|
|
(l1.TrimStart().StartsWith(GetDashChar()) || l1.TrimStart().StartsWith(GetAlternateDashChar())) &&
|
2020-04-17 09:12:20 +02:00
|
|
|
|
(l1.HasSentenceEnding(TwoLetterLanguageCode) || noLineEnding) &&
|
2020-02-16 21:07:56 +01:00
|
|
|
|
(l2.TrimStart().StartsWith(GetDashChar()) || l2.TrimStart().StartsWith(GetAlternateDashChar())))
|
2020-02-16 08:08:19 +01:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-17 09:12:20 +02:00
|
|
|
|
private bool IsDialogThreeLinesOneTwo(string l0, string l1, string l2)
|
2020-03-07 17:17:25 +01:00
|
|
|
|
{
|
2020-04-17 09:12:20 +02:00
|
|
|
|
return l0.HasSentenceEnding(TwoLetterLanguageCode) &&
|
2020-04-15 13:03:48 +02:00
|
|
|
|
(l1.TrimStart().StartsWith(GetDashChar()) || l1.TrimStart().StartsWith(GetAlternateDashChar())) &&
|
2020-04-17 09:12:20 +02:00
|
|
|
|
!l1.HasSentenceEnding(TwoLetterLanguageCode) &&
|
2020-04-15 13:03:48 +02:00
|
|
|
|
!(l2.TrimStart().StartsWith(GetDashChar()) || l2.TrimStart().StartsWith(GetAlternateDashChar()));
|
2020-03-07 17:17:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-17 09:12:20 +02:00
|
|
|
|
private bool IsDialogThreeLinesTwoOne(string l0, string l1, string l2)
|
2020-03-07 17:17:25 +01:00
|
|
|
|
{
|
2020-04-17 09:12:20 +02:00
|
|
|
|
return !l0.HasSentenceEnding(TwoLetterLanguageCode) &&
|
|
|
|
|
l1.HasSentenceEnding(TwoLetterLanguageCode) &&
|
2020-04-15 13:03:48 +02:00
|
|
|
|
!(l1.TrimStart().StartsWith(GetDashChar()) || l1.TrimStart().StartsWith(GetAlternateDashChar())) &&
|
|
|
|
|
(l2.TrimStart().StartsWith(GetDashChar())) || l2.TrimStart().StartsWith(GetAlternateDashChar());
|
2020-03-07 17:17:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-16 08:08:19 +01:00
|
|
|
|
private string GetLineStartFromDashStyle(int lineIndex)
|
|
|
|
|
{
|
|
|
|
|
switch (DialogStyle)
|
|
|
|
|
{
|
|
|
|
|
case DialogType.DashBothLinesWithSpace:
|
2020-02-16 15:54:45 +01:00
|
|
|
|
return GetDashChar() + " ";
|
2020-02-16 08:08:19 +01:00
|
|
|
|
case DialogType.DashBothLinesWithoutSpace:
|
2020-02-16 15:54:45 +01:00
|
|
|
|
return GetDashChar().ToString();
|
2020-02-16 08:08:19 +01:00
|
|
|
|
case DialogType.DashSecondLineWithSpace:
|
2020-02-16 15:54:45 +01:00
|
|
|
|
return lineIndex == 0 ? string.Empty : GetDashChar() + " ";
|
2020-02-16 08:08:19 +01:00
|
|
|
|
case DialogType.DashSecondLineWithoutSpace:
|
2020-02-16 15:54:45 +01:00
|
|
|
|
return lineIndex == 0 ? string.Empty : GetDashChar().ToString();
|
2020-02-16 08:08:19 +01:00
|
|
|
|
default:
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|