diff --git a/External/Plugins/ASCompletion/Completion/ASGenerator.cs b/External/Plugins/ASCompletion/Completion/ASGenerator.cs index 08812bffde..024e56b058 100644 --- a/External/Plugins/ASCompletion/Completion/ASGenerator.cs +++ b/External/Plugins/ASCompletion/Completion/ASGenerator.cs @@ -17,6 +17,7 @@ using PluginCore.Managers; using PluginCore.Utilities; using ScintillaNet; +using ScintillaNet.Lexers; namespace ASCompletion.Completion { @@ -72,7 +73,7 @@ public bool ContextualGenerator(ScintillaControl sci, int position, ListThe length of the highlight. void Highlight(int startIndex, int length) { - int es = sci.EndStyled; - int mask = (1 << sci.StyleBits) - 1; + var es = sci.EndStyled; sci.SetIndicStyle(Indicator, (int) IndicatorStyle.Container); sci.SetIndicFore(Indicator, 0x00FF00); sci.CurrentIndicator = Indicator; sci.IndicatorFillRange(startIndex, length); - sci.StartStyling(es, mask); + sci.StartStyling(es, 0xff); } /// @@ -925,11 +924,7 @@ void AddHistory(string value) { // Delete redo history int excessCount = history.Count - ++historyIndex; - if (excessCount > 0) - { - history.RemoveRange(historyIndex, excessCount); - } - + if (excessCount > 0) history.RemoveRange(historyIndex, excessCount); history.Add(value); // Trim beginning of history diff --git a/External/Plugins/FlashDebugger/Helpers/ScintillaHelper.cs b/External/Plugins/FlashDebugger/Helpers/ScintillaHelper.cs index 3fcb58d243..9715e268ac 100644 --- a/External/Plugins/FlashDebugger/Helpers/ScintillaHelper.cs +++ b/External/Plugins/FlashDebugger/Helpers/ScintillaHelper.cs @@ -152,77 +152,75 @@ public static void ToggleMarker(ScintillaControl sci, int marker, int line) public static void AddHighlight(ScintillaControl sci, int line, int indicator, int value) { if (sci is null) return; - int start = sci.PositionFromLine(line); - int length = sci.LineLength(line); + var start = sci.PositionFromLine(line); + var length = sci.LineLength(line); if (start < 0 || length < 1) return; - int es = sci.EndStyled; - int mask = (1 << sci.StyleBits) - 1; - Language lang = PluginBase.MainForm.SciConfig.GetLanguage(sci.ConfigurationLanguage); - if (indicator == indicatorDebugCurrentLine) + var es = sci.EndStyled; + var lang = PluginBase.MainForm.SciConfig.GetLanguage(sci.ConfigurationLanguage); + switch (indicator) { - sci.SetIndicFore(indicator, lang.editorstyle.DebugLineBack); - sci.SetIndicSetAlpha(indicator, 40); // Improve contrast - } - else if (indicator == indicatorDebugEnabledBreakpoint) - { - sci.SetIndicFore(indicator, lang.editorstyle.ErrorLineBack); - sci.SetIndicSetAlpha(indicator, 40); // Improve contrast - } - else if (indicator == indicatorDebugDisabledBreakpoint) - { - sci.SetIndicFore(indicator, lang.editorstyle.DisabledLineBack); - sci.SetIndicSetAlpha(indicator, 40); // Improve contrast + case indicatorDebugCurrentLine: + sci.SetIndicFore(indicator, lang.editorstyle.DebugLineBack); + sci.SetIndicSetAlpha(indicator, 40); // Improve contrast + break; + case indicatorDebugEnabledBreakpoint: + sci.SetIndicFore(indicator, lang.editorstyle.ErrorLineBack); + sci.SetIndicSetAlpha(indicator, 40); // Improve contrast + break; + case indicatorDebugDisabledBreakpoint: + sci.SetIndicFore(indicator, lang.editorstyle.DisabledLineBack); + sci.SetIndicSetAlpha(indicator, 40); // Improve contrast + break; } sci.SetIndicStyle(indicator, 7); sci.CurrentIndicator = indicator; sci.IndicatorValue = value; sci.IndicatorFillRange(start, length); - sci.StartStyling(es, mask); + sci.StartStyling(es, 0xff); } public static void RemoveHighlight(ScintillaControl sci, int line, int indicator) { if (sci is null) return; - int start = sci.PositionFromLine(line); - int length = sci.LineLength(line); + var start = sci.PositionFromLine(line); + var length = sci.LineLength(line); if (start < 0 || length < 1) return; - int es = sci.EndStyled; - int mask = (1 << sci.StyleBits) - 1; - Language lang = PluginBase.MainForm.SciConfig.GetLanguage(sci.ConfigurationLanguage); - if (indicator == indicatorDebugCurrentLine) - { - sci.SetIndicFore(indicator, lang.editorstyle.DebugLineBack); - sci.SetIndicSetAlpha(indicator, 40); // Improve contrast - } - else if (indicator == indicatorDebugEnabledBreakpoint) - { - sci.SetIndicFore(indicator, lang.editorstyle.ErrorLineBack); - sci.SetIndicSetAlpha(indicator, 40); // Improve contrast - } - else if (indicator == indicatorDebugDisabledBreakpoint) + var es = sci.EndStyled; + var lang = PluginBase.MainForm.SciConfig.GetLanguage(sci.ConfigurationLanguage); + switch (indicator) { - sci.SetIndicFore(indicator, lang.editorstyle.DisabledLineBack); - sci.SetIndicSetAlpha(indicator, 40); // Improve contrast + case indicatorDebugCurrentLine: + sci.SetIndicFore(indicator, lang.editorstyle.DebugLineBack); + sci.SetIndicSetAlpha(indicator, 40); // Improve contrast + break; + case indicatorDebugEnabledBreakpoint: + sci.SetIndicFore(indicator, lang.editorstyle.ErrorLineBack); + sci.SetIndicSetAlpha(indicator, 40); // Improve contrast + break; + case indicatorDebugDisabledBreakpoint: + sci.SetIndicFore(indicator, lang.editorstyle.DisabledLineBack); + sci.SetIndicSetAlpha(indicator, 40); // Improve contrast + break; } sci.SetIndicStyle(indicator, 7); sci.CurrentIndicator = indicator; sci.IndicatorClearRange(start, length); - sci.StartStyling(es, mask); + sci.StartStyling(es, 0xff); } public static void RemoveAllHighlights(ScintillaControl sci) { if (sci is null) return; - int es = sci.EndStyled; + var es = sci.EndStyled; int[] indics = { indicatorDebugCurrentLine, indicatorDebugDisabledBreakpoint, indicatorDebugEnabledBreakpoint }; - foreach (int indicator in indics) + foreach (var indicator in indics) { sci.CurrentIndicator = indicator; - for (int position = 0; position < sci.Length;) + for (var position = 0; position < sci.Length;) { - int start = sci.IndicatorStart(indicator, position); - int end = sci.IndicatorEnd(indicator, start); - int length = end - start; + var start = sci.IndicatorStart(indicator, position); + var end = sci.IndicatorEnd(indicator, start); + var length = end - start; if (length > 0) { sci.IndicatorClearRange(start, length); @@ -231,7 +229,7 @@ public static void RemoveAllHighlights(ScintillaControl sci) else break; } } - sci.StartStyling(es, (1 << sci.StyleBits) - 1); + sci.StartStyling(es, 0xff); } #endregion diff --git a/FlashDevelop/Bin/Debug/SciLexer.dll b/FlashDevelop/Bin/Debug/SciLexer.dll index 0db5a60219..3570ea6121 100755 Binary files a/FlashDevelop/Bin/Debug/SciLexer.dll and b/FlashDevelop/Bin/Debug/SciLexer.dll differ diff --git a/FlashDevelop/Bin/Debug/SciLexer64.dll b/FlashDevelop/Bin/Debug/SciLexer64.dll index 6b1059cc24..ccea3117c3 100755 Binary files a/FlashDevelop/Bin/Debug/SciLexer64.dll and b/FlashDevelop/Bin/Debug/SciLexer64.dll differ diff --git a/FlashDevelop/Managers/ScintillaManager.cs b/FlashDevelop/Managers/ScintillaManager.cs index 745699465f..4b7b85236a 100644 --- a/FlashDevelop/Managers/ScintillaManager.cs +++ b/FlashDevelop/Managers/ScintillaManager.cs @@ -229,6 +229,7 @@ public static void ApplySciSettings(ScintillaControl sci, bool hardUpdate) sci.TabWidth = settings.TabWidth; sci.ViewWS = Convert.ToInt32(settings.ViewWhitespace); sci.WrapMode = Convert.ToInt32(settings.WrapText); + sci.TabDrawMode = (int) settings.TabDrawMode; sci.SetProperty("fold", Convert.ToInt32(settings.UseFolding).ToString()); sci.SetProperty("fold.comment", Convert.ToInt32(settings.FoldComment).ToString()); sci.SetProperty("fold.compact", Convert.ToInt32(settings.FoldCompact).ToString()); @@ -375,7 +376,6 @@ public static ScintillaControl CreateControl(string file, string text, int codep sci.SelectionStart = 0; sci.SmartIndentType = SmartIndent.CPP; sci.Status = 0; - sci.StyleBits = 7; sci.TabIndex = 0; sci.TargetEnd = 0; sci.TargetStart = 0; diff --git a/FlashDevelop/Settings/Accessors.cs b/FlashDevelop/Settings/Accessors.cs index 4ca8fbb17c..c5208e8d8a 100644 --- a/FlashDevelop/Settings/Accessors.cs +++ b/FlashDevelop/Settings/Accessors.cs @@ -10,6 +10,7 @@ using PluginCore; using PluginCore.Localization; using ScintillaNet.Enums; +using TabDrawMode = ScintillaNet.Enums.TabDrawMode; namespace FlashDevelop.Settings { @@ -390,6 +391,11 @@ public int ClipboardHistorySize } } + [DefaultValue(TabDrawMode.LongArrow)] + [DisplayName("Tab draw mode")] + [LocalizedCategory("FlashDevelop.Category.Editor")] + public TabDrawMode TabDrawMode { get; set; } = TabDrawMode.LongArrow; + #endregion #region Locale diff --git a/PluginCore/PluginCore/Interfaces.cs b/PluginCore/PluginCore/Interfaces.cs index 61aef38ee0..e6522ccb1d 100644 --- a/PluginCore/PluginCore/Interfaces.cs +++ b/PluginCore/PluginCore/Interfaces.cs @@ -7,6 +7,7 @@ using ScintillaNet.Configuration; using ScintillaNet.Enums; using WeifenLuo.WinFormsUI.Docking; +using TabDrawMode = ScintillaNet.Enums.TabDrawMode; namespace PluginCore { @@ -576,7 +577,7 @@ public interface ISettings bool EndAtLastLine { get; set; } string InsertionTriggers { get; set; } int ClipboardHistorySize { get; set; } - + TabDrawMode TabDrawMode { get; set; } #endregion } diff --git a/PluginCore/ScintillaNet/Enums.cs b/PluginCore/ScintillaNet/Enums.cs index c45f1a77b7..17ac80b0f3 100644 --- a/PluginCore/ScintillaNet/Enums.cs +++ b/PluginCore/ScintillaNet/Enums.cs @@ -80,7 +80,8 @@ public enum MarginType Back = 2, Fore = 3, Text = 4, - Rtext = 5 + Rtext = 5, + Color = 6, } public enum WhiteSpace @@ -106,6 +107,7 @@ public enum StylesCommon ControlChar = 36, IndentGuide = 37, Calltip = 38, + FoldDisplayText = 39, LastPredefined = 39, Max = 255 } @@ -505,4 +507,10 @@ public enum HighlightMatchingWordsMode SelectedWord, None } -} + + public enum TabDrawMode + { + LongArrow = 0, + StrikeOut = 1, + } +} \ No newline at end of file diff --git a/PluginCore/ScintillaNet/Lexers.cs b/PluginCore/ScintillaNet/Lexers.cs index 2707e4635a..c62f460caf 100644 --- a/PluginCore/ScintillaNet/Lexers.cs +++ b/PluginCore/ScintillaNet/Lexers.cs @@ -81,9 +81,9 @@ public enum CPP HASHQUOTEDSTRING = 22, PREPROCESSORCOMMENT = 23, PREPROCESSORCOMMENTDOC = 24, - WORD3 = 24, - WORD4 = 25, - WORD5 = 26, + WORD3 = 100, + WORD4 = 101, + WORD5 = 102, GDEFAULT = 32, LINENUMBER = 33, BRACELIGHT = 34, diff --git a/PluginCore/ScintillaNet/ScintillaControl.cs b/PluginCore/ScintillaNet/ScintillaControl.cs index 3853c784e9..f6e4bce088 100644 --- a/PluginCore/ScintillaNet/ScintillaControl.cs +++ b/PluginCore/ScintillaNet/ScintillaControl.cs @@ -232,7 +232,7 @@ public ScintillaControl(string fullPath) { fullPath = Path.Combine(PathHelper.AppDir, fullPath); var lib = LoadLibrary(fullPath); - HandleSci = CreateWindowEx(0, "Scintilla", "", WS_CHILD_VISIBLE_TABSTOP, 0, 0, Width, Height, Handle, 0, new IntPtr(0), null); + HandleSci = CreateWindowEx(0, "Scintilla", string.Empty, WS_CHILD_VISIBLE_TABSTOP, 0, 0, Width, Height, Handle, 0, IntPtr.Zero, null); directPointer = SlowPerform(2185, IntPtr.Zero, IntPtr.Zero); var pointer = GetProcAddress(new HandleRef(null, lib), "Scintilla_DirectFunction"); if (pointer == IntPtr.Zero) pointer = GetProcAddress(new HandleRef(null, lib), "_Scintilla_DirectFunction@16"); @@ -264,19 +264,13 @@ public void OnResize(object sender, EventArgs e) { int vsbWidth = Controls.Contains(vScrollBar) && vScrollBar.Visible ? vScrollBar.Width : 0; int hsbHeight = Controls.Contains(hScrollBar) && hScrollBar.Visible ? hScrollBar.Height : 0; - if (Win32.ShouldUseWin32()) - { - SetWindowPos(HandleSci, 0, ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - vsbWidth, ClientRectangle.Height - hsbHeight, 0); - } + if (Win32.ShouldUseWin32()) SetWindowPos(HandleSci, 0, ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - vsbWidth, ClientRectangle.Height - hsbHeight, 0); if (Controls.Contains(vScrollBar)) { vScrollBar.SetBounds(ClientRectangle.Width - vsbWidth, 0, vScrollBar.Width, ClientRectangle.Height - hsbHeight); hScrollBar.SetBounds(0, ClientRectangle.Height - hsbHeight, ClientRectangle.Width - vsbWidth, hScrollBar.Height); scrollerCorner.Visible = vScrollBar.Visible && hScrollBar.Visible; - if (scrollerCorner.Visible) - { - scrollerCorner.Location = new Point(vScrollBar.Location.X, hScrollBar.Location.Y); - } + if (scrollerCorner.Visible) scrollerCorner.Location = new Point(vScrollBar.Location.X, hScrollBar.Location.Y); } } @@ -404,7 +398,6 @@ void SetLanguage(string value) lang.lexer.key = (int) key; configLanguage = value; Lexer = lang.lexer.key; - if (lang.lexer.stylebits > 0) StyleBits = lang.lexer.stylebits; if (lang.editorstyle != null) { EdgeColour = lang.editorstyle.PrintMarginColor; @@ -886,10 +879,13 @@ public int CaretPeriod /// /// Retrieve number of bits in style bytes used to hold the lexical state. /// + [Obsolete("Deprecated by 4.0.1. Please use `mask = 0xff` instead of `mask = ((1 << StyleBits) - 1)`")] public int StyleBits { - get => SPerform(2091).ToInt32(); - set => SPerform(2090, value); + get => 8; + set + { + } } /// @@ -1487,7 +1483,7 @@ public int ExtraAscent } /// - /// Set extra descent for each line + /// Gets or sets extra descent for each line /// public int ExtraDescent { @@ -1496,7 +1492,16 @@ public int ExtraDescent } /// - /// Get the start of the range of style numbers used for margin text + /// Gets or sets number of margins + /// + public int Margins + { + get => (int) SPerform(2253); + set => SPerform(2252, value); + } + + /// + /// Gets or sets the start of the range of style numbers used for margin text /// public int MarginStyleOffset { @@ -1505,7 +1510,7 @@ public int MarginStyleOffset } /// - /// Get the start of the range of style numbers used for annotations + /// Get or sets the start of the range of style numbers used for annotations /// public int AnnotationStyleOffset { @@ -1514,7 +1519,7 @@ public int AnnotationStyleOffset } /// - /// Get the start of the range of style numbers used for annotations + /// Get or sets the start of the range of style numbers used for annotations /// public bool AnnotationVisible { @@ -1523,7 +1528,7 @@ public bool AnnotationVisible } /// - /// Sets whether the maximum width line displayed is used to set scroll width. + /// Gets or sets whether the maximum width line displayed is used to set scroll width. /// public bool ScrollWidthTracking { @@ -1678,10 +1683,7 @@ public void SmartSelectionDuplicate() /// /// Sets a style to be italic or not. /// - public void StyleSetItalic(int style, bool italic) - { - SPerform(2054, style, italic ? 1 : 0); - } + public void StyleSetItalic(int style, bool italic) => SPerform(2054, style, italic ? 1 : 0); /// /// Gets whether a style is italic or not. @@ -1806,6 +1808,7 @@ public unsafe void AutoCSetFillUps(string characterSet) /// /// Retrieve the number of bits the current lexer needs for styling. /// + [Obsolete("Deprecated by 4.0.1")] public int GetStyleBitsNeeded() => SPerform(4011).ToInt32(); /// @@ -1956,6 +1959,16 @@ public unsafe void LexerLanguage(string language) /// public void SetMarginCursorN(int margin, int cursor) => SPerform(2248, margin, cursor); + /// + /// Gets the color of a margin. + /// + public int GetMarginBackN(int margin) => (int) SPerform(2251, margin); + + /// + /// Set the color of a margin. + /// + public void SetMarginBackN(int margin, int color) => SPerform(2250, margin, color); + /// /// Retrieve the style of an indicator. /// @@ -2714,6 +2727,14 @@ public unsafe void CallTipShow(int pos, string definition) /// public void SetFoldFlags(int flags) => SPerform(2233, flags); + public void ToggleFoldShowText(int line, char ch) => SPerform(2700, line, ch); + + public int FoldDisplayTextStyle + { + get => (int) SPerform(2707); + set => SPerform(2701, value); + } + /// /// Ensure a particular line is visible by expanding any header line hiding it. /// Use the currently set visibility policy to determine which range to display. @@ -2723,10 +2744,7 @@ public unsafe void CallTipShow(int pos, string definition) /// /// Get position of start of word. /// - public int WordStartPosition(int pos, bool onlyWordCharacters) - { - return SPerform(2266, pos, onlyWordCharacters ? 1 : 0); - } + public int WordStartPosition(int pos, bool onlyWordCharacters) => SPerform(2266, pos, onlyWordCharacters ? 1 : 0); /// /// Get position of end of word. @@ -3781,23 +3799,19 @@ public ShortcutOverride(Keys keys, Action action) public delegate IntPtr Perform(IntPtr sci, int iMessage, IntPtr wParam, IntPtr lParam); public uint SlowPerform(uint message, uint wParam, uint lParam) - { - return (uint) SendMessage(HandleSci, (int) message, (IntPtr)wParam, (IntPtr)lParam); - } + => (uint) SendMessage(HandleSci, (int) message, (IntPtr)wParam, (IntPtr)lParam); public IntPtr SlowPerform(int message, IntPtr wParam, IntPtr lParam) => SendMessage(HandleSci, message, wParam, lParam); public int SPerform(int message, int wParam, uint lParam) - { - if (Win32.ShouldUseWin32()) return (int)_sciFunction(directPointer, message, (IntPtr)wParam, (IntPtr)lParam); - return Encoding.ASCII.CodePage; - } + => Win32.ShouldUseWin32() + ? (int) _sciFunction(directPointer, message, (IntPtr) wParam, (IntPtr) lParam) + : Encoding.ASCII.CodePage; public int SPerform(int message, int wParam, int lParam) - { - if (Win32.ShouldUseWin32()) return (int)_sciFunction(directPointer, message, (IntPtr)wParam, (IntPtr)lParam); - return Encoding.ASCII.CodePage; - } + => Win32.ShouldUseWin32() + ? (int) _sciFunction(directPointer, message, (IntPtr) wParam, (IntPtr) lParam) + : Encoding.ASCII.CodePage; public IntPtr SPerform(int message) => SPerform(message, IntPtr.Zero); @@ -3811,33 +3825,32 @@ public IntPtr SPerform(int message, IntPtr wParam, IntPtr lParam) : (IntPtr) Encoding.ASCII.CodePage; public int SPerform(int message, int wParam, IntPtr lParam) - { - if (Win32.ShouldUseWin32()) return (int)_sciFunction(directPointer, message, (IntPtr)wParam, lParam); - return Encoding.ASCII.CodePage; - } + => Win32.ShouldUseWin32() + ? (int) _sciFunction(directPointer, message, (IntPtr) wParam, lParam) + : Encoding.ASCII.CodePage; public override bool PreProcessMessage(ref Message m) { switch (m.Msg) { case WM_KEYDOWN: + var keys = (int) ModifierKeys + (int) m.WParam; + if (!IsFocus || IgnoreAllKeys || ignoredKeys.ContainsKey(keys)) { - int keys = (int)ModifierKeys + (int)m.WParam; - if (!IsFocus || IgnoreAllKeys || ignoredKeys.ContainsKey(keys)) - { - if (ExecuteShortcut(keys) || base.PreProcessMessage(ref m)) return true; - } - if (((ModifierKeys & Keys.Control) != 0) && ((ModifierKeys & Keys.Alt) == 0)) + if (ExecuteShortcut(keys) || base.PreProcessMessage(ref m)) return true; + } + if (((ModifierKeys & Keys.Control) != 0) && ((ModifierKeys & Keys.Alt) == 0)) + { + var code = (int) m.WParam; + switch (code) { - int code = (int)m.WParam; - if ((code >= 65) && (code <= 90)) return true; // Eat non-writable characters - if ((code == 9) || (code == 33) || (code == 34)) // Transmit Ctrl with Tab, PageUp/PageDown - { - return base.PreProcessMessage(ref m); - } + case >= 65 and <= 90: return true; // Eat non-writable characters + case 9: + case 33: + case 34: return base.PreProcessMessage(ref m); // Transmit Ctrl with Tab, PageUp/PageDown } - break; } + break; case WM_SYSKEYDOWN: case WM_SYSCHAR: return base.PreProcessMessage(ref m); } @@ -3848,7 +3861,7 @@ protected override void WndProc(ref Message m) { if (m.Msg == WM_COMMAND) { - int message = (m.WParam.ToInt32() >> 16) & 0xffff; + var message = ((int)m.WParam >> 16) & 0xffff; if (message == (int)Enums.Command.SetFocus || message == (int)Enums.Command.KillFocus) { FocusChanged?.Invoke(this); @@ -3866,7 +3879,10 @@ protected override void WndProc(ref Message m) break; case (uint)Enums.ScintillaEvents.CharAdded: - CharAdded?.Invoke(this, scn.ch); + var ch = scn.ch == 0 && scn.modifiers != 0 + ? scn.modifiers // x64 + : scn.ch; + CharAdded?.Invoke(this, ch); break; case (uint)Enums.ScintillaEvents.SavePointReached: @@ -4971,15 +4987,23 @@ public string GetWordFromPosition(int position) } } + /// + /// Gets of set the tab draw mode + /// 0 - The "long arrow" which is the normal/default way + /// 1 - The "strike out" is a single horizontal line (like the arrow but with no arrow head). This is how Sublime text does and maybe others. + /// + public int TabDrawMode + { + get => (int) SPerform(2698); + set => SPerform(2699, value); + } + /// /// Insert text with wide-char to byte position conversion /// public void MBSafeInsertText(int position, string text) { - if (CodePage != 65001) - { - InsertText(position, text); - } + if (CodePage != 65001) InsertText(position, text); else { int mbpos = MBSafePosition(position); @@ -4992,10 +5016,7 @@ public void MBSafeInsertText(int position, string text) /// public void MBSafeGotoPos(int position) { - if (CodePage != 65001) - { - GotoPos(position); - } + if (CodePage != 65001) GotoPos(position); else { int mbpos = MBSafePosition(position); @@ -5008,10 +5029,7 @@ public void MBSafeGotoPos(int position) /// public void MBSafeSetSel(int start, int end) { - if (CodePage != 65001) - { - SetSel(start, end); - } + if (CodePage != 65001) SetSel(start, end); else { var count = Text.Substring(start, end - start); @@ -5026,10 +5044,7 @@ public void MBSafeSetSel(int start, int end) /// public void MBSafeSetSel(int start, string text) { - if (CodePage != 65001) - { - SetSel(start, start + text.Length); - } + if (CodePage != 65001) SetSel(start, start + text.Length); else { int mbpos = MBSafePosition(start); @@ -5180,7 +5195,7 @@ unsafe void HandleFileDrop(IntPtr hDrop) /// /// Returns the base style (without indicators) byte at the position. /// - public int BaseStyleAt(int pos) => (SPerform(2010, pos, 0) & ((1 << StyleBits) - 1)); + public int BaseStyleAt(int pos) => SPerform(2010, pos, 0) & 0xff; /// /// Adds the specified highlight to the control @@ -5189,8 +5204,7 @@ public void AddHighlight(int indicator, int indicStyle, int highlightColor, int { var doc = DocumentManager.FindDocument(this); if (doc is null) return; - int es = EndStyled; - int mask = (1 << StyleBits) - 1; + var es = EndStyled; // Define indics in both controls... doc.SplitSci1.SetIndicStyle(indicator, indicStyle); doc.SplitSci1.SetIndicFore(indicator, highlightColor); @@ -5201,12 +5215,11 @@ public void AddHighlight(int indicator, int indicStyle, int highlightColor, int CurrentIndicator = indicator; IndicatorValue = 1; IndicatorFillRange(start, length); - StartStyling(es, mask); - } - public void AddHighlight(int indicStyle, int highlightColor, int start, int length) - { - AddHighlight(0, indicStyle, highlightColor, start, length); + StartStyling(es, 0xff); } + + public void AddHighlight(int indicStyle, int highlightColor, int start, int length) => AddHighlight(0, indicStyle, highlightColor, start, length); + public void AddHighlight(int highlightColor, int start, int length) { int indicStyle = (int)Enums.IndicatorStyle.RoundBox; @@ -5221,11 +5234,10 @@ public void AddHighlights(int indicator, int indicStyle, List match if (matches is null) return; var doc = DocumentManager.FindDocument(this); if (doc is null) return; - foreach (SearchMatch match in matches) + foreach (var match in matches) { - int es = EndStyled; - int mask = (1 << StyleBits) - 1; - int start = MBSafePosition(match.Index); + var es = EndStyled; + var start = MBSafePosition(match.Index); // Define indics in both controls... doc.SplitSci1.SetIndicStyle(indicator, (int)Enums.IndicatorStyle.RoundBox); doc.SplitSci1.SetIndicFore(indicator, highlightColor); @@ -5236,7 +5248,7 @@ public void AddHighlights(int indicator, int indicStyle, List match CurrentIndicator = indicator; IndicatorValue = 1; IndicatorFillRange(start, MBSafeTextLength(match.Value)); - StartStyling(es, mask); + StartStyling(es, 0xff); } } public void AddHighlights(int indicator, List matches, int highlightColor) @@ -5255,11 +5267,10 @@ public void AddHighlights(List matches, int highlightColor) /// public void RemoveHighlight(int indicator, int start, int length) { - int es = EndStyled; - int mask = (1 << StyleBits) - 1; + var es = EndStyled; CurrentIndicator = indicator; IndicatorClearRange(start, length); - StartStyling(es, mask); + StartStyling(es, 0xff); } public void RemoveHighlight(int start, int length) => RemoveHighlight(0, start, length); @@ -5268,11 +5279,10 @@ public void RemoveHighlight(int indicator, int start, int length) /// public void RemoveHighlights(int indicator) { - int es = EndStyled; - int mask = (1 << StyleBits) - 1; + var es = EndStyled; CurrentIndicator = indicator; IndicatorClearRange(0, Length); - StartStyling(es, mask); + StartStyling(es, 0xff); } public void RemoveHighlights() => RemoveHighlights(0); diff --git a/Tests/External/Plugins/ASCompletion.Tests/ASCompletionTests.cs b/Tests/External/Plugins/ASCompletion.Tests/ASCompletionTests.cs index 1959c3e419..e8843338b9 100644 --- a/Tests/External/Plugins/ASCompletion.Tests/ASCompletionTests.cs +++ b/Tests/External/Plugins/ASCompletion.Tests/ASCompletionTests.cs @@ -75,7 +75,6 @@ public void FixtureTearDown() CodePage = 65001, Indent = settings.IndentSize, Lexer = 3, - StyleBits = 7, IsTabIndents = settings.TabIndents, IsUseTabs = settings.UseTabs, TabWidth = settings.TabWidth diff --git a/Tests/External/Plugins/ASCompletion.Tests/Completion/ASCompleteTests.cs b/Tests/External/Plugins/ASCompletion.Tests/Completion/ASCompleteTests.cs index 0b1f2e5fef..6998b2ae1b 100644 --- a/Tests/External/Plugins/ASCompletion.Tests/Completion/ASCompleteTests.cs +++ b/Tests/External/Plugins/ASCompletion.Tests/Completion/ASCompleteTests.cs @@ -1179,7 +1179,7 @@ static IEnumerable IsStringStyleTestCases yield return new TestCaseData("$(EntryPoint)120").Returns(false); yield return new TestCaseData("\"$(EntryPoint)120\"").Returns(true); yield return new TestCaseData("$(EntryPoint)\"120\"").Returns(true); - yield return new TestCaseData("$(EntryPoint)\"").Returns(true); + yield return new TestCaseData("$(EntryPoint)\"").Returns(false); yield return new TestCaseData("'$(EntryPoint)\"'").Returns(false); yield return new TestCaseData("'$(EntryPoint)120'").Returns(false); yield return new TestCaseData("$(EntryPoint)'120'").Returns(false); @@ -1206,7 +1206,7 @@ static IEnumerable IsCharStyleTestCases yield return new TestCaseData("'$(EntryPoint)\"'").Returns(true); yield return new TestCaseData("'$(EntryPoint)120'").Returns(true); yield return new TestCaseData("$(EntryPoint)'120'").Returns(true); - yield return new TestCaseData("$(EntryPoint)'").Returns(true); + yield return new TestCaseData("$(EntryPoint)'").Returns(false); yield return new TestCaseData("some_$(EntryPoint)120").Returns(false); } } @@ -1219,6 +1219,54 @@ public bool IsCharStyle(string text) } static IEnumerable IsTextStyleTestCases + { + get + { + yield return new TestCaseData("$(EntryPoint)120").Returns(false); + yield return new TestCaseData("$(EntryPoint)\"120\"").Returns(false); + yield return new TestCaseData("$(EntryPoint)'120'").Returns(false); + yield return new TestCaseData("$(EntryPoint)some").Returns(true); + yield return new TestCaseData("//$(EntryPoint)some").Returns(false); + yield return new TestCaseData("/*$(EntryPoint)some*/").Returns(false); + yield return new TestCaseData("$(EntryPoint)/\\s/gm") + .SetDescription("Is regex text?") + .Returns(true); + yield return new TestCaseData("/$(EntryPoint)\\s/gm") + .SetDescription("Is regex text?") + .Returns(true); + yield return new TestCaseData("'$(EntryPoint),'").Returns(false); + yield return new TestCaseData("\"$(EntryPoint),\"").Returns(false); + yield return new TestCaseData("$(EntryPoint)+").Returns(true); + yield return new TestCaseData("$(EntryPoint)=").Returns(true); + yield return new TestCaseData("thi$(EntryPoint)s").Returns(true); + yield return new TestCaseData("publ$(EntryPoint)ic").Returns(false); + yield return new TestCaseData("functi$(EntryPoint)on").Returns(false); + yield return new TestCaseData("sta$(EntryPoint)tic").Returns(false); + yield return new TestCaseData("clas$(EntryPoint)s").Returns(false); + yield return new TestCaseData("$(EntryPoint)final").Returns(false); + yield return new TestCaseData("$(EntryPoint)new").Returns(false); + yield return new TestCaseData("$(EntryPoint)var").Returns(false); + yield return new TestCaseData("ret$(EntryPoint)urn").Returns(false); + yield return new TestCaseData("class Na$(EntryPoint)me").Returns(true); + yield return new TestCaseData("var $(EntryPoint)name").Returns(true); + yield return new TestCaseData("var name:$(EntryPoint)Type").Returns(true); + yield return new TestCaseData("var name:$(EntryPoint)Type").Returns(true); + yield return new TestCaseData("$(EntryPoint),").Returns(true); + yield return new TestCaseData("$(EntryPoint);").Returns(true); + yield return new TestCaseData("$(EntryPoint)AS3").Returns(true); + yield return new TestCaseData("nu$(EntryPoint)ll").Returns(false); + yield return new TestCaseData("N$(EntryPoint)aN").Returns(false); + } + } + + [Test, TestCaseSource(nameof(IsTextStyleTestCases))] + public bool IsTextStyle(string text) + { + SetSrc(sci, text); + return ASComplete.IsTextStyle(sci.StyleAt(sci.CurrentPos)); + } + + static IEnumerable IsTextStyleExTestCases { get { @@ -1259,11 +1307,11 @@ static IEnumerable IsTextStyleTestCases } } - [Test, TestCaseSource(nameof(IsTextStyleTestCases))] - public bool IsTextStyle(string text) + [Test, TestCaseSource(nameof(IsTextStyleExTestCases))] + public bool IsTextStyleEx(string text) { SetSrc(sci, text); - return ASComplete.IsTextStyle(sci.StyleAt(sci.CurrentPos)); + return ASComplete.IsTextStyleEx(sci.StyleAt(sci.CurrentPos)); } static IEnumerable IsCommentStyleTestCases diff --git a/Tests/PluginCore/PluginCore.Tests/ScintillaNet/ScintillaControlTests.cs b/Tests/PluginCore/PluginCore.Tests/ScintillaNet/ScintillaControlTests.cs index c3552f1aa9..41584e4f4d 100644 --- a/Tests/PluginCore/PluginCore.Tests/ScintillaNet/ScintillaControlTests.cs +++ b/Tests/PluginCore/PluginCore.Tests/ScintillaNet/ScintillaControlTests.cs @@ -67,7 +67,6 @@ ScintillaControl GetBaseScintillaControl() CodePage = 65001, Indent = settings.IndentSize, Lexer = 3, - StyleBits = 7, IsTabIndents = settings.TabIndents, IsUseTabs = settings.UseTabs, TabWidth = settings.TabWidth