Add more variations of line-length in export custom sub - thx Irene :)

This commit is contained in:
niksedk 2022-03-07 21:09:25 +01:00
parent 037d8b441e
commit 2820ecba67
2 changed files with 53 additions and 25 deletions

View File

@ -55,6 +55,9 @@
this.tabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.textline2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cpsperiodToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cpsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textlengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.labelHeader = new System.Windows.Forms.Label();
this.textBoxHeader = new System.Windows.Forms.TextBox();
this.contextMenuStripHeader = new System.Windows.Forms.ContextMenuStrip(this.components);
@ -65,9 +68,8 @@
this.buttonOK = new System.Windows.Forms.Button();
this.groupBoxPreview = new System.Windows.Forms.GroupBox();
this.textBoxPreview = new System.Windows.Forms.TextBox();
this.cpsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textlengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cpsperiodToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textlengthnobrToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textlengthbr1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBoxTemplate.SuspendLayout();
this.contextMenuStripFooter.SuspendLayout();
this.contextMenuStripParagraph.SuspendLayout();
@ -256,9 +258,12 @@
this.textline2ToolStripMenuItem,
this.cpsperiodToolStripMenuItem,
this.cpsToolStripMenuItem,
this.textlengthToolStripMenuItem});
this.textlengthToolStripMenuItem,
this.textlengthnobrToolStripMenuItem,
this.textlengthbr1ToolStripMenuItem});
this.contextMenuStripParagraph.Name = "contextMenuStrip1";
this.contextMenuStripParagraph.Size = new System.Drawing.Size(147, 290);
this.contextMenuStripParagraph.Size = new System.Drawing.Size(181, 356);
this.contextMenuStripParagraph.Text = "{text-length-br1}";
//
// insertHHMMSSMSToolStripMenuItem
//
@ -330,6 +335,27 @@
this.textline2ToolStripMenuItem.Text = "{text-line-2}";
this.textline2ToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// cpsperiodToolStripMenuItem
//
this.cpsperiodToolStripMenuItem.Name = "cpsperiodToolStripMenuItem";
this.cpsperiodToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.cpsperiodToolStripMenuItem.Text = "{cps-period}";
this.cpsperiodToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// cpsToolStripMenuItem
//
this.cpsToolStripMenuItem.Name = "cpsToolStripMenuItem";
this.cpsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.cpsToolStripMenuItem.Text = "{cps-comma}";
this.cpsToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// textlengthToolStripMenuItem
//
this.textlengthToolStripMenuItem.Name = "textlengthToolStripMenuItem";
this.textlengthToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.textlengthToolStripMenuItem.Text = "{text-length}";
this.textlengthToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// labelHeader
//
this.labelHeader.AutoSize = true;
@ -426,26 +452,19 @@
this.textBoxPreview.Size = new System.Drawing.Size(340, 374);
this.textBoxPreview.TabIndex = 0;
//
// cpsToolStripMenuItem
// textlengthnobrToolStripMenuItem
//
this.cpsToolStripMenuItem.Name = "cpsToolStripMenuItem";
this.cpsToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
this.cpsToolStripMenuItem.Text = "{cps-comma}";
this.cpsToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
this.textlengthnobrToolStripMenuItem.Name = "textlengthnobrToolStripMenuItem";
this.textlengthnobrToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.textlengthnobrToolStripMenuItem.Text = "{text-length-br0}";
this.textlengthnobrToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// textlengthToolStripMenuItem
// textlengthbr1ToolStripMenuItem
//
this.textlengthToolStripMenuItem.Name = "textlengthToolStripMenuItem";
this.textlengthToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
this.textlengthToolStripMenuItem.Text = "{text-length}";
this.textlengthToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// cpsperiodToolStripMenuItem
//
this.cpsperiodToolStripMenuItem.Name = "cpsperiodToolStripMenuItem";
this.cpsperiodToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
this.cpsperiodToolStripMenuItem.Text = "{cps-period}";
this.cpsperiodToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
this.textlengthbr1ToolStripMenuItem.Name = "textlengthbr1ToolStripMenuItem";
this.textlengthbr1ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.textlengthbr1ToolStripMenuItem.Text = "{text-length-br1}";
this.textlengthbr1ToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// ExportCustomTextFormat
//
@ -518,5 +537,7 @@
private System.Windows.Forms.ToolStripMenuItem cpsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem textlengthToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem cpsperiodToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem textlengthnobrToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem textlengthbr1ToolStripMenuItem;
}
}

View File

@ -117,6 +117,8 @@ namespace Nikse.SubtitleEdit.Forms
s = s.Replace("{cps-comma}", "{10}");
s = s.Replace("{cps-period}", "{11}");
s = s.Replace("{text-length}", "{12}");
s = s.Replace("{text-length-br0}", "{13}");
s = s.Replace("{text-length-br1}", "{14}");
s = s.Replace("{tab}", "\t");
return s;
}
@ -311,7 +313,7 @@ namespace Nikse.SubtitleEdit.Forms
internal static string GetParagraph(string template, string start, string end, string text, string translation, int number, string actor, TimeCode duration, string timeCodeTemplate, double cps)
{
string d = duration.ToString();
var d = duration.ToString();
if (timeCodeTemplate == "ff" || timeCodeTemplate == "f")
{
d = SubtitleFormat.MillisecondsToFrames(duration.TotalMilliseconds).ToString(CultureInfo.InvariantCulture);
@ -388,10 +390,15 @@ namespace Nikse.SubtitleEdit.Forms
line2 = lines[1];
}
string s = template;
var s = template;
s = s.Replace("{{", "@@@@_@@@{");
s = s.Replace("}}", "}@@@_@@@@");
s = string.Format(s, start, end, text, translation, number + 1, number, d, actor, line1, line2, cps.ToString(CultureInfo.InvariantCulture).Replace(".", ","), cps.ToString(CultureInfo.InvariantCulture), text.Length);
s = string.Format(s, start, end, text, translation, number + 1, number, d, actor, line1, line2,
cps.ToString(CultureInfo.InvariantCulture).Replace(".", ","),
cps.ToString(CultureInfo.InvariantCulture),
text.Length,
text.RemoveChar('\r','\n').Length,
text.RemoveChar('\r', '\n').Length + lines.Count -1);
s = s.Replace("@@@@_@@@", "{");
s = s.Replace("@@@_@@@@", "}");
return s;