Skip to content

Commit 711d3a9

Browse files
committed
- QuickFind "More..." button crash fix + minor code cleanup
- Refactored highlight management with default highlight groups: find(indic 0), selection(indic 1), error(indic 2) - Improved selection highlighting, case matching and removal improvements NEEDS TESTING!
1 parent 42b0525 commit 711d3a9

6 files changed

Lines changed: 132 additions & 129 deletions

File tree

‎External/Plugins/AS3Context/Context.cs‎

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -644,18 +644,22 @@ private void BackgroundSyntaxCheck()
644644
? PluginBase.CurrentProject.CurrentSDK
645645
: as3settings.GetDefaultSDK().Path;
646646
FlexShells.Instance.CheckAS3(CurrentFile, sdk, src);
647+
}
648+
649+
private void AddSquiggles(ScintillaNet.ScintillaControl sci, int line, int start, int end)
650+
{
651+
if (sci == null) return;
652+
fileWithSquiggles = CurrentFile;
653+
int position = sci.PositionFromLine(line) + start;
654+
sci.AddHighlight(2, (int)ScintillaNet.Enums.IndicatorStyle.Squiggle, 0x000000ff, position, end - start);
647655
}
648656

649657
private void ClearSquiggles(ScintillaNet.ScintillaControl sci)
650658
{
651659
if (sci == null) return;
652660
try
653-
{
654-
int es = sci.EndStyled;
655-
int mask = (1 << sci.StyleBits);
656-
sci.StartStyling(0, mask);
657-
sci.SetStyling(sci.TextLength, 0);
658-
sci.StartStyling(es, mask - 1);
661+
{
662+
sci.RemoveHighlights(2);
659663
}
660664
finally
661665
{
@@ -698,19 +702,6 @@ private int MBSafeColumn(ScintillaNet.ScintillaControl sci, int line, int length
698702
return sci.MBSafeTextLength(text.Substring(0, length));
699703
}
700704

701-
private void AddSquiggles(ScintillaNet.ScintillaControl sci, int line, int start, int end)
702-
{
703-
if (sci == null) return;
704-
fileWithSquiggles = CurrentFile;
705-
int position = sci.PositionFromLine(line) + start;
706-
int es = sci.EndStyled;
707-
int mask = 1 << sci.StyleBits;
708-
sci.SetIndicStyle(0, (int)ScintillaNet.Enums.IndicatorStyle.Squiggle);
709-
sci.SetIndicFore(0, 0x000000ff);
710-
sci.StartStyling(position, mask);
711-
sci.SetStyling(end - start, mask);
712-
sci.StartStyling(es, mask - 1);
713-
}
714705
#endregion
715706

716707
#region class resolution

‎External/Plugins/FlashDebugger/Helpers/ScintillaHelper.cs‎

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,13 @@ static public Int32 GetMarkerMask(Int32 marker)
194194
/// <summary>
195195
///
196196
/// </summary>
197-
static public void AddHighlight(ScintillaControl sci, Int32 line, Int32 indicator, Int32 value)
197+
public static void AddHighlight(ScintillaControl sci, Int32 line, Int32 indicator, Int32 value)
198198
{
199+
if (sci == null) return;
199200
Int32 start = sci.PositionFromLine(line);
200201
Int32 length = sci.LineLength(line);
201-
if (start < 0 || length < 1)
202-
{
203-
return;
204-
}
205-
// Remember previous EndStyled marker and restore it when we are done.
202+
if (start < 0 || length < 1) return;
206203
Int32 es = sci.EndStyled;
207-
// Mask for style bits used for restore.
208204
Int32 mask = (1 << sci.StyleBits) - 1;
209205
Language lang = PluginBase.MainForm.SciConfig.GetLanguage(sci.ConfigurationLanguage);
210206
if (indicator == indicatorDebugCurrentLine)
@@ -229,18 +225,13 @@ static public void AddHighlight(ScintillaControl sci, Int32 line, Int32 indicato
229225
/// <summary>
230226
///
231227
/// </summary>
232-
static public void RemoveHighlight(ScintillaControl sci, Int32 line, Int32 indicator)
228+
public static void RemoveHighlight(ScintillaControl sci, Int32 line, Int32 indicator)
233229
{
234230
if (sci == null) return;
235231
Int32 start = sci.PositionFromLine(line);
236232
Int32 length = sci.LineLength(line);
237-
if (start < 0 || length < 1)
238-
{
239-
return;
240-
}
241-
// Remember previous EndStyled marker and restore it when we are done.
233+
if (start < 0 || length < 1) return;
242234
Int32 es = sci.EndStyled;
243-
// Mask for style bits used for restore.
244235
Int32 mask = (1 << sci.StyleBits) - 1;
245236
Language lang = PluginBase.MainForm.SciConfig.GetLanguage(sci.ConfigurationLanguage);
246237
if (indicator == indicatorDebugCurrentLine)
@@ -264,14 +255,15 @@ static public void RemoveHighlight(ScintillaControl sci, Int32 line, Int32 indic
264255
/// <summary>
265256
///
266257
/// </summary>
267-
static public void RemoveAllHighlights(ScintillaControl sci)
258+
public static void RemoveAllHighlights(ScintillaControl sci)
268259
{
269260
if (sci == null) return;
270261
Int32 es = sci.EndStyled;
271-
foreach (Int32 indicator in new Int32[] { indicatorDebugCurrentLine, indicatorDebugDisabledBreakpoint, indicatorDebugEnabledBreakpoint })
262+
Int32[] indics = new Int32[] { indicatorDebugCurrentLine, indicatorDebugDisabledBreakpoint, indicatorDebugEnabledBreakpoint };
263+
foreach (Int32 indicator in indics)
272264
{
273265
sci.CurrentIndicator = indicator;
274-
for (int position = 0; position < sci.Length; )
266+
for (int position = 0; position < sci.Length;)
275267
{
276268
Int32 start = sci.IndicatorStart(indicator, position);
277269
Int32 end = sci.IndicatorEnd(indicator, start);

‎External/Plugins/ResultsPanel/PluginUI.cs‎

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,9 @@ private void AddSquiggle(ListViewItem item)
830830
if (!document.IsEditable) continue;
831831
ScintillaControl sci = document.SciControl;
832832
Language language = PluginBase.MainForm.SciConfig.GetLanguage(sci.ConfigurationLanguage);
833-
Int32 indic = (item.ImageIndex == 0) ? (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox : (Int32)ScintillaNet.Enums.IndicatorStyle.Squiggle;
833+
Int32 style = (item.ImageIndex == 0) ? (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox : (Int32)ScintillaNet.Enums.IndicatorStyle.Squiggle;
834834
Int32 fore = (item.ImageIndex == 0) ? language.editorstyle.HighlightBackColor : 0x000000ff;
835+
Int32 indic = (item.ImageIndex == 0) ? 0 : 2;
835836
if (fname == document.FileName)
836837
{
837838
Int32 end;
@@ -852,16 +853,7 @@ private void AddSquiggle(ListViewItem item)
852853
if ((start >= 0) && (end > start) && (end < sci.TextLength))
853854
{
854855
Int32 position = sci.PositionFromLine(line) + start;
855-
Int32 es = sci.EndStyled;
856-
Int32 mask = 1 << sci.StyleBits;
857-
// Define indics in both controls...
858-
document.SplitSci1.SetIndicStyle(0, indic);
859-
document.SplitSci1.SetIndicFore(0, fore);
860-
document.SplitSci2.SetIndicStyle(0, indic);
861-
document.SplitSci2.SetIndicFore(0, fore);
862-
sci.StartStyling(position, mask);
863-
sci.SetStyling(end - start, mask);
864-
sci.StartStyling(es, mask - 1);
856+
sci.AddHighlight(indic, style, fore, position, end - start);
865857
}
866858
break;
867859
}
@@ -885,13 +877,10 @@ private void ClearSquiggles()
885877
fname = (item.SubItems[4].Text + "\\" + item.SubItems[3].Text).Replace('/','\\');
886878
if (fname == document.FileName && !cleared.Contains(fname))
887879
{
888-
cleared.Add(fname);
889-
Int32 es = sci.EndStyled;
890-
Int32 mask = (1 << sci.StyleBits);
891-
sci.StartStyling(0, mask);
892-
sci.SetStyling(sci.TextLength, 0);
893-
sci.StartStyling(es, mask - 1);
894-
break;
880+
Int32 indic = (item.ImageIndex == 0) ? 0 : 2;
881+
sci.RemoveHighlights(indic);
882+
cleared.Add(fname);
883+
break;
895884
}
896885
}
897886
}

‎FlashDevelop/Controls/QuickFind.cs‎

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
using PluginCore.Managers;
1515
using PluginCore.Utilities;
1616
using PluginCore.Controls;
17+
using PluginCore.Helpers;
1718
using ScintillaNet.Configuration;
1819
using ScintillaNet;
1920
using PluginCore;
20-
using PluginCore.Helpers;
2121

2222
namespace FlashDevelop.Controls
2323
{
@@ -382,10 +382,8 @@ private void FindTextBoxKeyPress(Object sender, KeyPressEventArgs e)
382382
if (e.KeyChar == (Char)Keys.Return && this.findTextBox.Text.Trim() != "")
383383
{
384384
e.Handled = true;
385-
if ((ModifierKeys & Keys.Shift) == Keys.Shift)
386-
FindPrev(findTextBox.Text, false);
387-
else
388-
FindNext(findTextBox.Text, false);
385+
if ((ModifierKeys & Keys.Shift) == Keys.Shift) FindPrev(findTextBox.Text, false);
386+
else FindNext(findTextBox.Text, false);
389387
}
390388
}
391389

@@ -422,12 +420,12 @@ private void HighlightAllCheckBoxClick(Object sender, EventArgs e)
422420
List<SearchMatch> matches = this.GetResults(sci, this.findTextBox.Text);
423421
if (matches != null && matches.Count != 0)
424422
{
425-
this.RemoveHighlights(sci);
423+
sci.RemoveHighlights();
426424
if (this.highlightTimer.Enabled) this.highlightTimer.Stop();
427425
if (this.highlightCheckBox.Checked) this.AddHighlights(sci, matches);
428426
}
429427
}
430-
else this.RemoveHighlights(sci);
428+
else sci.RemoveHighlights();
431429
}
432430

433431
/// <summary>
@@ -547,7 +545,7 @@ private void CloseButtonClick(Object sender, EventArgs e)
547545
private void MoreButtonClick(Object sender, EventArgs e)
548546
{
549547
this.CloseButtonClick(null, null);
550-
PluginBase.MainForm.CallCommand("FindAndReplaceFrom", this.findTextBox.Text);
548+
PluginBase.MainForm.CallCommand("FindAndReplace", null);
551549
}
552550

553551
/// <summary>
@@ -557,31 +555,15 @@ private void AddHighlights(ScintillaControl sci, List<SearchMatch> matches)
557555
{
558556
ITabbedDocument doc = DocumentManager.FindDocument(sci);
559557
Language language = MainForm.Instance.SciConfig.GetLanguage(sci.ConfigurationLanguage);
560-
foreach (SearchMatch match in matches)
561-
{
562-
Int32 start = sci.MBSafePosition(match.Index);
563-
Int32 end = start + sci.MBSafeTextLength(match.Value);
564-
Int32 line = sci.LineFromPosition(start);
565-
Int32 position = start;
566-
Int32 es = sci.EndStyled;
567-
Int32 mask = 1 << sci.StyleBits;
568-
// Define indics in both controls...
569-
doc.SplitSci1.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox);
570-
doc.SplitSci1.SetIndicFore(0, language.editorstyle.HighlightBackColor);
571-
doc.SplitSci2.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox);
572-
doc.SplitSci2.SetIndicFore(0, language.editorstyle.HighlightBackColor);
573-
sci.StartStyling(position, mask);
574-
sci.SetStyling(end - start, mask);
575-
sci.StartStyling(es, mask - 1);
576-
}
558+
sci.AddHighlights(matches, language.editorstyle.HighlightBackColor);
577559
}
578560

579561
/// <summary>
580562
/// Refreshes the highlights
581563
/// </summary>
582564
private void RefreshHighlights(ScintillaControl sci, List<SearchMatch> matches)
583565
{
584-
this.RemoveHighlights(sci);
566+
sci.RemoveHighlights();
585567
if (this.highlightTimer.Enabled) this.highlightTimer.Stop();
586568
Hashtable table = new Hashtable();
587569
table["sci"] = sci;
@@ -590,19 +572,6 @@ private void RefreshHighlights(ScintillaControl sci, List<SearchMatch> matches)
590572
this.highlightTimer.Start();
591573
}
592574

593-
/// <summary>
594-
/// Removes the highlights from the correct sci control
595-
/// </summary>
596-
private void RemoveHighlights(ScintillaControl sci)
597-
{
598-
Int32 es = sci.EndStyled;
599-
Int32 mask = (1 << sci.StyleBits);
600-
sci.StartStyling(0, mask);
601-
sci.SetStyling(sci.TextLength, 0);
602-
sci.StartStyling(es, mask - 1);
603-
}
604-
605-
/// <summary>
606575
/// Gets search results for a sci control
607576
/// </summary>
608577
private List<SearchMatch> GetResults(ScintillaControl sci, String text)

‎FlashDevelop/MainForm.cs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,12 +2707,10 @@ public void FindAndReplaceFrom(Object sender, System.EventArgs e)
27072707
{
27082708
ToolStripItem button = (ToolStripItem)sender;
27092709
String file = ((ItemData)button.Tag).Tag;
2710-
27112710
((Form)PluginBase.MainForm).BeginInvoke((MethodInvoker)delegate
27122711
{
27132712
OpenEditableDocument(file);
27142713
});
2715-
27162714
this.frInDocDialog.Show();
27172715
}
27182716

0 commit comments

Comments
 (0)