### 2024-12-20 星期五更新

------
#### SuperDesign    V3.0.2412.2001
- *.[新增]新增程序更新日志设置和自动发布功能。
- *.[修复]修复Post数据格式不正确时双击文本框会导致软件闪退的BUG。
This commit is contained in:
zilinsoft committed 2024-12-20 08:15:19 +08:00
1 parent 03bcb8c5fd
commit 993f1ca1a9
349 files changed
+81977 -13873

No files matched your search

@@ -8,6 +8,7 @@ namespace ScintillaNET_FindReplaceDialog
using System.Drawing;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
[TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class FindReplace : Component
@@ -864,14 +865,24 @@ namespace ScintillaNET_FindReplaceDialog
}
}
if (_scintilla.LineFromPosition(_scintilla.Selections[0].Start) != _scintilla.LineFromPosition(_scintilla.Selections[0].End)) //selRange.IsMultiLine)
if (_scintilla.LineFromPosition(_scintilla.Selections[0].Start) != _scintilla.LineFromPosition(_scintilla.Selections[0].End)) //selRange.IsMultiLine)
{
_window.chkSearchSelectionF.Checked = true;
}
_window.chkSearchSelectionR.Checked = true;
}
else if (_scintilla.Selections[0].End > _scintilla.Selections[0].Start)
{
_window.txtFindR.Text = _scintilla.SelectedText;
_window.TxtFileSearchText.Text = _scintilla.SelectedText;
_window.txtFindF.Text = _scintilla.SelectedText;
}
_window.chkSearchSelectionF.Checked = false;
_window.chkSearchSelectionR.Checked = false;
}
else
{
_window.chkSearchSelectionF.Checked = false;
_window.chkSearchSelectionR.Checked = false;
}
if (showTab == 0)
{
_window.tabAll.SelectedTab = _window.tabAll.TabPages["tpgFind"];
@@ -63,6 +63,7 @@ namespace ScintillaNET_FindReplaceDialog
this.cmdRecentReplace = new System.Windows.Forms.Button();
this.cmdRecentFindR = new System.Windows.Forms.Button();
this.tpgFileFind = new System.Windows.Forms.TabPage();
this.BtnBrowser = new System.Windows.Forms.Button();
this.fcFile = new SuperDesign.Controls.Highlight.FindReplace.FindConfig();
this.label2 = new System.Windows.Forms.Label();
this.NumLimitFileSize = new System.Windows.Forms.NumericUpDown();
@@ -167,7 +168,6 @@ namespace ScintillaNET_FindReplaceDialog
this.toolStripMenuItem51 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem50 = new System.Windows.Forms.ToolStripMenuItem();
this.nameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BtnBrowser = new System.Windows.Forms.Button();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.tabAll.SuspendLayout();
this.tpgFind.SuspendLayout();
@@ -246,6 +246,7 @@ namespace ScintillaNET_FindReplaceDialog
this.txtFindF.Name = "txtFindF";
this.txtFindF.Size = new System.Drawing.Size(408, 21);
this.txtFindF.TabIndex = 15;
this.txtFindF.TextChanged += new System.EventHandler(this.txtFindF_TextChanged);
//
// cmdRecentFindF
//
@@ -436,6 +437,7 @@ namespace ScintillaNET_FindReplaceDialog
this.txtReplace.Name = "txtReplace";
this.txtReplace.Size = new System.Drawing.Size(411, 21);
this.txtReplace.TabIndex = 21;
this.txtReplace.TextChanged += new System.EventHandler(this.txtReplace_TextChanged);
//
// txtFindR
//
@@ -446,6 +448,8 @@ namespace ScintillaNET_FindReplaceDialog
this.txtFindR.Name = "txtFindR";
this.txtFindR.Size = new System.Drawing.Size(411, 21);
this.txtFindR.TabIndex = 20;
this.txtFindR.SelectedIndexChanged += new System.EventHandler(this.txtFindR_SelectedIndexChanged);
this.txtFindR.TextChanged += new System.EventHandler(this.txtFindR_TextChanged);
//
// btnFindNextR
//
@@ -626,6 +630,16 @@ namespace ScintillaNET_FindReplaceDialog
this.tpgFileFind.Text = "文件夹查找";
this.tpgFileFind.UseVisualStyleBackColor = true;
//
// BtnBrowser
//
this.BtnBrowser.Location = new System.Drawing.Point(359, 86);
this.BtnBrowser.Name = "BtnBrowser";
this.BtnBrowser.Size = new System.Drawing.Size(27, 23);
this.BtnBrowser.TabIndex = 40;
this.BtnBrowser.Text = "...";
this.BtnBrowser.UseVisualStyleBackColor = true;
this.BtnBrowser.Click += new System.EventHandler(this.BtnBrowser_Click);
//
// fcFile
//
this.fcFile.FileWholeWord = false;
@@ -761,6 +775,7 @@ namespace ScintillaNET_FindReplaceDialog
this.TxtFileReplaceText.Name = "TxtFileReplaceText";
this.TxtFileReplaceText.Size = new System.Drawing.Size(312, 21);
this.TxtFileReplaceText.TabIndex = 27;
this.TxtFileReplaceText.TextChanged += new System.EventHandler(this.txtFindR_TextChanged);
//
// TxtFileSearchText
//
@@ -771,6 +786,7 @@ namespace ScintillaNET_FindReplaceDialog
this.TxtFileSearchText.Name = "TxtFileSearchText";
this.TxtFileSearchText.Size = new System.Drawing.Size(312, 21);
this.TxtFileSearchText.TabIndex = 26;
this.TxtFileSearchText.TextChanged += new System.EventHandler(this.txtFindF_TextChanged);
//
// TxtSearchPath
//
@@ -791,6 +807,7 @@ namespace ScintillaNET_FindReplaceDialog
this.TxtFileType.Size = new System.Drawing.Size(312, 21);
this.TxtFileType.TabIndex = 24;
this.TxtFileType.Text = "*.*";
this.TxtFileType.SelectedIndexChanged += new System.EventHandler(this.TxtFileType_SelectedIndexChanged);
//
// label5
//
@@ -1498,16 +1515,6 @@ namespace ScintillaNET_FindReplaceDialog
this.nameToolStripMenuItem.Size = new System.Drawing.Size(141, 22);
this.nameToolStripMenuItem.Text = "$(Name) 命名组";
//
// BtnBrowser
//
this.BtnBrowser.Location = new System.Drawing.Point(359, 86);
this.BtnBrowser.Name = "BtnBrowser";
this.BtnBrowser.Size = new System.Drawing.Size(27, 23);
this.BtnBrowser.TabIndex = 40;
this.BtnBrowser.Text = "...";
this.BtnBrowser.UseVisualStyleBackColor = true;
this.BtnBrowser.Click += new System.EventHandler(this.BtnBrowser_Click);
//
// FindReplaceDialog
//
this.AcceptButton = this.btnFindNextF;
@@ -1530,6 +1537,7 @@ namespace ScintillaNET_FindReplaceDialog
this.Activated += new System.EventHandler(this.FindReplaceDialog_Activated);
this.Deactivate += new System.EventHandler(this.FindReplaceDialog_Deactivate);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FindReplaceDialog_FormClosing);
this.Load += new System.EventHandler(this.FindReplaceDialog_Load);
this.tabAll.ResumeLayout(false);
this.tpgFind.ResumeLayout(false);
this.tpgFind.PerformLayout();
@@ -9,6 +9,7 @@ namespace ScintillaNET_FindReplaceDialog
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using static ScintillaNET.Style;
public partial class FindReplaceDialog : Form
{
@@ -38,6 +39,16 @@ namespace ScintillaNET_FindReplaceDialog
_autoPosition = true;
_mruFind = new List<string>();
_mruReplace = new List<string>();
var lst1 = RyFiles.ReadAllLines(Application.StartupPath + "\\UserDb\\mruFind.lst");
if (lst1 != null)
{
_mruFind.AddRange(lst1);
}
var lst2 = RyFiles.ReadAllLines(Application.StartupPath + "\\UserDb\\mruReplace.lst");
if (lst2 != null)
{
_mruReplace.AddRange(lst2);
}
_bindingSourceFind.DataSource = _mruFind;
_bindingSourceReplace.DataSource = _mruReplace;
txtFindF.DataSource = _bindingSourceFind;
@@ -45,15 +56,21 @@ namespace ScintillaNET_FindReplaceDialog
TxtFileSearchText.DataSource = _bindingSourceFind;
txtReplace.DataSource = _bindingSourceReplace;
TxtFileReplaceText.DataSource = _bindingSourceReplace;
ryCommon.Ini ini = new ryCommon.Ini(Application.StartupPath + "\\UserDb\\FindReplace.ini");
TxtFileType.Text = ini.ReadIni("FileFind", "Exts","*.*");
ChkSkipDirName.Checked = ini.ReadIni("FileFind", "SkipDirName_On",true);
CbbSkipDirName.Text = ini.ReadIni("FileFind", "SkipDirName_Text",CbbSkipDirName.Text);
ChkSubDir.Checked = ini.ReadIni("FileFind", "SearchSubDir", false);
ChkIgnoreBinExt.Checked = ini.ReadIni("FileFind", "IgnoreBinExt", true);
ChkHiddenDir.Checked = ini.ReadIni("FileFind", "SearchHiddenDir", false);
ChkLimitFileSize.Checked = ini.ReadIni("FileFind", "LimitFileSize_On", true);
NumLimitFileSize.Value = ini.ReadIni("FileFind", "LimitFileSize_Value",1,1000,20);
if (!DesignMode)
{
try
{
ryCommon.Ini ini = new ryCommon.Ini(Application.StartupPath + "\\UserDb\\FindReplace.ini");
TxtFileType.Text = ini.ReadIni("FileFind", "Exts", "*.*");
ChkSkipDirName.Checked = ini.ReadIni("FileFind", "SkipDirName_On", true);
CbbSkipDirName.Text = ini.ReadIni("FileFind", "SkipDirName_Text", CbbSkipDirName.Text);
ChkSubDir.Checked = ini.ReadIni("FileFind", "SearchSubDir", false);
ChkIgnoreBinExt.Checked = ini.ReadIni("FileFind", "IgnoreBinExt", true);
ChkHiddenDir.Checked = ini.ReadIni("FileFind", "SearchHiddenDir", false);
ChkLimitFileSize.Checked = ini.ReadIni("FileFind", "LimitFileSize_On", true);
NumLimitFileSize.Value = ini.ReadIni("FileFind", "LimitFileSize_Value", 1, 1000, 20); }
catch { }
}
LastTab = tpgFind;
LastFingConfig = fcFind;
}
@@ -136,6 +153,8 @@ namespace ScintillaNET_FindReplaceDialog
e.Cancel = true;
Hide();
}
RyFiles.WriteAllLines(Application.StartupPath + "\\UserDb\\mruFind.lst",_mruFind.ToArray(), System.Text.Encoding.UTF8);
RyFiles.WriteAllLines(Application.StartupPath + "\\UserDb\\mruReplace.lst", _mruReplace.ToArray(), System.Text.Encoding.UTF8);
}
#endregion Form Event Handlers
@@ -334,8 +353,7 @@ namespace ScintillaNET_FindReplaceDialog
else
lblStatus.Text = "搜索匹配换行到文档开头";
}
_scintilla.SetSel(nextRange.CpMin, nextRange.CpMax);
SetSel(nextRange.CpMin, nextRange.CpMax);
MoveFormAwayFromSelection();
}
}
@@ -420,7 +438,6 @@ namespace ScintillaNET_FindReplaceDialog
{
if (tabAll.SelectedTab == tpgFind)
{
txtFindF.Text = txtFindR.Text;
fcFind.LoadConfig(LastFingConfig);
chkWrapF.Checked = chkWrapR.Checked;
chkSearchSelectionF.Checked = chkSearchSelectionR.Checked;
@@ -428,21 +445,19 @@ namespace ScintillaNET_FindReplaceDialog
}
else if (tabAll.SelectedTab == tpgReplace)
{
txtFindR.Text = txtFindF.Text;
fcReplace.LoadConfig(LastFingConfig);
chkWrapR.Checked = chkWrapF.Checked;
chkSearchSelectionR.Checked = chkSearchSelectionF.Checked;
AcceptButton = btnReplaceNext;
}
else if (tabAll.SelectedTab == tpgFileFind)
{
TxtFileSearchText.Text = LastTab==tpgReplace? txtFindR.Text:txtFindF.Text;
fcFile.LoadConfig(LastFingConfig);
chkWrapR.Checked = chkWrapF.Checked;
chkSearchSelectionR.Checked = chkSearchSelectionF.Checked;
AcceptButton = btnReplaceNext;
}
SyncTextUI();
LastTab = tabAll.SelectedTab;
if(tabAll.SelectedTab== tpgFind)
{
@@ -457,7 +472,44 @@ namespace ScintillaNET_FindReplaceDialog
LastFingConfig = fcFile;
}
}
private void SyncTextUI()
{
if(tabAll.SelectedTab==tpgFind)
{
if (LastTab == tpgReplace)
{
txtFindF.Text=txtFindR.Text;
}
else if (LastTab == tpgFileFind)
{
txtFindF.Text = TxtFileSearchText.Text;
}
}
else if (tabAll.SelectedTab == tpgReplace)
{
if (LastTab == tpgFind)
{
txtFindR.Text = txtFindF.Text;
}
else if (LastTab == tpgFileFind)
{
txtFindR.Text = TxtFileSearchText.Text;
txtReplace.Text = TxtFileReplaceText.Text;
}
}
else if (tabAll.SelectedTab == tpgFileFind)
{
if (LastTab == tpgFind)
{
TxtFileSearchText.Text = txtFindF.Text;
}
else if (LastTab == tpgReplace)
{
TxtFileSearchText.Text = txtFindR.Text;
TxtFileReplaceText.Text = txtReplace.Text;
}
}
}
#endregion Event Handlers
#region Methods
@@ -465,7 +517,6 @@ namespace ScintillaNET_FindReplaceDialog
public void FindNext()
{
if (Scintilla == null) { return; }
SyncSearchText();
if (txtFindF.Text == string.Empty)
return;
@@ -498,8 +549,7 @@ namespace ScintillaNET_FindReplaceDialog
else
lblStatus.Text = "搜索匹配换行到文档开头";
}
Scintilla.SetSel(foundRange.CpMin, foundRange.CpMax);
SetSel(foundRange.CpMin, foundRange.CpMax);
MoveFormAwayFromSelection();
}
}
@@ -507,7 +557,6 @@ namespace ScintillaNET_FindReplaceDialog
public void FindPrevious()
{
if (Scintilla == null) { return; }
SyncSearchText();
if (txtFindF.Text == string.Empty)
return;
@@ -538,8 +587,7 @@ namespace ScintillaNET_FindReplaceDialog
else
lblStatus.Text = "搜索匹配换行到文档的结尾";
}
Scintilla.SetSel(foundRange.CpMin, foundRange.CpMax);
SetSel(foundRange.CpMin, foundRange.CpMax);
MoveFormAwayFromSelection();
}
}
@@ -595,7 +643,7 @@ namespace ScintillaNET_FindReplaceDialog
new Point(Location.X, cursorPoint.Y - Height - (lineHeight * 2)));
}
newLocation = Scintilla.PointToScreen(newLocation);
Location = newLocation;
//Location = newLocation;
}
}
@@ -631,26 +679,45 @@ namespace ScintillaNET_FindReplaceDialog
else
lblStatus.Text = "搜索匹配换行到文档开头";
}
Scintilla.SetSel(nextRange.CpMin, nextRange.CpMax);
SetSel(nextRange.CpMin, nextRange.CpMax);
MoveFormAwayFromSelection();
}
}
protected override void OnActivated(EventArgs e)
private void SetSel(int CpMin, int CpMax)
{
if (Scintilla.Selections.Count > 0)
if (_scintilla.GetColumn(CpMin) < _scintilla.GetColumn(CpMax))
{
chkSearchSelectionF.Enabled = true;
chkSearchSelectionR.Enabled = true;
_scintilla.GotoPosition(CpMax);
}
else
{
chkSearchSelectionF.Enabled = false;
chkSearchSelectionR.Enabled = false;
chkSearchSelectionF.Checked = false;
chkSearchSelectionR.Checked = false;
_scintilla.GotoPosition(CpMin);
}
var line=_scintilla.LineFromPosition(CpMax);
//var first_line = _scintilla.FirstVisibleLine;
_scintilla.FirstVisibleLine = line - 2;
_scintilla.SetSel(CpMin, CpMax);
}
protected override void OnActivated(EventArgs e)
{
if(Scintilla==null)
{
base.OnActivated(e);
return;
}
//if (Scintilla.Selections.Count > 0)
//{
// chkSearchSelectionF.Enabled = true;
// chkSearchSelectionR.Enabled = true;
//}
//else
//{
// chkSearchSelectionF.Enabled = false;
// chkSearchSelectionR.Enabled = false;
// chkSearchSelectionF.Checked = false;
// chkSearchSelectionR.Checked = false;
//}
// if they leave the dialog and come back any "Search Selection"
// range they might have had is invalidated
@@ -690,20 +757,41 @@ namespace ScintillaNET_FindReplaceDialog
base.OnKeyDown(e);
}
private void SyncSearchText()
private ComboBox GetFindTextBox()
{
if (tabAll.SelectedTab == tpgFind)
txtFindR.Text = txtFindF.Text;
{
return txtFindF;
}
else if (tabAll.SelectedTab == tpgReplace)
txtFindF.Text = txtFindR.Text;
{
return txtFindR;
}
else if (tabAll.SelectedTab == tpgFileFind)
TxtFileSearchText.Text = txtFindF.Text;
{
return TxtFileSearchText;
}
return null;
}
private ComboBox GetReplaceTextBox()
{
if (tabAll.SelectedTab == tpgFind)
{
return null;
}
else if (tabAll.SelectedTab == tpgReplace)
{
return txtReplace;
}
else if (tabAll.SelectedTab == tpgFileFind)
{
return TxtFileReplaceText;
}
return null;
}
private void AddFindMru()
{
string find = txtFindF.Text;
string find = GetFindTextBox().Text;
_mruFind.Remove(find);
_mruFind.Insert(0, find);
if(_mruFind.Count> _mruMaxCount)
@@ -711,19 +799,21 @@ namespace ScintillaNET_FindReplaceDialog
_mruFind.RemoveAt(_mruFind.Count - 1);
}
_bindingSourceFind.ResetBindings(false);
txtFindF.Text = find;
txtFindR.Text = find;
TxtFileSearchText.Text = find;
}
private void AddReplaceMru()
{
string find = txtFindR.Text;
string find =GetFindTextBox().Text;
_mruFind.Remove(find);
_mruFind.Insert(0, find);
if (_mruFind.Count > _mruMaxCount)
_mruFind.RemoveAt(_mruFind.Count - 1);
string replace = txtReplace.Text;
string replace = GetReplaceTextBox().Text;
if (replace != string.Empty)
{
_mruReplace.Remove(replace);
@@ -733,9 +823,13 @@ namespace ScintillaNET_FindReplaceDialog
if (_mruReplace.Count > _mruMaxCount)
_mruReplace.RemoveAt(_mruReplace.Count - 1);
}
_bindingSourceFind.ResetBindings(false);
_bindingSourceReplace.ResetBindings(false);
TxtFileReplaceText.Text = replace;
txtReplace.Text = replace;
txtFindF.Text = find;
txtFindR.Text = find;
TxtFileSearchText.Text = find;
}
private void ContextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
@@ -969,6 +1063,7 @@ namespace ScintillaNET_FindReplaceDialog
else
{
string textToFind = fcReplace.SearchMode==1 ? FindReplace.Transform(txtFindR.Text) : txtFindR.Text;
var aa = FindReplace.Find(selRange, textToFind, false);
if (selRange.Equals(FindReplace.Find(selRange, textToFind, false)))
{
// If searching up we do the replacement using the range object.
@@ -1026,39 +1121,7 @@ namespace ScintillaNET_FindReplaceDialog
private void BtnFileFindAll_Click(object sender, EventArgs e)
{
var folder = TxtSearchPath.Text;
if(!System.IO.Directory.Exists(folder))
{
MessageBox.Show("目录不存在。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if(TxtFileSearchText.Text.Length==0)
{
MessageBox.Show("待查找文本为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
ryCommon.Ini ini = new ryCommon.Ini(Application.StartupPath+"\\UserDb\\FindReplace.ini");
ini.WriteIni("FileFind", "Exts", TxtFileType.Text);
ini.WriteIni("FileFind", "SkipDirName_On", ChkSkipDirName.Checked);
ini.WriteIni("FileFind", "SkipDirName_Text", CbbSkipDirName.Text);
ini.WriteIni("FileFind", "SearchSubDir", ChkSubDir.Checked);
ini.WriteIni("FileFind", "IgnoreBinExt", ChkIgnoreBinExt.Checked);
ini.WriteIni("FileFind", "SearchHiddenDir", ChkHiddenDir.Checked);
ini.WriteIni("FileFind", "LimitFileSize_On", ChkLimitFileSize.Checked);
ini.WriteIni("FileFind", "LimitFileSize_Value", NumLimitFileSize.Value);
FrmFinding frm = new FrmFinding();
frm.SearchConfig.FindText = TxtFileSearchText.Text;
frm.SearchConfig.ReplaceText = TxtFileReplaceText.Text;
frm.SearchConfig.SearchDir= folder;
frm.SearchConfig.Exts = TxtFileType.Text;
frm.SearchConfig.SkipDirName = ChkSkipDirName.Checked ? CbbSkipDirName.Text : "";
frm.SearchConfig.LimitFileSize = ChkLimitFileSize.Checked ? (NumLimitFileSize.Value.ToInt() * 1024 * 1024) : 0;
frm.SearchConfig.SearchSubDir = ChkSubDir.Checked;
frm.SearchConfig.IgnoreBinExt = ChkIgnoreBinExt.Checked;
frm.SearchConfig.SearchHiddenDir = ChkHiddenDir.Checked;
frm.SearchConfig.RegexOptions = fcFile.GetRegexOptions();
frm.SearchConfig.SearchFlags = fcFile.GetSearchFlags();
frm.ShowDialog();
MessageBox.Show("暂不支持。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public string DefSearchDir { get; set; } = "";
private void ChkCurDir_CheckedChanged(object sender, EventArgs e)
@@ -1075,5 +1138,35 @@ namespace ScintillaNET_FindReplaceDialog
TxtSearchPath.Text = folderBrowserDialog1.SelectedPath;
}
}
private void txtFindF_TextChanged(object sender, EventArgs e)
{
//SyncTextUI();
}
private void txtFindR_TextChanged(object sender, EventArgs e)
{
//SyncTextUI();
}
private void txtReplace_TextChanged(object sender, EventArgs e)
{
//SyncTextUI();
}
private void FindReplaceDialog_Load(object sender, EventArgs e)
{
}
private void txtFindR_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void TxtFileType_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
@@ -1,7 +1,6 @@
using ryCommon;
using ryControls;
using ScintillaNET;
using SuperDesign.Tools.SmartEditor;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -14,7 +13,6 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using 开发辅助工具.Tools.SmartEditor;
using static ScintillaNET.Style;
using static System.Net.Mime.MediaTypeNames;
@@ -98,8 +96,8 @@ namespace ScintillaNET_FindReplaceDialog
return list;
int start = foundRange.CpMin + all_text.Substring(0, m.Index).Length;
int end = all_text.Substring(m.Index, m.Length).Length;
var LineNum = GetLineNum(start, out var LinePos);
list.Add(new CharacterRange(start, start + end) { LineNum=LineNum, LinePos=LinePos,RangeText=Text.Substring(start,end) });
var LineNum = GetLineNum(start, out var LinePos,out var LineText);
list.Add(new CharacterRange(start, start + end) {LineText= LineText, LineNum=LineNum, LinePos=LinePos,RangeText=Text.Substring(start,end) });
start_i = start+end + 1;
}
else
@@ -147,8 +145,8 @@ namespace ScintillaNET_FindReplaceDialog
}
if (Word_Start && Word_End)
{
var LineNum = GetLineNum(start, out var LinePos);
list.Add(new CharacterRange(start, start + end) { LineNum = LineNum, LinePos = LinePos, RangeText = Text.Substring(start, end) });
var LineNum = GetLineNum(start, out var LinePos, out var LineText);
list.Add(new CharacterRange(start, start + end) { LineText = LineText, LineNum = LineNum, LinePos = LinePos, RangeText = Text.Substring(start, end) });
}
start_i = start+ end + 1;
}
@@ -175,8 +173,8 @@ namespace ScintillaNET_FindReplaceDialog
}
if (Word_Start)
{
var LineNum = GetLineNum(start, out var LinePos);
list.Add(new CharacterRange(start, start + end) { LineNum = LineNum, LinePos = LinePos, RangeText = Text.Substring(start, end) });
var LineNum = GetLineNum(start, out var LinePos, out var LineText);
list.Add(new CharacterRange(start, start + end) { LineText = LineText, LineNum = LineNum, LinePos = LinePos, RangeText = Text.Substring(start, end) });
}
start_i = start+ end + 1;
}
@@ -187,8 +185,8 @@ namespace ScintillaNET_FindReplaceDialog
}
else
{
var LineNum = GetLineNum(start, out var LinePos);
list.Add(new CharacterRange(start, start + end) { LineNum = LineNum, LinePos = LinePos, RangeText = Text.Substring(start, end) });
var LineNum = GetLineNum(start, out var LinePos, out var LineText);
list.Add(new CharacterRange(start, start + end) { LineText = LineText, LineNum = LineNum, LinePos = LinePos, RangeText = Text.Substring(start, end) });
start_i = start+end + 1;
}
}
@@ -208,7 +206,7 @@ namespace ScintillaNET_FindReplaceDialog
}
}
//根据位置来获取该位置所在行
int GetLineNum(int pos,out int LinePos)
int GetLineNum(int pos,out int LinePos,out string LineText)
{
LinePos = -1;
var split_txt = Text.Split('\n');
@@ -218,6 +216,7 @@ namespace ScintillaNET_FindReplaceDialog
if (count+split_txt[i].Length+1>=pos)
{
LinePos = count;
LineText = split_txt[i];
return i;
}
else
@@ -225,6 +224,7 @@ namespace ScintillaNET_FindReplaceDialog
count += split_txt[i].Length+1;
}
}
LineText = "";
return -1;
}
return list;
@@ -227,7 +227,10 @@ namespace ScintillaNET_FindReplaceDialog
ScintillaNET_FindReplaceDialog.CharacterRange r = _findReplace.FindNext(txtFind.Text, true, _findReplace.Window.GetSearchFlags());
if (r.CpMin != r.CpMax)
_scintilla.SetSel(r.CpMin, r.CpMax);
{
_scintilla.GotoPosition(r.CpMin);
_scintilla.SetSel(r.CpMin, r.CpMax);
}
MoveFormAwayFromSelection();
}
@@ -241,7 +244,10 @@ namespace ScintillaNET_FindReplaceDialog
ScintillaNET_FindReplaceDialog.CharacterRange r = _findReplace.FindPrevious(txtFind.Text, true, _findReplace.Window.GetSearchFlags());
if (r.CpMin != r.CpMax)
{
_scintilla.GotoPosition(r.CpMin);
_scintilla.SetSel(r.CpMin, r.CpMax);
}
MoveFormAwayFromSelection();
}
@@ -282,7 +288,10 @@ namespace ScintillaNET_FindReplaceDialog
r = _findReplace.Find(0, pos, txtFind.Text, _findReplace.Window.GetSearchFlags());
if (r.CpMin != r.CpMax)
{
_scintilla.GotoPosition(r.CpMin);
_scintilla.SetSel(r.CpMin, r.CpMax);
}
else
txtFind.BackColor = Color.Tomato;