diff --git a/Scintilla.NET/NativeMethods.cs b/Scintilla.NET/NativeMethods.cs index 564f8f6..b582230 100644 --- a/Scintilla.NET/NativeMethods.cs +++ b/Scintilla.NET/NativeMethods.cs @@ -297,6 +297,31 @@ public static class NativeMethods public const int SCFIND_POSIX = 0x00400000; public const int SCFIND_CXX11REGEX = 0x00800000; + // Element colors + public const int SC_ELEMENT_LIST = 0; + public const int SC_ELEMENT_LIST_BACK = 1; + public const int SC_ELEMENT_LIST_SELECTED = 2; + public const int SC_ELEMENT_LIST_SELECTED_BACK = 3; + public const int SC_ELEMENT_SELECTION_TEXT = 10; + public const int SC_ELEMENT_SELECTION_BACK = 11; + public const int SC_ELEMENT_SELECTION_ADDITIONAL_TEXT = 12; + public const int SC_ELEMENT_SELECTION_ADDITIONAL_BACK = 13; + public const int SC_ELEMENT_SELECTION_SECONDARY_TEXT = 14; + public const int SC_ELEMENT_SELECTION_SECONDARY_BACK = 15; + public const int SC_ELEMENT_SELECTION_INACTIVE_TEXT = 16; + public const int SC_ELEMENT_SELECTION_INACTIVE_BACK = 17; + public const int SC_ELEMENT_SELECTION_INACTIVE_ADDITIONAL_TEXT = 18; + public const int SC_ELEMENT_SELECTION_INACTIVE_ADDITIONAL_BACK = 19; + public const int SC_ELEMENT_CARET = 40; + public const int SC_ELEMENT_CARET_ADDITIONAL = 41; + public const int SC_ELEMENT_CARET_LINE_BACK = 50; + public const int SC_ELEMENT_WHITE_SPACE = 60; + public const int SC_ELEMENT_WHITE_SPACE_BACK = 61; + public const int SC_ELEMENT_HOT_SPOT_ACTIVE = 70; + public const int SC_ELEMENT_HOT_SPOT_ACTIVE_BACK = 71; + public const int SC_ELEMENT_FOLD_LINE = 80; + public const int SC_ELEMENT_HIDDEN_LINE = 81; + // Functions public const int SCI_START = 2000; public const int SCI_OPTIONAL_START = 3000; @@ -965,6 +990,12 @@ public static class NativeMethods public const int SCI_FOLDDISPLAYTEXTSETSTYLE = 2701; public const int SCI_GETCARETLINEFRAME = 2704; public const int SCI_SETCARETLINEFRAME = 2705; + public const int SCI_SETELEMENTCOLOUR = 2753; + public const int SCI_GETELEMENTCOLOUR = 2754; + public const int SCI_RESETELEMENTCOLOUR = 2755; + public const int SCI_GETELEMENTISSET = 2756; + public const int SCI_GETELEMENTALLOWSTRANSLUCENT = 2757; + public const int SCI_GETELEMENTBASECOLOUR = 2758; public const int SCI_GETSELECTIONLAYER = 2762; public const int SCI_SETSELECTIONLAYER = 2763; public const int SCI_GETCARETLINELAYER = 2764; diff --git a/Scintilla.NET/Scintilla.cs b/Scintilla.NET/Scintilla.cs index 2193c9f..dbaff66 100644 --- a/Scintilla.NET/Scintilla.cs +++ b/Scintilla.NET/Scintilla.cs @@ -2414,6 +2414,7 @@ public void SelectAll() /// /// Additional selections background color. /// Calling will reset the specified. + [Obsolete("Superseded by SelectionAdditionalBackColor property.")] public void SetAdditionalSelBack(Color color) { var colour = HelperMethods.ToWin32Color(color); @@ -2425,6 +2426,7 @@ public void SetAdditionalSelBack(Color color) /// /// Additional selections foreground color. /// Calling will reset the specified. + [Obsolete("Superseded by SelectionAdditionalTextColor property.")] public void SetAdditionalSelFore(Color color) { var colour = HelperMethods.ToWin32Color(color); @@ -2645,6 +2647,7 @@ public void SetSelection(int caret, int anchor) /// true to override the selection background color; otherwise, false. /// The global selection background color. /// + [Obsolete("Superseded by SelectionBackColor property.")] public void SetSelectionBackColor(bool use, Color color) { var colour = HelperMethods.ToWin32Color(color); @@ -2659,6 +2662,7 @@ public void SetSelectionBackColor(bool use, Color color) /// true to override the selection foreground color; otherwise, false. /// The global selection foreground color. /// + [Obsolete("Superseded by SelectionTextColor property.")] public void SetSelectionForeColor(bool use, Color color) { var colour = HelperMethods.ToWin32Color(color); @@ -2748,6 +2752,7 @@ public void SetTargetRange(int start, int end) /// When not overridden globally, the whitespace background color is determined by the current lexer. /// /// + [Obsolete("Superseded by WhitespaceBackColor property.")] public void SetWhitespaceBackColor(bool use, Color color) { var colour = HelperMethods.ToWin32Color(color); @@ -2764,6 +2769,7 @@ public void SetWhitespaceBackColor(bool use, Color color) /// When not overridden globally, the whitespace foreground color is determined by the current lexer. /// /// + [Obsolete("Superseded by WhitespaceTextColor property.")] public void SetWhitespaceForeColor(bool use, Color color) { var colour = HelperMethods.ToWin32Color(color); @@ -3370,13 +3376,13 @@ public Color AdditionalCaretForeColor { get { - var color = DirectMessage(NativeMethods.SCI_GETADDITIONALCARETFORE).ToInt32(); + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_CARET_ADDITIONAL)).ToInt32(); return HelperMethods.FromWin32Color(color); } set { int color = HelperMethods.ToWin32Color(value); - DirectMessage(NativeMethods.SCI_SETADDITIONALCARETFORE, new IntPtr(color)); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_CARET_ADDITIONAL), new IntPtr(color)); } } @@ -3430,6 +3436,9 @@ public bool AdditionalCaretsVisible [DefaultValue(256)] [Category("Multiple Selection")] [Description("The transparency of additional selections.")] + [Obsolete("Use SelectionAdditionalTextColor with alpha channel instead.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Browsable(false)] public int AdditionalSelAlpha { get @@ -3509,6 +3518,86 @@ public Annotation AnnotationVisible } } + /// + /// Gets or sets the text color in autocompletion lists. + /// + [Description("The text color in autocompletion lists.")] + [Category("Autocompletion")] + [DefaultValue(typeof(Color), "Black")] + public Color AutocompleteListTextColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_LIST)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_LIST), new IntPtr(color)); + } + } + + /// + /// Gets or sets the background color in autocompletion lists. + /// + [Description("The background color in autocompletion lists.")] + [Category("Autocompletion")] + [DefaultValue(typeof(Color), "White")] + public Color AutocompleteListBackColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_LIST_BACK)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_LIST_BACK), new IntPtr(color)); + } + } + + /// + /// Gets or sets the text color of selected item in autocompletion lists. + /// + [Description("The text color of selected item in autocompletion lists.")] + [Category("Autocompletion")] + [DefaultValue(typeof(Color), "White")] + public Color AutocompleteListSelectedTextColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_LIST_SELECTED)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_LIST_SELECTED), new IntPtr(color)); + } + } + + /// + /// Gets or sets the background color of selected item in autocompletion lists. + /// + [Description("The background color of selected item in autocompletion lists.")] + [Category("Autocompletion")] + [DefaultValue(typeof(Color), "0, 120, 215")] + public Color AutocompleteListSelectedBackColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_LIST_SELECTED_BACK)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_LIST_SELECTED_BACK), new IntPtr(color)); + } + } + /// /// Gets a value indicating whether there is an autocompletion list displayed. /// @@ -4025,13 +4114,13 @@ public Color CaretForeColor { get { - var color = DirectMessage(NativeMethods.SCI_GETCARETFORE).ToInt32(); + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_CARET)).ToInt32(); return HelperMethods.FromWin32Color(color); } set { int color = HelperMethods.ToWin32Color(value); - DirectMessage(NativeMethods.SCI_SETCARETFORE, new IntPtr(color)); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_CARET), new IntPtr(color)); } } @@ -4046,13 +4135,13 @@ public Color CaretLineBackColor { get { - var color = DirectMessage(NativeMethods.SCI_GETCARETLINEBACK).ToInt32(); + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_CARET_LINE_BACK)).ToInt32(); return HelperMethods.FromWin32Color(color); } set { int color = HelperMethods.ToWin32Color(value); - DirectMessage(NativeMethods.SCI_SETCARETLINEBACK, new IntPtr(color)); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_CARET_LINE_BACK), new IntPtr(color)); } } @@ -4066,6 +4155,9 @@ public Color CaretLineBackColor [DefaultValue(256)] [Category("Caret")] [Description("The transparency of the current line background color.")] + [Obsolete("Use CaretLineBackColor with alpha channel instead.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Browsable(false)] public int CaretLineBackColorAlpha { get @@ -4106,11 +4198,14 @@ public int CaretLineFrame [DefaultValue(true)] [Category("Caret")] [Description("Determines whether to highlight the current caret line.")] + [Obsolete("Use CaretLineBackColor with alpha channel instead.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Browsable(false)] public bool CaretLineVisible { get { - return (DirectMessage(NativeMethods.SCI_GETCARETLINEVISIBLE) != IntPtr.Zero); + return DirectMessage(NativeMethods.SCI_GETCARETLINEVISIBLE) != IntPtr.Zero; } set { @@ -5521,6 +5616,326 @@ public bool SelectionEolFilled } } + /// + /// Gets or sets the color of visible white space. + /// + [Description("The color of visible white space.")] + [Category("Whitespace")] + [DefaultValue(typeof(Color), "Transparent")] + public Color WhitespaceTextColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_WHITE_SPACE)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_WHITE_SPACE), new IntPtr(color)); + } + } + + /// + /// Gets or sets the background color of visible white space. + /// + [Description("The background color of visible white space.")] + [Category("Whitespace")] + [DefaultValue(typeof(Color), "Transparent")] + public Color WhitespaceBackColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_WHITE_SPACE_BACK)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_WHITE_SPACE_BACK), new IntPtr(color)); + } + } + + /// + /// Gets or sets the text color of active hot spot. + /// + [Description("The text color of active hot spot.")] + [Category("Hotspot")] + [DefaultValue(typeof(Color), "Transparent")] + public Color ActiveHotspotTextColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_HOT_SPOT_ACTIVE)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_HOT_SPOT_ACTIVE), new IntPtr(color)); + } + } + + /// + /// Gets or sets the background color of active hot spot. + /// + [Description("The background color of active hot spot.")] + [Category("Hotspot")] + [DefaultValue(typeof(Color), "Transparent")] + public Color ActiveHotspotBackColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_HOT_SPOT_ACTIVE_BACK)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_HOT_SPOT_ACTIVE_BACK), new IntPtr(color)); + } + } + + /// + /// Gets or sets the text color of main selection. + /// + [Description("The text color of main selection.")] + [Category("Selection")] + [DefaultValue(typeof(Color), "Transparent")] + public Color SelectionTextColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_TEXT)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_TEXT), new IntPtr(color)); + } + } + + /// + /// Gets or sets the background color of main selection. + /// + [Description("The background color of main selection.")] + [Category("Selection")] + [DefaultValue(typeof(Color), "Silver")] + public Color SelectionBackColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_BACK)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_BACK), new IntPtr(color)); + } + } + + /// + /// Gets or sets the text color of additional selections. + /// + [Description("The text color of additional selections.")] + [Category("Selection")] + [DefaultValue(typeof(Color), "Transparent")] + public Color SelectionAdditionalTextColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_ADDITIONAL_TEXT)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_ADDITIONAL_TEXT), new IntPtr(color)); + } + } + + /// + /// Gets or sets the background color of additional selections. + /// + [Description("The background color of additional selections.")] + [Category("Selection")] + [DefaultValue(typeof(Color), "215, 215, 215")] + public Color SelectionAdditionalBackColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_ADDITIONAL_BACK)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_ADDITIONAL_BACK), new IntPtr(color)); + } + } + + /// + /// Gets or sets the text colour of selections when another window contains the primary selection. + /// + [Description("The text colour of selections when another window contains the primary selection.")] + [Category("Selection")] + [DefaultValue(typeof(Color), "Transparent")] + public Color SelectionSecondaryTextColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_SECONDARY_TEXT)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_SECONDARY_TEXT), new IntPtr(color)); + } + } + + /// + /// Gets or sets the background color of selections when another window contains the primary selection. + /// + [Description("The background color of selections when another window contains the primary selection.")] + [Category("Selection")] + [DefaultValue(typeof(Color), "176, 176, 176")] + public Color SelectionSecondaryBackColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_SECONDARY_BACK)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_SECONDARY_BACK), new IntPtr(color)); + } + } + + /// + /// Gets or sets the text colour of selections when the control has no focus. + /// + [Description("The text colour of selections when the control has no focus.")] + [Category("Selection")] + [DefaultValue(typeof(Color), "Transparent")] + public Color SelectionInactiveTextColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_INACTIVE_TEXT)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_INACTIVE_TEXT), new IntPtr(color)); + } + } + + /// + /// Gets or sets the selection highlight color to use when the control has no focus. + /// + [Description("The selection highlight color to use when the control has no focus.")] + [Category("Selection")] + [DefaultValue(typeof(Color), "63, 128, 128, 128")] + public Color SelectionInactiveBackColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_INACTIVE_BACK)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_INACTIVE_BACK), new IntPtr(color)); + } + } + + /// + /// Gets or sets the selected text color to use when the control has no focus. + /// + [Description("The selected text color to use when the control has no focus.")] + [Category("Selection")] + [DefaultValue(typeof(Color), "Transparent")] + public Color SelectionInactiveAdditionalTextColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_INACTIVE_ADDITIONAL_TEXT)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_INACTIVE_ADDITIONAL_TEXT), new IntPtr(color)); + } + } + + /// + /// Gets or sets the selection highlight color to use when the control has no focus. + /// + [Description("The selection highlight color to use when the control has no focus.")] + [Category("Selection")] + [DefaultValue(typeof(Color), "Transparent")] + public Color SelectionInactiveAdditionalBackColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_INACTIVE_ADDITIONAL_BACK)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_SELECTION_INACTIVE_ADDITIONAL_BACK), new IntPtr(color)); + } + } + + /// + /// Gets or sets the color of fold lines. + /// + [Description("The color of fold lines.")] + [Category("Folding")] + [DefaultValue(typeof(Color), "Transparent")] + public Color FoldLineBackColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_FOLD_LINE)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_FOLD_LINE), new IntPtr(color)); + } + } + + /// + /// Gets or sets the color of line drawn to show there are lines hidden at that point. + /// + [Description("The color of line drawn to show there are lines hidden at that point.")] + [Category("Folding")] + [DefaultValue(typeof(Color), "Transparent")] + public Color FoldLineStripColor + { + get + { + int color = DirectMessage(NativeMethods.SCI_GETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_HIDDEN_LINE)).ToInt32(); + return HelperMethods.FromWin32Color(color); + } + set + { + int color = HelperMethods.ToWin32Color(value); + DirectMessage(NativeMethods.SCI_SETELEMENTCOLOUR, new IntPtr(NativeMethods.SC_ELEMENT_HIDDEN_LINE), new IntPtr(color)); + } + } + /// /// Gets a collection representing multiple selections in a control. ///