mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Add new shortcut copy plain text
This commit is contained in:
parent
aded1e1bff
commit
259568edc4
@ -2377,6 +2377,7 @@ can edit in same subtitle file (collaboration)</Information>
|
||||
<AlignmentN9>Alignment top right - {\an9}</AlignmentN9>
|
||||
<ColorX>Color {0} ({1})</ColorX>
|
||||
<CopyTextOnly>Copy text only to clipboard (selected lines)</CopyTextOnly>
|
||||
<CopyPlainText>Copy plain text to clipboard (selected lines)</CopyPlainText>
|
||||
<CopyTextOnlyFromOriginalToCurrent>Copy text from original to current</CopyTextOnlyFromOriginalToCurrent>
|
||||
<AutoDurationSelectedLines>Auto-duration (selected lines)</AutoDurationSelectedLines>
|
||||
<FixRTLViaUnicodeChars>Fix RTL via Unicode control characters</FixRTLViaUnicodeChars>
|
||||
|
@ -2214,6 +2214,7 @@ $HorzAlign = Center
|
||||
public string MainListViewColor4 { get; set; }
|
||||
public string MainRemoveFormatting { get; set; }
|
||||
public string MainListViewCopyText { get; set; }
|
||||
public string MainListViewCopyPlainText { get; set; }
|
||||
public string MainListViewCopyTextFromOriginalToCurrent { get; set; }
|
||||
public string MainListViewAutoDuration { get; set; }
|
||||
public string MainListViewColumnDeleteText { get; set; }
|
||||
@ -8257,6 +8258,12 @@ $HorzAlign = Center
|
||||
shortcuts.MainListViewCopyText = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainListViewCopyPlainText");
|
||||
if (subNode != null)
|
||||
{
|
||||
shortcuts.MainListViewCopyPlainText = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainListViewCopyTextFromOriginalToCurrent");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -10238,6 +10245,7 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("MainListViewColor4", shortcuts.MainListViewColor4);
|
||||
textWriter.WriteElementString("MainRemoveFormatting", shortcuts.MainRemoveFormatting);
|
||||
textWriter.WriteElementString("MainListViewCopyText", shortcuts.MainListViewCopyText);
|
||||
textWriter.WriteElementString("MainListViewCopyPlainText", shortcuts.MainListViewCopyPlainText);
|
||||
textWriter.WriteElementString("MainListViewCopyTextFromOriginalToCurrent", shortcuts.MainListViewCopyTextFromOriginalToCurrent);
|
||||
textWriter.WriteElementString("MainListViewAutoDuration", shortcuts.MainListViewAutoDuration);
|
||||
textWriter.WriteElementString("MainListViewColumnDeleteText", shortcuts.MainListViewColumnDeleteText);
|
||||
|
@ -19078,6 +19078,30 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
MessageBox.Show("Unable to set clipboard text - some other application might have locked the clipboard.");
|
||||
}
|
||||
|
||||
private void CopyTextFromSelectedLinesToClipboard(bool removeTags)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (int i in SubtitleListview1.SelectedIndices)
|
||||
{
|
||||
var p = _subtitle.GetParagraphOrDefault(i);
|
||||
if (p != null)
|
||||
{
|
||||
sb.Append(p.Text).AppendLine(Environment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
if (sb.ToString().TrimEnd().Length > 0)
|
||||
{
|
||||
var text = sb.ToString().TrimEnd();
|
||||
if (removeTags)
|
||||
{
|
||||
text = HtmlUtil.RemoveHtmlTags(text, true);
|
||||
}
|
||||
|
||||
ClipboardSetText(text);
|
||||
}
|
||||
}
|
||||
|
||||
private void SubtitleListview1KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control) //Ctrl+c = Copy to clipboard
|
||||
@ -19106,21 +19130,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewCopyText)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (int i in SubtitleListview1.SelectedIndices)
|
||||
{
|
||||
var p = _subtitle.GetParagraphOrDefault(i);
|
||||
if (p != null)
|
||||
{
|
||||
sb.Append(p.Text).AppendLine(Environment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
if (sb.ToString().TrimEnd().Length > 0)
|
||||
{
|
||||
ClipboardSetText(sb.ToString().TrimEnd());
|
||||
}
|
||||
|
||||
CopyTextFromSelectedLinesToClipboard(false);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewCopyPlainText)
|
||||
{
|
||||
CopyTextFromSelectedLinesToClipboard(true);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewAutoDuration)
|
||||
|
@ -1461,6 +1461,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
|
||||
AddNode(listViewNode, language.ToggleDialogDashes, nameof(Configuration.Settings.Shortcuts.MainListViewToggleDashes));
|
||||
AddNode(listViewNode, language.Alignment, nameof(Configuration.Settings.Shortcuts.MainListViewAlignment), true);
|
||||
AddNode(listViewNode, language.CopyTextOnly, nameof(Configuration.Settings.Shortcuts.MainListViewCopyText));
|
||||
AddNode(listViewNode, language.CopyPlainText, nameof(Configuration.Settings.Shortcuts.MainListViewCopyPlainText));
|
||||
AddNode(listViewNode, language.CopyTextOnlyFromOriginalToCurrent, nameof(Configuration.Settings.Shortcuts.MainListViewCopyTextFromOriginalToCurrent), true);
|
||||
AddNode(listViewNode, language.AutoDurationSelectedLines, nameof(Configuration.Settings.Shortcuts.MainListViewAutoDuration));
|
||||
AddNode(listViewNode, language.ListViewColumnDelete, nameof(Configuration.Settings.Shortcuts.MainListViewColumnDeleteText), true);
|
||||
|
@ -2707,6 +2707,7 @@ can edit in same subtitle file (collaboration)",
|
||||
AlignmentN9 = "Alignment top right - {\\an9}",
|
||||
ColorX = "Color {0} ({1})",
|
||||
CopyTextOnly = "Copy text only to clipboard (selected lines)",
|
||||
CopyPlainText = "Copy plain text to clipboard (selected lines)",
|
||||
CopyTextOnlyFromOriginalToCurrent = "Copy text from original to current",
|
||||
AutoDurationSelectedLines = "Auto-duration (selected lines)",
|
||||
FixRTLViaUnicodeChars = "Fix RTL via Unicode control characters",
|
||||
|
@ -6502,6 +6502,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
case "Settings/CopyTextOnly":
|
||||
language.Settings.CopyTextOnly = reader.Value;
|
||||
break;
|
||||
case "Settings/CopyPlainText":
|
||||
language.Settings.CopyPlainText = reader.Value;
|
||||
break;
|
||||
case "Settings/CopyTextOnlyFromOriginalToCurrent":
|
||||
language.Settings.CopyTextOnlyFromOriginalToCurrent = reader.Value;
|
||||
break;
|
||||
|
@ -2560,6 +2560,7 @@
|
||||
public string AlignmentN9 { get; set; }
|
||||
public string ColorX { get; set; }
|
||||
public string CopyTextOnly { get; set; }
|
||||
public string CopyPlainText { get; set; }
|
||||
public string CopyTextOnlyFromOriginalToCurrent { get; set; }
|
||||
public string AutoDurationSelectedLines { get; set; }
|
||||
public string FixRTLViaUnicodeChars { get; set; }
|
||||
|
@ -191,6 +191,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public Keys MainListViewRemoveBlankLines { get; set; }
|
||||
public Keys MainListViewRemoveTimeCodes { get; set; }
|
||||
public Keys MainListViewCopyText { get; set; }
|
||||
public Keys MainListViewCopyPlainText { get; set; }
|
||||
public Keys MainEditFixRTLViaUnicodeChars { get; set; }
|
||||
public Keys MainEditRemoveRTLUnicodeChars { get; set; }
|
||||
public Keys MainEditReverseStartAndEndingForRtl { get; set; }
|
||||
@ -334,6 +335,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
MainEditReverseStartAndEndingForRtl = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditReverseStartAndEndingForRTL);
|
||||
MainToggleVideoControls = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleControls);
|
||||
MainListViewCopyText = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewCopyText);
|
||||
MainListViewCopyPlainText = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewCopyPlainText);
|
||||
MainTextBoxSplitAtCursor = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxSplitAtCursor);
|
||||
MainTextBoxSplitAtCursorAndVideoPos = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxSplitAtCursorAndVideoPos);
|
||||
MainTextBoxSplitSelectedLineBilingual = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxSplitSelectedLineBilingual);
|
||||
|
Loading…
Reference in New Issue
Block a user