Work on ASSA tag helper

This commit is contained in:
Nikolaj Olsson 2021-06-14 07:43:11 +02:00
parent d26298bcd0
commit 0484a39373
4 changed files with 52 additions and 19 deletions

View File

@ -2,8 +2,8 @@
3.6.2 BETA (xth July 2021)
* NEW:
* Keep ASSA tags (no html for italic/font etc.)
* ASSA tag helper/intellisense shortcut
* Keep ASSA override tags (no html for italic/font etc. in text box)
* ASSA override tag helper (shortcut + custom templates)
* Shortcuts for video contrast/brightness (mpv only)
* Waveform "Right-click + Ctrl" will toggle select of a subtitle
* Waveform "Right-click + Shift" will select a range subtitles
@ -15,7 +15,6 @@
* Update Polish translation - thx admas
* Update Portuguese translation - thx hugok79
* Update Hungarian translation - thx Zityi
* Use ngen64 on 64-bit - thx XhmikosR
* ASSA: Support for ScalingX/ScalingY/Spacing/Angle/Strikeout - thx ausencia
* MPC: Try to search for mpc-be too - thx Fábio
* Shortcut F5 is now "Play selected lines"
@ -24,7 +23,8 @@
* Try to pick best image for bdsup with fading - thx peter-qgd
* Adhere to max number of lines - thx Andrebavila
* Optimize "modify selection - styles"
* Update installer from Inno Setup version 5 to version 6
* Installer: Update Inno Setup from version 5 to version 6
* Installer: Use ngen64 on 64-bit - thx XhmikosR
* FIXED:
* Fix load/save some ASSA storage style settings - thx Andrebavila
* Fix for italic in DCinemaSmpte2007/2010/2014 - thx Marko

View File

@ -6781,6 +6781,26 @@ namespace Nikse.SubtitleEdit.Forms
private void HelpToolStripMenuItem1Click(object sender, EventArgs e)
{
if (_intellisenceList != null && _intellisenceList.Focused)
{
var item = _intellisenceList.Items[_intellisenceList.SelectedIndex] as AssaTagHelper.IntellisenseItem;
if (item != null && !string.IsNullOrEmpty(item.HelpLink))
{
UiUtil.OpenUrl(item.HelpLink);
}
return;
}
if (_intellisenceListOriginal != null && _intellisenceListOriginal.Focused)
{
var item = _intellisenceListOriginal.Items[_intellisenceListOriginal.SelectedIndex] as AssaTagHelper.IntellisenseItem;
if (item != null && !string.IsNullOrEmpty(item.HelpLink))
{
UiUtil.OpenUrl(item.HelpLink);
}
return;
}
ReloadFromSourceView();
UiUtil.ShowHelp(string.Empty);
}

View File

@ -19,12 +19,14 @@ namespace Nikse.SubtitleEdit.Logic
public string TypedWord { get; set; }
public string ActiveTagAtCursor { get; set; }
public Font Font { get; set; }
public string HelpLink { get; set; }
public IntellisenseItem(string value, string hint, bool allowInTransformations)
public IntellisenseItem(string value, string hint, bool allowInTransformations, string helpLink = null)
{
Value = value;
Hint = hint;
AllowInTransformations = allowInTransformations;
HelpLink = helpLink;
}
public override string ToString()
@ -50,17 +52,17 @@ namespace Nikse.SubtitleEdit.Logic
private static readonly List<IntellisenseItem> Keywords = new List<IntellisenseItem>
{
new IntellisenseItem("{\\i1}", "Italic on", false),
new IntellisenseItem("{\\i0}", "Italic off", false),
new IntellisenseItem("{\\i1}", "Italic on", false, "https://www.nikse.dk/SubtitleEdit/AssaOverrideTags#italic"),
new IntellisenseItem("{\\i0}", "Italic off", false,"https://www.nikse.dk/SubtitleEdit/AssaOverrideTags#italic"),
new IntellisenseItem("{\\b1}", "Bold on", false),
new IntellisenseItem("{\\b0}", "Bold off", false),
new IntellisenseItem("{\\b1}", "Bold on", false,"https://www.nikse.dk/SubtitleEdit/AssaOverrideTags#bold"),
new IntellisenseItem("{\\b0}", "Bold off", false,"https://www.nikse.dk/SubtitleEdit/AssaOverrideTags#bold"),
new IntellisenseItem("{\\u1}", "Underline on", false),
new IntellisenseItem("{\\u0}", "Underline off", false),
new IntellisenseItem("{\\u1}", "Underline on", false,"https://www.nikse.dk/SubtitleEdit/AssaOverrideTags#underline"),
new IntellisenseItem("{\\u0}", "Underline off", false,"https://www.nikse.dk/SubtitleEdit/AssaOverrideTags#underline"),
new IntellisenseItem("{\\s1}", "Strikeout on", false),
new IntellisenseItem("{\\s0}", "Strikeout off", false),
new IntellisenseItem("{\\s1}", "Strikeout on", false,"https://www.nikse.dk/SubtitleEdit/AssaOverrideTags#strikeout"),
new IntellisenseItem("{\\s0}", "Strikeout off", false,"https://www.nikse.dk/SubtitleEdit/AssaOverrideTags#strikeout"),
new IntellisenseItem("{\\mov(x1,y1,x2,y2,start,end)}", "Move", false),
new IntellisenseItem("{\\pos(x,y)}", "Set position", false),
@ -172,13 +174,20 @@ namespace Nikse.SubtitleEdit.Logic
}
else
{
tb.SelectedText = item.Value;
if (tb.SelectionStart > 0 && tb.Text[tb.SelectionStart-1] == '}' && item.Value.StartsWith('\\'))
{
tb.SelectedText = "{" + item.Value;
}
else
{
tb.SelectedText = item.Value;
}
}
var newStart = oldStart + item.Value.Length;
// merge tags before/after
var subtract = MergeTagAtCursor(tb, oldStart);
subtract += MergeTagAtCursor(tb, newStart);
var subtract = MergeTagAtCursor(tb, oldStart, true);
subtract += MergeTagAtCursor(tb, newStart, false);
tb.SelectionStart = newStart - subtract - item.TypedWord.Length;
tb.ResumeLayout();
@ -257,11 +266,16 @@ namespace Nikse.SubtitleEdit.Logic
tb.Text = tb.Text.Remove(start, endTagIndex - start + 1);
}
if (tb.Text[start] == '}')
{
start++;
}
tb.SelectionStart = start; // position cursor
}
}
public static int MergeTagAtCursor(SETextBox tb, int cursorPosition)
public static int MergeTagAtCursor(SETextBox tb, int cursorPosition, bool before)
{
if (cursorPosition >= tb.Text.Length)
{
@ -271,7 +285,7 @@ namespace Nikse.SubtitleEdit.Logic
if (cursorPosition > 0 && tb.Text[cursorPosition - 1] == '}' && tb.Text[cursorPosition] == '{')
{
tb.Text = tb.Text.Remove(cursorPosition - 1, 2);
return 2;
return before ? 2 : 0;
}
if (cursorPosition > 0 && tb.Text[cursorPosition - 1] == '\\' && tb.Text[cursorPosition] == '{')

View File

@ -1,5 +1,4 @@
using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.Enums;
using Nikse.SubtitleEdit.Core.SubtitleFormats;