From 8cf4ec99acba2c07d8375ebb095631dbd6c77022 Mon Sep 17 00:00:00 2001 From: latenightbuddha Date: Thu, 12 Feb 2026 16:59:36 -0500 Subject: [PATCH 1/3] Delete ScintillaNet directory --- ScintillaNet/CaretStyle.cs | 28 - ScintillaNet/CharAddedEventArgs.cs | 28 - ScintillaNet/Document.cs | 65 - ScintillaNet/EdgeMode.cs | 28 - ScintillaNet/Indicator.cs | 225 -- ScintillaNet/IndicatorCollection.cs | 78 - ScintillaNet/IndicatorStyle.cs | 104 - ScintillaNet/Lexer.cs | 44 - ScintillaNet/Line.cs | 405 --- ScintillaNet/Margin.cs | 126 - ScintillaNet/MarginClickEventArgs.cs | 60 - ScintillaNet/MarginCollection.cs | 146 - ScintillaNet/MarginType.cs | 43 - ScintillaNet/Marker.cs | 163 - ScintillaNet/MarkerCollection.cs | 70 - ScintillaNet/MarkerSymbol.cs | 172 - ScintillaNet/NativeMethods.cs | 1304 -------- ScintillaNet/Scintilla.cs | 4601 -------------------------- ScintillaNet/SearchFlags.cs | 45 - ScintillaNet/Selection.cs | 154 - ScintillaNet/Style.cs | 832 ----- ScintillaNet/StyleCase.cs | 28 - ScintillaNet/StyleCollection.cs | 70 - ScintillaNet/StyleNeededEventArgs.cs | 44 - ScintillaNet/WhitespaceMode.cs | 29 - ScintillaNet/WrapMode.cs | 33 - 26 files changed, 8925 deletions(-) delete mode 100644 ScintillaNet/CaretStyle.cs delete mode 100644 ScintillaNet/CharAddedEventArgs.cs delete mode 100644 ScintillaNet/Document.cs delete mode 100644 ScintillaNet/EdgeMode.cs delete mode 100644 ScintillaNet/Indicator.cs delete mode 100644 ScintillaNet/IndicatorCollection.cs delete mode 100644 ScintillaNet/IndicatorStyle.cs delete mode 100644 ScintillaNet/Lexer.cs delete mode 100644 ScintillaNet/Line.cs delete mode 100644 ScintillaNet/Margin.cs delete mode 100644 ScintillaNet/MarginClickEventArgs.cs delete mode 100644 ScintillaNet/MarginCollection.cs delete mode 100644 ScintillaNet/MarginType.cs delete mode 100644 ScintillaNet/Marker.cs delete mode 100644 ScintillaNet/MarkerCollection.cs delete mode 100644 ScintillaNet/MarkerSymbol.cs delete mode 100644 ScintillaNet/NativeMethods.cs delete mode 100644 ScintillaNet/Scintilla.cs delete mode 100644 ScintillaNet/SearchFlags.cs delete mode 100644 ScintillaNet/Selection.cs delete mode 100644 ScintillaNet/Style.cs delete mode 100644 ScintillaNet/StyleCase.cs delete mode 100644 ScintillaNet/StyleCollection.cs delete mode 100644 ScintillaNet/StyleNeededEventArgs.cs delete mode 100644 ScintillaNet/WhitespaceMode.cs delete mode 100644 ScintillaNet/WrapMode.cs diff --git a/ScintillaNet/CaretStyle.cs b/ScintillaNet/CaretStyle.cs deleted file mode 100644 index 35ebb8e..0000000 --- a/ScintillaNet/CaretStyle.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// The caret visual style. - /// - public enum CaretStyle - { - /// - /// The caret is not displayed. - /// - Invisible = NativeMethods.CARETSTYLE_INVISIBLE, - - /// - /// The caret is drawn as a vertical line. - /// - Line = NativeMethods.CARETSTYLE_LINE, - - /// - /// The caret is drawn as a block. - /// - Block = NativeMethods.CARETSTYLE_BLOCK - } -} diff --git a/ScintillaNet/CharAddedEventArgs.cs b/ScintillaNet/CharAddedEventArgs.cs deleted file mode 100644 index 5f5adc2..0000000 --- a/ScintillaNet/CharAddedEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// Provides data for the event. - /// - public class CharAddedEventArgs : EventArgs - { - /// - /// Gets the text character added to a control. - /// - /// The character added. - public int Char { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// The character added. - public CharAddedEventArgs(int ch) - { - Char = ch; - } - } -} diff --git a/ScintillaNet/Document.cs b/ScintillaNet/Document.cs deleted file mode 100644 index 7823db9..0000000 --- a/ScintillaNet/Document.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// A document. - /// - /// - /// This is an opaque type, meaning it can be used by a control but - /// otherwise has no public members of its own. - /// - public struct Document - { - internal IntPtr Value; - - /// - /// A read-only field that represents an uninitialized document. - /// - public static readonly Document Empty; - - /// - /// Returns a value indicating whether this instance is equal to a specified object. - /// - /// An object to compare with this instance or null. - /// true if is an instance of and equals the value of this instance; otherwise, false. - public override bool Equals(object obj) - { - return (obj is IntPtr) && Value == ((Document)obj).Value; - } - - /// - /// Returns the hash code for this instance. - /// - /// A 32-bit signed integer hash code. - public override int GetHashCode() - { - return Value.GetHashCode(); - } - - /// - /// Determines whether two specified instances of are equal. - /// - /// The first document to compare. - /// The second document to compare. - /// true if equals ; otherwise, false. - public static bool operator ==(Document a, Document b) - { - return a.Value == b.Value; - } - - /// - /// Determines whether two specified instances of are not equal. - /// - /// The first document to compare. - /// The second document to compare. - /// true if does not equal ; otherwise, false. - public static bool operator !=(Document a, Document b) - { - return a.Value != b.Value; - } - } -} diff --git a/ScintillaNet/EdgeMode.cs b/ScintillaNet/EdgeMode.cs deleted file mode 100644 index 8ae21fc..0000000 --- a/ScintillaNet/EdgeMode.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// The long line edge display mode. - /// - public enum EdgeMode - { - /// - /// Long lines are not indicated. This is the default. - /// - None = NativeMethods.EDGE_NONE, - - /// - /// Long lines are indicated with a vertical line. - /// - Line = NativeMethods.EDGE_LINE, - - /// - /// Long lines are indicated with a background color. - /// - Background = NativeMethods.EDGE_BACKGROUND - } -} diff --git a/ScintillaNet/Indicator.cs b/ScintillaNet/Indicator.cs deleted file mode 100644 index f172d7b..0000000 --- a/ScintillaNet/Indicator.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// Represents an indicator in a control. - /// - public class Indicator - { - private readonly Scintilla scintilla; - - /// - /// An OR mask to use with and to indicate - /// that the user-defined indicator value should be treated as a RGB color. - /// - public const int ValueBit = NativeMethods.SC_INDICVALUEBIT; - - /// - /// An AND mask to use with to retrieve the user-defined value as a RGB color when being treated as such. - /// - public const int ValueMask = NativeMethods.SC_INDICVALUEMASK; - - /* - /// - /// Given a position within a text range using this indicator, will return - /// the end position of that range. - /// - /// Any zero-based byte position with the range using this indicator. - /// The end position byte index. - public int FindEnd(int position) - { - return scintilla.DirectMessage(NativeMethods.SCI_INDICATOREND, new IntPtr(Index), new IntPtr(position)).ToInt32(); - } - - /// - /// Given a position within a text range using this indicator, will return - /// the start position of that range. - /// - /// Any zero-based byte position with the range using this indicator. - /// The start position byte index. - public int FindStart(int position) - { - return scintilla.DirectMessage(NativeMethods.SCI_INDICATORSTART, new IntPtr(Index), new IntPtr(position)).ToInt32(); - } - */ - - /// - /// Returns the user-defined value for the indicator at the specified position. - /// - /// The zero-based document position to get the indicator value for. - /// The user-defined value at the specified . - public int ValueAt(int position) - { - position = Helpers.Clamp(position, 0, scintilla.TextLength); - position = scintilla.Lines.CharToBytePosition(position); - - return scintilla.DirectMessage(NativeMethods.SCI_INDICATORVALUEAT, new IntPtr(Index), new IntPtr(position)).ToInt32(); - } - - /// - /// Gets or sets the alpha transparency of the indicator. - /// - /// - /// The alpha transparency ranging from 0 (completely transparent) - /// to 255 (no transparency). The default is 30. - /// - public int Alpha - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_INDICGETALPHA, new IntPtr(Index)).ToInt32(); - } - set - { - value = Helpers.Clamp(value, 0, 255); - scintilla.DirectMessage(NativeMethods.SCI_INDICSETALPHA, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets or sets the indicator flags. - /// - /// - /// A bitwise combination of the enumeration. - /// The default is . - /// - public IndicatorFlags Flags - { - get - { - return (IndicatorFlags)scintilla.DirectMessage(NativeMethods.SCI_INDICGETFLAGS, new IntPtr(Index)); - } - set - { - int flags = (int)value; - scintilla.DirectMessage(NativeMethods.SCI_INDICSETFLAGS, new IntPtr(Index), new IntPtr(flags)); - } - } - - /// - /// Gets or sets the color used to draw an indicator. - /// - /// The Color used to draw an indicator. The default varies. - /// Changing the property will reset the . - /// - public Color ForeColor - { - get - { - var color = scintilla.DirectMessage(NativeMethods.SCI_INDICGETFORE, new IntPtr(Index)).ToInt32(); - return ColorTranslator.FromWin32(color); - } - set - { - var color = ColorTranslator.ToWin32(value); - scintilla.DirectMessage(NativeMethods.SCI_INDICSETFORE, new IntPtr(Index), new IntPtr(color)); - } - } - - /// - /// Gets or sets the color used to draw an indicator when the mouse or caret is over an indicator. - /// - /// - /// The Color used to draw an indicator. - /// By default, the hover style is equal to the regular . - /// - /// Changing the property will reset the . - /// - public Color HoverForeColor - { - get - { - var color = scintilla.DirectMessage(NativeMethods.SCI_INDICGETHOVERFORE, new IntPtr(Index)).ToInt32(); - return ColorTranslator.FromWin32(color); - } - set - { - var color = ColorTranslator.ToWin32(value); - scintilla.DirectMessage(NativeMethods.SCI_INDICSETHOVERFORE, new IntPtr(Index), new IntPtr(color)); - } - } - - /// - /// Gets or sets the indicator style used when the mouse or caret is over an indicator. - /// - /// - /// One of the enumeration values. - /// By default, the hover style is equal to the regular . - /// - /// Changing the property will reset the . - /// - public IndicatorStyle HoverStyle - { - get - { - return (IndicatorStyle)scintilla.DirectMessage(NativeMethods.SCI_INDICGETHOVERSTYLE, new IntPtr(Index)); - } - set - { - var style = (int)value; - scintilla.DirectMessage(NativeMethods.SCI_INDICSETHOVERSTYLE, new IntPtr(Index), new IntPtr(style)); - } - } - - /// - /// Gets the zero-based indicator index this object represents. - /// - /// The indicator definition index within the . - public int Index { get; private set; } - - /// - /// Gets or sets the alpha transparency of the indicator outline. - /// - /// - /// The alpha transparency ranging from 0 (completely transparent) - /// to 255 (no transparency). The default is 50. - /// - public int OutlineAlpha - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_INDICGETOUTLINEALPHA, new IntPtr(Index)).ToInt32(); - } - set - { - value = Helpers.Clamp(value, 0, 255); - scintilla.DirectMessage(NativeMethods.SCI_INDICSETOUTLINEALPHA, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets or sets the indicator style. - /// - /// One of the enumeration values. The default varies. - /// Changing the property will reset the . - /// - public IndicatorStyle Style - { - get - { - return (IndicatorStyle)scintilla.DirectMessage(NativeMethods.SCI_INDICGETSTYLE, new IntPtr(Index)); - } - set - { - var style = (int)value; - scintilla.DirectMessage(NativeMethods.SCI_INDICSETSTYLE, new IntPtr(Index), new IntPtr(style)); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The control that created this indicator. - /// The index of this style within the that created it. - public Indicator(Scintilla scintilla, int index) - { - this.scintilla = scintilla; - Index = index; - } - } -} diff --git a/ScintillaNet/IndicatorCollection.cs b/ScintillaNet/IndicatorCollection.cs deleted file mode 100644 index b654823..0000000 --- a/ScintillaNet/IndicatorCollection.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// An immutable collection of indicators in a control. - /// - public class IndicatorCollection : IEnumerable - { - private readonly Scintilla scintilla; - - /// - /// Provides an enumerator that iterates through the collection. - /// - /// An object that contains all objects within the . - public IEnumerator GetEnumerator() - { - int count = Count; - for (int i = 0; i < count; i++) - yield return this[i]; - - yield break; - } - - IEnumerator IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } - - /// - /// Gets the number of indicators. - /// - /// The number of indicators in the . - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int Count - { - get - { - return (NativeMethods.INDIC_MAX + 1); - } - } - - /// - /// Gets an object at the specified index. - /// - /// The indicator index. - /// An object representing the indicator at the specified . - /// - /// Indicators 0 through 7 are used by lexers. - /// Indicators 32 through 35 are used for IME. - /// - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Indicator this[int index] - { - get - { - index = Helpers.Clamp(index, 0, Count - 1); - return new Indicator(scintilla, index); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The control that created this collection. - public IndicatorCollection(Scintilla scintilla) - { - this.scintilla = scintilla; - } - } -} diff --git a/ScintillaNet/IndicatorStyle.cs b/ScintillaNet/IndicatorStyle.cs deleted file mode 100644 index a628ccb..0000000 --- a/ScintillaNet/IndicatorStyle.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// The visual appearance of an indicator. - /// - public enum IndicatorStyle - { - /// - /// Underlined with a single, straight line. - /// - Plain = NativeMethods.INDIC_PLAIN, - - /// - /// A squiggly underline. Requires 3 pixels of descender space. - /// - Squiggle = NativeMethods.INDIC_SQUIGGLE, - - /// - /// A line of small T shapes. - /// - TT = NativeMethods.INDIC_TT, - - /// - /// Diagonal hatching. - /// - Diagonal = NativeMethods.INDIC_DIAGONAL, - - /// - /// Strike out. - /// - Strike = NativeMethods.INDIC_STRIKE, - - /// - /// An indicator with no visual effect. - /// - Hidden = NativeMethods.INDIC_HIDDEN, - - /// - /// A rectangle around the text. - /// - Box = NativeMethods.INDIC_BOX, - - /// - /// A rectangle around the text with rounded corners. The rectangle outline and fill transparencies can be adjusted using - /// and . - /// - RoundBox = NativeMethods.INDIC_ROUNDBOX, - - /// - /// A rectangle around the text. The rectangle outline and fill transparencies can be adjusted using - /// and . - /// - StraightBox = NativeMethods.INDIC_STRAIGHTBOX, - - /// - /// A dashed underline. - /// - Dash = NativeMethods.INDIC_DASH, - - /// - /// A dotted underline. - /// - Dots = NativeMethods.INDIC_DOTS, - - /// - /// Similar to but only using 2 vertical pixels so will fit under small fonts. - /// - SquiggleLow = NativeMethods.INDIC_SQUIGGLELOW, - - /// - /// A dotted rectangle around the text. The dots transparencies can be adjusted using - /// and . - /// - DotBox = NativeMethods.INDIC_DOTBOX, - - // PIXMAP - - /// - /// A 2-pixel thick underline with 1 pixel insets on either side. - /// - CompositionThick = NativeMethods.INDIC_COMPOSITIONTHICK, - - /// - /// A 1-pixel thick underline with 1 pixel insets on either side. - /// - CompositionThin = NativeMethods.INDIC_COMPOSITIONTHIN, - - /// - /// A rectangle around the entire character area. The rectangle outline and fill transparencies can be adjusted using - /// and . - /// - FullBox = NativeMethods.INDIC_FULLBOX, - - /// - /// An indicator that will change the foreground color of text to the foreground color of the indicator. - /// - TextFore = NativeMethods.INDIC_TEXTFORE - } -} diff --git a/ScintillaNet/Lexer.cs b/ScintillaNet/Lexer.cs deleted file mode 100644 index 8e8554a..0000000 --- a/ScintillaNet/Lexer.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// Specifies the lexer to use for syntax highlighting in a control. - /// - public enum Lexer - { - /// - /// Lexing is performed by the control container (host) using - /// the event. - /// - Container = NativeMethods.SCLEX_CONTAINER, - - /// - /// No lexing should be performed. - /// - Null = NativeMethods.SCLEX_NULL, - - /// - /// The Python language lexer. - /// - Python = NativeMethods.SCLEX_PYTHON, - - /// - /// The C language family (C++, C, C#, Java, JavaScript, etc...) lexer. - /// - Cpp = NativeMethods.SCLEX_CPP, - - /// - /// The Cascading Style Sheets (CSS, SCSS) lexer. - /// - Css = NativeMethods.SCLEX_CSS, - - /// - /// The Blitz (Blitz3D, BlitzMax, etc...) variant of Basic lexer. - /// - BlitzBasic = NativeMethods.SCLEX_BLITZBASIC - } -} diff --git a/ScintillaNet/Line.cs b/ScintillaNet/Line.cs deleted file mode 100644 index 37fd6ff..0000000 --- a/ScintillaNet/Line.cs +++ /dev/null @@ -1,405 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// Represents a line of text in a control. - /// - public class Line - { - private readonly Scintilla scintilla; - - /// - /// Navigates the caret to the start of the line. - /// - /// Any selection is discarded. - public void Goto() - { - scintilla.DirectMessage(NativeMethods.SCI_GOTOLINE, new IntPtr(Index)); - } - - /// - /// Adds the specified to the line. - /// - /// The zero-based index of the marker to add to the line. - /// A which can be used to track the line. - /// This method does not check if the line already contains the . - public MarkerHandle MarkerAdd(int marker) - { - marker = Helpers.Clamp(marker, 0, scintilla.Markers.Count - 1); - var handle = scintilla.DirectMessage(NativeMethods.SCI_MARKERADD, new IntPtr(Index), new IntPtr(marker)); - return new MarkerHandle { Value = handle }; - } - - /// - /// Adds one or more markers to the line in a single call using a bit mask. - /// - /// An unsigned 32-bit value with each bit cooresponding to one of the 32 zero-based indexes to add. - public void MarkerAddSet(uint markerMask) - { - var mask = unchecked((int)markerMask); - scintilla.DirectMessage(NativeMethods.SCI_MARKERADDSET, new IntPtr(Index), new IntPtr(mask)); - } - - /// - /// Removes the specified from the line. - /// - /// The zero-based index of the marker to remove from the line or -1 to delete all markers from the line. - /// If the same marker has been added to the line more than once, this will delete one copy each time it is used. - public void MarkerDelete(int marker) - { - marker = Helpers.Clamp(marker, -1, scintilla.Markers.Count - 1); - scintilla.DirectMessage(NativeMethods.SCI_MARKERDELETE, new IntPtr(Index), new IntPtr(marker)); - } - - /// - /// Returns a bit mask indicating which markers are present on the line. - /// - /// An unsigned 32-bit value with each bit cooresponding to one of the 32 zero-based indexes. - public uint MarkerGet() - { - var mask = scintilla.DirectMessage(NativeMethods.SCI_MARKERGET, new IntPtr(Index)).ToInt32(); - return unchecked((uint)mask); - } - - /// - /// Efficiently searches from the current line forward to the end of the document for the specified markers. - /// - /// An unsigned 32-bit value with each bit cooresponding to one of the 32 zero-based indexes. - /// If found, the zero-based line index containing one of the markers in ; otherwise, -1. - /// For example, the mask for marker index 10 is 1 shifted left 10 times (1 << 10). - public int MarkerNext(uint markerMask) - { - var mask = unchecked((int)markerMask); - return scintilla.DirectMessage(NativeMethods.SCI_MARKERNEXT, new IntPtr(Index), new IntPtr(mask)).ToInt32(); - } - - /// - /// Efficiently searches from the current line backward to the start of the document for the specified markers. - /// - /// An unsigned 32-bit value with each bit cooresponding to one of the 32 zero-based indexes. - /// If found, the zero-based line index containing one of the markers in ; otherwise, -1. - /// For example, the mask for marker index 10 is 1 shifted left 10 times (1 << 10). - public int MarkerPrevious(uint markerMask) - { - var mask = unchecked((int)markerMask); - return scintilla.DirectMessage(NativeMethods.SCI_MARKERPREVIOUS, new IntPtr(Index), new IntPtr(mask)).ToInt32(); - } - - /// - /// Gets the number of annotation lines of text. - /// - /// The number of annotation lines. - public int AnnotationLines - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETLINES, new IntPtr(Index)).ToInt32(); - } - } - - /// - /// Gets or sets the style of the annotation text. - /// - /// - /// The zero-based index of the annotation text or 256 when - /// has been used to set individual character styles. - /// - /// - public int AnnotationStyle - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETSTYLE, new IntPtr(Index)).ToInt32(); - } - set - { - value = Helpers.Clamp(value, 0, scintilla.Styles.Count - 1); - scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETSTYLE, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets or sets an array of style indexes corresponding to each charcter in the - /// so that each character may be individually styled. - /// - /// - /// An array of indexes corresponding with each annotation text character or an uninitialized - /// array when has been used to set a single style for all characters. - /// - /// - /// must be set prior to setting this property. - /// The specified should have a length equal to the length to properly style all characters. - /// - /// - public unsafe byte[] AnnotationStyles - { - get - { - var length = scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return new byte[0]; - - var text = new byte[length + 1]; - var styles = new byte[length + 1]; - - fixed (byte* textPtr = text) - fixed (byte* stylePtr = styles) - { - scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); - scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); - - return Helpers.ByteToCharStyles(stylePtr, textPtr, length, scintilla.Encoding); - } - } - set - { - var length = scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return; - - var text = new byte[length + 1]; - fixed (byte* textPtr = text) - { - scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); - - var styles = Helpers.CharToByteStyles(value ?? new byte[0], textPtr, length, scintilla.Encoding); - fixed (byte* stylePtr = styles) - scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); - } - } - } - - /// - /// Gets or sets the line annotation text. - /// - /// A String representing the line annotation text. - public unsafe string AnnotationText - { - get - { - var length = scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return string.Empty; - - var bytes = new byte[length + 1]; - fixed (byte* bp = bytes) - { - scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index), new IntPtr(bp)); - return Helpers.GetString(new IntPtr(bp), length, scintilla.Encoding); - } - } - set - { - if (string.IsNullOrEmpty(value)) - { - // Scintilla docs suggest that setting to NULL rather than an empty string will free memory - scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index), IntPtr.Zero); - } - else - { - var bytes = Helpers.GetBytes(value, scintilla.Encoding, zeroTerminated: true); - fixed (byte* bp = bytes) - scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETTEXT, new IntPtr(Index), new IntPtr(bp)); - } - } - } - - /// - /// Gets the zero-based character position in the document where the line ends (exclusive). - /// - /// The equivalent of + . - public int EndPosition - { - get - { - return Position + Length; - } - } - - /// - /// Gets the line index. - /// - /// The zero-based line index within the that created it. - public int Index { get; private set; } - - /// - /// Gets the length of the line. - /// - /// The number of characters in the line including any end of line characters. - public int Length - { - get - { - return scintilla.Lines.CharLineLength(Index); - } - } - - /// - /// Gets or sets the style of the margin text in a or margin. - /// - /// - /// The zero-based index of the margin text or 256 when - /// has been used to set individual character styles. - /// - /// - public int MarginStyle - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_MARGINGETSTYLE, new IntPtr(Index)).ToInt32(); - } - set - { - value = Helpers.Clamp(value, 0, scintilla.Styles.Count - 1); - scintilla.DirectMessage(NativeMethods.SCI_MARGINSETSTYLE, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets or sets an array of style indexes corresponding to each charcter in the - /// so that each character may be individually styled. - /// - /// - /// An array of indexes corresponding with each margin text character or an uninitialized - /// array when has been used to set a single style for all characters. - /// - /// - /// must be set prior to setting this property. - /// The specified should have a length equal to the length to properly style all characters. - /// - /// - public unsafe byte[] MarginStyles - { - get - { - var length = scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return new byte[0]; - - var text = new byte[length + 1]; - var styles = new byte[length + 1]; - - fixed (byte* textPtr = text) - fixed (byte* stylePtr = styles) - { - scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); - scintilla.DirectMessage(NativeMethods.SCI_MARGINGETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); - - return Helpers.ByteToCharStyles(stylePtr, textPtr, length, scintilla.Encoding); - } - } - set - { - var length = scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return; - - var text = new byte[length + 1]; - fixed (byte* textPtr = text) - { - scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); - - var styles = Helpers.CharToByteStyles(value ?? new byte[0], textPtr, length, scintilla.Encoding); - fixed (byte* stylePtr = styles) - scintilla.DirectMessage(NativeMethods.SCI_MARGINSETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); - } - } - } - - /// - /// Gets or sets the text displayed in the line margin when the margin type is - /// or . - /// - /// The text displayed in the line margin. - /// The margin text cannot contain any Unicode characters or it will not render correctly. - public unsafe string MarginText - { - get - { - var length = scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return string.Empty; - - var bytes = new byte[length + 1]; - fixed (byte* bp = bytes) - { - scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index), new IntPtr(bp)); - return Helpers.GetString(new IntPtr(bp), length, scintilla.Encoding); - } - } - set - { - if (string.IsNullOrEmpty(value)) - { - // Scintilla docs suggest that setting to NULL rather than an empty string will free memory - scintilla.DirectMessage(NativeMethods.SCI_MARGINSETTEXT, new IntPtr(Index), IntPtr.Zero); - } - else - { - var bytes = Helpers.GetBytes(value, scintilla.Encoding, zeroTerminated: true); - fixed (byte* bp = bytes) - scintilla.DirectMessage(NativeMethods.SCI_MARGINSETTEXT, new IntPtr(Index), new IntPtr(bp)); - } - } - } - - /// - /// Gets the zero-based character position in the document where the line begins. - /// - /// The document position of the first character in the line. - public int Position - { - get - { - return scintilla.Lines.CharPositionFromLine(Index); - } - } - - /// - /// Gets the line text. - /// - /// A string representing the document line. - /// The returned text includes any end of line characters. - public unsafe string Text - { - get - { - var start = scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(Index)); - var length = scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(Index)); - var ptr = scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, start, length); - if (ptr == IntPtr.Zero) - return string.Empty; - - var text = new string((sbyte*)ptr, 0, length.ToInt32(), scintilla.Encoding); - return text; - } - } - - /// - /// Gets the number of display lines this line would occupy when wrapping is enabled. - /// - /// The number of display lines needed to wrap the current document line. - public int WrapCount - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_WRAPCOUNT, new IntPtr(Index)).ToInt32(); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The control that created this line. - /// The index of this line within the that created it. - public Line(Scintilla scintilla, int index) - { - this.scintilla = scintilla; - Index = index; - } - } -} diff --git a/ScintillaNet/Margin.cs b/ScintillaNet/Margin.cs deleted file mode 100644 index cd7e42c..0000000 --- a/ScintillaNet/Margin.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// Represents a margin displayed on the left edge of a control. - /// - public class Margin - { - private readonly Scintilla scintilla; - - /// - /// Gets or sets the mouse cursor style when over the margin. - /// - /// One of the enumeration values. The default is . - public MarginCursor Cursor - { - get - { - return (MarginCursor)scintilla.DirectMessage(NativeMethods.SCI_GETMARGINCURSORN, new IntPtr(Index)); - } - set - { - var cursor = (int)value; - scintilla.DirectMessage(NativeMethods.SCI_SETMARGINCURSORN, new IntPtr(Index), new IntPtr(cursor)); - } - } - - /// - /// Gets the zero-based margin index this object represents. - /// - /// The margin index within the . - public int Index { get; private set; } - - /// - /// Gets or sets whether the margin is sensitive to mouse clicks. - /// - /// true if the margin is sensitive to mouse clicks; otherwise, false. The default is false. - /// - public bool Sensitive - { - get - { - return (scintilla.DirectMessage(NativeMethods.SCI_GETMARGINSENSITIVEN, new IntPtr(Index)) != IntPtr.Zero); - } - set - { - var sensitive = (value ? new IntPtr(1) : IntPtr.Zero); - scintilla.DirectMessage(NativeMethods.SCI_SETMARGINSENSITIVEN, new IntPtr(Index), sensitive); - } - } - - /// - /// Gets or sets the margin type. - /// - /// One of the enumeration values. The default is . - public MarginType Type - { - get - { - return (MarginType)(scintilla.DirectMessage(NativeMethods.SCI_GETMARGINTYPEN, new IntPtr(Index))); - } - set - { - var type = (int)value; - scintilla.DirectMessage(NativeMethods.SCI_SETMARGINTYPEN, new IntPtr(Index), new IntPtr(type)); - } - } - - /// - /// Gets or sets the width in pixels of the margin. - /// - /// The width of the margin measured in pixels. - /// Scintilla assigns various default widths. - public int Width - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_GETMARGINWIDTHN, new IntPtr(Index)).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - scintilla.DirectMessage(NativeMethods.SCI_SETMARGINWIDTHN, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets or sets a mask indicating which markers this margin can display. - /// - /// - /// An unsigned 32-bit value with each bit cooresponding to one of the 32 zero-based indexes. - /// The default is 0x1FFFFFF, which is every marker except folder markers (i.e. 0 through 24). - /// - /// - /// For example, the mask for marker index 10 is 1 shifted left 10 times (1 << 10). - /// is a useful constant for working with just folder margin indexes. - /// - public uint Mask - { - get - { - return unchecked((uint)scintilla.DirectMessage(NativeMethods.SCI_GETMARGINMASKN, new IntPtr(Index)).ToInt32()); - } - set - { - var mask = unchecked((int)value); - scintilla.DirectMessage(NativeMethods.SCI_SETMARGINMASKN, new IntPtr(Index), new IntPtr(mask)); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The control that created this margin. - /// The index of this margin within the that created it. - public Margin(Scintilla scintilla, int index) - { - this.scintilla = scintilla; - Index = index; - } - } -} diff --git a/ScintillaNet/MarginClickEventArgs.cs b/ScintillaNet/MarginClickEventArgs.cs deleted file mode 100644 index 1a779a2..0000000 --- a/ScintillaNet/MarginClickEventArgs.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -namespace ScintillaNET -{ - /// - /// Provides data for the event. - /// - public class MarginClickEventArgs : EventArgs - { - private readonly Scintilla scintilla; - private readonly int bytePosition; - private int? position; - - /// - /// Gets the margin clicked. - /// - /// The zero-based index of the clicked margin. - public int Margin { get; private set; } - - /// - /// Gets the modifier keys (SHIFT, CTRL, ALT) held down when the margin was clicked. - /// - /// A bitwise combination of the Keys enumeration indicating the modifier keys. - public Keys Modifiers { get; private set; } - - /// - /// Gets the zero-based document position where the line ajacent to the clicked margin starts. - /// - /// The zero-based character position within the document of the start of the line adjacent to the margin clicked. - public int Position - { - get - { - if (position == null) - position = scintilla.Lines.ByteToCharPosition(bytePosition); - - return (int)position; - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The control that generated this event. - /// The modifier keys that where held down at the time of the margin click. - /// The zero-based byte position within the document where the line adjacent to the clicked margin starts. - /// The zero-based index of the clicked margin. - public MarginClickEventArgs(Scintilla scintilla, Keys modifiers, int bytePosition, int margin) - { - this.scintilla = scintilla; - this.bytePosition = bytePosition; - Modifiers = modifiers; - Margin = margin; - } - } -} diff --git a/ScintillaNet/MarginCollection.cs b/ScintillaNet/MarginCollection.cs deleted file mode 100644 index e42b429..0000000 --- a/ScintillaNet/MarginCollection.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// An immutable collection of margins in a control. - /// - public class MarginCollection : IEnumerable - { - private readonly Scintilla scintilla; - - /// - /// Removes all text displayed in every and margins. - /// - public void ClearAllText() - { - scintilla.DirectMessage(NativeMethods.SCI_MARGINTEXTCLEARALL); - } - - /// - /// Provides an enumerator that iterates through the collection. - /// - /// An object that contains all objects within the . - public IEnumerator GetEnumerator() - { - int count = Count; - for (int i = 0; i < count; i++) - yield return this[i]; - - yield break; - } - - IEnumerator IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } - - /// - /// Gets the number of margins in the . - /// - /// This property always returns 5. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int Count - { - get - { - return (NativeMethods.SC_MAX_MARGIN + 1); - } - } - - /// - /// Gets or sets the width in pixels of the left margin padding. - /// - /// The left margin padding measured in pixels. The default is 1. - [DefaultValue(1)] - [Description("The left margin padding in pixels.")] - public int Left - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_GETMARGINLEFT).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - scintilla.DirectMessage(NativeMethods.SCI_SETMARGINLEFT, IntPtr.Zero, new IntPtr(value)); - } - } - - /* - /// - /// Gets or sets the margin options. - /// - /// - /// A that represents the margin options. - /// The default is . - /// - [DefaultValue(MarginOptions.None)] - [Description("Margin options flags.")] - [TypeConverter(typeof(FlagsEnumTypeConverter.FlagsEnumConverter))] - public MarginOptions Options - { - get - { - return (MarginOptions)scintilla.DirectMessage(NativeMethods.SCI_GETMARGINOPTIONS); - } - set - { - var options = (int)value; - scintilla.DirectMessage(NativeMethods.SCI_SETMARGINOPTIONS, new IntPtr(options)); - } - } - */ - - /// - /// Gets or sets the width in pixels of the right margin padding. - /// - /// The right margin padding measured in pixels. The default is 1. - [DefaultValue(1)] - [Description("The right margin padding in pixels.")] - public int Right - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_GETMARGINRIGHT).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - scintilla.DirectMessage(NativeMethods.SCI_SETMARGINRIGHT, IntPtr.Zero, new IntPtr(value)); - } - } - - /// - /// Gets a object at the specified index. - /// - /// The margin index. - /// An object representing the margin at the specified . - /// By convention margin 0 is used for line numbers and the two following for symbols. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Margin this[int index] - { - get - { - index = Helpers.Clamp(index, 0, Count - 1); - return new Margin(scintilla, index); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The control that created this collection. - public MarginCollection(Scintilla scintilla) - { - this.scintilla = scintilla; - } - } -} diff --git a/ScintillaNet/MarginType.cs b/ScintillaNet/MarginType.cs deleted file mode 100644 index 14540f9..0000000 --- a/ScintillaNet/MarginType.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// The behavior and appearance of a margin. - /// - public enum MarginType - { - /// - /// Margin can display symbols. - /// - Symbol = NativeMethods.SC_MARGIN_SYMBOL, - - /// - /// Margin displays line numbers. - /// - Number = NativeMethods.SC_MARGIN_NUMBER, - - /// - /// Margin can display symbols and has a background color equivalent to the default style background color. - /// - BackColor = NativeMethods.SC_MARGIN_BACK, - - /// - /// Margin can display symbols and has a background color equivalent to the default style foreground color. - /// - ForeColor = NativeMethods.SC_MARGIN_FORE, - - /// - /// Margin can display application defined text. - /// - Text = NativeMethods.SC_MARGIN_TEXT, - - /// - /// Margin can display application defined text right-justified. - /// - RightText = NativeMethods.SC_MARGIN_RTEXT - } -} diff --git a/ScintillaNet/Marker.cs b/ScintillaNet/Marker.cs deleted file mode 100644 index 7b39eb8..0000000 --- a/ScintillaNet/Marker.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Imaging; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// Represents a margin marker in a control. - /// - public class Marker - { - private readonly Scintilla scintilla; - - /// - /// An unsigned 32-bit mask of all indexes where each bit cooresponds to a margin index. - /// - public const uint MaskAll = unchecked((uint)-1); - - /// - /// An unsigned 32-bit mask of folder indexes (25 through 31) where each bit cooresponds to a margin index. - /// - /// - public const uint MaskFolders = NativeMethods.SC_MASK_FOLDERS; - - /// - /// Folder end marker index. This marker is typically configured to display the symbol. - /// - public const int FolderEnd = NativeMethods.SC_MARKNUM_FOLDEREND; - - /// - /// Folder open marker index. This marker is typically configured to display the symbol. - /// - public const int FolderOpenMid = NativeMethods.SC_MARKNUM_FOLDEROPENMID; - - /// - /// Folder mid tail marker index. This marker is typically configured to display the symbol. - /// - public const int FolderMidTail = NativeMethods.SC_MARKNUM_FOLDERMIDTAIL; - - /// - /// Folder tail marker index. This marker is typically configured to display the symbol. - /// - public const int FolderTail = NativeMethods.SC_MARKNUM_FOLDERTAIL; - - /// - /// Folder sub marker index. This marker is typically configured to display the symbol. - /// - public const int FolderSub = NativeMethods.SC_MARKNUM_FOLDERSUB; - - /// - /// Folder marker index. This marker is typically configured to display the symbol. - /// - public const int Folder = NativeMethods.SC_MARKNUM_FOLDER; - - /// - /// Folder open marker index. This marker is typically configured to display the symbol. - /// - public const int FolderOpen = NativeMethods.SC_MARKNUM_FOLDEROPEN; - - /// - /// Sets the marker symbol to a custom image. - /// - /// The Bitmap to use as a marker symbol. - /// Calling this method will also update the property to . - public unsafe void DefineRgbaImage(Bitmap image) - { - if (image == null) - return; - - scintilla.DirectMessage(NativeMethods.SCI_RGBAIMAGESETWIDTH, new IntPtr(image.Width)); - scintilla.DirectMessage(NativeMethods.SCI_RGBAIMAGESETHEIGHT, new IntPtr(image.Height)); - - var bytes = Helpers.BitmapToArgb(image); - fixed (byte* bp = bytes) - scintilla.DirectMessage(NativeMethods.SCI_MARKERDEFINERGBAIMAGE, new IntPtr(Index), new IntPtr(bp)); - } - - /// - /// Removes this marker from all lines. - /// - public void DeleteAll() - { - scintilla.MarkerDeleteAll(Index); - } - - /// - /// Sets the foreground alpha transparency for markers that are drawn in the content area. - /// - /// The alpha transparency ranging from 0 (completely transparent) to 255 (no transparency). - /// See the remarks on the method for a full explanation of when a marker can be drawn in the content area. - /// - public void SetAlpha(int alpha) - { - alpha = Helpers.Clamp(alpha, 0, 255); - scintilla.DirectMessage(NativeMethods.SCI_MARKERSETALPHA, new IntPtr(Index), new IntPtr(alpha)); - } - - /// - /// Sets the background color of the marker. - /// - /// The background Color. The default is White. - /// - /// The background color of the whole line will be drawn in the specified when the marker is not visible - /// because it is hidden by a or the is zero. - /// - /// - public void SetBackColor(Color color) - { - var colour = ColorTranslator.ToWin32(color); - scintilla.DirectMessage(NativeMethods.SCI_MARKERSETBACK, new IntPtr(Index), new IntPtr(colour)); - } - - /// - /// Sets the foreground color of the marker. - /// - /// The foreground Color. The default is Black. - public void SetForeColor(Color color) - { - var colour = ColorTranslator.ToWin32(color); - scintilla.DirectMessage(NativeMethods.SCI_MARKERSETFORE, new IntPtr(Index), new IntPtr(colour)); - } - - /// - /// Gets the zero-based marker index this object represents. - /// - /// The marker index within the . - public int Index { get; private set; } - - /// - /// Gets or sets the marker symbol. - /// - /// - /// One of the enumeration values. - /// The default is . - /// - public MarkerSymbol Symbol - { - get - { - return (MarkerSymbol)scintilla.DirectMessage(NativeMethods.SCI_MARKERSYMBOLDEFINED, new IntPtr(Index)); - } - set - { - var markerSymbol = (int)value; - scintilla.DirectMessage(NativeMethods.SCI_MARKERDEFINE, new IntPtr(Index), new IntPtr(markerSymbol)); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The control that created this marker. - /// The index of this style within the that created it. - public Marker(Scintilla scintilla, int index) - { - this.scintilla = scintilla; - Index = index; - } - } -} diff --git a/ScintillaNet/MarkerCollection.cs b/ScintillaNet/MarkerCollection.cs deleted file mode 100644 index 39f7412..0000000 --- a/ScintillaNet/MarkerCollection.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// An immutable collection of markers in a control. - /// - public class MarkerCollection : IEnumerable - { - private readonly Scintilla scintilla; - - /// - /// Provides an enumerator that iterates through the collection. - /// - /// An object for enumerating all objects within the . - public IEnumerator GetEnumerator() - { - int count = Count; - for (int i = 0; i < count; i++) - yield return this[i]; - - yield break; - } - - IEnumerator IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } - - /// - /// Gets the number of markers in the . - /// - /// This property always returns 32. - public int Count - { - get - { - return (NativeMethods.MARKER_MAX + 1); - } - } - - /// - /// Gets a object at the specified index. - /// - /// The marker index. - /// An object representing the marker at the specified . - /// Markers 25 through 31 are used by Scintilla for folding. - public Marker this[int index] - { - get - { - index = Helpers.Clamp(index, 0, Count - 1); - return new Marker(scintilla, index); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The control that created this collection. - public MarkerCollection(Scintilla scintilla) - { - this.scintilla = scintilla; - } - } -} diff --git a/ScintillaNet/MarkerSymbol.cs b/ScintillaNet/MarkerSymbol.cs deleted file mode 100644 index ad9a844..0000000 --- a/ScintillaNet/MarkerSymbol.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// The symbol displayed by a - /// - public enum MarkerSymbol - { - /// - /// A circle. This symbol is typically used to indicate a breakpoint. - /// - Circle = NativeMethods.SC_MARK_CIRCLE, - - /// - /// A rectangel with rounded edges. - /// - RoundRect = NativeMethods.SC_MARK_ROUNDRECT, - - /// - /// An arrow (triangle) pointing right. - /// - Arrow = NativeMethods.SC_MARK_ARROW, - - /// - /// A rectangle that is wider than it is tall. - /// - SmallRect = NativeMethods.SC_MARK_SMALLRECT, - - /// - /// An arrow and tail pointing right. This symbol is typically used to indicate the current line of execution. - /// - ShortArrow = NativeMethods.SC_MARK_SHORTARROW, - - /// - /// An invisible symbol useful for tracking the movement of lines. - /// - Empty = NativeMethods.SC_MARK_EMPTY, - - /// - /// An arrow (triangle) pointing down. - /// - ArrowDown = NativeMethods.SC_MARK_ARROWDOWN, - - /// - /// A minus (-) symbol. - /// - Minus = NativeMethods.SC_MARK_MINUS, - - /// - /// A plus (+) symbol. - /// - Plus = NativeMethods.SC_MARK_PLUS, - - /// - /// A thin vertical line. This symbol is typically used on the middle line of an expanded fold block. - /// - VLine = NativeMethods.SC_MARK_VLINE, - - /// - /// A thin 'L' shaped line. This symbol is typically used on the last line of an expanded fold block. - /// - LCorner = NativeMethods.SC_MARK_LCORNER, - - /// - /// A thin 't' shaped line. This symbol is typically used on the last line of an expanded nested fold block. - /// - TCorner = NativeMethods.SC_MARK_TCORNER, - - /// - /// A plus (+) symbol with surrounding box. This symbol is typically used on the first line of a collapsed fold block. - /// - BoxPlus = NativeMethods.SC_MARK_BOXPLUS, - - /// - /// A plus (+) symbol with surrounding box and thin vertical line. This symbol is typically used on the first line of a collapsed nested fold block. - /// - BoxPlusConnected = NativeMethods.SC_MARK_BOXPLUSCONNECTED, - - /// - /// A minus (-) symbol with surrounding box. This symbol is typically used on the first line of an expanded fold block. - /// - BoxMinus = NativeMethods.SC_MARK_BOXMINUS, - - /// - /// A minus (-) symbol with surrounding box and thin vertical line. This symbol is typically used on the first line of an expanded nested fold block. - /// - BoxMinusConnected = NativeMethods.SC_MARK_BOXMINUSCONNECTED, - - /// - /// Similar to a , but curved. - /// - LCornerCurve = NativeMethods.SC_MARK_LCORNERCURVE, - - /// - /// Similar to a , but curved. - /// - TCornerCurve = NativeMethods.SC_MARK_TCORNERCURVE, - - /// - /// Similar to a but surrounded by a circle. - /// - CirclePlus = NativeMethods.SC_MARK_CIRCLEPLUS, - - /// - /// Similar to a , but surrounded by a circle. - /// - CirclePlusConnected = NativeMethods.SC_MARK_CIRCLEPLUSCONNECTED, - - /// - /// Similar to a , but surrounded by a circle. - /// - CircleMinus = NativeMethods.SC_MARK_CIRCLEMINUS, - - /// - /// Similar to a , but surrounded by a circle. - /// - CircleMinusConnected = NativeMethods.SC_MARK_CIRCLEMINUSCONNECTED, - - /// - /// A special marker that displays no symbol but will affect the background color of the line. - /// - Background = NativeMethods.SC_MARK_BACKGROUND, - - /// - /// Three dots (ellipsis). - /// - DotDotDot = NativeMethods.SC_MARK_DOTDOTDOT, - - /// - /// Three bracket style arrows. - /// - Arrows = NativeMethods.SC_MARK_ARROWS, - - // PixMap = NativeMethods.SC_MARK_PIXMAP, - - /// - /// A rectangle occupying the entire marker space. - /// - FullRect = NativeMethods.SC_MARK_FULLRECT, - - /// - /// A rectangle occupying only the left edge of the marker space. - /// - LeftRect = NativeMethods.SC_MARK_LEFTRECT, - - /// - /// A special marker left available to plugins. - /// - Available = NativeMethods.SC_MARK_AVAILABLE, - - /// - /// A special marker that displays no symbol but will underline the current line text. - /// - Underline = NativeMethods.SC_MARK_UNDERLINE, - - /// - /// A user-defined image. Images can be set using the method. - /// - RgbaImage = NativeMethods.SC_MARK_RGBAIMAGE, - - /// - /// A left-rotated bookmark. - /// - Bookmark = NativeMethods.SC_MARK_BOOKMARK, - - // Character = NativeMethods.SC_MARK_CHARACTER - } -} diff --git a/ScintillaNet/NativeMethods.cs b/ScintillaNet/NativeMethods.cs deleted file mode 100644 index dac0a39..0000000 --- a/ScintillaNet/NativeMethods.cs +++ /dev/null @@ -1,1304 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; - -namespace ScintillaNET -{ - internal static class NativeMethods - { - #region Constants - - private const string DLL_NAME_KERNEL32 = "kernel32.dll"; - private const string DLL_NAME_USER32 = "user32.dll"; - - public const int INVALID_POSITION = -1; - - // Annotations - public const int ANNOTATION_HIDDEN = 0; - public const int ANNOTATION_STANDARD = 1; - public const int ANNOTATION_BOXED = 2; - public const int ANNOTATION_INDENTED = 3; - - // Indentation - public const int SC_IV_NONE = 0; - public const int SC_IV_REAL = 1; - public const int SC_IV_LOOKFORWARD = 2; - public const int SC_IV_LOOKBOTH = 3; - - // Keys - public const int SCMOD_NORM = 0; - public const int SCMOD_SHIFT = 1; - public const int SCMOD_CTRL = 2; - public const int SCMOD_ALT = 4; - public const int SCMOD_SUPER = 8; - public const int SCMOD_META = 16; - - public const int SCI_NORM = 0; - public const int SCI_SHIFT = SCMOD_SHIFT; - public const int SCI_CTRL = SCMOD_CTRL; - public const int SCI_ALT = SCMOD_ALT; - public const int SCI_META = SCMOD_META; - public const int SCI_CSHIFT = (SCI_CTRL | SCI_SHIFT); - public const int SCI_ASHIFT = (SCI_ALT | SCI_SHIFT); - - // Caret styles - public const int CARETSTYLE_INVISIBLE = 0; - public const int CARETSTYLE_LINE = 1; - public const int CARETSTYLE_BLOCK = 2; - - // Line edges - public const int EDGE_NONE = 0; - public const int EDGE_LINE = 1; - public const int EDGE_BACKGROUND = 2; - - // Indicators - public const int INDIC_PLAIN = 0; - public const int INDIC_SQUIGGLE = 1; - public const int INDIC_TT = 2; - public const int INDIC_DIAGONAL = 3; - public const int INDIC_STRIKE = 4; - public const int INDIC_HIDDEN = 5; - public const int INDIC_BOX = 6; - public const int INDIC_ROUNDBOX = 7; - public const int INDIC_STRAIGHTBOX = 8; - public const int INDIC_DASH = 9; - public const int INDIC_DOTS = 10; - public const int INDIC_SQUIGGLELOW = 11; - public const int INDIC_DOTBOX = 12; - public const int INDIC_SQUIGGLEPIXMAP = 13; - public const int INDIC_COMPOSITIONTHICK = 14; - public const int INDIC_COMPOSITIONTHIN = 15; - public const int INDIC_FULLBOX = 16; - public const int INDIC_TEXTFORE = 17; - public const int INDIC_MAX = 31; - public const int INDIC_CONTAINER = 8; - - // Indicator flags - public const int SC_INDICFLAG_VALUEFORE = 1; - public const int SC_INDICVALUEBIT = 0x1000000; - public const int SC_INDICVALUEMASK = 0xFFFFFF; - - // public const int INDIC0_MASK = 0x20; - // public const int INDIC1_MASK = 0x40; - // public const int INDIC2_MASK = 0x80; - // public const int INDICS_MASK = 0xE0; - - public const int KEYWORDSET_MAX = 8; - - // Alpha ranges - public const int SC_ALPHA_TRANSPARENT = 0; - public const int SC_ALPHA_OPAQUE = 255; - public const int SC_ALPHA_NOALPHA = 256; - - // Automatic folding - public const int SC_AUTOMATICFOLD_SHOW = 0x0001; - public const int SC_AUTOMATICFOLD_CLICK = 0x0002; - public const int SC_AUTOMATICFOLD_CHANGE = 0x0004; - - // Caret sticky behavior - public const int SC_CARETSTICKY_OFF = 0; - public const int SC_CARETSTICKY_ON = 1; - public const int SC_CARETSTICKY_WHITESPACE = 2; - - // Encodings - public const int SC_CP_UTF8 = 65001; - - // Cursors - public const int SC_CURSORNORMAL = -1; - public const int SC_CURSORARROW = 2; - public const int SC_CURSORWAIT = 4; - public const int SC_CURSORREVERSEARROW = 7; - - // Margins - public const int SC_MAX_MARGIN = 4; - - public const int SC_MARGIN_SYMBOL = 0; - public const int SC_MARGIN_NUMBER = 1; - public const int SC_MARGIN_BACK = 2; - public const int SC_MARGIN_FORE = 3; - public const int SC_MARGIN_TEXT = 4; - public const int SC_MARGIN_RTEXT = 5; - - public const int SC_MARGINOPTION_NONE = 0; - public const int SC_MARGINOPTION_SUBLINESELECT = 1; - - // Markers - public const int MARKER_MAX = 31; - public const int SC_MARK_CIRCLE = 0; - public const int SC_MARK_ROUNDRECT = 1; - public const int SC_MARK_ARROW = 2; - public const int SC_MARK_SMALLRECT = 3; - public const int SC_MARK_SHORTARROW = 4; - public const int SC_MARK_EMPTY = 5; - public const int SC_MARK_ARROWDOWN = 6; - public const int SC_MARK_MINUS = 7; - public const int SC_MARK_PLUS = 8; - public const int SC_MARK_VLINE = 9; - public const int SC_MARK_LCORNER = 10; - public const int SC_MARK_TCORNER = 11; - public const int SC_MARK_BOXPLUS = 12; - public const int SC_MARK_BOXPLUSCONNECTED = 13; - public const int SC_MARK_BOXMINUS = 14; - public const int SC_MARK_BOXMINUSCONNECTED = 15; - public const int SC_MARK_LCORNERCURVE = 16; - public const int SC_MARK_TCORNERCURVE = 17; - public const int SC_MARK_CIRCLEPLUS = 18; - public const int SC_MARK_CIRCLEPLUSCONNECTED = 19; - public const int SC_MARK_CIRCLEMINUS = 20; - public const int SC_MARK_CIRCLEMINUSCONNECTED = 21; - public const int SC_MARK_BACKGROUND = 22; - public const int SC_MARK_DOTDOTDOT = 23; - public const int SC_MARK_ARROWS = 24; - public const int SC_MARK_PIXMAP = 25; - public const int SC_MARK_FULLRECT = 26; - public const int SC_MARK_LEFTRECT = 27; - public const int SC_MARK_AVAILABLE = 28; - public const int SC_MARK_UNDERLINE = 29; - public const int SC_MARK_RGBAIMAGE = 30; - public const int SC_MARK_BOOKMARK = 31; - public const int SC_MARK_CHARACTER = 10000; - public const int SC_MARKNUM_FOLDEREND = 25; - public const int SC_MARKNUM_FOLDEROPENMID = 26; - public const int SC_MARKNUM_FOLDERMIDTAIL = 27; - public const int SC_MARKNUM_FOLDERTAIL = 28; - public const int SC_MARKNUM_FOLDERSUB = 29; - public const int SC_MARKNUM_FOLDER = 30; - public const int SC_MARKNUM_FOLDEROPEN = 31; - public const uint SC_MASK_FOLDERS = 0xFE000000; - - public const int SC_MULTIPASTE_ONCE = 0; - public const int SC_MULTIPASTE_EACH = 1; - - public const int SC_ORDER_PRESORTED = 0; - public const int SC_ORDER_PERFORMSORT = 1; - public const int SC_ORDER_CUSTOM = 2; - - // Update notification reasons - public const int SC_UPDATE_CONTENT = 0x01; - public const int SC_UPDATE_SELECTION = 0x02; - public const int SC_UPDATE_V_SCROLL = 0x04; - public const int SC_UPDATE_H_SCROLL = 0x08; - - // Modified notification types - public const int SC_MOD_INSERTTEXT = 0x1; - public const int SC_MOD_DELETETEXT = 0x2; - public const int SC_MOD_BEFOREINSERT = 0x400; - public const int SC_MOD_BEFOREDELETE = 0x800; - public const int SC_MOD_CHANGEANNOTATION = 0x20000; - public const int SC_MOD_INSERTCHECK = 0x100000; - - // Modified flags - public const int SC_PERFORMED_USER = 0x10; - public const int SC_PERFORMED_UNDO = 0x20; - public const int SC_PERFORMED_REDO = 0x40; - - // Status codes - public const int SC_STATUS_OK = 0; - public const int SC_STATUS_FAILURE = 1; - public const int SC_STATUS_BADALLOC = 2; - - // Dwell - public const int SC_TIME_FOREVER = 10000000; - - // Property types - public const int SC_TYPE_BOOLEAN = 0; - public const int SC_TYPE_INTEGER = 1; - public const int SC_TYPE_STRING = 2; - - // Search flags - public const int SCFIND_WHOLEWORD = 0x2; - public const int SCFIND_MATCHCASE = 0x4; - public const int SCFIND_WORDSTART = 0x00100000; - public const int SCFIND_REGEXP = 0x00200000; - public const int SCFIND_POSIX = 0x00400000; - public const int SCFIND_CXX11REGEX = 0x00800000; - - // Functions - public const int SCI_START = 2000; - public const int SCI_OPTIONAL_START = 3000; - public const int SCI_LEXER_START = 4000; - public const int SCI_ADDTEXT = 2001; - public const int SCI_ADDSTYLEDTEXT = 2002; - public const int SCI_INSERTTEXT = 2003; - public const int SCI_CHANGEINSERTION = 2672; - public const int SCI_CLEARALL = 2004; - public const int SCI_DELETERANGE = 2645; - public const int SCI_CLEARDOCUMENTSTYLE = 2005; - public const int SCI_GETLENGTH = 2006; - public const int SCI_GETCHARAT = 2007; - public const int SCI_GETCURRENTPOS = 2008; - public const int SCI_GETANCHOR = 2009; - public const int SCI_GETSTYLEAT = 2010; - public const int SCI_REDO = 2011; - public const int SCI_SETUNDOCOLLECTION = 2012; - public const int SCI_SELECTALL = 2013; - public const int SCI_SETSAVEPOINT = 2014; - public const int SCI_GETSTYLEDTEXT = 2015; - public const int SCI_CANREDO = 2016; - public const int SCI_MARKERLINEFROMHANDLE = 2017; - public const int SCI_MARKERDELETEHANDLE = 2018; - public const int SCI_GETUNDOCOLLECTION = 2019; - public const int SCI_GETVIEWWS = 2020; - public const int SCI_SETVIEWWS = 2021; - public const int SCI_POSITIONFROMPOINT = 2022; - public const int SCI_POSITIONFROMPOINTCLOSE = 2023; - public const int SCI_GOTOLINE = 2024; - public const int SCI_GOTOPOS = 2025; - public const int SCI_SETANCHOR = 2026; - public const int SCI_GETCURLINE = 2027; - public const int SCI_GETENDSTYLED = 2028; - public const int SCI_CONVERTEOLS = 2029; - public const int SCI_GETEOLMODE = 2030; - public const int SCI_SETEOLMODE = 2031; - public const int SCI_STARTSTYLING = 2032; - public const int SCI_SETSTYLING = 2033; - public const int SCI_GETBUFFEREDDRAW = 2034; - public const int SCI_SETBUFFEREDDRAW = 2035; - public const int SCI_SETTABWIDTH = 2036; - public const int SCI_GETTABWIDTH = 2121; - public const int SCI_CLEARTABSTOPS = 2675; - public const int SCI_ADDTABSTOP = 2676; - public const int SCI_GETNEXTTABSTOP = 2677; - public const int SCI_SETCODEPAGE = 2037; - public const int SCI_MARKERDEFINE = 2040; - public const int SCI_MARKERSETFORE = 2041; - public const int SCI_MARKERSETBACK = 2042; - public const int SCI_MARKERSETBACKSELECTED = 2292; - public const int SCI_MARKERENABLEHIGHLIGHT = 2293; - public const int SCI_MARKERADD = 2043; - public const int SCI_MARKERDELETE = 2044; - public const int SCI_MARKERDELETEALL = 2045; - public const int SCI_MARKERGET = 2046; - public const int SCI_MARKERNEXT = 2047; - public const int SCI_MARKERPREVIOUS = 2048; - public const int SCI_MARKERDEFINEPIXMAP = 2049; - public const int SCI_MARKERADDSET = 2466; - public const int SCI_MARKERSETALPHA = 2476; - public const int SCI_SETMARGINTYPEN = 2240; - public const int SCI_GETMARGINTYPEN = 2241; - public const int SCI_SETMARGINWIDTHN = 2242; - public const int SCI_GETMARGINWIDTHN = 2243; - public const int SCI_SETMARGINMASKN = 2244; - public const int SCI_GETMARGINMASKN = 2245; - public const int SCI_SETMARGINSENSITIVEN = 2246; - public const int SCI_GETMARGINSENSITIVEN = 2247; - public const int SCI_SETMARGINCURSORN = 2248; - public const int SCI_GETMARGINCURSORN = 2249; - public const int SCI_STYLECLEARALL = 2050; - public const int SCI_STYLESETFORE = 2051; - public const int SCI_STYLESETBACK = 2052; - public const int SCI_STYLESETBOLD = 2053; - public const int SCI_STYLESETITALIC = 2054; - public const int SCI_STYLESETSIZE = 2055; - public const int SCI_STYLESETFONT = 2056; - public const int SCI_STYLESETEOLFILLED = 2057; - public const int SCI_STYLERESETDEFAULT = 2058; - public const int SCI_STYLESETUNDERLINE = 2059; - public const int SCI_STYLEGETFORE = 2481; - public const int SCI_STYLEGETBACK = 2482; - public const int SCI_STYLEGETBOLD = 2483; - public const int SCI_STYLEGETITALIC = 2484; - public const int SCI_STYLEGETSIZE = 2485; - public const int SCI_STYLEGETFONT = 2486; - public const int SCI_STYLEGETEOLFILLED = 2487; - public const int SCI_STYLEGETUNDERLINE = 2488; - public const int SCI_STYLEGETCASE = 2489; - public const int SCI_STYLEGETCHARACTERSET = 2490; - public const int SCI_STYLEGETVISIBLE = 2491; - public const int SCI_STYLEGETCHANGEABLE = 2492; - public const int SCI_STYLEGETHOTSPOT = 2493; - public const int SCI_STYLESETCASE = 2060; - public const int SCI_STYLESETSIZEFRACTIONAL = 2061; - public const int SCI_STYLEGETSIZEFRACTIONAL = 2062; - public const int SCI_STYLESETWEIGHT = 2063; - public const int SCI_STYLEGETWEIGHT = 2064; - public const int SCI_STYLESETCHARACTERSET = 2066; - public const int SCI_STYLESETHOTSPOT = 2409; - public const int SCI_SETSELFORE = 2067; - public const int SCI_SETSELBACK = 2068; - public const int SCI_GETSELALPHA = 2477; - public const int SCI_SETSELALPHA = 2478; - public const int SCI_GETSELEOLFILLED = 2479; - public const int SCI_SETSELEOLFILLED = 2480; - public const int SCI_SETCARETFORE = 2069; - public const int SCI_ASSIGNCMDKEY = 2070; - public const int SCI_CLEARCMDKEY = 2071; - public const int SCI_CLEARALLCMDKEYS = 2072; - public const int SCI_SETSTYLINGEX = 2073; - public const int SCI_STYLESETVISIBLE = 2074; - public const int SCI_GETCARETPERIOD = 2075; - public const int SCI_SETCARETPERIOD = 2076; - public const int SCI_SETWORDCHARS = 2077; - public const int SCI_GETWORDCHARS = 2646; - public const int SCI_BEGINUNDOACTION = 2078; - public const int SCI_ENDUNDOACTION = 2079; - public const int SCI_INDICSETSTYLE = 2080; - public const int SCI_INDICGETSTYLE = 2081; - public const int SCI_INDICSETFORE = 2082; - public const int SCI_INDICGETFORE = 2083; - public const int SCI_INDICSETUNDER = 2510; - public const int SCI_INDICGETUNDER = 2511; - public const int SCI_INDICSETHOVERSTYLE = 2680; - public const int SCI_INDICGETHOVERSTYLE = 2681; - public const int SCI_INDICSETHOVERFORE = 2682; - public const int SCI_INDICGETHOVERFORE = 2683; - public const int SCI_INDICSETFLAGS = 2684; - public const int SCI_INDICGETFLAGS = 2685; - public const int SCI_SETWHITESPACEFORE = 2084; - public const int SCI_SETWHITESPACEBACK = 2085; - public const int SCI_SETWHITESPACESIZE = 2086; - public const int SCI_GETWHITESPACESIZE = 2087; - // public const int SCI_SETSTYLEBITS = 2090; - // public const int SCI_GETSTYLEBITS = 2091; - public const int SCI_SETLINESTATE = 2092; - public const int SCI_GETLINESTATE = 2093; - public const int SCI_GETMAXLINESTATE = 2094; - public const int SCI_GETCARETLINEVISIBLE = 2095; - public const int SCI_SETCARETLINEVISIBLE = 2096; - public const int SCI_GETCARETLINEBACK = 2097; - public const int SCI_SETCARETLINEBACK = 2098; - public const int SCI_STYLESETCHANGEABLE = 2099; - public const int SCI_AUTOCSHOW = 2100; - public const int SCI_AUTOCCANCEL = 2101; - public const int SCI_AUTOCACTIVE = 2102; - public const int SCI_AUTOCPOSSTART = 2103; - public const int SCI_AUTOCCOMPLETE = 2104; - public const int SCI_AUTOCSTOPS = 2105; - public const int SCI_AUTOCSETSEPARATOR = 2106; - public const int SCI_AUTOCGETSEPARATOR = 2107; - public const int SCI_AUTOCSELECT = 2108; - public const int SCI_AUTOCSETCANCELATSTART = 2110; - public const int SCI_AUTOCGETCANCELATSTART = 2111; - public const int SCI_AUTOCSETFILLUPS = 2112; - public const int SCI_AUTOCSETCHOOSESINGLE = 2113; - public const int SCI_AUTOCGETCHOOSESINGLE = 2114; - public const int SCI_AUTOCSETIGNORECASE = 2115; - public const int SCI_AUTOCGETIGNORECASE = 2116; - public const int SCI_USERLISTSHOW = 2117; - public const int SCI_AUTOCSETAUTOHIDE = 2118; - public const int SCI_AUTOCGETAUTOHIDE = 2119; - public const int SCI_AUTOCSETDROPRESTOFWORD = 2270; - public const int SCI_AUTOCGETDROPRESTOFWORD = 2271; - public const int SCI_REGISTERIMAGE = 2405; - public const int SCI_CLEARREGISTEREDIMAGES = 2408; - public const int SCI_AUTOCGETTYPESEPARATOR = 2285; - public const int SCI_AUTOCSETTYPESEPARATOR = 2286; - public const int SCI_AUTOCSETMAXWIDTH = 2208; - public const int SCI_AUTOCGETMAXWIDTH = 2209; - public const int SCI_AUTOCSETMAXHEIGHT = 2210; - public const int SCI_AUTOCGETMAXHEIGHT = 2211; - public const int SCI_SETINDENT = 2122; - public const int SCI_GETINDENT = 2123; - public const int SCI_SETUSETABS = 2124; - public const int SCI_GETUSETABS = 2125; - public const int SCI_SETLINEINDENTATION = 2126; - public const int SCI_GETLINEINDENTATION = 2127; - public const int SCI_GETLINEINDENTPOSITION = 2128; - public const int SCI_GETCOLUMN = 2129; - public const int SCI_COUNTCHARACTERS = 2633; - public const int SCI_SETHSCROLLBAR = 2130; - public const int SCI_GETHSCROLLBAR = 2131; - public const int SCI_SETINDENTATIONGUIDES = 2132; - public const int SCI_GETINDENTATIONGUIDES = 2133; - public const int SCI_SETHIGHLIGHTGUIDE = 2134; - public const int SCI_GETHIGHLIGHTGUIDE = 2135; - public const int SCI_GETLINEENDPOSITION = 2136; - public const int SCI_GETCODEPAGE = 2137; - public const int SCI_GETCARETFORE = 2138; - public const int SCI_GETREADONLY = 2140; - public const int SCI_SETCURRENTPOS = 2141; - public const int SCI_SETSELECTIONSTART = 2142; - public const int SCI_GETSELECTIONSTART = 2143; - public const int SCI_SETSELECTIONEND = 2144; - public const int SCI_GETSELECTIONEND = 2145; - public const int SCI_SETEMPTYSELECTION = 2556; - public const int SCI_SETPRINTMAGNIFICATION = 2146; - public const int SCI_GETPRINTMAGNIFICATION = 2147; - public const int SCI_SETPRINTCOLOURMODE = 2148; - public const int SCI_GETPRINTCOLOURMODE = 2149; - public const int SCI_FINDTEXT = 2150; - public const int SCI_FORMATRANGE = 2151; - public const int SCI_GETFIRSTVISIBLELINE = 2152; - public const int SCI_GETLINE = 2153; - public const int SCI_GETLINECOUNT = 2154; - public const int SCI_SETMARGINLEFT = 2155; - public const int SCI_GETMARGINLEFT = 2156; - public const int SCI_SETMARGINRIGHT = 2157; - public const int SCI_GETMARGINRIGHT = 2158; - public const int SCI_GETMODIFY = 2159; - public const int SCI_SETSEL = 2160; - public const int SCI_GETSELTEXT = 2161; - public const int SCI_GETTEXTRANGE = 2162; - public const int SCI_HIDESELECTION = 2163; - public const int SCI_POINTXFROMPOSITION = 2164; - public const int SCI_POINTYFROMPOSITION = 2165; - public const int SCI_LINEFROMPOSITION = 2166; - public const int SCI_POSITIONFROMLINE = 2167; - public const int SCI_LINESCROLL = 2168; - public const int SCI_SCROLLCARET = 2169; - public const int SCI_SCROLLRANGE = 2569; - public const int SCI_REPLACESEL = 2170; - public const int SCI_SETREADONLY = 2171; - public const int SCI_NULL = 2172; - public const int SCI_CANPASTE = 2173; - public const int SCI_CANUNDO = 2174; - public const int SCI_EMPTYUNDOBUFFER = 2175; - public const int SCI_UNDO = 2176; - public const int SCI_CUT = 2177; - public const int SCI_COPY = 2178; - public const int SCI_PASTE = 2179; - public const int SCI_CLEAR = 2180; - public const int SCI_SETTEXT = 2181; - public const int SCI_GETTEXT = 2182; - public const int SCI_GETTEXTLENGTH = 2183; - public const int SCI_GETDIRECTFUNCTION = 2184; - public const int SCI_GETDIRECTPOINTER = 2185; - public const int SCI_SETOVERTYPE = 2186; - public const int SCI_GETOVERTYPE = 2187; - public const int SCI_SETCARETWIDTH = 2188; - public const int SCI_GETCARETWIDTH = 2189; - public const int SCI_SETTARGETSTART = 2190; - public const int SCI_GETTARGETSTART = 2191; - public const int SCI_SETTARGETEND = 2192; - public const int SCI_GETTARGETEND = 2193; - public const int SCI_REPLACETARGET = 2194; - public const int SCI_REPLACETARGETRE = 2195; - public const int SCI_SEARCHINTARGET = 2197; - public const int SCI_SETSEARCHFLAGS = 2198; - public const int SCI_GETSEARCHFLAGS = 2199; - public const int SCI_CALLTIPSHOW = 2200; - public const int SCI_CALLTIPCANCEL = 2201; - public const int SCI_CALLTIPACTIVE = 2202; - public const int SCI_CALLTIPPOSSTART = 2203; - public const int SCI_CALLTIPSETPOSSTART = 2214; - public const int SCI_CALLTIPSETHLT = 2204; - public const int SCI_CALLTIPSETBACK = 2205; - public const int SCI_CALLTIPSETFORE = 2206; - public const int SCI_CALLTIPSETFOREHLT = 2207; - public const int SCI_CALLTIPUSESTYLE = 2212; - public const int SCI_CALLTIPSETPOSITION = 2213; - public const int SCI_VISIBLEFROMDOCLINE = 2220; - public const int SCI_DOCLINEFROMVISIBLE = 2221; - public const int SCI_WRAPCOUNT = 2235; - public const int SCI_SETFOLDLEVEL = 2222; - public const int SCI_GETFOLDLEVEL = 2223; - public const int SCI_GETLASTCHILD = 2224; - public const int SCI_GETFOLDPARENT = 2225; - public const int SCI_SHOWLINES = 2226; - public const int SCI_HIDELINES = 2227; - public const int SCI_GETLINEVISIBLE = 2228; - public const int SCI_GETALLLINESVISIBLE = 2236; - public const int SCI_SETFOLDEXPANDED = 2229; - public const int SCI_GETFOLDEXPANDED = 2230; - public const int SCI_TOGGLEFOLD = 2231; - public const int SCI_FOLDLINE = 2237; - public const int SCI_FOLDCHILDREN = 2238; - public const int SCI_EXPANDCHILDREN = 2239; - public const int SCI_FOLDALL = 2662; - public const int SCI_ENSUREVISIBLE = 2232; - public const int SCI_SETAUTOMATICFOLD = 2663; - public const int SCI_GETAUTOMATICFOLD = 2664; - public const int SCI_SETFOLDFLAGS = 2233; - public const int SCI_ENSUREVISIBLEENFORCEPOLICY = 2234; - public const int SCI_SETTABINDENTS = 2260; - public const int SCI_GETTABINDENTS = 2261; - public const int SCI_SETBACKSPACEUNINDENTS = 2262; - public const int SCI_GETBACKSPACEUNINDENTS = 2263; - public const int SCI_SETMOUSEDWELLTIME = 2264; - public const int SCI_GETMOUSEDWELLTIME = 2265; - public const int SCI_WORDSTARTPOSITION = 2266; - public const int SCI_WORDENDPOSITION = 2267; - public const int SCI_SETWRAPMODE = 2268; - public const int SCI_GETWRAPMODE = 2269; - public const int SCI_SETWRAPVISUALFLAGS = 2460; - public const int SCI_GETWRAPVISUALFLAGS = 2461; - public const int SCI_SETWRAPVISUALFLAGSLOCATION = 2462; - public const int SCI_GETWRAPVISUALFLAGSLOCATION = 2463; - public const int SCI_SETWRAPSTARTINDENT = 2464; - public const int SCI_GETWRAPSTARTINDENT = 2465; - public const int SCI_SETWRAPINDENTMODE = 2472; - public const int SCI_GETWRAPINDENTMODE = 2473; - public const int SCI_SETLAYOUTCACHE = 2272; - public const int SCI_GETLAYOUTCACHE = 2273; - public const int SCI_SETSCROLLWIDTH = 2274; - public const int SCI_GETSCROLLWIDTH = 2275; - public const int SCI_SETSCROLLWIDTHTRACKING = 2516; - public const int SCI_GETSCROLLWIDTHTRACKING = 2517; - public const int SCI_TEXTWIDTH = 2276; - public const int SCI_SETENDATLASTLINE = 2277; - public const int SCI_GETENDATLASTLINE = 2278; - public const int SCI_TEXTHEIGHT = 2279; - public const int SCI_SETVSCROLLBAR = 2280; - public const int SCI_GETVSCROLLBAR = 2281; - public const int SCI_APPENDTEXT = 2282; - public const int SCI_GETTWOPHASEDRAW = 2283; - public const int SCI_SETTWOPHASEDRAW = 2284; - public const int SCI_GETPHASESDRAW = 2673; - public const int SCI_SETPHASESDRAW = 2674; - public const int SCI_SETFONTQUALITY = 2611; - public const int SCI_GETFONTQUALITY = 2612; - public const int SCI_SETFIRSTVISIBLELINE = 2613; - public const int SCI_SETMULTIPASTE = 2614; - public const int SCI_GETMULTIPASTE = 2615; - public const int SCI_GETTAG = 2616; - public const int SCI_TARGETFROMSELECTION = 2287; - public const int SCI_LINESJOIN = 2288; - public const int SCI_LINESSPLIT = 2289; - public const int SCI_SETFOLDMARGINCOLOUR = 2290; - public const int SCI_SETFOLDMARGINHICOLOUR = 2291; - public const int SCI_LINEDOWN = 2300; - public const int SCI_LINEDOWNEXTEND = 2301; - public const int SCI_LINEUP = 2302; - public const int SCI_LINEUPEXTEND = 2303; - public const int SCI_CHARLEFT = 2304; - public const int SCI_CHARLEFTEXTEND = 2305; - public const int SCI_CHARRIGHT = 2306; - public const int SCI_CHARRIGHTEXTEND = 2307; - public const int SCI_WORDLEFT = 2308; - public const int SCI_WORDLEFTEXTEND = 2309; - public const int SCI_WORDRIGHT = 2310; - public const int SCI_WORDRIGHTEXTEND = 2311; - public const int SCI_HOME = 2312; - public const int SCI_HOMEEXTEND = 2313; - public const int SCI_LINEEND = 2314; - public const int SCI_LINEENDEXTEND = 2315; - public const int SCI_DOCUMENTSTART = 2316; - public const int SCI_DOCUMENTSTARTEXTEND = 2317; - public const int SCI_DOCUMENTEND = 2318; - public const int SCI_DOCUMENTENDEXTEND = 2319; - public const int SCI_PAGEUP = 2320; - public const int SCI_PAGEUPEXTEND = 2321; - public const int SCI_PAGEDOWN = 2322; - public const int SCI_PAGEDOWNEXTEND = 2323; - public const int SCI_EDITTOGGLEOVERTYPE = 2324; - public const int SCI_CANCEL = 2325; - public const int SCI_DELETEBACK = 2326; - public const int SCI_TAB = 2327; - public const int SCI_BACKTAB = 2328; - public const int SCI_NEWLINE = 2329; - public const int SCI_FORMFEED = 2330; - public const int SCI_VCHOME = 2331; - public const int SCI_VCHOMEEXTEND = 2332; - public const int SCI_ZOOMIN = 2333; - public const int SCI_ZOOMOUT = 2334; - public const int SCI_DELWORDLEFT = 2335; - public const int SCI_DELWORDRIGHT = 2336; - public const int SCI_DELWORDRIGHTEND = 2518; - public const int SCI_LINECUT = 2337; - public const int SCI_LINEDELETE = 2338; - public const int SCI_LINETRANSPOSE = 2339; - public const int SCI_LINEDUPLICATE = 2404; - public const int SCI_LOWERCASE = 2340; - public const int SCI_UPPERCASE = 2341; - public const int SCI_LINESCROLLDOWN = 2342; - public const int SCI_LINESCROLLUP = 2343; - public const int SCI_DELETEBACKNOTLINE = 2344; - public const int SCI_HOMEDISPLAY = 2345; - public const int SCI_HOMEDISPLAYEXTEND = 2346; - public const int SCI_LINEENDDISPLAY = 2347; - public const int SCI_LINEENDDISPLAYEXTEND = 2348; - public const int SCI_HOMEWRAP = 2349; - public const int SCI_HOMEWRAPEXTEND = 2450; - public const int SCI_LINEENDWRAP = 2451; - public const int SCI_LINEENDWRAPEXTEND = 2452; - public const int SCI_VCHOMEWRAP = 2453; - public const int SCI_VCHOMEWRAPEXTEND = 2454; - public const int SCI_LINECOPY = 2455; - public const int SCI_MOVECARETINSIDEVIEW = 2401; - public const int SCI_LINELENGTH = 2350; - public const int SCI_BRACEHIGHLIGHT = 2351; - public const int SCI_BRACEHIGHLIGHTINDICATOR = 2498; - public const int SCI_BRACEBADLIGHT = 2352; - public const int SCI_BRACEBADLIGHTINDICATOR = 2499; - public const int SCI_BRACEMATCH = 2353; - public const int SCI_GETVIEWEOL = 2355; - public const int SCI_SETVIEWEOL = 2356; - public const int SCI_GETDOCPOINTER = 2357; - public const int SCI_SETDOCPOINTER = 2358; - public const int SCI_SETMODEVENTMASK = 2359; - public const int SCI_GETEDGECOLUMN = 2360; - public const int SCI_SETEDGECOLUMN = 2361; - public const int SCI_GETEDGEMODE = 2362; - public const int SCI_SETEDGEMODE = 2363; - public const int SCI_GETEDGECOLOUR = 2364; - public const int SCI_SETEDGECOLOUR = 2365; - public const int SCI_SEARCHANCHOR = 2366; - public const int SCI_SEARCHNEXT = 2367; - public const int SCI_SEARCHPREV = 2368; - public const int SCI_LINESONSCREEN = 2370; - public const int SCI_USEPOPUP = 2371; - public const int SCI_SELECTIONISRECTANGLE = 2372; - public const int SCI_SETZOOM = 2373; - public const int SCI_GETZOOM = 2374; - public const int SCI_CREATEDOCUMENT = 2375; - public const int SCI_ADDREFDOCUMENT = 2376; - public const int SCI_RELEASEDOCUMENT = 2377; - public const int SCI_GETMODEVENTMASK = 2378; - public const int SCI_SETFOCUS = 2380; - public const int SCI_GETFOCUS = 2381; - public const int SCI_SETSTATUS = 2382; - public const int SCI_GETSTATUS = 2383; - public const int SCI_SETMOUSEDOWNCAPTURES = 2384; - public const int SCI_GETMOUSEDOWNCAPTURES = 2385; - public const int SCI_SETCURSOR = 2386; - public const int SCI_GETCURSOR = 2387; - public const int SCI_SETCONTROLCHARSYMBOL = 2388; - public const int SCI_GETCONTROLCHARSYMBOL = 2389; - public const int SCI_WORDPARTLEFT = 2390; - public const int SCI_WORDPARTLEFTEXTEND = 2391; - public const int SCI_WORDPARTRIGHT = 2392; - public const int SCI_WORDPARTRIGHTEXTEND = 2393; - public const int SCI_SETVISIBLEPOLICY = 2394; - public const int SCI_DELLINELEFT = 2395; - public const int SCI_DELLINERIGHT = 2396; - public const int SCI_SETXOFFSET = 2397; - public const int SCI_GETXOFFSET = 2398; - public const int SCI_CHOOSECARETX = 2399; - public const int SCI_GRABFOCUS = 2400; - public const int SCI_SETXCARETPOLICY = 2402; - public const int SCI_SETYCARETPOLICY = 2403; - public const int SCI_SETPRINTWRAPMODE = 2406; - public const int SCI_GETPRINTWRAPMODE = 2407; - public const int SCI_SETHOTSPOTACTIVEFORE = 2410; - public const int SCI_GETHOTSPOTACTIVEFORE = 2494; - public const int SCI_SETHOTSPOTACTIVEBACK = 2411; - public const int SCI_GETHOTSPOTACTIVEBACK = 2495; - public const int SCI_SETHOTSPOTACTIVEUNDERLINE = 2412; - public const int SCI_GETHOTSPOTACTIVEUNDERLINE = 2496; - public const int SCI_SETHOTSPOTSINGLELINE = 2421; - public const int SCI_GETHOTSPOTSINGLELINE = 2497; - public const int SCI_PARADOWN = 2413; - public const int SCI_PARADOWNEXTEND = 2414; - public const int SCI_PARAUP = 2415; - public const int SCI_PARAUPEXTEND = 2416; - public const int SCI_POSITIONBEFORE = 2417; - public const int SCI_POSITIONAFTER = 2418; - public const int SCI_POSITIONRELATIVE = 2670; - public const int SCI_COPYRANGE = 2419; - public const int SCI_COPYTEXT = 2420; - public const int SCI_SETSELECTIONMODE = 2422; - public const int SCI_GETSELECTIONMODE = 2423; - public const int SCI_GETLINESELSTARTPOSITION = 2424; - public const int SCI_GETLINESELENDPOSITION = 2425; - public const int SCI_LINEDOWNRECTEXTEND = 2426; - public const int SCI_LINEUPRECTEXTEND = 2427; - public const int SCI_CHARLEFTRECTEXTEND = 2428; - public const int SCI_CHARRIGHTRECTEXTEND = 2429; - public const int SCI_HOMERECTEXTEND = 2430; - public const int SCI_VCHOMERECTEXTEND = 2431; - public const int SCI_LINEENDRECTEXTEND = 2432; - public const int SCI_PAGEUPRECTEXTEND = 2433; - public const int SCI_PAGEDOWNRECTEXTEND = 2434; - public const int SCI_STUTTEREDPAGEUP = 2435; - public const int SCI_STUTTEREDPAGEUPEXTEND = 2436; - public const int SCI_STUTTEREDPAGEDOWN = 2437; - public const int SCI_STUTTEREDPAGEDOWNEXTEND = 2438; - public const int SCI_WORDLEFTEND = 2439; - public const int SCI_WORDLEFTENDEXTEND = 2440; - public const int SCI_WORDRIGHTEND = 2441; - public const int SCI_WORDRIGHTENDEXTEND = 2442; - public const int SCI_SETWHITESPACECHARS = 2443; - public const int SCI_GETWHITESPACECHARS = 2647; - public const int SCI_SETPUNCTUATIONCHARS = 2648; - public const int SCI_GETPUNCTUATIONCHARS = 2649; - public const int SCI_SETCHARSDEFAULT = 2444; - public const int SCI_AUTOCGETCURRENT = 2445; - public const int SCI_AUTOCGETCURRENTTEXT = 2610; - public const int SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR = 2634; - public const int SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR = 2635; - public const int SCI_AUTOCSETMULTI = 2636; - public const int SCI_AUTOCGETMULTI = 2637; - public const int SCI_AUTOCSETORDER = 2660; - public const int SCI_AUTOCGETORDER = 2661; - public const int SCI_ALLOCATE = 2446; - public const int SCI_TARGETASUTF8 = 2447; - public const int SCI_SETLENGTHFORENCODE = 2448; - public const int SCI_ENCODEDFROMUTF8 = 2449; - public const int SCI_FINDCOLUMN = 2456; - public const int SCI_GETCARETSTICKY = 2457; - public const int SCI_SETCARETSTICKY = 2458; - public const int SCI_TOGGLECARETSTICKY = 2459; - public const int SCI_SETPASTECONVERTENDINGS = 2467; - public const int SCI_GETPASTECONVERTENDINGS = 2468; - public const int SCI_SELECTIONDUPLICATE = 2469; - public const int SCI_SETCARETLINEBACKALPHA = 2470; - public const int SCI_GETCARETLINEBACKALPHA = 2471; - public const int SCI_SETCARETSTYLE = 2512; - public const int SCI_GETCARETSTYLE = 2513; - public const int SCI_SETINDICATORCURRENT = 2500; - public const int SCI_GETINDICATORCURRENT = 2501; - public const int SCI_SETINDICATORVALUE = 2502; - public const int SCI_GETINDICATORVALUE = 2503; - public const int SCI_INDICATORFILLRANGE = 2504; - public const int SCI_INDICATORCLEARRANGE = 2505; - public const int SCI_INDICATORALLONFOR = 2506; - public const int SCI_INDICATORVALUEAT = 2507; - public const int SCI_INDICATORSTART = 2508; - public const int SCI_INDICATOREND = 2509; - public const int SCI_SETPOSITIONCACHE = 2514; - public const int SCI_GETPOSITIONCACHE = 2515; - public const int SCI_COPYALLOWLINE = 2519; - public const int SCI_GETCHARACTERPOINTER = 2520; - public const int SCI_GETRANGEPOINTER = 2643; - public const int SCI_GETGAPPOSITION = 2644; - public const int SCI_SETKEYSUNICODE = 2521; - public const int SCI_GETKEYSUNICODE = 2522; - public const int SCI_INDICSETALPHA = 2523; - public const int SCI_INDICGETALPHA = 2524; - public const int SCI_INDICSETOUTLINEALPHA = 2558; - public const int SCI_INDICGETOUTLINEALPHA = 2559; - public const int SCI_SETEXTRAASCENT = 2525; - public const int SCI_GETEXTRAASCENT = 2526; - public const int SCI_SETEXTRADESCENT = 2527; - public const int SCI_GETEXTRADESCENT = 2528; - public const int SCI_MARKERSYMBOLDEFINED = 2529; - public const int SCI_MARGINSETTEXT = 2530; - public const int SCI_MARGINGETTEXT = 2531; - public const int SCI_MARGINSETSTYLE = 2532; - public const int SCI_MARGINGETSTYLE = 2533; - public const int SCI_MARGINSETSTYLES = 2534; - public const int SCI_MARGINGETSTYLES = 2535; - public const int SCI_MARGINTEXTCLEARALL = 2536; - public const int SCI_MARGINSETSTYLEOFFSET = 2537; - public const int SCI_MARGINGETSTYLEOFFSET = 2538; - public const int SCI_SETMARGINOPTIONS = 2539; - public const int SCI_GETMARGINOPTIONS = 2557; - public const int SCI_ANNOTATIONSETTEXT = 2540; - public const int SCI_ANNOTATIONGETTEXT = 2541; - public const int SCI_ANNOTATIONSETSTYLE = 2542; - public const int SCI_ANNOTATIONGETSTYLE = 2543; - public const int SCI_ANNOTATIONSETSTYLES = 2544; - public const int SCI_ANNOTATIONGETSTYLES = 2545; - public const int SCI_ANNOTATIONGETLINES = 2546; - public const int SCI_ANNOTATIONCLEARALL = 2547; - public const int SCI_ANNOTATIONSETVISIBLE = 2548; - public const int SCI_ANNOTATIONGETVISIBLE = 2549; - public const int SCI_ANNOTATIONSETSTYLEOFFSET = 2550; - public const int SCI_ANNOTATIONGETSTYLEOFFSET = 2551; - public const int SCI_RELEASEALLEXTENDEDSTYLES = 2552; - public const int SCI_ALLOCATEEXTENDEDSTYLES = 2553; - public const int SCI_ADDUNDOACTION = 2560; - public const int SCI_CHARPOSITIONFROMPOINT = 2561; - public const int SCI_CHARPOSITIONFROMPOINTCLOSE = 2562; - public const int SCI_SETMOUSESELECTIONRECTANGULARSWITCH = 2668; - public const int SCI_GETMOUSESELECTIONRECTANGULARSWITCH = 2669; - public const int SCI_SETMULTIPLESELECTION = 2563; - public const int SCI_GETMULTIPLESELECTION = 2564; - public const int SCI_SETADDITIONALSELECTIONTYPING = 2565; - public const int SCI_GETADDITIONALSELECTIONTYPING = 2566; - public const int SCI_SETADDITIONALCARETSBLINK = 2567; - public const int SCI_GETADDITIONALCARETSBLINK = 2568; - public const int SCI_SETADDITIONALCARETSVISIBLE = 2608; - public const int SCI_GETADDITIONALCARETSVISIBLE = 2609; - public const int SCI_GETSELECTIONS = 2570; - public const int SCI_GETSELECTIONEMPTY = 2650; - public const int SCI_CLEARSELECTIONS = 2571; - public const int SCI_SETSELECTION = 2572; - public const int SCI_ADDSELECTION = 2573; - public const int SCI_DROPSELECTIONN = 2671; - public const int SCI_SETMAINSELECTION = 2574; - public const int SCI_GETMAINSELECTION = 2575; - public const int SCI_SETSELECTIONNCARET = 2576; - public const int SCI_GETSELECTIONNCARET = 2577; - public const int SCI_SETSELECTIONNANCHOR = 2578; - public const int SCI_GETSELECTIONNANCHOR = 2579; - public const int SCI_SETSELECTIONNCARETVIRTUALSPACE = 2580; - public const int SCI_GETSELECTIONNCARETVIRTUALSPACE = 2581; - public const int SCI_SETSELECTIONNANCHORVIRTUALSPACE = 2582; - public const int SCI_GETSELECTIONNANCHORVIRTUALSPACE = 2583; - public const int SCI_SETSELECTIONNSTART = 2584; - public const int SCI_GETSELECTIONNSTART = 2585; - public const int SCI_SETSELECTIONNEND = 2586; - public const int SCI_GETSELECTIONNEND = 2587; - public const int SCI_SETRECTANGULARSELECTIONCARET = 2588; - public const int SCI_GETRECTANGULARSELECTIONCARET = 2589; - public const int SCI_SETRECTANGULARSELECTIONANCHOR = 2590; - public const int SCI_GETRECTANGULARSELECTIONANCHOR = 2591; - public const int SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE = 2592; - public const int SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE = 2593; - public const int SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE = 2594; - public const int SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE = 2595; - public const int SCI_SETVIRTUALSPACEOPTIONS = 2596; - public const int SCI_GETVIRTUALSPACEOPTIONS = 2597; - public const int SCI_SETRECTANGULARSELECTIONMODIFIER = 2598; - public const int SCI_GETRECTANGULARSELECTIONMODIFIER = 2599; - public const int SCI_SETADDITIONALSELFORE = 2600; - public const int SCI_SETADDITIONALSELBACK = 2601; - public const int SCI_SETADDITIONALSELALPHA = 2602; - public const int SCI_GETADDITIONALSELALPHA = 2603; - public const int SCI_SETADDITIONALCARETFORE = 2604; - public const int SCI_GETADDITIONALCARETFORE = 2605; - public const int SCI_ROTATESELECTION = 2606; - public const int SCI_SWAPMAINANCHORCARET = 2607; - public const int SCI_CHANGELEXERSTATE = 2617; - public const int SCI_CONTRACTEDFOLDNEXT = 2618; - public const int SCI_VERTICALCENTRECARET = 2619; - public const int SCI_MOVESELECTEDLINESUP = 2620; - public const int SCI_MOVESELECTEDLINESDOWN = 2621; - public const int SCI_SETIDENTIFIER = 2622; - public const int SCI_GETIDENTIFIER = 2623; - public const int SCI_RGBAIMAGESETWIDTH = 2624; - public const int SCI_RGBAIMAGESETHEIGHT = 2625; - public const int SCI_RGBAIMAGESETSCALE = 2651; - public const int SCI_MARKERDEFINERGBAIMAGE = 2626; - public const int SCI_REGISTERRGBAIMAGE = 2627; - public const int SCI_SCROLLTOSTART = 2628; - public const int SCI_SCROLLTOEND = 2629; - public const int SCI_SETTECHNOLOGY = 2630; - public const int SCI_GETTECHNOLOGY = 2631; - public const int SCI_CREATELOADER = 2632; - public const int SCI_FINDINDICATORSHOW = 2640; - public const int SCI_FINDINDICATORFLASH = 2641; - public const int SCI_FINDINDICATORHIDE = 2642; - public const int SCI_VCHOMEDISPLAY = 2652; - public const int SCI_VCHOMEDISPLAYEXTEND = 2653; - public const int SCI_GETCARETLINEVISIBLEALWAYS = 2654; - public const int SCI_SETCARETLINEVISIBLEALWAYS = 2655; - public const int SCI_SETLINEENDTYPESALLOWED = 2656; - public const int SCI_GETLINEENDTYPESALLOWED = 2657; - public const int SCI_GETLINEENDTYPESACTIVE = 2658; - public const int SCI_SETREPRESENTATION = 2665; - public const int SCI_GETREPRESENTATION = 2666; - public const int SCI_CLEARREPRESENTATION = 2667; - public const int SCI_SETTARGETRANGE = 2686; - public const int SCI_GETTARGETTEXT = 2687; - public const int SCI_STARTRECORD = 3001; - public const int SCI_STOPRECORD = 3002; - public const int SCI_SETLEXER = 4001; - public const int SCI_GETLEXER = 4002; - public const int SCI_COLOURISE = 4003; - public const int SCI_SETPROPERTY = 4004; - public const int SCI_SETKEYWORDS = 4005; - public const int SCI_SETLEXERLANGUAGE = 4006; - public const int SCI_LOADLEXERLIBRARY = 4007; - public const int SCI_GETPROPERTY = 4008; - public const int SCI_GETPROPERTYEXPANDED = 4009; - public const int SCI_GETPROPERTYINT = 4010; - // public const int SCI_GETSTYLEBITSNEEDED = 4011; - public const int SCI_GETLEXERLANGUAGE = 4012; - public const int SCI_PRIVATELEXERCALL = 4013; - public const int SCI_PROPERTYNAMES = 4014; - public const int SCI_PROPERTYTYPE = 4015; - public const int SCI_DESCRIBEPROPERTY = 4016; - public const int SCI_DESCRIBEKEYWORDSETS = 4017; - public const int SCI_GETLINEENDTYPESSUPPORTED = 4018; - public const int SCI_ALLOCATESUBSTYLES = 4020; - public const int SCI_GETSUBSTYLESSTART = 4021; - public const int SCI_GETSUBSTYLESLENGTH = 4022; - public const int SCI_GETSTYLEFROMSUBSTYLE = 4027; - public const int SCI_GETPRIMARYSTYLEFROMSTYLE = 4028; - public const int SCI_FREESUBSTYLES = 4023; - public const int SCI_SETIDENTIFIERS = 4024; - public const int SCI_DISTANCETOSECONDARYSTYLES = 4025; - public const int SCI_GETSUBSTYLEBASES = 4026; - // public const int SCI_SETUSEPALETTE = 2039; - // public const int SCI_GETUSEPALETTE = 2139; - - // Notifications - public const int SCN_STYLENEEDED = 2000; - public const int SCN_CHARADDED = 2001; - public const int SCN_SAVEPOINTREACHED = 2002; - public const int SCN_SAVEPOINTLEFT = 2003; - public const int SCN_MODIFYATTEMPTRO = 2004; - public const int SCN_KEY = 2005; - public const int SCN_DOUBLECLICK = 2006; - public const int SCN_UPDATEUI = 2007; - public const int SCN_MODIFIED = 2008; - public const int SCN_MACRORECORD = 2009; - public const int SCN_MARGINCLICK = 2010; - public const int SCN_NEEDSHOWN = 2011; - public const int SCN_PAINTED = 2013; - public const int SCN_USERLISTSELECTION = 2014; - public const int SCN_URIDROPPED = 2015; - public const int SCN_DWELLSTART = 2016; - public const int SCN_DWELLEND = 2017; - public const int SCN_ZOOM = 2018; - public const int SCN_HOTSPOTCLICK = 2019; - public const int SCN_HOTSPOTDOUBLECLICK = 2020; - public const int SCN_CALLTIPCLICK = 2021; - public const int SCN_AUTOCSELECTION = 2022; - public const int SCN_INDICATORCLICK = 2023; - public const int SCN_INDICATORRELEASE = 2024; - public const int SCN_AUTOCCANCELLED = 2025; - public const int SCN_AUTOCCHARDELETED = 2026; - public const int SCN_HOTSPOTRELEASECLICK = 2027; - public const int SCN_FOCUSIN = 2028; - public const int SCN_FOCUSOUT = 2029; - - // Line wrapping - public const int SC_WRAP_NONE = 0; - public const int SC_WRAP_WORD = 1; - public const int SC_WRAP_CHAR = 2; - public const int SC_WRAP_WHITESPACE = 3; - - public const int SC_WRAPVISUALFLAG_NONE = 0x0000; - public const int SC_WRAPVISUALFLAG_END = 0x0001; - public const int SC_WRAPVISUALFLAG_START = 0x0002; - public const int SC_WRAPVISUALFLAG_MARGIN = 0x0004; - - public const int SC_WRAPVISUALFLAGLOC_DEFAULT = 0x0000; - public const int SC_WRAPVISUALFLAGLOC_END_BY_TEXT = 0x0001; - public const int SC_WRAPVISUALFLAGLOC_START_BY_TEXT = 0x0002; - - public const int SC_WRAPINDENT_FIXED = 0; - public const int SC_WRAPINDENT_SAME = 1; - public const int SC_WRAPINDENT_INDENT = 2; - - // Virtual space - public const int SCVS_NONE = 0; - public const int SCVS_RECTANGULARSELECTION = 1; - public const int SCVS_USERACCESSIBLE = 2; - - // Styles constants - public const int STYLE_DEFAULT = 32; - public const int STYLE_LINENUMBER = 33; - public const int STYLE_BRACELIGHT = 34; - public const int STYLE_BRACEBAD = 35; - public const int STYLE_CONTROLCHAR = 36; - public const int STYLE_INDENTGUIDE = 37; - public const int STYLE_CALLTIP = 38; - public const int STYLE_LASTPREDEFINED = 39; - public const int STYLE_MAX = 255; - - public const int SC_FONT_SIZE_MULTIPLIER = 100; - public const int SC_CASE_MIXED = 0; - public const int SC_CASE_UPPER = 1; - public const int SC_CASE_LOWER = 2; - - // Undo - public const int UNDO_MAY_COALESCE = 1; - - // Whitespace - public const int SCWS_INVISIBLE = 0; - public const int SCWS_VISIBLEALWAYS = 1; - public const int SCWS_VISIBLEAFTERINDENT = 2; - - // Window messages - public const int WM_NOTIFY = 0x004E; - public const int WM_USER = 0x0400; - public const int WM_REFLECT = WM_USER + 0x1C00; - - // Window styles - public const int WS_BORDER = 0x00800000; - public const int WS_EX_CLIENTEDGE = 0x00000200; - - #endregion Constants - - #region Lexer Constants - - // Lexers - public const int SCLEX_CONTAINER = 0; - public const int SCLEX_NULL = 1; - public const int SCLEX_PYTHON = 2; - public const int SCLEX_CPP = 3; - public const int SCLEX_HTML = 4; - public const int SCLEX_XML = 5; - public const int SCLEX_PERL = 6; - public const int SCLEX_SQL = 7; - public const int SCLEX_VB = 8; - public const int SCLEX_PROPERTIES = 9; - public const int SCLEX_ERRORLIST = 10; - public const int SCLEX_MAKEFILE = 11; - public const int SCLEX_BATCH = 12; - public const int SCLEX_XCODE = 13; - public const int SCLEX_LATEX = 14; - public const int SCLEX_LUA = 15; - public const int SCLEX_DIFF = 16; - public const int SCLEX_CONF = 17; - public const int SCLEX_PASCAL = 18; - public const int SCLEX_AVE = 19; - public const int SCLEX_ADA = 20; - public const int SCLEX_LISP = 21; - public const int SCLEX_RUBY = 22; - public const int SCLEX_EIFFEL = 23; - public const int SCLEX_EIFFELKW = 24; - public const int SCLEX_TCL = 25; - public const int SCLEX_NNCRONTAB = 26; - public const int SCLEX_BULLANT = 27; - public const int SCLEX_VBSCRIPT = 28; - public const int SCLEX_BAAN = 31; - public const int SCLEX_MATLAB = 32; - public const int SCLEX_SCRIPTOL = 33; - public const int SCLEX_ASM = 34; - public const int SCLEX_CPPNOCASE = 35; - public const int SCLEX_FORTRAN = 36; - public const int SCLEX_F77 = 37; - public const int SCLEX_CSS = 38; - public const int SCLEX_POV = 39; - public const int SCLEX_LOUT = 40; - public const int SCLEX_ESCRIPT = 41; - public const int SCLEX_PS = 42; - public const int SCLEX_NSIS = 43; - public const int SCLEX_MMIXAL = 44; - public const int SCLEX_CLW = 45; - public const int SCLEX_CLWNOCASE = 46; - public const int SCLEX_LOT = 47; - public const int SCLEX_YAML = 48; - public const int SCLEX_TEX = 49; - public const int SCLEX_METAPOST = 50; - public const int SCLEX_POWERBASIC = 51; - public const int SCLEX_FORTH = 52; - public const int SCLEX_ERLANG = 53; - public const int SCLEX_OCTAVE = 54; - public const int SCLEX_MSSQL = 55; - public const int SCLEX_VERILOG = 56; - public const int SCLEX_KIX = 57; - public const int SCLEX_GUI4CLI = 58; - public const int SCLEX_SPECMAN = 59; - public const int SCLEX_AU3 = 60; - public const int SCLEX_APDL = 61; - public const int SCLEX_BASH = 62; - public const int SCLEX_ASN1 = 63; - public const int SCLEX_VHDL = 64; - public const int SCLEX_CAML = 65; - public const int SCLEX_BLITZBASIC = 66; - public const int SCLEX_PUREBASIC = 67; - public const int SCLEX_HASKELL = 68; - public const int SCLEX_PHPSCRIPT = 69; - public const int SCLEX_TADS3 = 70; - public const int SCLEX_REBOL = 71; - public const int SCLEX_SMALLTALK = 72; - public const int SCLEX_FLAGSHIP = 73; - public const int SCLEX_CSOUND = 74; - public const int SCLEX_FREEBASIC = 75; - public const int SCLEX_INNOSETUP = 76; - public const int SCLEX_OPAL = 77; - public const int SCLEX_SPICE = 78; - public const int SCLEX_D = 79; - public const int SCLEX_CMAKE = 80; - public const int SCLEX_GAP = 81; - public const int SCLEX_PLM = 82; - public const int SCLEX_PROGRESS = 83; - public const int SCLEX_ABAQUS = 84; - public const int SCLEX_ASYMPTOTE = 85; - public const int SCLEX_R = 86; - public const int SCLEX_MAGIK = 87; - public const int SCLEX_POWERSHELL = 88; - public const int SCLEX_MYSQL = 89; - public const int SCLEX_PO = 90; - public const int SCLEX_TAL = 91; - public const int SCLEX_COBOL = 92; - public const int SCLEX_TACL = 93; - public const int SCLEX_SORCUS = 94; - public const int SCLEX_POWERPRO = 95; - public const int SCLEX_NIMROD = 96; - public const int SCLEX_SML = 97; - public const int SCLEX_MARKDOWN = 98; - public const int SCLEX_TXT2TAGS = 99; - public const int SCLEX_A68K = 100; - public const int SCLEX_MODULA = 101; - public const int SCLEX_COFFEESCRIPT = 102; - public const int SCLEX_TCMD = 103; - public const int SCLEX_AVS = 104; - public const int SCLEX_ECL = 105; - public const int SCLEX_OSCRIPT = 106; - public const int SCLEX_VISUALPROLOG = 107; - public const int SCLEX_LITERATEHASKELL = 108; - public const int SCLEX_STTXT = 109; - public const int SCLEX_KVIRC = 110; - public const int SCLEX_RUST = 111; - public const int SCLEX_DMAP = 112; - public const int SCLEX_AS = 113; - public const int SCLEX_DMIS = 114; - public const int SCLEX_REGISTRY = 115; - public const int SCLEX_BIBTEX = 116; - public const int SCLEX_SREC = 117; - public const int SCLEX_IHEX = 118; - public const int SCLEX_TEHEX = 119; - public const int SCLEX_AUTOMATIC = 1000; - - // Python - public const int SCE_P_DEFAULT = 0; - public const int SCE_P_COMMENTLINE = 1; - public const int SCE_P_NUMBER = 2; - public const int SCE_P_STRING = 3; - public const int SCE_P_CHARACTER = 4; - public const int SCE_P_WORD = 5; - public const int SCE_P_TRIPLE = 6; - public const int SCE_P_TRIPLEDOUBLE = 7; - public const int SCE_P_CLASSNAME = 8; - public const int SCE_P_DEFNAME = 9; - public const int SCE_P_OPERATOR = 10; - public const int SCE_P_IDENTIFIER = 11; - public const int SCE_P_COMMENTBLOCK = 12; - public const int SCE_P_STRINGEOL = 13; - public const int SCE_P_WORD2 = 14; - public const int SCE_P_DECORATOR = 15; - - // Cpp - public const int SCE_C_DEFAULT = 0; - public const int SCE_C_COMMENT = 1; - public const int SCE_C_COMMENTLINE = 2; - public const int SCE_C_COMMENTDOC = 3; - public const int SCE_C_NUMBER = 4; - public const int SCE_C_WORD = 5; - public const int SCE_C_STRING = 6; - public const int SCE_C_CHARACTER = 7; - public const int SCE_C_UUID = 8; - public const int SCE_C_PREPROCESSOR = 9; - public const int SCE_C_OPERATOR = 10; - public const int SCE_C_IDENTIFIER = 11; - public const int SCE_C_STRINGEOL = 12; - public const int SCE_C_VERBATIM = 13; - public const int SCE_C_REGEX = 14; - public const int SCE_C_COMMENTLINEDOC = 15; - public const int SCE_C_WORD2 = 16; - public const int SCE_C_COMMENTDOCKEYWORD = 17; - public const int SCE_C_COMMENTDOCKEYWORDERROR = 18; - public const int SCE_C_GLOBALCLASS = 19; - public const int SCE_C_STRINGRAW = 20; - public const int SCE_C_TRIPLEVERBATIM = 21; - public const int SCE_C_HASHQUOTEDSTRING = 22; - public const int SCE_C_PREPROCESSORCOMMENT = 23; - public const int SCE_C_PREPROCESSORCOMMENTDOC = 24; - public const int SCE_C_USERLITERAL = 25; - public const int SCE_C_TASKMARKER = 26; - public const int SCE_C_ESCAPESEQUENCE = 27; - - // Css - public const int SCE_CSS_DEFAULT = 0; - public const int SCE_CSS_TAG = 1; - public const int SCE_CSS_CLASS = 2; - public const int SCE_CSS_PSEUDOCLASS = 3; - public const int SCE_CSS_UNKNOWN_PSEUDOCLASS = 4; - public const int SCE_CSS_OPERATOR = 5; - public const int SCE_CSS_IDENTIFIER = 6; - public const int SCE_CSS_UNKNOWN_IDENTIFIER = 7; - public const int SCE_CSS_VALUE = 8; - public const int SCE_CSS_COMMENT = 9; - public const int SCE_CSS_ID = 10; - public const int SCE_CSS_IMPORTANT = 11; - public const int SCE_CSS_DIRECTIVE = 12; - public const int SCE_CSS_DOUBLESTRING = 13; - public const int SCE_CSS_SINGLESTRING = 14; - public const int SCE_CSS_IDENTIFIER2 = 15; - public const int SCE_CSS_ATTRIBUTE = 16; - public const int SCE_CSS_IDENTIFIER3 = 17; - public const int SCE_CSS_PSEUDOELEMENT = 18; - public const int SCE_CSS_EXTENDED_IDENTIFIER = 19; - public const int SCE_CSS_EXTENDED_PSEUDOCLASS = 20; - public const int SCE_CSS_EXTENDED_PSEUDOELEMENT = 21; - public const int SCE_CSS_MEDIA = 22; - public const int SCE_CSS_VARIABLE = 23; - - public const int SCE_B_DEFAULT = 0; - public const int SCE_B_COMMENT = 1; - public const int SCE_B_NUMBER = 2; - public const int SCE_B_KEYWORD = 3; - public const int SCE_B_STRING = 4; - public const int SCE_B_PREPROCESSOR = 5; - public const int SCE_B_OPERATOR = 6; - public const int SCE_B_IDENTIFIER = 7; - public const int SCE_B_DATE = 8; - public const int SCE_B_STRINGEOL = 9; - public const int SCE_B_KEYWORD2 = 10; - public const int SCE_B_KEYWORD3 = 11; - public const int SCE_B_KEYWORD4 = 12; - public const int SCE_B_CONSTANT = 13; - public const int SCE_B_ASM = 14; - public const int SCE_B_LABEL = 15; - public const int SCE_B_ERROR = 16; - public const int SCE_B_HEXNUMBER = 17; - public const int SCE_B_BINNUMBER = 18; - public const int SCE_B_COMMENTBLOCK = 19; - public const int SCE_B_DOCLINE = 20; - public const int SCE_B_DOCBLOCK = 21; - public const int SCE_B_DOCKEYWORD = 22; - - #endregion Lexer Constants - - #region Callbacks - - public delegate IntPtr Scintilla_DirectFunction(IntPtr ptr, int iMessage, IntPtr wParam, IntPtr lParam); - - #endregion Callbacks - - #region Functions - - [DllImport(DLL_NAME_KERNEL32, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] - public static extern IntPtr GetProcAddress(HandleRef hModule, string lpProcName); - - [DllImport(DLL_NAME_KERNEL32, EntryPoint = "LoadLibraryW", CharSet = CharSet.Unicode, SetLastError = true)] - public static extern IntPtr LoadLibrary(string lpFileName); - - [DllImport(DLL_NAME_USER32, EntryPoint = "SendMessageW", CharSet = CharSet.Unicode, SetLastError = true)] - public static extern IntPtr SendMessage(HandleRef hWnd, int msg, IntPtr wParam, IntPtr lParam); - - #endregion Functions - - #region Structures - - // http://www.openrce.org/articles/full_view/23 - // It's worth noting that this structure represents the ILoader class virtual function - // table (vtable), not the ILoader interface defined in ILexer.h. In this case they are - // identical because the ILoader class contains only functions. - [StructLayout(LayoutKind.Sequential)] - public unsafe struct ILoaderVTable - { - public ReleaseDelegate Release; - public AddDataDelegate AddData; - public ConvertToDocumentDelegate ConvertToDocument; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int ReleaseDelegate(IntPtr self); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int AddDataDelegate(IntPtr self, byte* data, int length); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate IntPtr ConvertToDocumentDelegate(IntPtr self); - } - - [StructLayout(LayoutKind.Sequential)] - public struct Sci_CharacterRange - { - public int cpMin; - public int cpMax; - } - - [StructLayout(LayoutKind.Sequential)] - public struct Sci_NotifyHeader - { - public IntPtr hwndFrom; - public IntPtr idFrom; - public int code; - } - - [StructLayout(LayoutKind.Sequential)] - public struct Sci_TextRange - { - public Sci_CharacterRange chrg; - public IntPtr lpstrText; - } - - [StructLayout(LayoutKind.Sequential)] - public struct SCNotification - { - public Sci_NotifyHeader nmhdr; - public int position; - public int ch; - public int modifiers; - public int modificationType; - public IntPtr text; - public int length; - public int linesAdded; - public int message; - public IntPtr wParam; - public IntPtr lParam; - public int line; - public int foldLevelNow; - public int foldLevelPrev; - public int margin; - public int listType; - public int x; - public int y; - public int token; - public int annotationLinesAdded; - public int updated; - } - - #endregion Structures - } -} diff --git a/ScintillaNet/Scintilla.cs b/ScintillaNet/Scintilla.cs deleted file mode 100644 index 652e84c..0000000 --- a/ScintillaNet/Scintilla.cs +++ /dev/null @@ -1,4601 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Drawing; -using System.Drawing.Design; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Security.AccessControl; -using System.Security.Principal; -using System.Text; -using System.Threading; -using System.Windows.Forms; - -namespace ScintillaNET -{ - /// - /// Represents a Scintilla editor control. - /// - [Docking(DockingBehavior.Ask)] - public class Scintilla : Control - { - #region Fields - - // Static module data - private static string modulePath; - private static IntPtr moduleHandle; - private static NativeMethods.Scintilla_DirectFunction directFunction; - - // Events - private static readonly object scNotificationEventKey = new object(); - private static readonly object insertCheckEventKey = new object(); - private static readonly object beforeInsertEventKey = new object(); - private static readonly object beforeDeleteEventKey = new object(); - private static readonly object insertEventKey = new object(); - private static readonly object deleteEventKey = new object(); - private static readonly object updateUIEventKey = new object(); - private static readonly object modifyAttemptEventKey = new object(); - private static readonly object styleNeededEventKey = new object(); - private static readonly object savePointReachedEventKey = new object(); - private static readonly object savePointLeftEventKey = new object(); - private static readonly object changeAnnotationEventKey = new object(); - private static readonly object marginClickEventKey = new object(); - private static readonly object charAddedEventKey = new object(); - private static readonly object autoCSelectionEventKey = new object(); - private static readonly object autoCCancelledEventKey = new object(); - private static readonly object autoCCharDeletedEventKey = new object(); - private static readonly object dwellStartEventKey = new object(); - private static readonly object dwellEndEventKey = new object(); - private static readonly object borderStyleChangedEventKey = new object(); - - // The goods - private IntPtr sciPtr; - private BorderStyle borderStyle; - - private int stylingPosition; - private int stylingBytePosition; - - // Modified event optimization - private int? cachedPosition = null; - private string cachedText = null; - - /// - /// A constant used to specify an infinite mouse dwell wait time. - /// - public const int TimeForever = NativeMethods.SC_TIME_FOREVER; - - /// - /// A constant used to specify an invalid document position. - /// - public const int InvalidPosition = NativeMethods.INVALID_POSITION; - - #endregion Fields - - #region Methods - - /// - /// Increases the reference count of the specified document by 1. - /// - /// The document reference count to increase. - public void AddRefDocument(Document document) - { - var ptr = document.Value; - DirectMessage(NativeMethods.SCI_ADDREFDOCUMENT, IntPtr.Zero, ptr); - } - - /// - /// Adds an additional selection range to the existing main selection. - /// - /// The zero-based document position to end the selection. - /// The zero-based document position to start the selection. - /// A main selection must first have been set by a call to . - public void AddSelection(int caret, int anchor) - { - var textLength = TextLength; - caret = Helpers.Clamp(caret, 0, textLength); - anchor = Helpers.Clamp(anchor, 0, textLength); - - caret = Lines.CharToBytePosition(caret); - anchor = Lines.CharToBytePosition(anchor); - - DirectMessage(NativeMethods.SCI_ADDSELECTION, new IntPtr(caret), new IntPtr(anchor)); - } - - /// - /// Inserts the specified text at the current caret position. - /// - /// The text to insert at the current caret position. - /// The caret position is set to the end of the inserted text, but it is not scrolled into view. - public unsafe void AddText(string text) - { - var bytes = Helpers.GetBytes(text ?? string.Empty, Encoding, zeroTerminated: false); - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_ADDTEXT, new IntPtr(bytes.Length), new IntPtr(bp)); - } - - /// - /// Removes the annotation text for every in the document. - /// - public void AnnotationClearAll() - { - DirectMessage(NativeMethods.SCI_ANNOTATIONCLEARALL); - } - - /// - /// Adds the specified text to the end of the document. - /// - /// The text to add to the document. - /// The current selection is not changed and the new text is not scrolled into view. - public unsafe void AppendText(string text) - { - var bytes = Helpers.GetBytes(text ?? string.Empty, Encoding, zeroTerminated: false); - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_APPENDTEXT, new IntPtr(bytes.Length), new IntPtr(bp)); - } - - /// - /// Assigns the specified key definition to a command. - /// - /// The key combination to bind. - /// The command to assign. - public void AssignCmdKey(Keys keyDefinition, Command sciCommand) - { - DirectMessage(NativeMethods.SCI_ASSIGNCMDKEY, new IntPtr((int)keyDefinition), new IntPtr((int)sciCommand)); - } - - /// - /// Cancels any displayed autocompletion list. - /// - /// - public void AutoCCancel() - { - DirectMessage(NativeMethods.SCI_AUTOCCANCEL); - } - - /// - /// Triggers completion of the current autocompletion word. - /// - public void AutoCComplete() - { - DirectMessage(NativeMethods.SCI_AUTOCCOMPLETE); - } - - /// - /// Selects an item in the autocompletion list. - /// - /// - /// The autocompletion word to select. - /// If found, the word in the autocompletion list is selected and the index can be obtained by calling . - /// If not found, the behavior is determined by . - /// - /// - /// Comparisons are performed according to the property - /// and will match the first word starting with . - /// - /// - /// - /// - public unsafe void AutoCSelect(string select) - { - var bytes = Helpers.GetBytes(select, Encoding, zeroTerminated: true); - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_AUTOCSELECT, IntPtr.Zero, new IntPtr(bp)); - } - - /// - /// Displays an auto completion list. - /// - /// The number of characters already entered to match on. - /// A list of autocompletion words separated by the character. - public unsafe void AutoCShow(int lenEntered, string list) - { - if (string.IsNullOrEmpty(list)) - return; - - lenEntered = Helpers.ClampMin(lenEntered, 0); - if (lenEntered > 0) - { - // Convert to bytes by counting back the specified number of characters - var endPos = DirectMessage(NativeMethods.SCI_GETCURRENTPOS).ToInt32(); - var startPos = endPos; - for (int i = 0; i < lenEntered; i++) - startPos = DirectMessage(NativeMethods.SCI_POSITIONBEFORE, new IntPtr(startPos)).ToInt32(); - - lenEntered = (endPos - startPos); - } - - var bytes = Helpers.GetBytes(list, Encoding, zeroTerminated: true); - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_AUTOCSHOW, new IntPtr(lenEntered), new IntPtr(bp)); - } - - /// - /// Specifies the characters that will automatically cancel autocompletion without the need to call . - /// - /// A String of the characters that will cancel autocompletion. The default is empty. - /// Characters specified should be limited to printable ASCII characters. - public unsafe void AutoCStops(string chars) - { - var bytes = Helpers.GetBytes(chars ?? string.Empty, Encoding.ASCII, zeroTerminated: true); - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_AUTOCSTOPS, IntPtr.Zero, new IntPtr(bp)); - } - - /// - /// Marks the beginning of a set of actions that should be treated as a single undo action. - /// - /// A call to should be followed by a call to . - /// - public void BeginUndoAction() - { - DirectMessage(NativeMethods.SCI_BEGINUNDOACTION); - } - - /// - /// Styles the specified character position with the style when there is an unmatched brace. - /// - /// The zero-based document position of the unmatched brace character or to remove the highlight. - public void BraceBadLight(int position) - { - position = Helpers.Clamp(position, -1, TextLength); - if (position > 0) - position = Lines.CharToBytePosition(position); - - DirectMessage(NativeMethods.SCI_BRACEBADLIGHT, new IntPtr(position)); - } - - /// - /// Styles the specified character positions with the style. - /// - /// The zero-based document position of the open brace character. - /// The zero-based document position of the close brace character. - /// Brace highlighting can be removed by specifying for and . - /// - public void BraceHighlight(int position1, int position2) - { - var textLength = TextLength; - - position1 = Helpers.Clamp(position1, -1, textLength); - if (position1 > 0) - position1 = Lines.CharToBytePosition(position1); - - position2 = Helpers.Clamp(position2, -1, textLength); - if (position2 > 0) - position2 = Lines.CharToBytePosition(position2); - - DirectMessage(NativeMethods.SCI_BRACEHIGHLIGHT, new IntPtr(position1), new IntPtr(position2)); - } - - /// - /// Finds a corresponding matching brace starting at the position specified. - /// The brace characters handled are '(', ')', '[', ']', '{', '}', '<', and '>'. - /// - /// The zero-based document position of a brace character to start the search from for a matching brace character. - /// The zero-based document position of the corresponding matching brace or it no matching brace could be found. - /// A match only occurs if the style of the matching brace is the same as the starting brace. Nested braces are handled correctly. - public int BraceMatch(int position) - { - position = Helpers.Clamp(position, 0, TextLength); - position = Lines.CharToBytePosition(position); - - var match = DirectMessage(NativeMethods.SCI_BRACEMATCH, new IntPtr(position), IntPtr.Zero).ToInt32(); - if (match > 0) - match = Lines.ByteToCharPosition(match); - - return match; - } - - /// - /// Cancels the display of a call tip window. - /// - public void CallTipCancel() - { - DirectMessage(NativeMethods.SCI_CALLTIPCANCEL); - } - - /// - /// Sets the color of highlighted text in a call tip. - /// - /// The new highlight text Color. The default is dark blue. - public void CallTipSetForeHlt(Color color) - { - var colour = ColorTranslator.ToWin32(color); - DirectMessage(NativeMethods.SCI_CALLTIPSETFOREHLT, new IntPtr(colour)); - } - - /// - /// Sets the specified range of the call tip text to display in a highlighted style. - /// - /// The zero-based index in the call tip text to start highlighting. - /// The zero-based index in the call tip text to stop highlighting (exclusive). - public void CallTipSetHlt(int hlStart, int hlEnd) - { - // Call tips are ASCII only so (fortunately) we don't need to adjust these positions - DirectMessage(NativeMethods.SCI_CALLTIPSETHLT, new IntPtr(hlStart), new IntPtr(hlEnd)); - } - - /// - /// Determines whether to display a call tip above or below text. - /// - /// true to display above text; otherwise, false. The default is false. - public void CallTipSetPosition(bool above) - { - var val = (above ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_CALLTIPSETPOSITION, val); - } - - /// - /// Displays a call tip window. - /// - /// The zero-based document position where the call tip window should be aligned. - /// The call tip text. - /// - /// A call tip should be limited to printable ASCII characters, - /// line feed '\n' characters, and tab '\t' characters. Any other characters will likely display incorrectly. - /// - public unsafe void CallTipShow(int posStart, string definition) - { - posStart = Helpers.Clamp(posStart, 0, TextLength); - if (definition == null) - return; - - posStart = Lines.CharToBytePosition(posStart); - var bytes = Helpers.GetBytes(definition, Encoding.ASCII, zeroTerminated: true); - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_CALLTIPSHOW, new IntPtr(posStart), new IntPtr(bp)); - } - - /// - /// Sets the call tip tab size in pixels. - /// - /// The width in pixels of a tab '\t' character in a call tip. Specifying 0 disables special treatment of tabs. - public void CallTipTabSize(int tabSize) - { - // To support the STYLE_CALLTIP style we call SCI_CALLTIPUSESTYLE when the control is created. At - // this point we're only adjusting the tab size. This breaks a bit with Scintilla convention, but - // that's okay because the Scintilla convention is lame. - - tabSize = Helpers.ClampMin(tabSize, 0); - DirectMessage(NativeMethods.SCI_CALLTIPUSESTYLE, new IntPtr(tabSize)); - } - - /// - /// Indicates to the current that the internal lexer state has changed in the specified - /// range and therefore may need to be redrawn. - /// - /// The zero-based document position at which the lexer state change starts. - /// The zero-based document position at which the lexer state change ends. - public void ChangeLexerState(int startPos, int endPos) - { - var textLength = TextLength; - startPos = Helpers.Clamp(startPos, 0, textLength); - endPos = Helpers.Clamp(endPos, 0, textLength); - - startPos = Lines.CharToBytePosition(startPos); - endPos = Lines.CharToBytePosition(endPos); - - DirectMessage(NativeMethods.SCI_CHANGELEXERSTATE, new IntPtr(startPos), new IntPtr(endPos)); - } - - /// - /// Removes the selected text from the document. - /// - public void Clear() - { - DirectMessage(NativeMethods.SCI_CLEAR); - } - - /// - /// Deletes all document text, unless the document is read-only. - /// - public void ClearAll() - { - DirectMessage(NativeMethods.SCI_CLEARALL); - } - - /// - /// Makes the specified key definition do nothing. - /// - /// The key combination to bind. - /// This is equivalent to binding the keys to . - public void ClearCmdKey(Keys keyDefinition) - { - DirectMessage(NativeMethods.SCI_CLEARCMDKEY, new IntPtr((int)keyDefinition), IntPtr.Zero); - } - - /// - /// Removes all the key definition command mappings. - /// - public void ClearAllCmdKeys() - { - DirectMessage(NativeMethods.SCI_CLEARALLCMDKEYS); - } - - /// - /// Removes all styling from the document and resets the folding state. - /// - public void ClearDocumentStyle() - { - DirectMessage(NativeMethods.SCI_CLEARDOCUMENTSTYLE); - } - - /// - /// Removes all images registered for autocompletion lists. - /// - public void ClearRegisteredImages() - { - DirectMessage(NativeMethods.SCI_CLEARREGISTEREDIMAGES); - } - - /// - /// Sets a single empty selection at the start of the document. - /// - public void ClearSelections() - { - DirectMessage(NativeMethods.SCI_CLEARSELECTIONS); - } - - /// - /// Requests that the current lexer restyle the specified range. - /// - /// The zero-based document position at which to start styling. - /// The zero-based document position at which to stop styling (exclusive). - /// This will also cause fold levels in the range specified to be reset. - public void Colorize(int startPos, int endPos) - { - var textLength = TextLength; - startPos = Helpers.Clamp(startPos, 0, textLength); - endPos = Helpers.Clamp(endPos, 0, textLength); - - startPos = Lines.CharToBytePosition(startPos); - endPos = Lines.CharToBytePosition(endPos); - - DirectMessage(NativeMethods.SCI_COLOURISE, new IntPtr(startPos), new IntPtr(endPos)); - } - - /// - /// Copies the selected text from the document and places it on the clipboard. - /// - public void Copy() - { - DirectMessage(NativeMethods.SCI_COPY); - } - - /// - /// Copies the selected text from the document and places it on the clipboard. - /// If the selection is empty the current line is copied. - /// - /// - /// If the selection is empty and the current line copied, an extra "MSDEVLineSelect" marker is added to the - /// clipboard which is then used in to paste the whole line before the current line. - /// - public void CopyAllowLine() - { - DirectMessage(NativeMethods.SCI_COPYALLOWLINE); - } - - /// - /// Copies the specified range of text to the clipboard. - /// - /// The zero-based character position in the document to start copying. - /// The zero-based character position (exclusive) in the document to stop copying. - public void CopyRange(int start, int end) - { - var textLength = TextLength; - start = Helpers.Clamp(start, 0, textLength); - end = Helpers.Clamp(end, 0, textLength); - - // Convert to byte positions - start = Lines.CharToBytePosition(start); - end = Lines.CharToBytePosition(end); - - DirectMessage(NativeMethods.SCI_COPYRANGE, new IntPtr(start), new IntPtr(end)); - } - - /// - /// Create a new, empty document. - /// - /// A new with a reference count of 1. - /// You are responsible for ensuring the reference count eventually reaches 0 or memory leaks will occur. - public Document CreateDocument() - { - var ptr = DirectMessage(NativeMethods.SCI_CREATEDOCUMENT); - return new Document { Value = ptr }; - } - - /// - /// Creates an object capable of loading a on a background (non-UI) thread. - /// - /// The initial number of characters to allocate. - /// A new object, or null if the loader could not be created. - public ILoader CreateLoader(int length) - { - length = Helpers.ClampMin(length, 0); - var ptr = DirectMessage(NativeMethods.SCI_CREATELOADER, new IntPtr(length)); - if (ptr == IntPtr.Zero) - return null; - - return new Loader(ptr, Encoding); - } - - /// - /// Cuts the selected text from the document and places it on the clipboard. - /// - public void Cut() - { - DirectMessage(NativeMethods.SCI_CUT); - } - - /// - /// Deletes a range of text from the document. - /// - /// The zero-based character position to start deleting. - /// The number of characters to delete. - public void DeleteRange(int position, int length) - { - var textLength = TextLength; - position = Helpers.Clamp(position, 0, textLength); - length = Helpers.Clamp(length, 0, textLength - position); - - // Convert to byte position/length - var byteStartPos = Lines.CharToBytePosition(position); - var byteEndPos = Lines.CharToBytePosition(position + length); - - DirectMessage(NativeMethods.SCI_DELETERANGE, new IntPtr(byteStartPos), new IntPtr(byteEndPos - byteStartPos)); - } - - /// - /// Retrieves a description of keyword sets supported by the current . - /// - /// A String describing each keyword set separated by line breaks for the current lexer. - public unsafe string DescribeKeywordSets() - { - var length = DirectMessage(NativeMethods.SCI_DESCRIBEKEYWORDSETS).ToInt32(); - var bytes = new byte[length + 1]; - - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_DESCRIBEKEYWORDSETS, IntPtr.Zero, new IntPtr(bp)); - - var str = Encoding.ASCII.GetString(bytes, 0, length); - return str; - } - - /// - /// Retrieves a brief description of the specified property name for the current . - /// - /// A property name supported by the current . - /// A String describing the lexer property name if found; otherwise, String.Empty. - /// A list of supported property names for the current can be obtained by calling . - public unsafe string DescribeProperty(string name) - { - if (String.IsNullOrEmpty(name)) - return String.Empty; - - var nameBytes = Helpers.GetBytes(name, Encoding.ASCII, zeroTerminated: true); - fixed (byte* nb = nameBytes) - { - var length = DirectMessage(NativeMethods.SCI_DESCRIBEPROPERTY, new IntPtr(nb), IntPtr.Zero).ToInt32(); - if (length == 0) - return string.Empty; - - var descriptionBytes = new byte[length + 1]; - fixed (byte* db = descriptionBytes) - { - DirectMessage(NativeMethods.SCI_DESCRIBEPROPERTY, new IntPtr(nb), new IntPtr(db)); - return Helpers.GetString(new IntPtr(db), length, Encoding.ASCII); - } - } - } - - internal IntPtr DirectMessage(int msg) - { - return DirectMessage(msg, IntPtr.Zero, IntPtr.Zero); - } - - internal IntPtr DirectMessage(int msg, IntPtr wParam) - { - return DirectMessage(msg, wParam, IntPtr.Zero); - } - - /// - /// Sends the specified message directly to the native Scintilla window, - /// bypassing any managed APIs. - /// - /// The message ID. - /// The message wparam field. - /// The message lparam field. - /// An representing the result of the message request. - /// This API supports the Scintilla infrastructure and is not intended to be used directly from your code. - [EditorBrowsable(EditorBrowsableState.Advanced)] - public virtual IntPtr DirectMessage(int msg, IntPtr wParam, IntPtr lParam) - { - // If the control handle, ptr, direct function, etc... hasn't been created yet, it will be now. - var result = DirectMessage(SciPointer, msg, wParam, lParam); - return result; - } - - private static IntPtr DirectMessage(IntPtr sciPtr, int msg, IntPtr wParam, IntPtr lParam) - { - // Like Win32 SendMessage but directly to Scintilla - var result = directFunction(sciPtr, msg, wParam, lParam); - return result; - } - - /// - /// If there are multiple selections, removes the specified selection. - /// - /// The zero-based selection index. - /// - public void DropSelection(int selection) - { - selection = Helpers.ClampMin(selection, 0); - DirectMessage(NativeMethods.SCI_DROPSELECTIONN, new IntPtr(selection)); - } - - /// - /// Clears any undo or redo history. - /// - /// This will also cause to be called but will not raise the event. - public void EmptyUndoBuffer() - { - DirectMessage(NativeMethods.SCI_EMPTYUNDOBUFFER); - } - - /// - /// Marks the end of a set of actions that should be treated as a single undo action. - /// - /// - public void EndUndoAction() - { - DirectMessage(NativeMethods.SCI_ENDUNDOACTION); - } - - /// - /// Performs the specified command. - /// - /// The command to perform. - public void ExecuteCmd(Command sciCommand) - { - var cmd = (int)sciCommand; - DirectMessage(cmd); - } - - /// - /// Returns the character as the specified document position. - /// - /// The zero-based document position of the character to get. - /// The character at the specified . - public unsafe int GetCharAt(int position) - { - position = Helpers.Clamp(position, 0, TextLength); - position = Lines.CharToBytePosition(position); - - var nextPosition = DirectMessage(NativeMethods.SCI_POSITIONAFTER, new IntPtr(position)).ToInt32(); - var length = (nextPosition - position); - if (length <= 1) - { - // Position is at single-byte character - return DirectMessage(NativeMethods.SCI_GETCHARAT, new IntPtr(position)).ToInt32(); - } - - // Position is at multibyte character - var bytes = new byte[length + 1]; - fixed (byte* bp = bytes) - { - NativeMethods.Sci_TextRange* range = stackalloc NativeMethods.Sci_TextRange[1]; - range->chrg.cpMin = position; - range->chrg.cpMax = nextPosition; - range->lpstrText = new IntPtr(bp); - - DirectMessage(NativeMethods.SCI_GETTEXTRANGE, IntPtr.Zero, new IntPtr(range)); - var str = Helpers.GetString(new IntPtr(bp), length, Encoding); - return str[0]; - } - } - - /// - /// Returns the column number of the specified document position, taking the width of tabs into account. - /// - /// The zero-based document position to get the column for. - /// The number of columns from the start of the line to the specified document . - public int GetColumn(int position) - { - position = Helpers.Clamp(position, 0, TextLength); - position = Lines.CharToBytePosition(position); - return DirectMessage(NativeMethods.SCI_GETCOLUMN, new IntPtr(position)).ToInt32(); - } - - /// - /// Returns the last document position likely to be styled correctly. - /// - /// The zero-based document position of the last styled character. - public int GetEndStyled() - { - var pos = DirectMessage(NativeMethods.SCI_GETENDSTYLED).ToInt32(); - return Lines.ByteToCharPosition(pos); - } - - private static string GetModulePath() - { - // UI thread... - if (modulePath == null) - { - // Extract the embedded SciLexer DLL - // http://stackoverflow.com/a/768429/2073621 - var version = typeof(Scintilla).Assembly.GetName().Version.ToString(3); - modulePath = Path.Combine(Path.GetTempPath(), "ScintillaNET", version, (IntPtr.Size == 4 ? "x86" : "x64"), "SciLexer.dll"); - modulePath = AppDomain.CurrentDomain.BaseDirectory.Replace('\\', '/') + "SciLexer_x64.dll"; - - if (!File.Exists(modulePath)) - { - // http://stackoverflow.com/a/229567/2073621 - // Synchronize access to the file across processes - var guid = ((GuidAttribute)typeof(Scintilla).Assembly.GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value.ToString(); - var name = string.Format(CultureInfo.InvariantCulture, "Global\\{{{0}}}", guid); - using (var mutex = new Mutex(false, name)) - { - var access = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow); - var security = new MutexSecurity(); - security.AddAccessRule(access); - mutex.SetAccessControl(security); - - var ownsHandle = false; - try - { - try - { - ownsHandle = mutex.WaitOne(5000, false); // 5 sec - if (ownsHandle == false) - { - var timeoutMessage = string.Format(CultureInfo.InvariantCulture, "Timeout waiting for exclusive access to '{0}'.", modulePath); - throw new TimeoutException(timeoutMessage); - } - } - catch (AbandonedMutexException) - { - // Previous process terminated abnormally - ownsHandle = true; - } - - // Double-checked (process) lock - if (!File.Exists(modulePath)) - { - // Write the embedded file to disk - var directory = Path.GetDirectoryName(modulePath); - if (!Directory.Exists(directory)) - Directory.CreateDirectory(directory); - - var resource = string.Format(CultureInfo.InvariantCulture, "ScintillaNET.{0}.SciLexer.dll", (IntPtr.Size == 4 ? "x86" : "x64")); - var resourceStream = typeof(Scintilla).Assembly.GetManifestResourceStream(resource); // Don't close the resource stream - using (var fileStream = File.Create(modulePath)) - resourceStream.CopyTo(fileStream); - } - } - finally - { - if (ownsHandle) - mutex.ReleaseMutex(); - } - } - } - } - - return modulePath; - } - - /// - /// Lookup a property value for the current . - /// - /// The property name to lookup. - /// - /// A String representing the property value if found; otherwise, String.Empty. - /// Any embedded property name macros as described in will not be replaced (expanded). - /// - /// - public unsafe string GetProperty(string name) - { - if (String.IsNullOrEmpty(name)) - return String.Empty; - - var nameBytes = Helpers.GetBytes(name, Encoding.ASCII, zeroTerminated: true); - fixed (byte* nb = nameBytes) - { - var length = DirectMessage(NativeMethods.SCI_GETPROPERTY, new IntPtr(nb)).ToInt32(); - if (length == 0) - return String.Empty; - - var valueBytes = new byte[length + 1]; - fixed (byte* vb = valueBytes) - { - DirectMessage(NativeMethods.SCI_GETPROPERTY, new IntPtr(nb), new IntPtr(vb)); - return Helpers.GetString(new IntPtr(vb), length, Encoding.ASCII); - } - } - } - - /// - /// Lookup a property value for the current and expand any embedded property macros. - /// - /// The property name to lookup. - /// - /// A String representing the property value if found; otherwise, String.Empty. - /// Any embedded property name macros as described in will be replaced (expanded). - /// - /// - public unsafe string GetPropertyExpanded(string name) - { - if (String.IsNullOrEmpty(name)) - return String.Empty; - - var nameBytes = Helpers.GetBytes(name, Encoding.ASCII, zeroTerminated: true); - fixed (byte* nb = nameBytes) - { - var length = DirectMessage(NativeMethods.SCI_GETPROPERTYEXPANDED, new IntPtr(nb)).ToInt32(); - if (length == 0) - return String.Empty; - - var valueBytes = new byte[length + 1]; - fixed (byte* vb = valueBytes) - { - DirectMessage(NativeMethods.SCI_GETPROPERTYEXPANDED, new IntPtr(nb), new IntPtr(vb)); - return Helpers.GetString(new IntPtr(vb), length, Encoding.ASCII); - } - } - } - - /// - /// Lookup a property value for the current and convert it to an integer. - /// - /// The property name to lookup. - /// A default value to return if the property name is not found or has no value. - /// - /// An Integer representing the property value if found; - /// otherwise, if not found or the property has no value; - /// otherwise, 0 if the property is not a number. - /// - public unsafe int GetPropertyInt(string name, int defaultValue) - { - if (String.IsNullOrEmpty(name)) - return defaultValue; - - var bytes = Helpers.GetBytes(name, Encoding.ASCII, zeroTerminated: true); - fixed (byte* bp = bytes) - return DirectMessage(NativeMethods.SCI_GETPROPERTYINT, new IntPtr(bp), new IntPtr(defaultValue)).ToInt32(); - } - - /// - /// Gets the style of the specified document position. - /// - /// The zero-based document position of the character to get the style for. - /// The zero-based index used at the specified . - public int GetStyleAt(int position) - { - position = Helpers.Clamp(position, 0, TextLength); - position = Lines.CharToBytePosition(position); - - return DirectMessage(NativeMethods.SCI_GETSTYLEAT, new IntPtr(position)).ToInt32(); - } - - /// - /// Gets a range of text from the document. - /// - /// The zero-based starting character position of the range to get. - /// The number of characters to get. - /// A string representing the text range. - public unsafe string GetTextRange(int position, int length) - { - var textLength = TextLength; - position = Helpers.Clamp(position, 0, textLength); - length = Helpers.Clamp(length, 0, textLength - position); - - // Convert to byte position/length - var byteStartPos = Lines.CharToBytePosition(position); - var byteEndPos = Lines.CharToBytePosition(position + length); - - var ptr = DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, new IntPtr(byteStartPos), new IntPtr(byteEndPos - byteStartPos)); - if (ptr == IntPtr.Zero) - return string.Empty; - - return Helpers.GetString(ptr, (byteEndPos - byteStartPos), Encoding); - } - - /// - /// Returns the version information of the native Scintilla library. - /// - /// An object representing the version information of the native Scintilla library. - public FileVersionInfo GetVersionInfo() - { - var path = GetModulePath(); - var version = FileVersionInfo.GetVersionInfo(path); - - return version; - } - - /// - /// Navigates the caret to the document position specified. - /// - /// The zero-based document character position to navigate to. - /// Any selection is discarded. - public void GotoPosition(int position) - { - position = Helpers.Clamp(position, 0, TextLength); - position = Lines.CharToBytePosition(position); - DirectMessage(NativeMethods.SCI_GOTOPOS, new IntPtr(position)); - } - - /// - /// Removes the indicator (and user-defined value) from the specified range of text. - /// - /// The zero-based character position within the document to start clearing. - /// The number of characters to clear. - public void IndicatorClearRange(int position, int length) - { - var textLength = TextLength; - position = Helpers.Clamp(position, 0, textLength); - length = Helpers.Clamp(length, 0, textLength - position); - - var startPos = Lines.CharToBytePosition(position); - var endPos = Lines.CharToBytePosition(position + length); - - DirectMessage(NativeMethods.SCI_INDICATORCLEARRANGE, new IntPtr(startPos), new IntPtr(endPos - startPos)); - } - - /// - /// Adds the indicator and value to the specified range of text. - /// - /// The zero-based character position within the document to start filling. - /// The number of characters to fill. - public void IndicatorFillRange(int position, int length) - { - var textLength = TextLength; - position = Helpers.Clamp(position, 0, textLength); - length = Helpers.Clamp(length, 0, textLength - position); - - var startPos = Lines.CharToBytePosition(position); - var endPos = Lines.CharToBytePosition(position + length); - - DirectMessage(NativeMethods.SCI_INDICATORFILLRANGE, new IntPtr(startPos), new IntPtr(endPos - startPos)); - } - - /// - /// Inserts text at the specified position. - /// - /// The zero-based character position to insert the text. Specify -1 to use the current caret position. - /// The text to insert into the document. - /// - /// less than zero and not equal to -1. -or- - /// is greater than the document length. - /// - /// No scrolling is performed. - public unsafe void InsertText(int position, string text) - { - if (position < -1) - throw new ArgumentOutOfRangeException("position", "Position must be greater or equal to zero, or -1."); - - if (position != -1) - { - var textLength = TextLength; - if (position > textLength) - throw new ArgumentOutOfRangeException("position", "Position cannot exceed document length."); - - position = Lines.CharToBytePosition(position); - } - - fixed (byte* bp = Helpers.GetBytes(text ?? string.Empty, Encoding, zeroTerminated: true)) - DirectMessage(NativeMethods.SCI_INSERTTEXT, new IntPtr(position), new IntPtr(bp)); - } - - /// - /// Returns the line that contains the document position specified. - /// - /// The zero-based document character position. - /// The zero-based document line index containing the character . - public int LineFromPosition(int position) - { - position = Helpers.Clamp(position, 0, TextLength); - return Lines.LineFromCharPosition(position); - } - - /// - /// Scrolls the display the number of lines and columns specified. - /// - /// The number of lines to scroll. - /// The number of columns to scroll. - /// - /// Negative values scroll in the opposite direction. - /// A column is the width in pixels of a space character in the style. - /// - public void LineScroll(int lines, int columns) - { - DirectMessage(NativeMethods.SCI_LINESCROLL, new IntPtr(columns), new IntPtr(lines)); - } - - /// - /// Loads a compatible lexer from an external DLL. - /// - /// The path to the external lexer DLL. - public unsafe void LoadLexerLibrary(string path) - { - if (String.IsNullOrEmpty(path)) - return; - - var bytes = Helpers.GetBytes(path, Encoding.Default, zeroTerminated: true); - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_LOADLEXERLIBRARY, IntPtr.Zero, new IntPtr(bp)); - } - - /// - /// Removes the specified marker from all lines. - /// - /// The zero-based index to remove from all lines, or -1 to remove all markers from all lines. - public void MarkerDeleteAll(int marker) - { - marker = Helpers.Clamp(marker, -1, Markers.Count - 1); - DirectMessage(NativeMethods.SCI_MARKERDELETEALL, new IntPtr(marker)); - } - - /// - /// Searches the document for the marker handle and deletes the marker if found. - /// - /// The created by a previous call to of the marker to delete. - public void MarkerDeleteHandle(MarkerHandle markerHandle) - { - DirectMessage(NativeMethods.SCI_MARKERDELETEHANDLE, markerHandle.Value); - } - - /// - /// Searches the document for the marker handle and returns the line number containing the marker if found. - /// - /// The created by a previous call to of the marker to search for. - /// If found, the zero-based line index containing the marker; otherwise, -1. - public int MarkerLineFromHandle(MarkerHandle markerHandle) - { - return DirectMessage(NativeMethods.SCI_MARKERLINEFROMHANDLE, markerHandle.Value).ToInt32(); - } - - /// - /// Raises the event. - /// - /// An that contains the event data. - protected virtual void OnAutoCCancelled(EventArgs e) - { - var handler = Events[autoCCancelledEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// An that contains the event data. - protected virtual void OnAutoCCharDeleted(EventArgs e) - { - var handler = Events[autoCCharDeletedEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// An that contains the event data. - protected virtual void OnAutoCSelection(AutoCSelectionEventArgs e) - { - var handler = Events[autoCSelectionEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// A that contains the event data. - protected virtual void OnBeforeDelete(BeforeModificationEventArgs e) - { - var handler = Events[beforeDeleteEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// A that contains the event data. - protected virtual void OnBeforeInsert(BeforeModificationEventArgs e) - { - var handler = Events[beforeInsertEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// An EventArgs that contains the event data. - protected virtual void OnBorderStyleChanged(EventArgs e) - { - var handler = Events[borderStyleChangedEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// A that contains the event data. - protected virtual void OnChangeAnnotation(ChangeAnnotationEventArgs e) - { - var handler = Events[changeAnnotationEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// A that contains the event data. - protected virtual void OnCharAdded(CharAddedEventArgs e) - { - var handler = Events[charAddedEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// A that contains the event data. - protected virtual void OnDelete(ModificationEventArgs e) - { - var handler = Events[deleteEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// A that contains the event data. - protected virtual void OnDwellEnd(DwellEventArgs e) - { - var handler = Events[dwellEndEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// A that contains the event data. - protected virtual void OnDwellStart(DwellEventArgs e) - { - var handler = Events[dwellStartEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the HandleCreated event. - /// - /// An EventArgs that contains the event data. - protected override void OnHandleCreated(EventArgs e) - { - // Set more intelligent defaults... - - // I would like to see all of my text please - DirectMessage(NativeMethods.SCI_SETSCROLLWIDTHTRACKING, new IntPtr(1)); - - // It's pointless to do any encoding other than UTF-8 in Scintilla - DirectMessage(NativeMethods.SCI_SETCODEPAGE, new IntPtr(NativeMethods.SC_CP_UTF8)); - - // The default tab width of 8 is crazy big - DirectMessage(NativeMethods.SCI_SETTABWIDTH, new IntPtr(4)); - - // Enable support for the call tip style and tabs - DirectMessage(NativeMethods.SCI_CALLTIPUSESTYLE, new IntPtr(16)); - - base.OnHandleCreated(e); - } - - /// - /// Raises the event. - /// - /// A that contains the event data. - protected virtual void OnInsert(ModificationEventArgs e) - { - var handler = Events[insertEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// An that contains the event data. - protected virtual void OnInsertCheck(InsertCheckEventArgs e) - { - var handler = Events[insertCheckEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// A that contains the event data. - protected virtual void OnMarginClick(MarginClickEventArgs e) - { - var handler = Events[marginClickEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// An that contains the event data. - protected virtual void OnModifyAttempt(EventArgs e) - { - var handler = Events[modifyAttemptEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// An that contains the event data. - protected virtual void OnSavePointLeft(EventArgs e) - { - var handler = Events[savePointLeftEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// An that contains the event data. - protected virtual void OnSavePointReached(EventArgs e) - { - var handler = Events[savePointReachedEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// A that contains the event data. - protected virtual void OnStyleNeeded(StyleNeededEventArgs e) - { - var handler = Events[styleNeededEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Raises the event. - /// - /// An that contains the event data. - protected virtual void OnUpdateUI(UpdateUIEventArgs e) - { - EventHandler handler = Events[updateUIEventKey] as EventHandler; - if (handler != null) - handler(this, e); - } - - /// - /// Pastes the contents of the clipboard into the current selection. - /// - public void Paste() - { - DirectMessage(NativeMethods.SCI_PASTE); - } - - /// - /// Retrieves a list of property names that can be set for the current . - /// - /// A String of property names separated by line breaks. - public unsafe string PropertyNames() - { - var length = DirectMessage(NativeMethods.SCI_PROPERTYNAMES).ToInt32(); - if (length == 0) - return string.Empty; - - var bytes = new byte[length + 1]; - fixed (byte* bp = bytes) - { - DirectMessage(NativeMethods.SCI_PROPERTYNAMES, IntPtr.Zero, new IntPtr(bp)); - return Helpers.GetString(new IntPtr(bp), length, Encoding.ASCII); - } - } - - /// - /// Retrieves the data type of the specified property name for the current . - /// - /// A property name supported by the current . - /// One of the enumeration values. The default is . - /// A list of supported property names for the current can be obtained by calling . - public unsafe PropertyType PropertyType(string name) - { - if (String.IsNullOrEmpty(name)) - return ScintillaNET.PropertyType.Boolean; - - var bytes = Helpers.GetBytes(name, Encoding.ASCII, zeroTerminated: true); - fixed (byte* bp = bytes) - return (PropertyType)DirectMessage(NativeMethods.SCI_PROPERTYTYPE, new IntPtr(bp)); - } - - /// - /// Redoes the effect of an operation. - /// - public void Redo() - { - DirectMessage(NativeMethods.SCI_REDO); - } - - /// - /// Maps the specified image to a type identifer for use in an autocompletion list. - /// - /// The numeric identifier for this image. - /// The Bitmap to use in an autocompletion list. - /// - /// The registered can be referenced by its identifer in an autocompletion - /// list by suffixing a word with the character and the value. e.g. - /// "int?2 long?3 short?1" etc.... - /// - /// - public unsafe void RegisterRgbaImage(int type, Bitmap image) - { - // TODO Clamp type? - if (image == null) - return; - - DirectMessage(NativeMethods.SCI_RGBAIMAGESETWIDTH, new IntPtr(image.Width)); - DirectMessage(NativeMethods.SCI_RGBAIMAGESETHEIGHT, new IntPtr(image.Height)); - - var bytes = Helpers.BitmapToArgb(image); - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_REGISTERRGBAIMAGE, new IntPtr(type), new IntPtr(bp)); - } - - /// - /// Decreases the reference count of the specified document by 1. - /// - /// - /// The document reference count to decrease. - /// When a document's reference count reaches 0 it is destroyed and any associated memory released. - /// - public void ReleaseDocument(Document document) - { - var ptr = document.Value; - DirectMessage(NativeMethods.SCI_RELEASEDOCUMENT, IntPtr.Zero, ptr); - } - - /// - /// Replaces the current selection with the specified text. - /// - /// The text that should replace the current selection. - /// - /// If there is not a current selection, the text will be inserted at the current caret position. - /// Following the operation the caret is placed at the end of the inserted text and scrolled into view. - /// - public unsafe void ReplaceSelection(string text) - { - // TODO I don't like how using a null/empty string does nothing - - fixed (byte* bp = Helpers.GetBytes(text ?? string.Empty, Encoding, zeroTerminated: true)) - DirectMessage(NativeMethods.SCI_REPLACESEL, IntPtr.Zero, new IntPtr(bp)); - } - - private void ResetAdditionalCaretForeColor() - { - AdditionalCaretForeColor = Color.FromArgb(127, 127, 127); - } - - private void ScnMarginClick(ref NativeMethods.SCNotification scn) - { - var keys = Keys.Modifiers & (Keys)(scn.modifiers << 16); - var eventArgs = new MarginClickEventArgs(this, keys, scn.position, scn.margin); - OnMarginClick(eventArgs); - } - - private void ScnModified(ref NativeMethods.SCNotification scn) - { - // The InsertCheck, BeforeInsert, BeforeDelete, Insert, and Delete events can all potentially require - // the same conversions: byte to char position, char* to string, etc.... To avoid doing the same work - // multiple times we share that data between events. - - if ((scn.modificationType & NativeMethods.SC_MOD_INSERTCHECK) > 0) - { - var eventArgs = new InsertCheckEventArgs(this, scn.position, scn.length, scn.text); - OnInsertCheck(eventArgs); - - cachedPosition = eventArgs.CachedPosition; - cachedText = eventArgs.CachedText; - } - - const int sourceMask = (NativeMethods.SC_PERFORMED_USER | NativeMethods.SC_PERFORMED_UNDO | NativeMethods.SC_PERFORMED_REDO); - - if ((scn.modificationType & (NativeMethods.SC_MOD_BEFOREDELETE | NativeMethods.SC_MOD_BEFOREINSERT)) > 0) - { - var source = (ModificationSource)(scn.modificationType & sourceMask); - var eventArgs = new BeforeModificationEventArgs(this, source, scn.position, scn.length, scn.text); - - eventArgs.CachedPosition = cachedPosition; - eventArgs.CachedText = cachedText; - - if ((scn.modificationType & NativeMethods.SC_MOD_BEFOREINSERT) > 0) - { - OnBeforeInsert(eventArgs); - } - else - { - OnBeforeDelete(eventArgs); - } - - cachedPosition = eventArgs.CachedPosition; - cachedText = eventArgs.CachedText; - } - - if ((scn.modificationType & (NativeMethods.SC_MOD_DELETETEXT | NativeMethods.SC_MOD_INSERTTEXT)) > 0) - { - var source = (ModificationSource)(scn.modificationType & sourceMask); - var eventArgs = new ModificationEventArgs(this, source, scn.position, scn.length, scn.text, scn.linesAdded); - - eventArgs.CachedPosition = cachedPosition; - eventArgs.CachedText = cachedText; - - if ((scn.modificationType & NativeMethods.SC_MOD_INSERTTEXT) > 0) - { - OnInsert(eventArgs); - } - else - { - OnDelete(eventArgs); - } - - // Always clear the cache - cachedPosition = null; - cachedText = null; - - // For backward compatibility.... Of course this means that we'll raise two - // TextChanged events for replace (insert/delete) operations, but that's life. - OnTextChanged(EventArgs.Empty); - } - - if ((scn.modificationType & NativeMethods.SC_MOD_CHANGEANNOTATION) > 0) - { - var eventArgs = new ChangeAnnotationEventArgs(scn.line); - OnChangeAnnotation(eventArgs); - } - } - - /// - /// Scrolls the current position into view, if it is not already visible. - /// - public void ScrollCaret() - { - DirectMessage(NativeMethods.SCI_SCROLLCARET); - } - - /// - /// Scrolls the specified range into view. - /// - /// The zero-based document start position to scroll to. - /// - /// The zero-based document end position to scroll to if doing so does not cause the - /// position to scroll out of view. - /// - /// This may be used to make a search match visible. - public void ScrollRange(int start, int end) - { - var textLength = TextLength; - start = Helpers.Clamp(start, 0, textLength); - end = Helpers.Clamp(end, 0, textLength); - - // Convert to byte positions - start = Lines.CharToBytePosition(start); - end = Lines.CharToBytePosition(end); - - DirectMessage(NativeMethods.SCI_SCROLLRANGE, new IntPtr(end), new IntPtr(start)); - } - - /// - /// Searches for the first occurrence of the specified pattern in the target defined by and . - /// - /// The text pattern to search for. The interpretation of the pattern is defined by the . - /// The zero-based start position of the matched text within the document if successful; otherwise, -1. - /// If successful, the and properties will be updated to start and end positions of the matched text. - public unsafe int SearchInTarget(string pattern) - { - int bytePos = 0; - var bytes = Helpers.GetBytes(pattern ?? string.Empty, Encoding, zeroTerminated: false); - fixed (byte* bp = bytes) - bytePos = DirectMessage(NativeMethods.SCI_SEARCHINTARGET, new IntPtr(bytes.Length), new IntPtr(bp)).ToInt32(); - - if (bytePos == -1) - return bytePos; - - return Lines.ByteToCharPosition(bytePos); - } - - /// - /// Sets the background color of additional selections. - /// - /// Additional selections background color. - /// Calling will reset the specified. - public void SetAdditionalSelBack(Color color) - { - var colour = ColorTranslator.ToWin32(color); - DirectMessage(NativeMethods.SCI_SETADDITIONALSELBACK, new IntPtr(colour)); - } - - /// - /// Sets the foreground color of additional selections. - /// - /// Additional selections foreground color. - /// Calling will reset the specified. - public void SetAdditionalSelFore(Color color) - { - var colour = ColorTranslator.ToWin32(color); - DirectMessage(NativeMethods.SCI_SETADDITIONALSELFORE, new IntPtr(colour)); - } - - /// - /// Updates a keyword set used by the current . - /// - /// The zero-based index of the keyword set to update. - /// - /// A list of keywords pertaining to the current separated by whitespace (space, tab, '\n', '\r') characters. - /// - /// The keywords specified will be styled according to the current . - /// - public unsafe void SetKeywords(int set, string keywords) - { - set = Helpers.Clamp(set, 0, NativeMethods.KEYWORDSET_MAX); - var bytes = Helpers.GetBytes(keywords ?? string.Empty, Encoding.ASCII, zeroTerminated: true); - - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_SETKEYWORDS, new IntPtr(set), new IntPtr(bp)); - } - - /// - /// Sets the application-wide default module path of the native Scintilla library. - /// - /// The native Scintilla module path. - /// - /// This method must be called prior to the first control being created. - /// The can be relative or absolute. - /// - public static void SetModulePath(string modulePath) - { - if (Scintilla.modulePath == null) - { - Scintilla.modulePath = modulePath; - } - } - - /// - /// Passes the specified property name-value pair to the current . - /// - /// The property name to set. - /// - /// The property value. Values can refer to other property names using the syntax $(name), where 'name' is another property - /// name for the current . When the property value is retrieved by a call to - /// the embedded property name macro will be replaced (expanded) with that current property value. - /// - /// Property names are case-sensitive. - public unsafe void SetProperty(string name, string value) - { - if (String.IsNullOrEmpty(name)) - return; - - var nameBytes = Helpers.GetBytes(name, Encoding.ASCII, zeroTerminated: true); - var valueBytes = Helpers.GetBytes(value ?? string.Empty, Encoding.ASCII, zeroTerminated: true); - - fixed (byte* nb = nameBytes) - fixed (byte* vb = valueBytes) - { - DirectMessage(NativeMethods.SCI_SETPROPERTY, new IntPtr(nb), new IntPtr(vb)); - } - } - - /// - /// Marks the document as unmodified. - /// - /// - public void SetSavePoint() - { - DirectMessage(NativeMethods.SCI_SETSAVEPOINT); - } - - /// - /// Sets a single selection from anchor to caret. - /// - /// The zero-based document position to end the selection. - /// The zero-based document position to start the selection. - public void SetSelection(int caret, int anchor) - { - var textLength = TextLength; - caret = Helpers.Clamp(caret, 0, textLength); - anchor = Helpers.Clamp(anchor, 0, textLength); - - caret = Lines.CharToBytePosition(caret); - anchor = Lines.CharToBytePosition(anchor); - - DirectMessage(NativeMethods.SCI_SETSELECTION, new IntPtr(caret), new IntPtr(anchor)); - } - - /// - /// Sets a global override to the selection background color. - /// - /// true to override the selection background color; otherwise, false. - /// The global selection background color. - /// - public void SetSelectionBackColor(bool use, Color color) - { - var colour = ColorTranslator.ToWin32(color); - var useSelectionForeColour = (use ? new IntPtr(1) : IntPtr.Zero); - - DirectMessage(NativeMethods.SCI_SETSELBACK, useSelectionForeColour, new IntPtr(colour)); - } - - /// - /// Sets a global override to the selection foreground color. - /// - /// true to override the selection foreground color; otherwise, false. - /// The global selection foreground color. - /// - public void SetSelectionForeColor(bool use, Color color) - { - var colour = ColorTranslator.ToWin32(color); - var useSelectionForeColour = (use ? new IntPtr(1) : IntPtr.Zero); - - DirectMessage(NativeMethods.SCI_SETSELFORE, useSelectionForeColour, new IntPtr(colour)); - } - - /// - /// Styles the specified length of characters. - /// - /// The number of characters to style. - /// The definition index to assign each character. - /// - /// or is less than zero. -or- - /// The sum of a preceeding call to or and is greater than the document length. -or- - /// is greater than or equal to the number of style definitions. - /// - /// - /// The styling position is advanced by after each call allowing multiple - /// calls to for a single call to . - /// - /// - public void SetStyling(int length, int style) - { - var textLength = TextLength; - - if (length < 0) - throw new ArgumentOutOfRangeException("length", "Length cannot be less than zero."); - if (stylingPosition + length > textLength) - throw new ArgumentOutOfRangeException("length", "Position and length must refer to a range within the document."); - if (style < 0 || style >= Styles.Count) - throw new ArgumentOutOfRangeException("style", "Style must be non-negative and less than the size of the collection."); - - var endPos = stylingPosition + length; - var endBytePos = Lines.CharToBytePosition(endPos); - DirectMessage(NativeMethods.SCI_SETSTYLING, new IntPtr(endBytePos - stylingBytePosition), new IntPtr(style)); - - // Track this for the next call - stylingPosition = endPos; - stylingBytePosition = endBytePos; - } - - /// - /// Sets the and properties - /// - /// The zero-based character position within the document to start a search or replace operation. - /// The zero-based character position within the document to end a search or replace operation. - /// - /// - public void SetTargetRange(int start, int end) - { - var textLength = TextLength; - start = Helpers.Clamp(start, 0, textLength); - end = Helpers.Clamp(end, 0, textLength); - - start = Lines.CharToBytePosition(start); - end = Lines.CharToBytePosition(end); - - DirectMessage(NativeMethods.SCI_SETTARGETRANGE, new IntPtr(start), new IntPtr(end)); - } - - /// - /// Sets a global override to the whitespace background color. - /// - /// true to override the whitespace background color; otherwise, false. - /// The global whitespace background color. - /// When not overridden globally, the whitespace background color is determined by the current lexer. - /// - /// - public void SetWhitespaceBackColor(bool use, Color color) - { - var colour = ColorTranslator.ToWin32(color); - var useWhitespaceBackColour = (use ? new IntPtr(1) : IntPtr.Zero); - - DirectMessage(NativeMethods.SCI_SETWHITESPACEBACK, useWhitespaceBackColour, new IntPtr(colour)); - } - - /// - /// Sets a global override to the whitespace foreground color. - /// - /// true to override the whitespace foreground color; otherwise, false. - /// The global whitespace foreground color. - /// When not overridden globally, the whitespace foreground color is determined by the current lexer. - /// - /// - public void SetWhitespaceForeColor(bool use, Color color) - { - var colour = ColorTranslator.ToWin32(color); - var useWhitespaceForeColour = (use ? new IntPtr(1) : IntPtr.Zero); - - DirectMessage(NativeMethods.SCI_SETWHITESPACEFORE, useWhitespaceForeColour, new IntPtr(colour)); - } - - private bool ShouldSerializeAdditionalCaretForeColor() - { - return AdditionalCaretForeColor != Color.FromArgb(127, 127, 127); - } - - /// - /// Prepares for styling by setting the styling to start at. - /// - /// The zero-based character position in the document to start styling. - /// - /// After preparing the document for styling, use successive calls to - /// to style the document. - /// - /// - public void StartStyling(int position) - { - position = Helpers.Clamp(position, 0, TextLength); - var pos = Lines.CharToBytePosition(position); - DirectMessage(NativeMethods.SCI_STARTSTYLING, new IntPtr(pos)); - - // Track this so we can validate calls to SetStyling - stylingPosition = position; - stylingBytePosition = pos; - } - - /// - /// Resets all style properties to those currently configured for the style. - /// - /// - public void StyleClearAll() - { - DirectMessage(NativeMethods.SCI_STYLECLEARALL); - } - - /// - /// Resets the style to its initial state. - /// - /// - public void StyleResetDefault() - { - DirectMessage(NativeMethods.SCI_STYLERESETDEFAULT); - } - - /// - /// Sets the and to the start and end positions of the selection. - /// - public void TargetFromSelection() - { - DirectMessage(NativeMethods.SCI_TARGETFROMSELECTION); - } - - /// - /// Measures the width in pixels of the specified string when rendered in the specified style. - /// - /// The index of the to use when rendering the text to measure. - /// The text to measure. - /// The width in pixels. - public unsafe int TextWidth(int style, string text) - { - style = Helpers.Clamp(style, 0, Styles.Count - 1); - var bytes = Helpers.GetBytes(text ?? string.Empty, Encoding, zeroTerminated: true); - - fixed (byte* bp = bytes) - { - return DirectMessage(NativeMethods.SCI_TEXTWIDTH, new IntPtr(style), new IntPtr(bp)).ToInt32(); - } - } - - /// - /// Undoes the previous action. - /// - public void Undo() - { - DirectMessage(NativeMethods.SCI_UNDO); - } - - private void WmReflectNotify(ref Message m) - { - // A standard Windows notification and a Scintilla notification header are compatible - NativeMethods.SCNotification scn = (NativeMethods.SCNotification)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.SCNotification)); - if (scn.nmhdr.code >= NativeMethods.SCN_STYLENEEDED && scn.nmhdr.code <= NativeMethods.SCN_FOCUSOUT) - { - var handler = Events[scNotificationEventKey] as EventHandler; - if (handler != null) - handler(this, new SCNotificationEventArgs(scn)); - - switch (scn.nmhdr.code) - { - case NativeMethods.SCN_MODIFIED: - ScnModified(ref scn); - break; - - case NativeMethods.SCN_MODIFYATTEMPTRO: - OnModifyAttempt(EventArgs.Empty); - break; - - case NativeMethods.SCN_STYLENEEDED: - OnStyleNeeded(new StyleNeededEventArgs(this, scn.position)); - break; - - case NativeMethods.SCN_SAVEPOINTLEFT: - OnSavePointLeft(EventArgs.Empty); - break; - - case NativeMethods.SCN_SAVEPOINTREACHED: - OnSavePointReached(EventArgs.Empty); - break; - - case NativeMethods.SCN_MARGINCLICK: - ScnMarginClick(ref scn); - break; - - case NativeMethods.SCN_UPDATEUI: - OnUpdateUI(new UpdateUIEventArgs((UpdateChange)scn.updated)); - break; - - case NativeMethods.SCN_CHARADDED: - OnCharAdded(new CharAddedEventArgs(scn.ch)); - break; - - case NativeMethods.SCN_AUTOCSELECTION: - OnAutoCSelection(new AutoCSelectionEventArgs(this, scn.position, scn.text)); - break; - - case NativeMethods.SCN_AUTOCCANCELLED: - OnAutoCCancelled(EventArgs.Empty); - break; - - case NativeMethods.SCN_AUTOCCHARDELETED: - OnAutoCCharDeleted(EventArgs.Empty); - break; - - case NativeMethods.SCN_DWELLSTART: - OnDwellStart(new DwellEventArgs(this, scn.position, scn.x, scn.y)); - break; - - case NativeMethods.SCN_DWELLEND: - OnDwellEnd(new DwellEventArgs(this, scn.position, scn.x, scn.y)); - break; - - default: - // Not our notification - base.WndProc(ref m); - break; - } - } - } - - /// - /// Processes Windows messages. - /// - /// The Windows Message to process. - protected override void WndProc(ref Message m) - { - switch (m.Msg) - { - case (NativeMethods.WM_REFLECT + NativeMethods.WM_NOTIFY): - WmReflectNotify(ref m); - break; - - default: - base.WndProc(ref m); - break; - } - } - - /// - /// Returns the position where a word ends, searching forward from the position specified. - /// - /// The zero-based document position to start searching from. - /// - /// true to stop searching at the first non-word character regardless of whether the search started at a word or non-word character. - /// false to use the first character in the search as a word or non-word indicator and then search for that word or non-word boundary. - /// - /// The zero-based document postion of the word boundary. - /// - public int WordEndPosition(int position, bool onlyWordCharacters) - { - var onlyWordChars = (onlyWordCharacters ? new IntPtr(1) : IntPtr.Zero); - position = Helpers.Clamp(position, 0, TextLength); - position = Lines.CharToBytePosition(position); - position = DirectMessage(NativeMethods.SCI_WORDENDPOSITION, new IntPtr(position), onlyWordChars).ToInt32(); - return Lines.ByteToCharPosition(position); - } - - /// - /// Returns the position where a word starts, searching backward from the position specified. - /// - /// The zero-based document position to start searching from. - /// - /// true to stop searching at the first non-word character regardless of whether the search started at a word or non-word character. - /// false to use the first character in the search as a word or non-word indicator and then search for that word or non-word boundary. - /// - /// The zero-based document postion of the word boundary. - /// - public int WordStartPosition(int position, bool onlyWordCharacters) - { - var onlyWordChars = (onlyWordCharacters ? new IntPtr(1) : IntPtr.Zero); - position = Helpers.Clamp(position, 0, TextLength); - position = Lines.CharToBytePosition(position); - position = DirectMessage(NativeMethods.SCI_WORDSTARTPOSITION, new IntPtr(position), onlyWordChars).ToInt32(); - return Lines.ByteToCharPosition(position); - } - - /// - /// Increases the zoom factor by 1 until it reaches 20 points. - /// - /// - public void ZoomIn() - { - DirectMessage(NativeMethods.SCI_ZOOMIN); - } - - /// - /// Decreases the zoom factor by 1 until it reaches -10 points. - /// - /// - public void ZoomOut() - { - DirectMessage(NativeMethods.SCI_ZOOMOUT); - } - - #endregion Methods - - #region Properties - - /// - /// Gets or sets the caret foreground color for additional selections. - /// - /// The caret foreground color in additional selections. The default is (127, 127, 127). - [Category("Multiple Selection")] - [Description("The additional caret foreground color.")] - public Color AdditionalCaretForeColor - { - get - { - var color = DirectMessage(NativeMethods.SCI_GETADDITIONALCARETFORE).ToInt32(); - return ColorTranslator.FromWin32(color); - } - set - { - var color = ColorTranslator.ToWin32(value); - DirectMessage(NativeMethods.SCI_SETADDITIONALCARETFORE, new IntPtr(color)); - } - } - - /// - /// Gets or sets whether the carets in additional selections will blink. - /// - /// true if additional selection carets should blink; otherwise, false. The default is true. - [DefaultValue(true)] - [Category("Multiple Selection")] - [Description("Whether the carets in additional selections should blink.")] - public bool AdditionalCaretsBlink - { - get - { - return DirectMessage(NativeMethods.SCI_GETADDITIONALCARETSBLINK) != IntPtr.Zero; - } - set - { - var additionalCaretsBlink = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETADDITIONALCARETSBLINK, additionalCaretsBlink); - } - } - - /// - /// Gets or sets whether the carets in additional selections are visible. - /// - /// true if additional selection carets are visible; otherwise, false. The default is true. - [DefaultValue(true)] - [Category("Multiple Selection")] - [Description("Whether the carets in additional selections are visible.")] - public bool AdditionalCaretsVisible - { - get - { - return DirectMessage(NativeMethods.SCI_GETADDITIONALCARETSVISIBLE) != IntPtr.Zero; - } - set - { - var additionalCaretsBlink = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETADDITIONALCARETSVISIBLE, additionalCaretsBlink); - } - } - - /// - /// Gets or sets the alpha transparency of additional multiple selections. - /// - /// - /// The alpha transparency ranging from 0 (completely transparent) to 255 (completely opaque). - /// The value 256 will disable alpha transparency. The default is 256. - /// - [DefaultValue(256)] - [Category("Multiple Selection")] - [Description("The transparency of additional selections.")] - public int AdditionalSelAlpha - { - get - { - return DirectMessage(NativeMethods.SCI_GETADDITIONALSELALPHA).ToInt32(); - } - set - { - value = Helpers.Clamp(value, 0, NativeMethods.SC_ALPHA_NOALPHA); - DirectMessage(NativeMethods.SCI_SETADDITIONALSELALPHA, new IntPtr(value)); - } - } - - /// - /// Gets or sets whether additional typing affects multiple selections. - /// - /// true if typing will affect multiple selections instead of just the main selection; otherwise, false. The default is false. - [DefaultValue(false)] - [Category("Multiple Selection")] - [Description("Whether typing, backspace, or delete works with multiple selection simultaneously.")] - public bool AdditionalSelectionTyping - { - get - { - return DirectMessage(NativeMethods.SCI_GETADDITIONALSELECTIONTYPING) != IntPtr.Zero; - } - set - { - var additionalSelectionTyping = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETADDITIONALSELECTIONTYPING, additionalSelectionTyping); - } - } - - /// - /// Gets or sets the current anchor position. - /// - /// The zero-based character position of the anchor. - /// - /// Setting the current anchor position will create a selection between it and the . - /// The caret is not scrolled into view. - /// - /// - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int AnchorPosition - { - get - { - var bytePos = DirectMessage(NativeMethods.SCI_GETANCHOR).ToInt32(); - return Lines.ByteToCharPosition(bytePos); - } - set - { - value = Helpers.Clamp(value, 0, TextLength); - var bytePos = Lines.CharToBytePosition(value); - DirectMessage(NativeMethods.SCI_SETANCHOR, new IntPtr(bytePos)); - } - } - - /// - /// Gets or sets the display of annotations. - /// - /// One of the enumeration values. The default is . - [DefaultValue(Annotation.Hidden)] - [Category("Appearance")] - [Description("Display and location of annotations.")] - public Annotation AnnotationVisible - { - get - { - return (Annotation)DirectMessage(NativeMethods.SCI_ANNOTATIONGETVISIBLE).ToInt32(); - } - set - { - var visible = (int)value; - DirectMessage(NativeMethods.SCI_ANNOTATIONSETVISIBLE, new IntPtr(visible)); - } - } - - /// - /// Gets a value indicating whether there is an autocompletion list displayed. - /// - /// true if there is an active autocompletion list; otherwise, false. - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public bool AutoCActive - { - get - { - return DirectMessage(NativeMethods.SCI_AUTOCACTIVE) != IntPtr.Zero; - } - } - - /// - /// Gets or sets whether to automatically cancel autocompletion when there are no viable matches. - /// - /// - /// true to automatically cancel autocompletion when there is no possible match; otherwise, false. - /// The default is true. - /// - [DefaultValue(true)] - [Category("Autocompletion")] - [Description("Whether to automatically cancel autocompletion when no match is possible.")] - public bool AutoCAutoHide - { - get - { - return DirectMessage(NativeMethods.SCI_AUTOCGETAUTOHIDE) != IntPtr.Zero; - } - set - { - var autoHide = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_AUTOCSETAUTOHIDE, autoHide); - } - } - - /// - /// Gets or sets whether to cancel an autocompletion if the caret moves from its initial location, - /// or is allowed to move to the word start. - /// - /// - /// true to cancel autocompletion when the caret moves. - /// false to allow the caret to move to the beginning of the word without cancelling autocompletion. - /// - [DefaultValue(true)] - [Category("Autocompletion")] - [Description("Whether to cancel an autocompletion if the caret moves from its initial location, or is allowed to move to the word start.")] - public bool AutoCCancelAtStart - { - get - { - return DirectMessage(NativeMethods.SCI_AUTOCGETCANCELATSTART) != IntPtr.Zero; - } - set - { - var cancel = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_AUTOCSETCANCELATSTART, cancel); - } - } - - /// - /// Gets the index of the current autocompletion list selection. - /// - /// The zero-based index of the current autocompletion selection. - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public int AutoCCurrent - { - get - { - return DirectMessage(NativeMethods.SCI_AUTOCGETCURRENT).ToInt32(); - } - } - - /// - /// Gets or sets whether to automatically select an item when it is the only one in an autocompletion list. - /// - /// - /// true to automatically choose the only autocompletion item and not display the list; otherwise, false. - /// The default is false. - /// - [DefaultValue(false)] - [Category("Autocompletion")] - [Description("Whether to automatically choose an autocompletion item when it is the only one in the list.")] - public bool AutoCChooseSingle - { - get - { - return DirectMessage(NativeMethods.SCI_AUTOCGETCHOOSESINGLE) != IntPtr.Zero; - } - set - { - var chooseSingle = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_AUTOCSETCHOOSESINGLE, chooseSingle); - } - } - - /// - /// Gets or sets whether to delete any word characters following the caret after an autocompletion. - /// - /// - /// true to delete any word characters following the caret after autocompletion; otherwise, false. - /// The default is false. - [DefaultValue(false)] - [Category("Autocompletion")] - [Description("Whether to delete any existing word characters following the caret after autocompletion.")] - public bool AutoCDropRestOfWord - { - get - { - return DirectMessage(NativeMethods.SCI_AUTOCGETDROPRESTOFWORD) != IntPtr.Zero; - } - set - { - var dropRestOfWord = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_AUTOCSETDROPRESTOFWORD, dropRestOfWord); - } - } - - /// - /// Gets or sets whether matching characters to an autocompletion list is case-insensitive. - /// - /// true to use case-insensitive matching; otherwise, false. The default is false. - [DefaultValue(false)] - [Category("Autocompletion")] - [Description("Whether autocompletion word matching can ignore case.")] - public bool AutoCIgnoreCase - { - get - { - return DirectMessage(NativeMethods.SCI_AUTOCGETIGNORECASE) != IntPtr.Zero; - } - set - { - var ignoreCase = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_AUTOCSETIGNORECASE, ignoreCase); - } - } - - /// - /// Gets or sets the maximum height of the autocompletion list measured in rows. - /// - /// The max number of rows to display in an autocompletion window. The default is 5. - /// If there are more items in the list than max rows, a vertical scrollbar is shown. - [DefaultValue(5)] - [Category("Autocompletion")] - [Description("The maximum number of rows to display in an autocompletion list.")] - public int AutoCMaxHeight - { - get - { - return DirectMessage(NativeMethods.SCI_AUTOCGETMAXHEIGHT).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_AUTOCSETMAXHEIGHT, new IntPtr(value)); - } - } - - /// - /// Gets or sets the width in characters of the autocompletion list. - /// - /// - /// The width of the autocompletion list expressed in characters, or 0 to automatically set the width - /// to the longest item. The default is 0. - /// - /// Any items that cannot be fully displayed will be indicated with ellipsis. - [DefaultValue(0)] - [Category("Autocompletion")] - [Description("The width of the autocompletion list measured in characters.")] - public int AutoCMaxWidth - { - get - { - return DirectMessage(NativeMethods.SCI_AUTOCGETMAXWIDTH).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_AUTOCSETMAXWIDTH, new IntPtr(value)); - } - } - - /// - /// Gets or sets the autocompletion list sort order to expect when calling . - /// - /// One of the enumeration values. The default is . - [DefaultValue(Order.Presorted)] - [Category("Autocompletion")] - [Description("The order of words in an autocompletion list.")] - public Order AutoCOrder - { - get - { - return (Order)DirectMessage(NativeMethods.SCI_AUTOCGETORDER).ToInt32(); - } - set - { - var order = (int)value; - DirectMessage(NativeMethods.SCI_AUTOCSETORDER, new IntPtr(order)); - } - } - - /// - /// Gets the document position at the time was called. - /// - /// The zero-based document position at the time was called. - /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public int AutoCPosStart - { - get - { - var pos = DirectMessage(NativeMethods.SCI_AUTOCPOSSTART).ToInt32(); - pos = Lines.ByteToCharPosition(pos); - - return pos; - } - } - - /// - /// Gets or sets the delimiter character used to separate words in an autocompletion list. - /// - /// The separator character used when calling . The default is the space character. - /// The specified should be limited to printable ASCII characters. - [DefaultValue(' ')] - [Category("Autocompletion")] - [Description("The autocompletion list word delimiter. The default is a space character.")] - public Char AutoCSeparator - { - get - { - var separator = DirectMessage(NativeMethods.SCI_AUTOCGETSEPARATOR).ToInt32(); - return (Char)separator; - } - set - { - // The autocompletion separator character is stored as a byte within Scintilla, - // not a character. Thus it's possible for a user to supply a character that does - // not fit within a single byte. The likelyhood of this, however, seems so remote that - // I'm willing to risk a possible conversion error to provide a better user experience. - var separator = (byte)value; - DirectMessage(NativeMethods.SCI_AUTOCSETSEPARATOR, new IntPtr(separator)); - } - } - - /// - /// Gets or sets the delimiter character used to separate words and image type identifiers in an autocompletion list. - /// - /// The separator character used to reference an image registered with . The default is '?'. - /// The specified should be limited to printable ASCII characters. - [DefaultValue('?')] - [Category("Autocompletion")] - [Description("The autocompletion list image type delimiter.")] - public Char AutoCTypeSeparator - { - get - { - var separatorCharacter = DirectMessage(NativeMethods.SCI_AUTOCGETTYPESEPARATOR).ToInt32(); - return (Char)separatorCharacter; - } - set - { - // The autocompletion type separator character is stored as a byte within Scintilla, - // not a character. Thus it's possible for a user to supply a character that does - // not fit within a single byte. The likelyhood of this, however, seems so remote that - // I'm willing to risk a possible conversion error to provide a better user experience. - var separatorCharacter = (byte)value; - DirectMessage(NativeMethods.SCI_AUTOCSETTYPESEPARATOR, new IntPtr(separatorCharacter)); - } - } - - /// - /// Gets or sets the automatic folding flags. - /// - /// - /// A bitwise combination of the enumeration. - /// The default is . - /// - [DefaultValue(AutomaticFold.None)] - [Category("Behavior")] - [Description("Options for allowing the control to automatically handle folding.")] - [TypeConverter(typeof(FlagsEnumTypeConverter.FlagsEnumConverter))] - public AutomaticFold AutomaticFold - { - get - { - return (AutomaticFold)DirectMessage(NativeMethods.SCI_GETAUTOMATICFOLD); - } - set - { - var automaticFold = (int)value; - DirectMessage(NativeMethods.SCI_SETAUTOMATICFOLD, new IntPtr(automaticFold)); - } - } - - /// - /// Not supported. - /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public override Color BackColor - { - get - { - return base.BackColor; - } - set - { - base.BackColor = value; - } - } - - /// - /// Not supported. - /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public override Image BackgroundImage - { - get - { - return base.BackgroundImage; - } - set - { - base.BackgroundImage = value; - } - } - - /// - /// Not supported. - /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public override ImageLayout BackgroundImageLayout - { - get - { - return base.BackgroundImageLayout; - } - set - { - base.BackgroundImageLayout = value; - } - } - - /// - /// Gets or sets the border type of the control. - /// - /// A BorderStyle enumeration value that represents the border type of the control. The default is Fixed3D. - /// A value that is not within the range of valid values for the enumeration was assigned to the property. - [DefaultValue(BorderStyle.Fixed3D)] - [Category("Appearance")] - [Description("Indicates whether the control should have a border.")] - public BorderStyle BorderStyle - { - get - { - return borderStyle; - } - set - { - if (borderStyle != value) - { - if (!Enum.IsDefined(typeof(BorderStyle), value)) - throw new InvalidEnumArgumentException("value", (int)value, typeof(BorderStyle)); - - borderStyle = value; - UpdateStyles(); - OnBorderStyleChanged(EventArgs.Empty); - } - } - } - - /* - /// - /// Gets or sets the current position of a call tip. - /// - /// The zero-based document position indicated when was called to display a call tip. - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public int CallTipPosStart - { - get - { - var pos = DirectMessage(NativeMethods.SCI_CALLTIPPOSSTART).ToInt32(); - if (pos < 0) - return pos; - - return Lines.ByteToCharPosition(pos); - } - set - { - value = Helpers.Clamp(value, 0, TextLength); - value = Lines.CharToBytePosition(value); - DirectMessage(NativeMethods.SCI_CALLTIPSETPOSSTART, new IntPtr(value)); - } - } - */ - - /// - /// Gets a value indicating whether there is a call tip window displayed. - /// - /// true if there is an active call tip window; otherwise, false. - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public bool CallTipActive - { - get - { - return DirectMessage(NativeMethods.SCI_CALLTIPACTIVE) != IntPtr.Zero; - } - } - - /// - /// Gets a value indicating whether there is text on the clipboard that can be pasted into the document. - /// - /// true when there is text on the clipboard to paste; otherwise, false. - /// The document cannot be and the selection cannot contain protected text. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool CanPaste - { - get - { - return (DirectMessage(NativeMethods.SCI_CANPASTE) != IntPtr.Zero); - } - } - - /// - /// Gets a value indicating whether there is an undo action to redo. - /// - /// true when there is something to redo; otherwise, false. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool CanRedo - { - get - { - return (DirectMessage(NativeMethods.SCI_CANREDO) != IntPtr.Zero); - } - } - - /// - /// Gets a value indicating whether there is an action to undo. - /// - /// true when there is something to undo; otherwise, false. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool CanUndo - { - get - { - return (DirectMessage(NativeMethods.SCI_CANUNDO) != IntPtr.Zero); - } - } - - /// - /// Gets or sets the caret foreground color. - /// - /// The caret foreground color. The default is black. - [DefaultValue(typeof(Color), "Black")] - [Category("Caret")] - [Description("The caret foreground color.")] - public Color CaretForeColor - { - get - { - var color = DirectMessage(NativeMethods.SCI_GETCARETFORE).ToInt32(); - return ColorTranslator.FromWin32(color); - } - set - { - var color = ColorTranslator.ToWin32(value); - DirectMessage(NativeMethods.SCI_SETCARETFORE, new IntPtr(color)); - } - } - - /// - /// Gets or sets the caret line background color. - /// - /// The caret line background color. The default is yellow. - [DefaultValue(typeof(Color), "Yellow")] - [Category("Caret")] - [Description("The background color of the current line.")] - public Color CaretLineBackColor - { - get - { - var color = DirectMessage(NativeMethods.SCI_GETCARETLINEBACK).ToInt32(); - return ColorTranslator.FromWin32(color); - } - set - { - var color = ColorTranslator.ToWin32(value); - DirectMessage(NativeMethods.SCI_SETCARETLINEBACK, new IntPtr(color)); - } - } - - /// - /// Gets or sets the alpha transparency of the . - /// - /// - /// The alpha transparency ranging from 0 (completely transparent) to 255 (completely opaque). - /// The value 256 will disable alpha transparency. The default is 256. - /// - [DefaultValue(256)] - [Category("Caret")] - [Description("The transparency of the current line background color.")] - public int CaretLineBackColorAlpha - { - get - { - return DirectMessage(NativeMethods.SCI_GETCARETLINEBACKALPHA).ToInt32(); - } - set - { - value = Helpers.Clamp(value, 0, NativeMethods.SC_ALPHA_NOALPHA); - DirectMessage(NativeMethods.SCI_SETCARETLINEBACKALPHA, new IntPtr(value)); - } - } - - /// - /// Gets or sets whether the caret line is visible (highlighted). - /// - /// true if the caret line is visible; otherwise, false. The default is false. - [DefaultValue(false)] - [Category("Caret")] - [Description("Determines whether to highlight the current caret line.")] - public bool CaretLineVisible - { - get - { - return (DirectMessage(NativeMethods.SCI_GETCARETLINEVISIBLE) != IntPtr.Zero); - } - set - { - var visible = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETCARETLINEVISIBLE, visible); - } - } - - /// - /// Gets or sets the caret blink rate in milliseconds. - /// - /// The caret blink rate measured in milliseconds. The default is 530. - /// A value of 0 will stop the caret blinking. - [DefaultValue(530)] - [Category("Caret")] - [Description("The caret blink rate in milliseconds.")] - public int CaretPeriod - { - get - { - return DirectMessage(NativeMethods.SCI_GETCARETPERIOD).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETCARETPERIOD, new IntPtr(value)); - } - } - - /// - /// Gets or sets the caret display style. - /// - /// - /// One of the enumeration values. - /// The default is . - /// - [DefaultValue(CaretStyle.Line)] - [Category("Caret")] - [Description("The caret display style.")] - public CaretStyle CaretStyle - { - get - { - return (CaretStyle)DirectMessage(NativeMethods.SCI_GETCARETSTYLE).ToInt32(); - } - set - { - var style = (int)value; - DirectMessage(NativeMethods.SCI_SETCARETSTYLE, new IntPtr(style)); - } - } - - /// - /// Gets or sets the width in pixels of the caret. - /// - /// The width of the caret in pixels. The default is 1 pixel. - /// - /// The caret width can only be set to a value of 0, 1, 2 or 3 pixels and is only effective - /// when the property is set to . - /// - [DefaultValue(1)] - [Category("Caret")] - [Description("The width of the caret line measured in pixels (between 0 and 3).")] - public int CaretWidth - { - get - { - return DirectMessage(NativeMethods.SCI_GETCARETWIDTH).ToInt32(); - } - set - { - value = Helpers.Clamp(value, 0, 3); - DirectMessage(NativeMethods.SCI_SETCARETWIDTH, new IntPtr(value)); - } - } - - /// - /// Gets the required creation parameters when the control handle is created. - /// - /// A CreateParams that contains the required creation parameters when the handle to the control is created. - protected override CreateParams CreateParams - { - get - { - if (moduleHandle == IntPtr.Zero) - { - var path = GetModulePath(); - - // Load the native Scintilla library - moduleHandle = NativeMethods.LoadLibrary(path); - if (moduleHandle == IntPtr.Zero) - { - var message = string.Format(CultureInfo.InvariantCulture, "Could not load the Scintilla module at the path '{0}'.", path); - throw new Win32Exception(message, new Win32Exception()); // Will GetLastError - } - - // Get the native Scintilla direct function -- the only function the library exports - var directFunctionPointer = NativeMethods.GetProcAddress(new HandleRef(this, moduleHandle), "Scintilla_DirectFunction"); - if (directFunctionPointer == IntPtr.Zero) - { - var message = "The Scintilla module has no export for the 'Scintilla_DirectFunction' procedure."; - throw new Win32Exception(message, new Win32Exception()); // Will GetLastError - } - - // Create a managed callback - directFunction = (NativeMethods.Scintilla_DirectFunction)Marshal.GetDelegateForFunctionPointer( - directFunctionPointer, - typeof(NativeMethods.Scintilla_DirectFunction)); - } - - CreateParams cp = base.CreateParams; - cp.ClassName = "Scintilla"; - - // The border effect is achieved through a native Windows style - cp.ExStyle &= (~NativeMethods.WS_EX_CLIENTEDGE); - cp.Style &= (~NativeMethods.WS_BORDER); - switch (borderStyle) - { - case BorderStyle.Fixed3D: - cp.ExStyle |= NativeMethods.WS_EX_CLIENTEDGE; - break; - case BorderStyle.FixedSingle: - cp.Style |= NativeMethods.WS_BORDER; - break; - } - - return cp; - } - } - - /// - /// Gets or sets the current caret position. - /// - /// The zero-based character position of the caret. - /// - /// Setting the current caret position will create a selection between it and the current . - /// The caret is not scrolled into view. - /// - /// - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int CurrentPosition - { - get - { - var bytePos = DirectMessage(NativeMethods.SCI_GETCURRENTPOS).ToInt32(); - return Lines.ByteToCharPosition(bytePos); - } - set - { - value = Helpers.Clamp(value, 0, TextLength); - var bytePos = Lines.CharToBytePosition(value); - DirectMessage(NativeMethods.SCI_SETCURRENTPOS, new IntPtr(bytePos)); - } - } - - /// - /// Gets or sets the default cursor for the control. - /// - /// An object of type Cursor representing the current default cursor. - protected override Cursor DefaultCursor - { - get - { - return Cursors.IBeam; - } - } - - /// - /// Gets the default size of the control. - /// - /// The default Size of the control. - protected override Size DefaultSize - { - get - { - // I've discovered that using a DefaultSize property other than 'empty' triggers a flaw (IMO) - // in Windows Forms that will cause CreateParams to be called in the base constructor. - // That's too early. It makes it impossible to use the Site or DesignMode properties during - // handle creation because they haven't been set yet. Since we don't currently depend on those - // properties it's okay, but if we need them this is the place to start fixing things. - - return new Size(200, 100); - } - } - - /// - /// Gets or sets the current document used by the control. - /// - /// The current . - /// - /// Setting this property is equivalent to calling on the current document, and - /// calling if the new is or - /// if the new is not . - /// - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Document Document - { - get - { - var ptr = DirectMessage(NativeMethods.SCI_GETDOCPOINTER); - return new Document { Value = ptr }; - } - set - { - var ptr = value.Value; - DirectMessage(NativeMethods.SCI_SETDOCPOINTER, IntPtr.Zero, ptr); - - // Rebuild the line cache - Lines.RebuildLineData(); - } - } - - internal Encoding Encoding - { - get - { - // Should always be UTF-8 unless someone has done an end run around us - int codePage = (int)DirectMessage(NativeMethods.SCI_GETCODEPAGE); - return (codePage == 0 ? Encoding.Default : Encoding.GetEncoding(codePage)); - } - } - - /// - /// Gets or sets whether vertical scrolling ends at the last line or can scroll past. - /// - /// true if the maximum vertical scroll position ends at the last line; otherwise, false. The default is true. - [DefaultValue(true)] - [Category("Scrolling")] - [Description("Determines whether the maximum vertical scroll position ends at the last line or can scroll past.")] - public bool EndAtLastLine - { - get - { - return (DirectMessage(NativeMethods.SCI_GETENDATLASTLINE) != IntPtr.Zero); - } - set - { - var endAtLastLine = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETENDATLASTLINE, endAtLastLine); - } - } - - /// - /// Gets or sets the background color to use when indicating long lines with - /// . - /// - /// The background Color. The default is Silver. - [DefaultValue(typeof(Color), "Silver")] - [Category("Long Lines")] - [Description("The background color to use when indicating long lines.")] - public Color EdgeColor - { - get - { - var color = DirectMessage(NativeMethods.SCI_GETEDGECOLOUR).ToInt32(); - return ColorTranslator.FromWin32(color); - } - set - { - var color = ColorTranslator.ToWin32(value); - DirectMessage(NativeMethods.SCI_SETEDGECOLOUR, new IntPtr(color)); - } - } - - /// - /// Gets or sets the column number at which to begin indicating long lines. - /// - /// The number of columns in a long line. The default is 0. - /// - /// When using , a column is defined as the width of a space character in the style. - /// When using a column is equal to a character (including tabs). - /// - [DefaultValue(0)] - [Category("Long Lines")] - [Description("The number of columns at which to display long line indicators.")] - public int EdgeColumn - { - get - { - return DirectMessage(NativeMethods.SCI_GETEDGECOLUMN).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETEDGECOLUMN, new IntPtr(value)); - } - } - - /// - /// Gets or sets the mode for indicating long lines. - /// - /// - /// One of the enumeration values. - /// The default is . - /// - [DefaultValue(EdgeMode.None)] - [Category("Long Lines")] - [Description("Determines how long lines are indicated.")] - public EdgeMode EdgeMode - { - get - { - return (EdgeMode)DirectMessage(NativeMethods.SCI_GETEDGEMODE); - } - set - { - var edgeMode = (int)value; - DirectMessage(NativeMethods.SCI_SETEDGEMODE, new IntPtr(edgeMode)); - } - } - - /// - /// Gets or sets the amount of whitespace added to the ascent (top) of each line. - /// - /// The extra line ascent. The default is zero. - [DefaultValue(0)] - [Category("Whitespace")] - [Description("Extra whitespace added to the ascent (top) of each line.")] - public int ExtraAscent - { - get - { - return DirectMessage(NativeMethods.SCI_GETEXTRAASCENT).ToInt32(); - } - set - { - DirectMessage(NativeMethods.SCI_SETEXTRAASCENT, new IntPtr(value)); - } - } - - /// - /// Gets or sets the amount of whitespace added to the descent (bottom) of each line. - /// - /// The extra line descent. The default is zero. - [DefaultValue(0)] - [Category("Whitespace")] - [Description("Extra whitespace added to the descent (bottom) of each line.")] - public int ExtraDescent - { - get - { - return DirectMessage(NativeMethods.SCI_GETEXTRADESCENT).ToInt32(); - } - set - { - DirectMessage(NativeMethods.SCI_SETEXTRADESCENT, new IntPtr(value)); - } - } - - /// - /// Gets or sets the first visible line on screen. - /// - /// The zero-based index of the first visible screen line. - /// The value is a visible line, not a document line. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int FirstVisibleLine - { - get - { - return DirectMessage(NativeMethods.SCI_GETFIRSTVISIBLELINE).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETFIRSTVISIBLELINE, new IntPtr(value)); - } - } - - /// - /// Not supported. - /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public override Font Font - { - get - { - return base.Font; - } - set - { - base.Font = value; - } - } - - /// - /// Not supported. - /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public override Color ForeColor - { - get - { - return base.ForeColor; - } - set - { - base.ForeColor = value; - } - } - - /// - /// Gets or sets the column number of the indentation guide to highlight. - /// - /// The column number of the indentation guide to highlight or 0 if disabled. - /// Guides are highlighted in the style. Column numbers can be determined by calling . - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int HighlightGuide - { - get - { - return DirectMessage(NativeMethods.SCI_GETHIGHLIGHTGUIDE).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETHIGHLIGHTGUIDE, new IntPtr(value)); - } - } - - /// - /// Gets or sets whether to display the horizontal scroll bar. - /// - /// true to display the horizontal scroll bar when needed; otherwise, false. The default is true. - [DefaultValue(true)] - [Category("Scrolling")] - [Description("Determines whether to show the horizontal scroll bar if needed.")] - public bool HScrollBar - { - get - { - return (DirectMessage(NativeMethods.SCI_GETHSCROLLBAR) != IntPtr.Zero); - } - set - { - var visible = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETHSCROLLBAR, visible); - } - } - - /// - /// Gets or sets the size of indentation in terms of space characters. - /// - /// The indentation size measured in characters. The default is 0. - /// A value of 0 will make the indent width the same as the tab width. - [DefaultValue(0)] - [Category("Indentation")] - [Description("The indentation size in characters or 0 to make it the same as the tab width.")] - public int IndentWidth - { - get - { - return DirectMessage(NativeMethods.SCI_GETINDENT).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETINDENT, new IntPtr(value)); - } - } - - /// - /// Gets or sets whether to display indentation guides. - /// - /// One of the enumeration values. The default is . - /// The style can be used to specify the foreground and background color of indentation guides. - [DefaultValue(IndentView.None)] - [Category("Indentation")] - [Description("Indicates whether indentation guides are displayed.")] - public IndentView IndentationGuides - { - get - { - return (IndentView)DirectMessage(NativeMethods.SCI_GETINDENTATIONGUIDES); - } - set - { - var indentView = (int)value; - DirectMessage(NativeMethods.SCI_SETINDENTATIONGUIDES, new IntPtr(indentView)); - } - } - - /// - /// Gets or sets the indicator used in a subsequent call to or . - /// - /// The zero-based indicator index to apply when calling or remove when calling . - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int IndicatorCurrent - { - get - { - return DirectMessage(NativeMethods.SCI_GETINDICATORCURRENT).ToInt32(); - } - set - { - value = Helpers.Clamp(value, 0, Indicators.Count - 1); - DirectMessage(NativeMethods.SCI_SETINDICATORCURRENT, new IntPtr(value)); - } - } - - /// - /// Gets a collection of objects for working with indicators. - /// - /// A collection of objects. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public IndicatorCollection Indicators { get; private set; } - - /// - /// Gets or sets the user-defined value used in a subsequent call to . - /// - /// The indicator value to apply when calling . - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int IndicatorValue - { - get - { - return DirectMessage(NativeMethods.SCI_GETINDICATORVALUE).ToInt32(); - } - set - { - DirectMessage(NativeMethods.SCI_SETINDICATORVALUE, new IntPtr(value)); - } - } - - /// - /// Gets or sets the current lexer. - /// - /// One of the enumeration values. The default is . - [DefaultValue(Lexer.Container)] - [Category("Lexing")] - [Description("The current lexer.")] - public Lexer Lexer - { - get - { - return (Lexer)DirectMessage(NativeMethods.SCI_GETLEXER); - } - set - { - var lexer = (int)value; - DirectMessage(NativeMethods.SCI_SETLEXER, new IntPtr(lexer)); - } - } - - /// - /// Gets or sets the current lexer by name. - /// - /// A String representing the current lexer. - /// Lexer names are case-sensitive. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public unsafe string LexerLanguage - { - get - { - var length = DirectMessage(NativeMethods.SCI_GETLEXERLANGUAGE).ToInt32(); - if (length == 0) - return string.Empty; - - var bytes = new byte[length + 1]; - fixed (byte* bp = bytes) - { - DirectMessage(NativeMethods.SCI_GETLEXERLANGUAGE, IntPtr.Zero, new IntPtr(bp)); - return Helpers.GetString(new IntPtr(bp), length, Encoding.ASCII); - } - } - set - { - if (string.IsNullOrEmpty(value)) - { - DirectMessage(NativeMethods.SCI_SETLEXERLANGUAGE, IntPtr.Zero, IntPtr.Zero); - } - else - { - var bytes = Helpers.GetBytes(value, Encoding.ASCII, zeroTerminated: true); - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_SETLEXERLANGUAGE, IntPtr.Zero, new IntPtr(bp)); - } - } - } - - /// - /// Gets a collection representing lines of text in the control. - /// - /// A collection of text lines. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public LineCollection Lines { get; private set; } - - /// - /// Gets the number of lines that can be shown on screen given a constant - /// line height and the space available. - /// - /// - /// The number of screen lines which could be displayed (including any partial lines). - /// - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int LinesOnScreen - { - get - { - return DirectMessage(NativeMethods.SCI_LINESONSCREEN).ToInt32(); - } - } - - /// - /// Gets or sets the main selection when their are multiple selections. - /// - /// The zero-based main selection index. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int MainSelection - { - get - { - return DirectMessage(NativeMethods.SCI_GETMAINSELECTION).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETMAINSELECTION, new IntPtr(value)); - } - } - - /// - /// Gets a collection representing margins in a control. - /// - /// A collection of margins. - [Category("Collections")] - [Description("The margins collection.")] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - [TypeConverter(typeof(ExpandableObjectConverter))] - public MarginCollection Margins { get; private set; } - - /// - /// Gets a collection representing markers in a control. - /// - /// A collection of markers. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public MarkerCollection Markers { get; private set; } - - /// - /// Gets a value indicating whether the document has been modified (is dirty) - /// since the last call to . - /// - /// true if the document has been modified; otherwise, false. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool Modified - { - get - { - return (DirectMessage(NativeMethods.SCI_GETMODIFY) != IntPtr.Zero); - } - } - - /// - /// Gets or sets the time in milliseconds the mouse must linger to generate a event. - /// - /// - /// The time in milliseconds the mouse must linger to generate a event - /// or if dwell events are disabled. - /// - [DefaultValue(TimeForever)] - [Category("Behavior")] - [Description("The time in milliseconds the mouse must linger to generate a dwell start event. A value of 10000000 disables dwell events.")] - public int MouseDwellTime - { - get - { - return DirectMessage(NativeMethods.SCI_GETMOUSEDWELLTIME).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETMOUSEDWELLTIME, new IntPtr(value)); - } - } - - /// - /// Gets or sets the ability to switch to rectangular selection mode while making a selection with the mouse. - /// - /// - /// true if the current mouse selection can be switched to a rectangular selection by pressing the ALT key; otherwise, false. - /// The default is false. - /// - [DefaultValue(false)] - [Category("Multiple Selection")] - [Description("Enable or disable the ability to switch to rectangular selection mode while making a selection with the mouse.")] - public bool MouseSelectionRectangularSwitch - { - get - { - return DirectMessage(NativeMethods.SCI_GETMOUSESELECTIONRECTANGULARSWITCH) != IntPtr.Zero; - } - set - { - var mouseSelectionRectangularSwitch = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETMOUSESELECTIONRECTANGULARSWITCH, mouseSelectionRectangularSwitch); - } - } - - /// - /// Gets or sets whether multiple selection is enabled. - /// - /// - /// true if multiple selections can be made by holding the CTRL key and dragging the mouse; otherwise, false. - /// The default is false. - /// - [DefaultValue(false)] - [Category("Multiple Selection")] - [Description("Enable or disable multiple selection with the CTRL key.")] - public bool MultipleSelection - { - get - { - return DirectMessage(NativeMethods.SCI_GETMULTIPLESELECTION) != IntPtr.Zero; - } - set - { - var multipleSelection = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETMULTIPLESELECTION, multipleSelection); - } - } - - /// - /// Gets or sets the behavior when pasting text into multiple selections. - /// - /// One of the enumeration values. The default is . - [DefaultValue(MultiPaste.Once)] - [Category("Multiple Selection")] - [Description("Determines how pasted text is applied to multiple selections.")] - public MultiPaste MultiPaste - { - get - { - return (MultiPaste)DirectMessage(NativeMethods.SCI_GETMULTIPASTE); - } - set - { - var multiPaste = (int)value; - DirectMessage(NativeMethods.SCI_SETMULTIPASTE, new IntPtr(multiPaste)); - } - } - - /// - /// Gets or sets whether to write over text rather than insert it. - /// - /// true to write over text; otherwise, false. The default is false. - [DefaultValue(false)] - [Category("Behavior")] - [Description("Puts the caret into overtype mode.")] - public bool Overtype - { - get - { - return (DirectMessage(NativeMethods.SCI_GETOVERTYPE) != IntPtr.Zero); - } - set - { - var overtype = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETOVERTYPE, overtype); - } - } - - /// - /// Not supported. - /// - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public new Padding Padding - { - get - { - return base.Padding; - } - set - { - base.Padding = value; - } - } - - /// - /// Gets or sets whether line breaks in pasted text are convereted to the documents . - /// - /// true to convert line breaks in pasted text; otherwise, false. The default is true. - [DefaultValue(true)] - [Category("Behavior")] - [Description("Whether line breaks in pasted text are converted to match the document EOL mode.")] - public bool PasteConvertEndings - { - get - { - return (DirectMessage(NativeMethods.SCI_GETPASTECONVERTENDINGS) != IntPtr.Zero); - } - set - { - var convert = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETPASTECONVERTENDINGS, convert); - } - } - - /// - /// Gets or sets whether the document is read-only. - /// - /// true if the document is read-only; otherwise, false. The default is false. - /// - [DefaultValue(false)] - [Category("Behavior")] - [Description("Controls whether the document text can be modified.")] - public bool ReadOnly - { - get - { - return (DirectMessage(NativeMethods.SCI_GETREADONLY) != IntPtr.Zero); - } - set - { - var readOnly = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETREADONLY, readOnly); - } - } - - /// - /// Gets or sets the anchor position of the rectangular selection. - /// - /// The zero-based document position of the rectangular selection anchor. - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int RectangularSelectionAnchor - { - get - { - var pos = DirectMessage(NativeMethods.SCI_GETRECTANGULARSELECTIONANCHOR).ToInt32(); - if (pos <= 0) - return pos; - - return Lines.ByteToCharPosition(pos); - } - set - { - value = Helpers.Clamp(value, 0, TextLength); - value = Lines.CharToBytePosition(value); - DirectMessage(NativeMethods.SCI_SETRECTANGULARSELECTIONANCHOR, new IntPtr(value)); - } - } - - /// - /// Gets or sets the amount of anchor virtual space in a rectangular selection. - /// - /// The amount of virtual space past the end of the line offsetting the rectangular selection anchor. - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int RectangularSelectionAnchorVirtualSpace - { - get - { - return DirectMessage(NativeMethods.SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE, new IntPtr(value)); - } - } - - /// - /// Gets or sets the caret position of the rectangular selection. - /// - /// The zero-based document position of the rectangular selection caret. - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int RectangularSelectionCaret - { - get - { - var pos = DirectMessage(NativeMethods.SCI_GETRECTANGULARSELECTIONCARET).ToInt32(); - if (pos <= 0) - return 0; - - return Lines.ByteToCharPosition(pos); - } - set - { - value = Helpers.Clamp(value, 0, TextLength); - value = Lines.CharToBytePosition(value); - DirectMessage(NativeMethods.SCI_SETRECTANGULARSELECTIONCARET, new IntPtr(value)); - } - } - - /// - /// Gets or sets the amount of caret virtual space in a rectangular selection. - /// - /// The amount of virtual space past the end of the line offsetting the rectangular selection caret. - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int RectangularSelectionCaretVirtualSpace - { - get - { - return DirectMessage(NativeMethods.SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE, new IntPtr(value)); - } - } - - private IntPtr SciPointer - { - get - { - // Enforce illegal cross-thread calls the way the Handle property does - if (Control.CheckForIllegalCrossThreadCalls && InvokeRequired) - { - string message = string.Format(CultureInfo.InvariantCulture, "Control '{0}' accessed from a thread other than the thread it was created on.", Name); - throw new InvalidOperationException(message); - } - - if (sciPtr == IntPtr.Zero) - { - // Get a pointer to the native Scintilla object (i.e. C++ 'this') to use with the - // direct function. This will happen for each Scintilla control instance. - sciPtr = NativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.SCI_GETDIRECTPOINTER, IntPtr.Zero, IntPtr.Zero); - } - - return sciPtr; - } - } - - /// - /// Gets or sets the range of the horizontal scroll bar. - /// - /// The range in pixels of the horizontal scroll bar. The default is 2000. - /// The width will automatically increase as needed when is enabled. - [DefaultValue(2000)] - [Category("Scrolling")] - [Description("The range in pixels of the horizontal scroll bar.")] - public int ScrollWidth - { - get - { - return DirectMessage(NativeMethods.SCI_GETSCROLLWIDTH).ToInt32(); - } - set - { - DirectMessage(NativeMethods.SCI_SETSCROLLWIDTH, new IntPtr(value)); - } - } - - /// - /// Gets or sets whether the is automatically increased as needed. - /// - /// - /// true to automatically increase the horizontal scroll width as needed; otherwise, false. - /// The default is true. - /// - [DefaultValue(true)] - [Category("Scrolling")] - [Description("Determines whether to increase the horizontal scroll width as needed.")] - public bool ScrollWidthTracking - { - get - { - return (DirectMessage(NativeMethods.SCI_GETSCROLLWIDTHTRACKING) != IntPtr.Zero); - } - set - { - var tracking = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETSCROLLWIDTHTRACKING, tracking); - } - } - - /// - /// Gets or sets the search flags used when searching text. - /// - /// A bitwise combination of values. The default is . - /// - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public SearchFlags SearchFlags - { - get - { - return (SearchFlags)DirectMessage(NativeMethods.SCI_GETSEARCHFLAGS).ToInt32(); - } - set - { - var searchFlags = (int)value; - DirectMessage(NativeMethods.SCI_SETSEARCHFLAGS, new IntPtr(searchFlags)); - } - } - - /// - /// Gets the selected text. - /// - /// The selected text if there is any; otherwise, an empty string. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public unsafe string SelectedText - { - get - { - // NOTE: For some reason the length returned by this API includes the terminating NULL - var length = DirectMessage(NativeMethods.SCI_GETSELTEXT).ToInt32() - 1; - if (length <= 0) - return string.Empty; - - var bytes = new byte[length + 1]; - fixed (byte* bp = bytes) - { - DirectMessage(NativeMethods.SCI_GETSELTEXT, IntPtr.Zero, new IntPtr(bp)); - return Helpers.GetString(new IntPtr(bp), length, Encoding); - } - } - } - - /// - /// Gets or sets whether to fill past the end of a line with the selection background color. - /// - /// true to fill past the end of the line; otherwise, false. The default is false. - [DefaultValue(false)] - [Category("Selection")] - [Description("Determines whether a selection should fill past the end of the line.")] - public bool SelectionEolFilled - { - get - { - return (DirectMessage(NativeMethods.SCI_GETSELEOLFILLED) != IntPtr.Zero); - } - set - { - var eolFilled = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETSELEOLFILLED, eolFilled); - } - } - - /// - /// Gets a collection representing multiple selections in a control. - /// - /// A collection of selections. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public SelectionCollection Selections { get; private set; } - - /// - /// Gets a collection representing style definitions in a control. - /// - /// A collection of style definitions. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public StyleCollection Styles { get; private set; } - - /// - /// Gets or sets the width of a tab as a multiple of a space character. - /// - /// The width of a tab measured in characters. The default is 4. - [DefaultValue(4)] - [Category("Indentation")] - [Description("The tab size in characters.")] - public int TabWidth - { - get - { - return DirectMessage(NativeMethods.SCI_GETTABWIDTH).ToInt32(); - } - set - { - DirectMessage(NativeMethods.SCI_SETTABWIDTH, new IntPtr(value)); - } - } - - /// - /// Gets or sets the end position used when performing a search or replace. - /// - /// The zero-based character position within the document to end a search or replace operation. - /// - /// - /// - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int TargetEnd - { - get - { - // The position can become stale. If it's beyond the end of the document - // report the end of the document; otherwise, we can't convert it. - var bytePos = DirectMessage(NativeMethods.SCI_GETTARGETEND).ToInt32(); - var byteLength = DirectMessage(NativeMethods.SCI_GETTEXTLENGTH).ToInt32(); - if (bytePos >= byteLength) - return TextLength; - - return Lines.ByteToCharPosition(bytePos); - } - set - { - value = Helpers.Clamp(value, 0, TextLength); - - var bytePos = Lines.CharToBytePosition(value); - DirectMessage(NativeMethods.SCI_SETTARGETEND, new IntPtr(bytePos)); - } - } - - /// - /// Gets or sets the start position used when performing a search or replace. - /// - /// The zero-based character position within the document to start a search or replace operation. - /// - /// - /// - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int TargetStart - { - get - { - // See above - var bytePos = DirectMessage(NativeMethods.SCI_GETTARGETSTART).ToInt32(); - var byteLength = DirectMessage(NativeMethods.SCI_GETTEXTLENGTH).ToInt32(); - if (bytePos >= byteLength) - return TextLength; - - return Lines.ByteToCharPosition(bytePos); - } - set - { - value = Helpers.Clamp(value, 0, TextLength); - - var bytePos = Lines.CharToBytePosition(value); - DirectMessage(NativeMethods.SCI_SETTARGETSTART, new IntPtr(bytePos)); - } - } - - /// - /// Gets the current target text. - /// - /// A String representing the text between and . - /// Targets which have a start position equal or greater to the end position will return an empty String. - /// - /// - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public unsafe string TargetText - { - get - { - // I'm unsure whether it's better to use the actual SCI_GETTARGETTEXT call which creates a intermediate buffer or - // implement our own equivalent using SCI_GETTARGETSTART, SCI_GETTARGETEND, and SCI_GETRANGEPOINTER. For now we'll - // stick SCI_GETTARGETTEXT because there is a lot of work in range checking the target start and end that we don't - // have to do if we use that. - - var length = DirectMessage(NativeMethods.SCI_GETTARGETTEXT).ToInt32(); - if (length == 0) - return string.Empty; - - var bytes = new byte[length + 1]; - fixed (byte* bp = bytes) - { - DirectMessage(NativeMethods.SCI_GETTARGETTEXT, IntPtr.Zero, new IntPtr(bp)); - return Helpers.GetString(new IntPtr(bp), length, Encoding); - } - } - } - - /// - /// Gets or sets the current document text in the control. - /// - /// The text displayed in the control. - /// Depending on the length of text get or set, this operation can be expensive. - [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design", typeof(UITypeEditor))] - public unsafe override string Text - { - get - { - var length = DirectMessage(NativeMethods.SCI_GETTEXTLENGTH).ToInt32(); - var ptr = DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, new IntPtr(0), new IntPtr(length)); - if (ptr == IntPtr.Zero) - return string.Empty; - - // Assumption is that moving the gap will always be equal to or less expensive - // than using one of the APIs which requires an intermediate buffer. - var text = new string((sbyte*)ptr, 0, length, Encoding); - return text; - } - set - { - if (string.IsNullOrEmpty(value)) - { - DirectMessage(NativeMethods.SCI_CLEARALL); - } - else - { - fixed (byte* bp = Helpers.GetBytes(value, Encoding, zeroTerminated: true)) - DirectMessage(NativeMethods.SCI_SETTEXT, IntPtr.Zero, new IntPtr(bp)); - } - } - } - - /// - /// Gets the length of the text in the control. - /// - /// The number of characters in the document. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int TextLength - { - get - { - return Lines.TextLength; - } - } - - /// - /// Gets or sets whether to collect undo and redo information. - /// - /// true to collect undo and redo information; otherwise, false. The default is true. - /// Disabling undo collection will also empty the undo buffer. See . - [DefaultValue(true)] - [Category("Behavior")] - [Description("Determines whether to collect undo and redo information.")] - public bool UndoCollection - { - get - { - return (DirectMessage(NativeMethods.SCI_GETUNDOCOLLECTION) != IntPtr.Zero); - } - set - { - var collectUndo = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETUNDOCOLLECTION, collectUndo); - if (!value) - { - // Scintilla documentation makes it clear that if you fail to empty the undo buffer - // when you disable collection the buffer could become unsynchronized with the document. - // Seems like something we should do automatically. - DirectMessage(NativeMethods.SCI_EMPTYUNDOBUFFER); - } - } - } - - /// - /// Gets or sets whether to use a mixture of tabs and spaces for indentation or purely spaces. - /// - /// true to use tab characters; otherwise, false. The default is true. - [DefaultValue(true)] - [Category("Indentation")] - [Description("Determines whether indentation allows tab characters or purely space characters.")] - public bool UseTabs - { - get - { - return (DirectMessage(NativeMethods.SCI_GETUSETABS) != IntPtr.Zero); - } - set - { - var useTabs = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETUSETABS, useTabs); - } - } - - /// - /// Gets or sets how to display whitespace characters. - /// - /// One of the enumeration values. The default is . - /// - /// - [DefaultValue(WhitespaceMode.Invisible)] - [Category("Whitespace")] - [Description("Options for displaying whitespace characters.")] - public WhitespaceMode ViewWhitespace - { - get - { - return (WhitespaceMode)DirectMessage(NativeMethods.SCI_GETVIEWWS); - } - set - { - var wsMode = (int)value; - DirectMessage(NativeMethods.SCI_SETVIEWWS, new IntPtr(wsMode)); - } - } - - /// - /// Gets or sets the ability for the caret to move into an area beyond the end of each line, otherwise known as virtual space. - /// - /// - /// A bitwise combination of the enumeration. - /// The default is . - /// - [DefaultValue(VirtualSpace.None)] - [Category("Behavior")] - [Description("Options for allowing the caret to move beyond the end of each line.")] - [TypeConverter(typeof(FlagsEnumTypeConverter.FlagsEnumConverter))] - public VirtualSpace VirtualSpaceOptions - { - get - { - return (VirtualSpace)DirectMessage(NativeMethods.SCI_GETVIRTUALSPACEOPTIONS); - } - set - { - var virtualSpace = (int)value; - DirectMessage(NativeMethods.SCI_SETVIRTUALSPACEOPTIONS, new IntPtr(virtualSpace)); - } - } - - /// - /// Gets or sets whether to display the vertical scroll bar. - /// - /// true to display the vertical scroll bar when needed; otherwise, false. The default is true. - [DefaultValue(true)] - [Category("Scrolling")] - [Description("Determines whether to show the vertical scroll bar when needed.")] - public bool VScrollBar - { - get - { - return (DirectMessage(NativeMethods.SCI_GETVSCROLLBAR) != IntPtr.Zero); - } - set - { - var visible = (value ? new IntPtr(1) : IntPtr.Zero); - DirectMessage(NativeMethods.SCI_SETVSCROLLBAR, visible); - } - } - - /// - /// Gets or sets the size of the dots used to mark whitespace. - /// - /// The size of the dots used to mark whitespace. The default is 1. - /// - [DefaultValue(1)] - [Category("Whitespace")] - [Description("The size of whitespace dots.")] - public int WhitespaceSize - { - get - { - return DirectMessage(NativeMethods.SCI_GETWHITESPACESIZE).ToInt32(); - } - set - { - DirectMessage(NativeMethods.SCI_SETWHITESPACESIZE, new IntPtr(value)); - } - } - - /* - /// - /// Gets or sets the characters considered 'word' characters when using any word-based logic. - /// - /// A String of word characters. - public unsafe string WordChars - { - get - { - var length = DirectMessage(NativeMethods.SCI_GETWORDCHARS, IntPtr.Zero, IntPtr.Zero).ToInt32(); - var bytes = new byte[length + 1]; - fixed (byte* bp = bytes) - { - DirectMessage(NativeMethods.SCI_GETWORDCHARS, IntPtr.Zero, new IntPtr(bp)); - return Helpers.GetString(new IntPtr(bp), length, Encoding.UTF8); - } - } - set - { - if (value == null) - { - DirectMessage(NativeMethods.SCI_SETWORDCHARS, IntPtr.Zero, IntPtr.Zero); - return; - } - - // Scintilla stores each of the characters specified in a char array which it then - // uses as a lookup for word matching logic. Thus, any multibyte chars wouldn't work. - var bytes = Helpers.GetBytes(value, Encoding.ASCII, zeroTerminated: true); - fixed (byte* bp = bytes) - DirectMessage(NativeMethods.SCI_SETWORDCHARS, IntPtr.Zero, new IntPtr(bp)); - } - } - */ - - /// - /// Gets or sets the line wrapping indent mode. - /// - /// - /// One of the enumeration values. - /// The default is . - /// - [DefaultValue(WrapIndentMode.Fixed)] - [Category("Line Wrapping")] - [Description("Determines how wrapped sublines are indented.")] - public WrapIndentMode WrapIndentMode - { - get - { - return (WrapIndentMode)DirectMessage(NativeMethods.SCI_GETWRAPINDENTMODE); - } - set - { - var wrapIndentMode = (int)value; - DirectMessage(NativeMethods.SCI_SETWRAPINDENTMODE, new IntPtr(wrapIndentMode)); - } - } - - /// - /// Gets or sets the line wrapping mode. - /// - /// - /// One of the enumeration values. - /// The default is . - /// - [DefaultValue(WrapMode.None)] - [Category("Line Wrapping")] - [Description("The line wrapping strategy.")] - public WrapMode WrapMode - { - get - { - return (WrapMode)DirectMessage(NativeMethods.SCI_GETWRAPMODE); - } - set - { - var wrapMode = (int)value; - DirectMessage(NativeMethods.SCI_SETWRAPMODE, new IntPtr(wrapMode)); - } - } - - /// - /// Gets or sets the indented size in pixels of wrapped sublines. - /// - /// The indented size of wrapped sublines measured in pixels. The default is 0. - /// - /// Setting to will add an - /// additional 1 pixel to the value specified. - /// - [DefaultValue(0)] - [Category("Line Wrapping")] - [Description("The amount of pixels to indent wrapped sublines.")] - public int WrapStartIndent - { - get - { - return DirectMessage(NativeMethods.SCI_GETWRAPSTARTINDENT).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETWRAPSTARTINDENT, new IntPtr(value)); - } - } - - /// - /// Gets or sets the wrap visual flags. - /// - /// - /// A bitwise combination of the enumeration. - /// The default is . - /// - [DefaultValue(WrapVisualFlags.None)] - [Category("Line Wrapping")] - [Description("The visual indicator displayed on a wrapped line.")] - [TypeConverter(typeof(FlagsEnumTypeConverter.FlagsEnumConverter))] - public WrapVisualFlags WrapVisualFlags - { - get - { - return (WrapVisualFlags)DirectMessage(NativeMethods.SCI_GETWRAPVISUALFLAGS); - } - set - { - int wrapVisualFlags = (int)value; - DirectMessage(NativeMethods.SCI_SETWRAPVISUALFLAGS, new IntPtr(wrapVisualFlags)); - } - } - - /// - /// Gets or sets additional location options when displaying wrap visual flags. - /// - /// - /// One of the enumeration values. - /// The default is . - /// - [DefaultValue(WrapVisualFlagLocation.Default)] - [Category("Line Wrapping")] - [Description("The location of wrap visual flags in relation to the line text.")] - public WrapVisualFlagLocation WrapVisualFlagLocation - { - get - { - return (WrapVisualFlagLocation)DirectMessage(NativeMethods.SCI_GETWRAPVISUALFLAGSLOCATION); - } - set - { - var location = (int)value; - DirectMessage(NativeMethods.SCI_SETWRAPVISUALFLAGSLOCATION, new IntPtr(location)); - } - } - - /// - /// Gets or sets the horizontal scroll offset. - /// - /// The horizontal scroll offset in pixels. - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int XOffset - { - get - { - return DirectMessage(NativeMethods.SCI_GETXOFFSET).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - DirectMessage(NativeMethods.SCI_SETXOFFSET, new IntPtr(value)); - } - } - - /// - /// Gets or sets the zoom factor. - /// - /// The zoom factor measured in points. - /// For best results, values should range from -10 to 20 points. - /// - /// - [DefaultValue(0)] - [Category("Appearance")] - [Description("Zoom factor in points applied to the displayed text.")] - public int Zoom - { - get - { - return DirectMessage(NativeMethods.SCI_GETZOOM).ToInt32(); - } - set - { - DirectMessage(NativeMethods.SCI_SETZOOM, new IntPtr(value)); - } - } - - #endregion Properties - - #region Events - - /// - /// Occurs when an autocompletion list is cancelled. - /// - [Category("Notifications")] - [Description("Occurs when an autocompletion list is cancelled.")] - public event EventHandler AutoCCancelled - { - add - { - Events.AddHandler(autoCCancelledEventKey, value); - } - remove - { - Events.RemoveHandler(autoCCancelledEventKey, value); - } - } - - /// - /// Occurs when the user deletes a character while an autocompletion list is active. - /// - [Category("Notifications")] - [Description("Occurs when the user deletes a character while an autocompletion list is active.")] - public event EventHandler AutoCCharDeleted - { - add - { - Events.AddHandler(autoCCharDeletedEventKey, value); - } - remove - { - Events.RemoveHandler(autoCCharDeletedEventKey, value); - } - } - - /// - /// Occurs when a user has selected an item in an autocompletion list. - /// - /// Automatic insertion can be cancelled by calling from the event handler. - [Category("Notifications")] - [Description("Occurs when a user has selected an item in an autocompletion list.")] - public event EventHandler AutoCSelection - { - add - { - Events.AddHandler(autoCSelectionEventKey, value); - } - remove - { - Events.RemoveHandler(autoCSelectionEventKey, value); - } - } - - /// - /// Occurs when text is about to be deleted. - /// - [Category("Notifications")] - [Description("Occurs before text is deleted.")] - public event EventHandler BeforeDelete - { - add - { - Events.AddHandler(beforeDeleteEventKey, value); - } - remove - { - Events.RemoveHandler(beforeDeleteEventKey, value); - } - } - - /// - /// Occurs when text is about to be inserted. - /// - [Category("Notifications")] - [Description("Occurs before text is inserted.")] - public event EventHandler BeforeInsert - { - add - { - Events.AddHandler(beforeInsertEventKey, value); - } - remove - { - Events.RemoveHandler(beforeInsertEventKey, value); - } - } - - /// - /// Occurs when the value of the property has changed. - /// - [Category("Property Changed")] - [Description("Occurs when the value of the BorderStyle property changes.")] - public event EventHandler BorderStyleChanged - { - add - { - Events.AddHandler(borderStyleChangedEventKey, value); - } - remove - { - Events.RemoveHandler(borderStyleChangedEventKey, value); - } - } - - /// - /// Occurs when an annotation has changed. - /// - [Category("Notifications")] - [Description("Occurs when an annotation has changed.")] - public event EventHandler ChangeAnnotation - { - add - { - Events.AddHandler(changeAnnotationEventKey, value); - } - remove - { - Events.RemoveHandler(changeAnnotationEventKey, value); - } - } - - /// - /// Occurs when the user enters a text character. - /// - [Category("Notifications")] - [Description("Occurs when the user types a character.")] - public event EventHandler CharAdded - { - add - { - Events.AddHandler(charAddedEventKey, value); - } - remove - { - Events.RemoveHandler(charAddedEventKey, value); - } - } - - /// - /// Occurs when text has been deleted from the document. - /// - [Category("Notifications")] - [Description("Occurs when text is deleted.")] - public event EventHandler Delete - { - add - { - Events.AddHandler(deleteEventKey, value); - } - remove - { - Events.RemoveHandler(deleteEventKey, value); - } - } - - /// - /// Occurs when the mouse moves or another activity such as a key press ends a event. - /// - [Category("Notifications")] - [Description("Occurs when the mouse moves from its dwell start position.")] - public event EventHandler DwellEnd - { - add - { - Events.AddHandler(dwellEndEventKey, value); - } - remove - { - Events.RemoveHandler(dwellEndEventKey, value); - } - } - - /// - /// Occurs when the mouse is kept in one position (hovers) for the . - /// - [Category("Notifications")] - [Description("Occurs when the mouse is kept in one position (hovers) for a period of time.")] - public event EventHandler DwellStart - { - add - { - Events.AddHandler(dwellStartEventKey, value); - } - remove - { - Events.RemoveHandler(dwellStartEventKey, value); - } - } - - /// - /// Occurs when text has been inserted into the document. - /// - [Category("Notifications")] - [Description("Occurs when text is inserted.")] - public event EventHandler Insert - { - add - { - Events.AddHandler(insertEventKey, value); - } - remove - { - Events.RemoveHandler(insertEventKey, value); - } - } - - /// - /// Occurs when text is about to be inserted. The inserted text can be changed. - /// - [Category("Notifications")] - [Description("Occurs before text is inserted. Permits changing the inserted text.")] - public event EventHandler InsertCheck - { - add - { - Events.AddHandler(insertCheckEventKey, value); - } - remove - { - Events.RemoveHandler(insertCheckEventKey, value); - } - } - - /// - /// Occurs when the mouse was clicked inside a margin that was marked as sensitive. - /// - /// The property must be set for a margin to raise this event. - [Category("Notifications")] - [Description("Occurs when the mouse is clicked in a sensitive margin.")] - public event EventHandler MarginClick - { - add - { - Events.AddHandler(marginClickEventKey, value); - } - remove - { - Events.RemoveHandler(marginClickEventKey, value); - } - } - - /// - /// Occurs when a user attempts to change text while the document is in read-only mode. - /// - /// - [Category("Notifications")] - [Description("Occurs when an attempt is made to change text in read-only mode.")] - public event EventHandler ModifyAttempt - { - add - { - Events.AddHandler(modifyAttemptEventKey, value); - } - remove - { - Events.RemoveHandler(modifyAttemptEventKey, value); - } - } - - internal event EventHandler SCNotification - { - add - { - Events.AddHandler(scNotificationEventKey, value); - } - remove - { - Events.RemoveHandler(scNotificationEventKey, value); - } - } - - /// - /// Occurs when the document becomes 'dirty'. - /// - /// The document 'dirty' state can be checked with the property and reset by calling . - /// - /// - [Category("Notifications")] - [Description("Occurs when a save point is left and the document becomes dirty.")] - public event EventHandler SavePointLeft - { - add - { - Events.AddHandler(savePointLeftEventKey, value); - } - remove - { - Events.RemoveHandler(savePointLeftEventKey, value); - } - } - - /// - /// Occurs when the document 'dirty' flag is reset. - /// - /// The document 'dirty' state can be reset by calling or undoing an action that modified the document. - /// - /// - [Category("Notifications")] - [Description("Occurs when a save point is reached and the document is no longer dirty.")] - public event EventHandler SavePointReached - { - add - { - Events.AddHandler(savePointReachedEventKey, value); - } - remove - { - Events.RemoveHandler(savePointReachedEventKey, value); - } - } - - /// - /// Occurs when the control is about to display or print text and requires styling. - /// - /// - /// This event is only raised when is set to . - /// The last position styled correctly can be determined by calling . - /// - /// - [Category("Notifications")] - [Description("Occurs when the text needs styling.")] - public event EventHandler StyleNeeded - { - add - { - Events.AddHandler(styleNeededEventKey, value); - } - remove - { - Events.RemoveHandler(styleNeededEventKey, value); - } - } - - /// - /// Occurs when the control UI is updated as a result of changes to text (including styling), - /// selection, and/or scroll positions. - /// - [Category("Notifications")] - [Description("Occurs when the control UI is updated.")] - public event EventHandler UpdateUI - { - add - { - Events.AddHandler(updateUIEventKey, value); - } - remove - { - Events.RemoveHandler(updateUIEventKey, value); - } - } - - #endregion Events - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - public Scintilla() - { - // We don't want .NET to use GetWindowText because we manage ('cache') our own text - base.SetStyle(ControlStyles.CacheText, true); - - // Necessary control styles (see TextBoxBase) - base.SetStyle(ControlStyles.StandardClick | - ControlStyles.StandardDoubleClick | - ControlStyles.UseTextForAccessibility | - ControlStyles.UserPaint, - false); - - this.borderStyle = BorderStyle.Fixed3D; - - Lines = new LineCollection(this); - Styles = new StyleCollection(this); - Indicators = new IndicatorCollection(this); - Margins = new MarginCollection(this); - Markers = new MarkerCollection(this); - Selections = new SelectionCollection(this); - } - - #endregion Constructors - } -} diff --git a/ScintillaNet/SearchFlags.cs b/ScintillaNet/SearchFlags.cs deleted file mode 100644 index d10a930..0000000 --- a/ScintillaNet/SearchFlags.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// Specifies the how patterns are matched when performing a search in a control. - /// - /// This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values. - [Flags] - public enum SearchFlags - { - /// - /// Matches every instance of the search string. - /// - None = 0, - - /// - /// A match only occurs with text that matches the case of the search string. - /// - MatchCase = NativeMethods.SCFIND_MATCHCASE, - - /// - /// A match only occurs if the characters before and after are not word characters. - /// - WholeWord = NativeMethods.SCFIND_WHOLEWORD, - - /// - /// A match only occurs if the character before is not a word character. - /// - WordStart = NativeMethods.SCFIND_WORDSTART, - - /// - /// The search string should be interpreted as a regular expression. - /// - Regex = NativeMethods.SCFIND_REGEXP, - - /// - /// Treat regular expression in a more POSIX compatible manner by interpreting bare ( and ) for tagged sections rather than \( and \). - /// - Posix = NativeMethods.SCFIND_POSIX - } -} diff --git a/ScintillaNet/Selection.cs b/ScintillaNet/Selection.cs deleted file mode 100644 index 7fe7a8d..0000000 --- a/ScintillaNet/Selection.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// Represents a selection when there are multiple active selections in a control. - /// - public class Selection - { - private readonly Scintilla scintilla; - - /// - /// Gets or sets the anchor position of the selection. - /// - /// The zero-based document position of the selection anchor. - public int Anchor - { - get - { - var pos = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNANCHOR, new IntPtr(Index)).ToInt32(); - if (pos <= 0) - return pos; - - return scintilla.Lines.ByteToCharPosition(pos); - } - set - { - value = Helpers.Clamp(value, 0, scintilla.TextLength); - value = scintilla.Lines.CharToBytePosition(value); - scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNANCHOR, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets or sets the amount of anchor virtual space. - /// - /// The amount of virtual space past the end of the line offsetting the selection anchor. - public int AnchorVirtualSpace - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNANCHORVIRTUALSPACE, new IntPtr(Index)).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNANCHORVIRTUALSPACE, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets or sets the caret position of the selection. - /// - /// The zero-based document position of the selection caret. - public int Caret - { - get - { - var pos = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNCARET, new IntPtr(Index)).ToInt32(); - if (pos <= 0) - return pos; - - return scintilla.Lines.ByteToCharPosition(pos); - } - set - { - value = Helpers.Clamp(value, 0, scintilla.TextLength); - value = scintilla.Lines.CharToBytePosition(value); - scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNCARET, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets or sets the amount of caret virtual space. - /// - /// The amount of virtual space past the end of the line offsetting the selection caret. - public int CaretVirtualSpace - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNCARETVIRTUALSPACE, new IntPtr(Index)).ToInt32(); - } - set - { - value = Helpers.ClampMin(value, 0); - scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNCARETVIRTUALSPACE, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets or sets the end position of the selection. - /// - /// The zero-based document position where the selection ends. - public int End - { - get - { - var pos = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNEND, new IntPtr(Index)).ToInt32(); - if (pos <= 0) - return pos; - - return scintilla.Lines.ByteToCharPosition(pos); - } - set - { - value = Helpers.Clamp(value, 0, scintilla.TextLength); - value = scintilla.Lines.CharToBytePosition(value); - scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNEND, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets the selection index. - /// - /// The zero-based selection index within the that created it. - public int Index { get; private set; } - - /// - /// Gets or sets the start position of the selection. - /// - /// The zero-based document position where the selection starts. - public int Start - { - get - { - var pos = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNSTART, new IntPtr(Index)).ToInt32(); - if (pos <= 0) - return pos; - - return scintilla.Lines.ByteToCharPosition(pos); - } - set - { - value = Helpers.Clamp(value, 0, scintilla.TextLength); - value = scintilla.Lines.CharToBytePosition(value); - scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNSTART, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The control that created this selection. - /// The index of this selection within the that created it. - public Selection(Scintilla scintilla, int index) - { - this.scintilla = scintilla; - Index = index; - } - } -} diff --git a/ScintillaNet/Style.cs b/ScintillaNet/Style.cs deleted file mode 100644 index 6caa338..0000000 --- a/ScintillaNet/Style.cs +++ /dev/null @@ -1,832 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// A style definition in a control. - /// - public class Style - { - #region Constants - - /// - /// Default style index. This style is used to define properties that all styles receive when calling . - /// - public const int Default = NativeMethods.STYLE_DEFAULT; - - /// - /// Line number style index. This style is used for text in line number margins. The background color of this style also - /// sets the background color for all margins that do not have any folding mask set. - /// - public const int LineNumber = NativeMethods.STYLE_LINENUMBER; - - /// - /// Call tip style index. Only font name, size, foreground color, background color, and character set attributes - /// can be used when displaying a call tip. - /// - public const int CallTip = NativeMethods.STYLE_CALLTIP; - - /// - /// Indent guide style index. This style is used to specify the foreground and background colors of . - /// - public const int IndentGuide = NativeMethods.STYLE_INDENTGUIDE; - - /// - /// Brace highlighting style index. This style is used on a brace character when set with the method - /// or the indentation guide when used with the property. - /// - public const int BraceLight = NativeMethods.STYLE_BRACELIGHT; - - /// - /// Bad brace style index. This style is used on an unmatched brace character when set with the method. - /// - public const int BraceBad = NativeMethods.STYLE_BRACEBAD; - - #endregion Constants - - #region Fields - - private readonly Scintilla scintilla; - - #endregion Fields - - #region Properties - - /// - /// Gets or sets the background color of the style. - /// - /// A Color object representing the style background color. The default is White. - /// Alpha color values are ignored. - public Color BackColor - { - get - { - var color = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETBACK, new IntPtr(Index), IntPtr.Zero).ToInt32(); - return ColorTranslator.FromWin32(color); - } - set - { - if (value.IsEmpty) - value = Color.White; - - var color = ColorTranslator.ToWin32(value); - scintilla.DirectMessage(NativeMethods.SCI_STYLESETBACK, new IntPtr(Index), new IntPtr(color)); - } - } - - /// - /// Gets or sets whether the style font is bold. - /// - /// true if bold; otherwise, false. The default is false. - /// Setting this property affects the property. - public bool Bold - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_STYLEGETBOLD, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - var bold = (value ? new IntPtr(1) : IntPtr.Zero); - scintilla.DirectMessage(NativeMethods.SCI_STYLESETBOLD, new IntPtr(Index), bold); - } - } - - /// - /// Gets or sets the casing used to display the styled text. - /// - /// One of the enum values. The default is . - /// This does not affect how text is stored, only displayed. - public StyleCase Case - { - get - { - var @case = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETCASE, new IntPtr(Index), IntPtr.Zero).ToInt32(); - return (StyleCase)@case; - } - set - { - // Just an excuse to use @... syntax - var @case = (int)value; - scintilla.DirectMessage(NativeMethods.SCI_STYLESETCASE, new IntPtr(Index), new IntPtr(@case)); - } - } - - /// - /// Gets or sets whether the remainder of the line is filled with the - /// when this style is used on the last character of a line. - /// - /// true to fill the line; otherwise, false. The default is false. - public bool FillLine - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_STYLEGETEOLFILLED, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - var fillLine = (value ? new IntPtr(1) : IntPtr.Zero); - scintilla.DirectMessage(NativeMethods.SCI_STYLESETEOLFILLED, new IntPtr(Index), fillLine); - } - } - - /// - /// Gets or sets the style font name. - /// - /// The style font name. The default is Verdana. - /// Scintilla caches fonts by name so font names and casing should be consistent. - public string Font - { - get - { - var length = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFONT, new IntPtr(Index), IntPtr.Zero).ToInt32(); - var font = new byte[length]; - unsafe - { - fixed (byte* bp = font) - scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFONT, new IntPtr(Index), new IntPtr(bp)); - } - - var name = Encoding.Default.GetString(font, 0, length); - return name; - } - set - { - if (string.IsNullOrEmpty(value)) - value = "Verdana"; - - // As best I can tell, Scintilla is using the LOGFONTA structure for loading - // and saving fonts. Meaning we need to convert our font name to ANSI. - var font = Helpers.GetBytes(value, Encoding.Default, true); - unsafe - { - fixed (byte* bp = font) - scintilla.DirectMessage(NativeMethods.SCI_STYLESETFONT, new IntPtr(Index), new IntPtr(bp)); - } - } - } - - /// - /// Gets or sets the foreground color of the style. - /// - /// A Color object representing the style foreground color. The default is Black. - /// Alpha color values are ignored. - public Color ForeColor - { - get - { - var color = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFORE, new IntPtr(Index), IntPtr.Zero).ToInt32(); - return ColorTranslator.FromWin32(color); - } - set - { - if (value.IsEmpty) - value = Color.Black; - - var color = ColorTranslator.ToWin32(value); - scintilla.DirectMessage(NativeMethods.SCI_STYLESETFORE, new IntPtr(Index), new IntPtr(color)); - } - } - - /// - /// Gets or sets whether hovering the mouse over the style text exhibits hyperlink behavior. - /// - /// true to use hyperlink behavior; otherwise, false. The default is false. - public bool Hotspot - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_STYLEGETHOTSPOT, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - var hotspot = (value ? new IntPtr(1) : IntPtr.Zero); - scintilla.DirectMessage(NativeMethods.SCI_STYLESETHOTSPOT, new IntPtr(Index), hotspot); - } - } - - /// - /// Gets the zero-based style definition index. - /// - /// The style definition index within the . - public int Index { get; private set; } - - /// - /// Gets or sets whether the style font is italic. - /// - /// true if italic; otherwise, false. The default is false. - public bool Italic - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_STYLEGETITALIC, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - var italic = (value ? new IntPtr(1) : IntPtr.Zero); - scintilla.DirectMessage(NativeMethods.SCI_STYLESETITALIC, new IntPtr(Index), italic); - } - } - - /// - /// Gets or sets the size of the style font in points. - /// - /// The size of the style font as a whole number of points. The default is 8. - public int Size - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_STYLEGETSIZE, new IntPtr(Index), IntPtr.Zero).ToInt32(); - } - set - { - scintilla.DirectMessage(NativeMethods.SCI_STYLESETSIZE, new IntPtr(Index), new IntPtr(value)); - } - } - - /// - /// Gets or sets the size of the style font in fractoinal points. - /// - /// The size of the style font in fractional number of points. The default is 8. - public float SizeF - { - get - { - var fraction = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETSIZEFRACTIONAL, new IntPtr(Index), IntPtr.Zero).ToInt32(); - return (float)fraction / NativeMethods.SC_FONT_SIZE_MULTIPLIER; - } - set - { - var fraction = (int)(value * NativeMethods.SC_FONT_SIZE_MULTIPLIER); - scintilla.DirectMessage(NativeMethods.SCI_STYLESETSIZEFRACTIONAL, new IntPtr(Index), new IntPtr(fraction)); - } - } - - /// - /// Gets or sets whether the style is underlined. - /// - /// true if underlined; otherwise, false. The default is false. - public bool Underline - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_STYLEGETUNDERLINE, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - var underline = (value ? new IntPtr(1) : IntPtr.Zero); - scintilla.DirectMessage(NativeMethods.SCI_STYLESETUNDERLINE, new IntPtr(Index), underline); - } - } - - /// - /// Gets or sets whether the style text is visible. - /// - /// true to display the style text; otherwise, false. The default is true. - public bool Visible - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_STYLEGETVISIBLE, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - var visible = (value ? new IntPtr(1) : IntPtr.Zero); - scintilla.DirectMessage(NativeMethods.SCI_STYLESETVISIBLE, new IntPtr(Index), visible); - } - } - - /// - /// Gets or sets the style font weight. - /// - /// The font weight. The default is 400. - /// Setting this property affects the property. - public int Weight - { - get - { - return scintilla.DirectMessage(NativeMethods.SCI_STYLEGETWEIGHT, new IntPtr(Index), IntPtr.Zero).ToInt32(); - } - set - { - scintilla.DirectMessage(NativeMethods.SCI_STYLESETWEIGHT, new IntPtr(Index), new IntPtr(value)); - } - } - - #endregion Properties - - #region Constructors - - /// - /// Initializes a new instances of the class. - /// - /// The control that created this style. - /// The index of this style within the that created it. - public Style(Scintilla scintilla, int index) - { - this.scintilla = scintilla; - Index = index; - } - - #endregion Constructors - - #region Python - - /// - /// Style constants for use with the lexer. - /// - public static class Python - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_P_DEFAULT; - - /// - /// Line comment style index. - /// - public const int CommentLine = NativeMethods.SCE_P_COMMENTLINE; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_P_NUMBER; - - /// - /// String style index. - /// - public const int String = NativeMethods.SCE_P_STRING; - - /// - /// Single-quote style index. - /// - public const int Character = NativeMethods.SCE_P_CHARACTER; - - /// - /// Keyword style index. - /// - public const int Word = NativeMethods.SCE_P_WORD; - - /// - /// Triple single-quote style index. - /// - public const int Triple = NativeMethods.SCE_P_TRIPLE; - - /// - /// Triple double-quote style index. - /// - public const int TripleDouble = NativeMethods.SCE_P_TRIPLEDOUBLE; - - /// - /// Class name style index. - /// - public const int ClassName = NativeMethods.SCE_P_CLASSNAME; - - /// - /// Function or method name style index. - /// - public const int DefName = NativeMethods.SCE_P_DEFNAME; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_P_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_P_IDENTIFIER; - - /// - /// Block comment style index. - /// - public const int CommentBlock = NativeMethods.SCE_P_COMMENTBLOCK; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_P_STRINGEOL; - - /// - /// Keyword style 2 index. - /// - public const int Word2 = NativeMethods.SCE_P_WORD2; - - /// - /// Decorator style index. - /// - public const int Decorator = NativeMethods.SCE_P_DECORATOR; - } - - #endregion Python - - #region Cpp - - /// - /// Style constants for use with the lexer. - /// - public static class Cpp - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_C_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_C_COMMENT; - - /// - /// Line comment style index. - /// - public const int CommentLine = NativeMethods.SCE_C_COMMENTLINE; - - /// - /// Documentation comment style index. - /// - public const int CommentDoc = NativeMethods.SCE_C_COMMENTDOC; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_C_NUMBER; - - /// - /// Keyword style index. - /// - public const int Word = NativeMethods.SCE_C_WORD; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_C_STRING; - - /// - /// Single-quoted string style index. - /// - public const int Character = NativeMethods.SCE_C_CHARACTER; - - /// - /// UUID style index. - /// - public const int Uuid = NativeMethods.SCE_C_UUID; - - /// - /// Preprocessor style index. - /// - public const int Preprocessor = NativeMethods.SCE_C_PREPROCESSOR; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_C_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_C_IDENTIFIER; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_C_STRINGEOL; - - /// - /// Verbatim string style index. - /// - public const int Verbatim = NativeMethods.SCE_C_VERBATIM; - - /// - /// Regular expression style index. - /// - public const int Regex = NativeMethods.SCE_C_REGEX; - - /// - /// Documentation comment line style index. - /// - public const int CommentLineDoc = NativeMethods.SCE_C_COMMENTLINEDOC; - - /// - /// Keyword style 2 index. - /// - public const int Word2 = NativeMethods.SCE_C_WORD2; - - /// - /// Comment keyword style index. - /// - public const int CommentDocKeyword = NativeMethods.SCE_C_COMMENTDOCKEYWORD; - - /// - /// Comment keyword error style index. - /// - public const int CommentDocKeywordError = NativeMethods.SCE_C_COMMENTDOCKEYWORDERROR; - - /// - /// Global class style index. - /// - public const int GlobalClass = NativeMethods.SCE_C_GLOBALCLASS; - - /// - /// Raw string style index. - /// - public const int StringRaw = NativeMethods.SCE_C_STRINGRAW; - - /// - /// Triple-quoted string style index. - /// - public const int TripleVerbatim = NativeMethods.SCE_C_TRIPLEVERBATIM; - - /// - /// Hash-quoted string style index. - /// - public const int HashQuotedString = NativeMethods.SCE_C_HASHQUOTEDSTRING; - - /// - /// Preprocessor comment style index. - /// - public const int PreprocessorComment = NativeMethods.SCE_C_PREPROCESSORCOMMENT; - - /// - /// Preprocessor documentation comment style index. - /// - public const int PreprocessorCommentDoc = NativeMethods.SCE_C_PREPROCESSORCOMMENTDOC; - - /// - /// User-defined literal style index. - /// - public const int UserLiteral = NativeMethods.SCE_C_USERLITERAL; - - /// - /// Task marker style index. - /// - public const int TaskMarker = NativeMethods.SCE_C_TASKMARKER; - - /// - /// Escape sequence style index. - /// - public const int EscapeSequence = NativeMethods.SCE_C_ESCAPESEQUENCE; - } - - #endregion Cpp - - #region Css - - /// - /// Style constants for use with the lexer. - /// - public static class Css - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_CSS_DEFAULT; - - /// - /// Tag style index. - /// - public const int Tag = NativeMethods.SCE_CSS_TAG; - - /// - /// Class style index. - /// - public const int Class = NativeMethods.SCE_CSS_CLASS; - - /// - /// Pseudo class style index. - /// - public const int PseudoClass = NativeMethods.SCE_CSS_PSEUDOCLASS; - - /// - /// Unknown pseudo class style index. - /// - public const int UnknownPseudoClass = NativeMethods.SCE_CSS_UNKNOWN_PSEUDOCLASS; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_CSS_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_CSS_IDENTIFIER; - - /// - /// Unknown identifier style index. - /// - public const int UnknownIdentifier = NativeMethods.SCE_CSS_UNKNOWN_IDENTIFIER; - - /// - /// Value style index. - /// - public const int Value = NativeMethods.SCE_CSS_VALUE; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_CSS_COMMENT; - - /// - /// ID style index. - /// - public const int Id = NativeMethods.SCE_CSS_ID; - - /// - /// Important style index. - /// - public const int Important = NativeMethods.SCE_CSS_IMPORTANT; - - /// - /// Directive style index. - /// - public const int Directive = NativeMethods.SCE_CSS_DIRECTIVE; - - /// - /// Double-quoted string style index. - /// - public const int DoubleString = NativeMethods.SCE_CSS_DOUBLESTRING; - - /// - /// Single-quoted string style index. - /// - public const int SingleString = NativeMethods.SCE_CSS_SINGLESTRING; - - /// - /// Identifier style 2 index. - /// - public const int Identifier2 = NativeMethods.SCE_CSS_IDENTIFIER2; - - /// - /// Attribute style index. - /// - public const int Attribute = NativeMethods.SCE_CSS_ATTRIBUTE; - - /// - /// Identifier style 3 index. - /// - public const int Identifier3 = NativeMethods.SCE_CSS_IDENTIFIER3; - - /// - /// Pseudo element style index. - /// - public const int PseudoElement = NativeMethods.SCE_CSS_PSEUDOELEMENT; - - /// - /// Extended identifier style index. - /// - public const int ExtendedIdentifier = NativeMethods.SCE_CSS_EXTENDED_IDENTIFIER; - - /// - /// Extended pseudo class style index. - /// - public const int ExtendedPseudoClass = NativeMethods.SCE_CSS_EXTENDED_PSEUDOCLASS; - - /// - /// Extended pseudo element style index. - /// - public const int ExtendedPseudoElement = NativeMethods.SCE_CSS_EXTENDED_PSEUDOELEMENT; - - /// - /// Media style index. - /// - public const int Media = NativeMethods.SCE_CSS_MEDIA; - - /// - /// Variable style index. - /// - public const int Variable = NativeMethods.SCE_CSS_VARIABLE; - } - - #endregion Css - - #region Basic - - /// - /// Style constants for use with the lexer. - /// - public static class Basic - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_CSS_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_B_COMMENT; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_B_NUMBER; - - /// - /// Keyword style index. - /// - public const int Keyword = NativeMethods.SCE_B_KEYWORD; - - /// - /// String style index. - /// - public const int String = NativeMethods.SCE_B_STRING; - - /// - /// Preprocessor style index. - /// - public const int Preprocessor = NativeMethods.SCE_B_PREPROCESSOR; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_B_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_B_IDENTIFIER; - - /// - /// Date style index. - /// - public const int Date = NativeMethods.SCE_B_DATE; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_B_STRINGEOL; - - /// - /// Keyword list 2 style index. - /// - public const int Keyword2 = NativeMethods.SCE_B_KEYWORD2; - - /// - /// Keyword list 3 style index. - /// - public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; - - /// - /// Keyword list 4 style index. - /// - public const int Keyword4 = NativeMethods.SCE_B_KEYWORD4; - - /// - /// Constant style index. - /// - public const int Constant = NativeMethods.SCE_B_CONSTANT; - - /// - /// Inline assembler style index. - /// - public const int Asm = NativeMethods.SCE_B_ASM; - - /// - /// Label style index. - /// - public const int Label = NativeMethods.SCE_B_LABEL; - - /// - /// Error style index. - /// - public const int Error = NativeMethods.SCE_B_ERROR; - - /// - /// Hexadecimal number style index. - /// - public const int HexNumber = NativeMethods.SCE_B_HEXNUMBER; - - /// - /// Binary number style index. - /// - public const int BinNumber = NativeMethods.SCE_B_BINNUMBER; - - /// - /// Block comment style index. - /// - public const int CommentBlock = NativeMethods.SCE_B_COMMENTBLOCK; - - /// - /// Documentation line style index. - /// - public const int DocLine = NativeMethods.SCE_B_DOCLINE; - - /// - /// Documentation block style index. - /// - public const int DocBlock = NativeMethods.SCE_B_DOCBLOCK; - - /// - /// Documentation keyword style index. - /// - public const int DocKeyword = NativeMethods.SCE_B_DOCKEYWORD; - } - - #endregion Basic - } -} diff --git a/ScintillaNet/StyleCase.cs b/ScintillaNet/StyleCase.cs deleted file mode 100644 index 5b6b986..0000000 --- a/ScintillaNet/StyleCase.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// The possible casing styles of a style. - /// - public enum StyleCase - { - /// - /// Display the text normally. - /// - Mixed = NativeMethods.SC_CASE_MIXED, - - /// - /// Display the text in upper case. - /// - Upper = NativeMethods.SC_CASE_UPPER, - - /// - /// Display the text in lower case. - /// - Lower = NativeMethods.SC_CASE_LOWER - } -} diff --git a/ScintillaNet/StyleCollection.cs b/ScintillaNet/StyleCollection.cs deleted file mode 100644 index 19bbce5..0000000 --- a/ScintillaNet/StyleCollection.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ScintillaNET -{ - /// - /// An immutable collection of style definitions in a control. - /// - public class StyleCollection : IEnumerable