More fixes for find/count

This commit is contained in:
niksedk 2016-01-21 10:04:27 +01:00
parent aed79721bf
commit 2dd5a4103e
3 changed files with 23 additions and 4 deletions

View File

@ -46,6 +46,7 @@
this.textBoxFind.Name = "textBoxFind";
this.textBoxFind.Size = new System.Drawing.Size(189, 21);
this.textBoxFind.TabIndex = 0;
this.textBoxFind.TextChanged += new System.EventHandler(this.textBoxFind_TextChanged);
this.textBoxFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFind_KeyDown);
//
// buttonFind
@ -106,10 +107,11 @@
// comboBoxFind
//
this.comboBoxFind.FormattingEnabled = true;
this.comboBoxFind.Location = new System.Drawing.Point(12, 12);
this.comboBoxFind.Location = new System.Drawing.Point(12, 13);
this.comboBoxFind.Name = "comboBoxFind";
this.comboBoxFind.Size = new System.Drawing.Size(189, 21);
this.comboBoxFind.TabIndex = 0;
this.comboBoxFind.TextChanged += new System.EventHandler(this.comboBoxFind_TextChanged);
this.comboBoxFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ComboBoxFind_KeyDown);
//
// buttonCount
@ -140,6 +142,7 @@
this.checkBoxWholeWord.TabIndex = 4;
this.checkBoxWholeWord.Text = "Whole word";
this.checkBoxWholeWord.UseVisualStyleBackColor = true;
this.checkBoxWholeWord.CheckedChanged += new System.EventHandler(this.checkBoxWholeWord_CheckedChanged);
//
// FindDialog
//

View File

@ -64,7 +64,7 @@ namespace Nikse.SubtitleEdit.Forms
{
get
{
if (textBoxFind.Visible || !comboBoxFind.Visible)
if (Configuration.Settings.Tools.FindHistory.Count == 0)
return textBoxFind.Text;
return comboBoxFind.Text;
}
@ -148,6 +148,7 @@ namespace Nikse.SubtitleEdit.Forms
comboBoxFind.ContextMenu = null;
}
checkBoxWholeWord.Enabled = !radioButtonRegEx.Checked;
labelCount.Text = string.Empty;
}
internal void Initialize(string selectedText, FindReplaceDialogHelper findHelper)
@ -202,5 +203,20 @@ namespace Nikse.SubtitleEdit.Forms
labelCount.Text = count == 1 ? Configuration.Settings.Language.FindDialog.OneMatch : string.Format(Configuration.Settings.Language.FindDialog.XNumberOfMatches, count);
}
private void comboBoxFind_TextChanged(object sender, EventArgs e)
{
labelCount.Text = string.Empty;
}
private void textBoxFind_TextChanged(object sender, EventArgs e)
{
labelCount.Text = string.Empty;
}
private void checkBoxWholeWord_CheckedChanged(object sender, EventArgs e)
{
labelCount.Text = string.Empty;
}
}
}

View File

@ -8,8 +8,8 @@ namespace Nikse.SubtitleEdit.Logic
{
public class FindReplaceDialogHelper
{
private const string StartChars = " >-\"”“['`´¶(♪¿¡.…—\r\n\u2028";
private const string EndChars = " <-\"”“]'`´¶)♪,.!?:;…—\r\n\u2028";
private const string StartChars = " >-\"”“[]'`´¶(){}♪¿¡.…—\r\n\u2028";
private const string EndChars = " <-\"”“]'`´¶(){}♪,.!?:;…—\r\n\u2028";
private readonly string _findText = string.Empty;
private readonly string _replaceText = string.Empty;
private Regex _regEx;