mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 15:02:35 +01:00
Fix #690 Persistent find history - thx vmb :)
This commit is contained in:
parent
663fc53baa
commit
817ad364b2
@ -11,7 +11,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
public sealed partial class FindDialog : Form
|
||||
{
|
||||
private Regex _regEx;
|
||||
private List<string> _history = new List<string>();
|
||||
|
||||
public FindDialog()
|
||||
{
|
||||
@ -61,7 +60,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
public FindReplaceDialogHelper GetFindDialogHelper(int startLineIndex)
|
||||
{
|
||||
return new FindReplaceDialogHelper(GetFindType(), FindText, _history, _regEx, string.Empty, 200, 300, startLineIndex);
|
||||
return new FindReplaceDialogHelper(GetFindType(), FindText, _regEx, string.Empty, 200, 300, startLineIndex);
|
||||
}
|
||||
|
||||
private void FormFindDialog_KeyDown(object sender, KeyEventArgs e)
|
||||
@ -77,7 +76,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string searchText = FindText;
|
||||
textBoxFind.Text = searchText;
|
||||
comboBoxFind.Text = searchText;
|
||||
_history.Add(searchText);
|
||||
|
||||
if (searchText.Length == 0)
|
||||
{
|
||||
@ -141,18 +139,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
internal void Initialize(string selectedText, FindReplaceDialogHelper findHelper)
|
||||
{
|
||||
if (findHelper != null && findHelper.FindTextHistory.Count > 0)
|
||||
if (Configuration.Settings.Tools.FindHistory.Count > 0)
|
||||
{
|
||||
textBoxFind.Visible = false;
|
||||
comboBoxFind.Visible = true;
|
||||
comboBoxFind.Text = selectedText;
|
||||
comboBoxFind.SelectAll();
|
||||
comboBoxFind.Items.Clear();
|
||||
_history = new List<string>();
|
||||
foreach (string s in findHelper.FindTextHistory)
|
||||
for (int index = 0; index < Configuration.Settings.Tools.FindHistory.Count; index++)
|
||||
{
|
||||
string s = Configuration.Settings.Tools.FindHistory[index];
|
||||
comboBoxFind.Items.Add(s);
|
||||
_history.Add(s);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -160,9 +157,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
comboBoxFind.Visible = false;
|
||||
textBoxFind.Visible = true;
|
||||
textBoxFind.Text = selectedText;
|
||||
textBoxFind.SelectAll();
|
||||
textBoxFind.SelectAll();
|
||||
}
|
||||
|
||||
|
||||
if (findHelper != null)
|
||||
{
|
||||
if (findHelper.FindType == FindType.RegEx)
|
||||
|
@ -3792,7 +3792,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
_findHelper = findDialog.GetFindDialogHelper(_subtitleListViewIndex);
|
||||
_findHelper.AddHistory(_findHelper.FindText);
|
||||
if (!string.IsNullOrWhiteSpace(_findHelper.FindText))
|
||||
{
|
||||
Configuration.Settings.Tools.FindHistory.Insert(0, _findHelper.FindText);
|
||||
}
|
||||
ShowStatus(string.Format(_language.SearchingForXFromLineY, _findHelper.FindText, _subtitleListViewIndex + 1));
|
||||
if (tabControlSubtitle.SelectedIndex == TabControlListView)
|
||||
{
|
||||
@ -11538,7 +11541,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private void FindDoubleWordsToolStripMenuItemClick(object sender, EventArgs e)
|
||||
{
|
||||
var regex = new Regex(@"\b(\w+)\s+\1\b");
|
||||
_findHelper = new FindReplaceDialogHelper(FindType.RegEx, string.Format(_language.DoubleWordsViaRegEx, regex), new List<string>(), regex, string.Empty, 0, 0, _subtitleListViewIndex);
|
||||
_findHelper = new FindReplaceDialogHelper(FindType.RegEx, string.Format(_language.DoubleWordsViaRegEx, regex), regex, string.Empty, 0, 0, _subtitleListViewIndex);
|
||||
|
||||
ReloadFromSourceView();
|
||||
FindNext();
|
||||
|
@ -60,7 +60,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
public FindReplaceDialogHelper GetFindDialogHelper(int startLineIndex)
|
||||
{
|
||||
return new FindReplaceDialogHelper(GetFindType(), textBoxFind.Text, new List<string>(), _regEx, textBoxReplace.Text, _left, _top, startLineIndex);
|
||||
return new FindReplaceDialogHelper(GetFindType(), textBoxFind.Text, _regEx, textBoxReplace.Text, _left, _top, startLineIndex);
|
||||
}
|
||||
|
||||
private void FormReplaceDialog_KeyDown(object sender, KeyEventArgs e)
|
||||
|
@ -20,7 +20,6 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public int WindowPositionTop { get; set; }
|
||||
public int StartLineIndex { get; set; }
|
||||
public bool MatchInOriginal { get; set; }
|
||||
public List<string> FindTextHistory { get; private set; }
|
||||
|
||||
public int FindTextLength
|
||||
{
|
||||
@ -46,7 +45,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
}
|
||||
|
||||
public FindReplaceDialogHelper(FindType findType, string findText, List<string> history, Regex regEx, string replaceText, int left, int top, int startLineIndex)
|
||||
public FindReplaceDialogHelper(FindType findType, string findText, Regex regEx, string replaceText, int left, int top, int startLineIndex)
|
||||
{
|
||||
FindType = findType;
|
||||
_findText = findText;
|
||||
@ -56,7 +55,6 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
WindowPositionLeft = left;
|
||||
WindowPositionTop = top;
|
||||
StartLineIndex = startLineIndex;
|
||||
FindTextHistory = history;
|
||||
}
|
||||
|
||||
public bool Find(Subtitle subtitle, Subtitle originalSubtitle, int startIndex)
|
||||
@ -261,12 +259,5 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void AddHistory(string findText)
|
||||
{
|
||||
if (FindTextHistory.Contains(findText))
|
||||
FindTextHistory.Remove(findText);
|
||||
FindTextHistory.Add(findText);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -159,6 +159,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public string ChangeCasingChoice { get; set; }
|
||||
public bool UseNoLineBreakAfter { get; set; }
|
||||
public string NoLineBreakAfterEnglish { get; set; }
|
||||
public List<string> FindHistory { get; set; }
|
||||
|
||||
public ToolsSettings()
|
||||
{
|
||||
@ -217,6 +218,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
ExportCustomTemplates = "SubRipÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]ÆæMicroDVDÆÆ{{start}}{{end}}{text}\r\nÆffÆ||Æ";
|
||||
UseNoLineBreakAfter = false;
|
||||
NoLineBreakAfterEnglish = " Mrs.; Ms.; Mr.; Dr.; a; an; the; my; my own; your; his; our; their; it's; is; are;'s; 're; would;'ll;'ve;'d; will; that; which; who; whom; whose; whichever; whoever; wherever; each; either; every; all; both; few; many; sevaral; all; any; most; been; been doing; none; some; my own; your own; his own; her own; our own; their own; I; she; he; as per; as regards; into; onto; than; where as; abaft; aboard; about; above; across; afore; after; against; along; alongside; amid; amidst; among; amongst; anenst; apropos; apud; around; as; aside; astride; at; athwart; atop; barring; before; behind; below; beneath; beside; besides; between; betwixt; beyond; but; by; circa; ca; concerning; despite; down; during; except; excluding; following; for; forenenst; from; given; in; including; inside; into; lest; like; minus; modulo; near; next; of; off; on; onto; opposite; out; outside; over; pace; past; per; plus; pro; qua; regarding; round; sans; save; since; than; through; thru; throughout; thruout; till; to; toward; towards; under; underneath; unlike; until; unto; up; upon; versus; vs; via; vice; with; within; without; considering; respecting; one; two; another; three; our; five; six; seven; eight; nine; ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen; seventeen; eighteen; nineteen; twenty; thirty; forty; fifty; sixty; seventy; eighty; ninety; hundred; thousand; million; billion; trillion; while; however; what; zero; little; enough; after; although; and; as; if; though; although; because; before; both; but; even; how; than; nor; or; only; unless; until; yet; was; were";
|
||||
FindHistory = new List<string>();
|
||||
ImportTextLineBreak = "|";
|
||||
}
|
||||
|
||||
@ -1759,6 +1761,17 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
subNode = node.SelectSingleNode("NoLineBreakAfterEnglish");
|
||||
if (subNode != null)
|
||||
settings.Tools.NoLineBreakAfterEnglish = subNode.InnerText.Replace(" ", " ");
|
||||
subNode = node.SelectSingleNode("FindHistory");
|
||||
if (subNode != null)
|
||||
{
|
||||
foreach (XmlNode findItem in subNode.ChildNodes)
|
||||
{
|
||||
if (findItem.Name == "Text")
|
||||
{
|
||||
settings.Tools.FindHistory.Add(findItem.InnerText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
settings.SubtitleSettings = new SubtitleSettings();
|
||||
node = doc.DocumentElement.SelectSingleNode("SubtitleSettings");
|
||||
@ -2844,7 +2857,19 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
textWriter.WriteElementString("ChangeCasingChoice", settings.Tools.ChangeCasingChoice);
|
||||
textWriter.WriteElementString("UseNoLineBreakAfter", settings.Tools.UseNoLineBreakAfter.ToString());
|
||||
textWriter.WriteElementString("NoLineBreakAfterEnglish", settings.Tools.NoLineBreakAfterEnglish);
|
||||
|
||||
if (settings.Tools.FindHistory != null && settings.Tools.FindHistory.Count > 0)
|
||||
{
|
||||
textWriter.WriteStartElement("FindHistory", "");
|
||||
for (int index = 0; index < settings.Tools.FindHistory.Count; index++)
|
||||
{
|
||||
if (index < 15) // allow up to 15 entries for find history
|
||||
{
|
||||
var text = settings.Tools.FindHistory[index];
|
||||
textWriter.WriteElementString("Text", text);
|
||||
}
|
||||
}
|
||||
textWriter.WriteEndElement();
|
||||
}
|
||||
textWriter.WriteEndElement();
|
||||
|
||||
textWriter.WriteStartElement("SubtitleSettings", "");
|
||||
|
Loading…
Reference in New Issue
Block a user