mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
Add some re-split shortcuts (not in UI)
This commit is contained in:
parent
ee27c440f2
commit
9a714e6cdb
@ -1163,7 +1163,8 @@ $HorzAlign = Center
|
||||
public string MainAdjustEndXMsForward { get; set; }
|
||||
public string MainInsertAfter { get; set; }
|
||||
public string MainTextBoxAutoBreak { get; set; }
|
||||
public string MainTextBoxBreakAtPosition { get; set; }
|
||||
public string MainTextBoxBreakAtPosition { get; set; }
|
||||
public string MainTextBoxBreakAtPositionAndGoToNext { get; set; }
|
||||
public string MainTextBoxUnbreak { get; set; }
|
||||
public string MainWaveformInsertAtCurrentPosition { get; set; }
|
||||
public string MainInsertBefore { get; set; }
|
||||
@ -5225,6 +5226,12 @@ $HorzAlign = Center
|
||||
settings.Shortcuts.MainTextBoxBreakAtPosition = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainTextBoxBreakAtPositionAndGoToNext");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Shortcuts.MainTextBoxBreakAtPositionAndGoToNext = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainTextBoxUnbreak");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -6223,6 +6230,7 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("MainInsertAfter", settings.Shortcuts.MainInsertAfter);
|
||||
textWriter.WriteElementString("MainTextBoxAutoBreak", settings.Shortcuts.MainTextBoxAutoBreak);
|
||||
textWriter.WriteElementString("MainTextBoxBreakAtPosition", settings.Shortcuts.MainTextBoxBreakAtPosition);
|
||||
textWriter.WriteElementString("MainTextBoxBreakAtPositionAndGoToNext", settings.Shortcuts.MainTextBoxBreakAtPositionAndGoToNext);
|
||||
textWriter.WriteElementString("MainTextBoxUnbreak", settings.Shortcuts.MainTextBoxUnbreak);
|
||||
textWriter.WriteElementString("MainWaveformInsertAtCurrentPosition", settings.Shortcuts.MainWaveformInsertAtCurrentPosition);
|
||||
textWriter.WriteElementString("MainInsertBefore", settings.Shortcuts.MainInsertBefore);
|
||||
|
@ -2774,5 +2774,33 @@ namespace Nikse.SubtitleEdit.Core
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public static string ReSplit(string text, int selectionStart)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text) || !text.Contains(" ") || selectionStart == 0)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
var isFixed = false;
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
var ch = text[i];
|
||||
|
||||
if (!isFixed && ch == ' ' && (i > 0 && i + 1 == selectionStart || i >= selectionStart && ch == ' '))
|
||||
{
|
||||
sb.Append(Environment.NewLine);
|
||||
isFixed = true;
|
||||
}
|
||||
|
||||
sb.Append(ch == '\r' || ch == '\n' ? ' ' : ch);
|
||||
}
|
||||
|
||||
if (!isFixed)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
return sb.ToString().Replace(" ", " ").Replace(Environment.NewLine + " ", Environment.NewLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +217,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private Keys _mainInsertBefore = Keys.None;
|
||||
private Keys _mainTextBoxAutoBreak = Keys.None;
|
||||
private Keys _mainTextBoxBreakAtCursorPosition = Keys.None;
|
||||
private Keys _mainTextBoxBreakAtCursorPositionAndGoToNext = Keys.None;
|
||||
private Keys _mainTextBoxUnbreak = Keys.None;
|
||||
private Keys _mainMergeDialog = Keys.None;
|
||||
private Keys _mainToggleFocus = Keys.None;
|
||||
@ -9255,8 +9256,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
int numberOfLines = Utilities.GetNumberOfLines(textBoxListViewText.Text);
|
||||
|
||||
//Utilities.CheckAutoWrap(textBoxListViewText, e, numberOfNewLines);
|
||||
|
||||
if (e.Modifiers == Keys.None && e.KeyCode == Keys.Enter && numberOfLines > Configuration.Settings.Tools.ListViewSyntaxMoreThanXLinesX)
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
@ -9266,6 +9265,22 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ButtonAutoBreakClick(null, null);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _mainTextBoxBreakAtCursorPosition)
|
||||
{
|
||||
textBoxListViewText.Text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart);
|
||||
var lines = textBoxListViewText.Text.SplitToLines();
|
||||
if (lines.Count > 0)
|
||||
{
|
||||
textBoxListViewText.SelectionStart = lines[0].Length;
|
||||
}
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _mainTextBoxBreakAtCursorPositionAndGoToNext)
|
||||
{
|
||||
textBoxListViewText.Text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart);
|
||||
ButtonNextClick(null, null);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _mainTextBoxUnbreak)
|
||||
{
|
||||
ButtonUnBreakClick(null, null);
|
||||
@ -19423,6 +19438,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_mainInsertBefore = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainInsertBefore);
|
||||
_mainTextBoxAutoBreak = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxAutoBreak);
|
||||
_mainTextBoxBreakAtCursorPosition = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxBreakAtPosition);
|
||||
_mainTextBoxBreakAtCursorPositionAndGoToNext = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxBreakAtPositionAndGoToNext);
|
||||
_mainTextBoxUnbreak = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxUnbreak);
|
||||
_mainMergeDialog = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainMergeDialog);
|
||||
_mainToggleFocus = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToggleFocus);
|
||||
@ -22072,14 +22088,24 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
|
||||
else if (e.KeyData == _mainTextBoxBreakAtCursorPosition)
|
||||
{
|
||||
if (textBoxListViewTextAlternate.Text.Length > 0)
|
||||
textBoxListViewTextAlternate.Text = Utilities.ReSplit(textBoxListViewTextAlternate.Text, textBoxListViewTextAlternate.SelectionStart);
|
||||
var lines = textBoxListViewTextAlternate.Text.SplitToLines();
|
||||
if (lines.Count > 0)
|
||||
{
|
||||
//TODO: fix
|
||||
textBoxListViewTextAlternate.SelectionStart = lines[0].Length;
|
||||
}
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
|
||||
else if (e.KeyData == _mainTextBoxBreakAtCursorPosition)
|
||||
{
|
||||
textBoxListViewText.Text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart);
|
||||
ButtonNextClick(null, null);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _mainTextBoxUnbreak)
|
||||
{
|
||||
textBoxListViewTextAlternate.Text = Utilities.UnbreakLine(textBoxListViewTextAlternate.Text);
|
||||
|
@ -1078,7 +1078,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
AddNode(textBoxNode, language.MainTextBoxSelectionToUpper, nameof(Configuration.Settings.Shortcuts.MainTextBoxSelectionToUpper));
|
||||
AddNode(textBoxNode, language.MainTextBoxToggleAutoDuration, nameof(Configuration.Settings.Shortcuts.MainTextBoxToggleAutoDuration));
|
||||
AddNode(textBoxNode, language.MainTextBoxAutoBreak, nameof(Configuration.Settings.Shortcuts.MainTextBoxAutoBreak));
|
||||
// AddNode(textBoxNode, "Break at first space from cursor position", nameof(Configuration.Settings.Shortcuts.MainTextBoxBreakAtPosition));
|
||||
//TODO: AddNode(textBoxNode, "Break at first space from cursor position", nameof(Configuration.Settings.Shortcuts.MainTextBoxBreakAtPosition));
|
||||
//TODO: AddNode(textBoxNode, "Break at first space from cursor position and go to next", nameof(Configuration.Settings.Shortcuts.MainTextBoxBreakAtPositionAndGoToNext));
|
||||
AddNode(textBoxNode, language.MainTextBoxUnbreak, nameof(Configuration.Settings.Shortcuts.MainTextBoxUnbreak));
|
||||
if (textBoxNode.Nodes.Count > 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user