From 7ed8521f5f72fcb7e6700935cffeaa436cf2c741 Mon Sep 17 00:00:00 2001 From: Ahmet Sait Date: Thu, 29 Aug 2024 10:46:06 +0300 Subject: [PATCH] Make Scintilla.NET compatible with C# 7.3 --- .editorconfig | 210 +- Scintilla.NET.TestApp/FormMain.cs | 445 +- Scintilla.NET.TestApp/Program.cs | 23 +- .../Scintilla.NET.TestApp.csproj | 2 - Scintilla.NET/Annotation.cs | 41 +- .../AutoCSelectionChangeEventArgs.cs | 2 +- Scintilla.NET/AutoCSelectionEventArgs.cs | 125 +- Scintilla.NET/AutomaticFold.cs | 45 +- Scintilla.NET/BeforeModificationEventArgs.cs | 127 +- Scintilla.NET/BiDirectionalDisplayType.cs | 33 +- Scintilla.NET/CallTipClickEventArgs.cs | 39 +- Scintilla.NET/CallTipClickType.cs | 33 +- Scintilla.NET/CaretStyle.cs | 33 +- Scintilla.NET/ChangeAnnotationEventArgs.cs | 33 +- Scintilla.NET/ChangeHistory.cs | 43 +- Scintilla.NET/CharAddedEventArgs.cs | 33 +- Scintilla.NET/ColorSpace.cs | 181 +- Scintilla.NET/Command.cs | 1155 +-- Scintilla.NET/CopyFormat.cs | 35 +- Scintilla.NET/Document.cs | 101 +- Scintilla.NET/DoubleClickEventArgs.cs | 95 +- Scintilla.NET/DwellEventArgs.cs | 93 +- Scintilla.NET/EdgeMode.cs | 43 +- Scintilla.NET/Eol.cs | 33 +- Scintilla.NET/FlagsConverter.cs | 115 +- Scintilla.NET/FlagsEditor.cs | 33 +- Scintilla.NET/FlagsEditorControl.Designer.cs | 233 +- Scintilla.NET/FlagsEditorControl.cs | 249 +- Scintilla.NET/FlagsEnumConverter.cs | 305 +- Scintilla.NET/FoldAction.cs | 33 +- Scintilla.NET/FoldDisplayText.cs | 33 +- Scintilla.NET/FoldFlags.cs | 63 +- Scintilla.NET/FoldLevelFlags.cs | 29 +- Scintilla.NET/FontQuality.cs | 43 +- Scintilla.NET/GapBuffer.cs | 267 +- Scintilla.NET/HelperMethods.cs | 175 +- Scintilla.NET/Helpers.cs | 2138 +++--- Scintilla.NET/HotspotClickEventArgs.cs | 73 +- Scintilla.NET/ILoader.cs | 63 +- Scintilla.NET/IdleStyling.cs | 51 +- Scintilla.NET/IndentView.cs | 49 +- Scintilla.NET/Indicator.cs | 449 +- Scintilla.NET/IndicatorClickEventArgs.cs | 37 +- Scintilla.NET/IndicatorCollection.cs | 111 +- Scintilla.NET/IndicatorFlags.cs | 33 +- Scintilla.NET/IndicatorReleaseEventArgs.cs | 53 +- Scintilla.NET/IndicatorStyle.cs | 251 +- Scintilla.NET/InsertCheckEventArgs.cs | 103 +- Scintilla.NET/Layer.cs | 35 +- Scintilla.NET/Lexer.cs | 1111 +-- Scintilla.NET/Lexilla.cs | 221 +- Scintilla.NET/Line.cs | 1047 +-- Scintilla.NET/LineCollection.cs | 892 +-- Scintilla.NET/LineEndType.cs | 33 +- Scintilla.NET/ListCompletionMethod.cs | 51 +- Scintilla.NET/Loader.cs | 101 +- Scintilla.NET/Margin.cs | 253 +- Scintilla.NET/MarginClickEventArgs.cs | 83 +- Scintilla.NET/MarginCollection.cs | 257 +- Scintilla.NET/MarginCursor.cs | 25 +- Scintilla.NET/MarginOptions.cs | 29 +- Scintilla.NET/MarginType.cs | 65 +- Scintilla.NET/Marker.cs | 329 +- Scintilla.NET/MarkerCollection.cs | 97 +- Scintilla.NET/MarkerHandle.cs | 101 +- Scintilla.NET/MarkerSymbol.cs | 347 +- Scintilla.NET/ModificationEventArgs.cs | 83 +- Scintilla.NET/ModificationSource.cs | 33 +- Scintilla.NET/MultiPaste.cs | 25 +- Scintilla.NET/NativeMemoryStream.cs | 213 +- Scintilla.NET/NativeMethods.cs | 4167 +++++----- Scintilla.NET/NeedShownEventArgs.cs | 89 +- Scintilla.NET/Order.cs | 33 +- Scintilla.NET/Phases.cs | 35 +- Scintilla.NET/PopupMode.cs | 39 +- Scintilla.NET/ProjectionEqualityComparer.cs | 208 +- Scintilla.NET/PropertyType.cs | 33 +- Scintilla.NET/SCNotificationEventArgs.cs | 17 +- Scintilla.NET/Scintilla.NET.csproj | 3 - Scintilla.NET/Scintilla.cs | 537 +- Scintilla.NET/ScintillaDesigner.cs | 56 +- Scintilla.NET/ScintillaReader.cs | 321 +- Scintilla.NET/SearchFlags.cs | 95 +- Scintilla.NET/Selection.cs | 237 +- Scintilla.NET/SelectionCollection.cs | 113 +- Scintilla.NET/Status.cs | 41 +- Scintilla.NET/Style.cs | 6807 +++++++++-------- Scintilla.NET/StyleCase.cs | 41 +- Scintilla.NET/StyleCollection.cs | 97 +- Scintilla.NET/StyleNeededEventArgs.cs | 55 +- Scintilla.NET/TabDrawMode.cs | 25 +- Scintilla.NET/Technology.cs | 27 +- Scintilla.NET/UpdateChange.cs | 45 +- Scintilla.NET/UpdateUIEventArgs.cs | 45 +- Scintilla.NET/VirtualSpace.cs | 45 +- Scintilla.NET/WhitespaceMode.cs | 43 +- Scintilla.NET/WinApiHelper.cs | 43 +- Scintilla.NET/WrapIndentMode.cs | 35 +- Scintilla.NET/WrapMode.cs | 41 +- Scintilla.NET/WrapVisualFlagLocation.cs | 33 +- Scintilla.NET/WrapVisualFlags.cs | 45 +- 101 files changed, 13571 insertions(+), 13303 deletions(-) diff --git a/.editorconfig b/.editorconfig index 63d867d..851ba14 100644 --- a/.editorconfig +++ b/.editorconfig @@ -33,8 +33,7 @@ indent_size = 2 [[Aa]pp.{config,manifest}] indent_size = 2 -# C# files -[*.cs] +[*] #### .NET Coding Conventions #### @@ -44,63 +43,108 @@ dotnet_sort_system_directives_first = true file_header_template = unset # this. and Me. preferences -dotnet_style_qualification_for_event = false -dotnet_style_qualification_for_field = true -dotnet_style_qualification_for_method = false -dotnet_style_qualification_for_property = false +dotnet_style_qualification_for_event = false:silent +dotnet_style_qualification_for_field = true:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_property = false:silent # Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true -dotnet_style_predefined_type_for_member_access = true +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent # Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary -dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary -dotnet_style_parentheses_in_other_operators = never_if_unnecessary -dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:silent # Modifier preferences -dotnet_style_require_accessibility_modifiers = for_non_interface_members +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent # Expression-level preferences -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_collection_initializer = true -dotnet_style_explicit_tuple_names = true -dotnet_style_namespace_match_folder = true +dotnet_style_coalesce_expression = false:silent +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_namespace_match_folder = true:suggestion dotnet_style_null_propagation = true:suggestion dotnet_style_object_initializer = true:suggestion dotnet_style_operator_placement_when_wrapping = beginning_of_line dotnet_style_prefer_auto_properties = true:silent -dotnet_style_prefer_collection_expression = when_types_loosely_match -dotnet_style_prefer_compound_assignment = true -dotnet_style_prefer_conditional_expression_over_assignment = true -dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_collection_expression = never:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed -dotnet_style_prefer_inferred_anonymous_type_member_names = true -dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion -dotnet_style_prefer_simplified_boolean_expressions = true -dotnet_style_prefer_simplified_interpolation = true +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion # Field preferences -dotnet_style_readonly_field = true +dotnet_style_readonly_field = true:suggestion # Parameter preferences -dotnet_code_quality_unused_parameters = non_public +dotnet_code_quality_unused_parameters = non_public:suggestion # Suppression preferences dotnet_remove_unnecessary_suppression_exclusions = none # New line preferences -dotnet_style_allow_multiple_blank_lines_experimental = false -dotnet_style_allow_statement_immediately_after_block_experimental = false +dotnet_style_allow_multiple_blank_lines_experimental = false:silent +dotnet_style_allow_statement_immediately_after_block_experimental = false:silent + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +# C# files +[*.cs] #### C# Coding Conventions #### # var preferences -csharp_style_var_elsewhere = false -csharp_style_var_for_built_in_types = false -csharp_style_var_when_type_is_apparent = true +csharp_style_var_elsewhere = false:silent +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = true:silent # Expression-bodied members csharp_style_expression_bodied_accessors = when_on_single_line:silent @@ -113,54 +157,54 @@ csharp_style_expression_bodied_operators = when_on_single_line:silent csharp_style_expression_bodied_properties = when_on_single_line:silent # Pattern matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true -csharp_style_pattern_matching_over_is_with_cast_check = true -csharp_style_prefer_extended_property_pattern = true -csharp_style_prefer_not_pattern = true -csharp_style_prefer_pattern_matching = true -csharp_style_prefer_switch_expression = false +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_prefer_extended_property_pattern = true:suggestion +csharp_style_prefer_not_pattern = false:suggestion +csharp_style_prefer_pattern_matching = false:silent +csharp_style_prefer_switch_expression = false:suggestion # Null-checking preferences -csharp_style_conditional_delegate_call = true +csharp_style_conditional_delegate_call = true:suggestion # Modifier preferences -csharp_prefer_static_local_function = true +csharp_prefer_static_local_function = true:suggestion csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async -csharp_style_prefer_readonly_struct = true -csharp_style_prefer_readonly_struct_member = true +csharp_style_prefer_readonly_struct = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion # Code-block preferences csharp_prefer_braces = when_multiline:silent -csharp_prefer_simple_using_statement = true:silent -csharp_style_namespace_declarations = file_scoped:silent +csharp_prefer_simple_using_statement = false:silent +csharp_style_namespace_declarations = block_scoped:silent csharp_style_prefer_method_group_conversion = true:silent -csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_prefer_primary_constructors = false:suggestion csharp_style_prefer_top_level_statements = false:silent # Expression-level preferences -csharp_prefer_simple_default_expression = true -csharp_style_deconstructed_variable_declaration = true -csharp_style_implicit_object_creation_when_type_is_apparent = true -csharp_style_inlined_variable_declaration = true -csharp_style_prefer_index_operator = false -csharp_style_prefer_local_over_anonymous_function = true -csharp_style_prefer_null_check_over_type_check = true -csharp_style_prefer_range_operator = true -csharp_style_prefer_tuple_swap = true -csharp_style_prefer_utf8_string_literals = true -csharp_style_throw_expression = true +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = false:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_prefer_index_operator = false:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_range_operator = false:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = true:suggestion +csharp_style_throw_expression = true:suggestion csharp_style_unused_value_assignment_preference = discard_variable:silent -csharp_style_unused_value_expression_statement_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable:silent # 'using' directive preferences csharp_using_directive_placement = outside_namespace:silent # New line preferences -csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true -csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true -csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true -csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false -csharp_style_allow_embedded_statements_on_same_line_experimental = false +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:silent +csharp_style_allow_embedded_statements_on_same_line_experimental = false:silent #### C# Formatting Rules #### @@ -208,45 +252,3 @@ csharp_space_between_square_brackets = false # Wrapping preferences csharp_preserve_single_line_blocks = true csharp_preserve_single_line_statements = false - -#### Naming styles #### - -# Naming rules - -dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion -dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface -dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i - -dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.types_should_be_pascal_case.symbols = types -dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case - -dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members -dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case - -# Symbol specifications - -dotnet_naming_symbols.interface.applicable_kinds = interface -dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.interface.required_modifiers = - -dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum -dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.types.required_modifiers = - -dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method -dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.non_field_members.required_modifiers = - -# Naming styles - -dotnet_naming_style.pascal_case.required_prefix = -dotnet_naming_style.pascal_case.required_suffix = -dotnet_naming_style.pascal_case.word_separator = -dotnet_naming_style.pascal_case.capitalization = pascal_case - -dotnet_naming_style.begins_with_i.required_prefix = I -dotnet_naming_style.begins_with_i.required_suffix = -dotnet_naming_style.begins_with_i.word_separator = -dotnet_naming_style.begins_with_i.capitalization = pascal_case diff --git a/Scintilla.NET.TestApp/FormMain.cs b/Scintilla.NET.TestApp/FormMain.cs index 4dbc578..ad1ce2c 100644 --- a/Scintilla.NET.TestApp/FormMain.cs +++ b/Scintilla.NET.TestApp/FormMain.cs @@ -6,279 +6,286 @@ using System.Text; using System.Windows.Forms; -namespace ScintillaNET.TestApp; - -public partial class FormMain : Form +namespace ScintillaNET.TestApp { - string baseTitle; - string? currentFileName = null; - - public string? CurrentFileName + public partial class FormMain : Form { - get => this.currentFileName; - set + private string baseTitle; + private string currentFileName = null; + + public string CurrentFileName { - BaseTitle = Path.GetFileName(this.currentFileName = value); + get => this.currentFileName; + set + { + BaseTitle = Path.GetFileName(this.currentFileName = value); + } } - } - public string BaseTitle - { - get => this.baseTitle; - set + public string BaseTitle { - this.Text = (this.baseTitle = value) + (scintilla.Modified ? " *" : ""); + get => this.baseTitle; + set + { + Text = (this.baseTitle = value) + (this.scintilla.Modified ? " *" : ""); + } } - } - public FormMain() - { - InitializeComponent(); + public FormMain() + { + InitializeComponent(); - baseTitle = this.Text; + this.baseTitle = Text; - scintilla.AssignCmdKey(Keys.Control | Keys.Shift | Keys.Z, Command.Redo); + this.scintilla.AssignCmdKey(Keys.Control | Keys.Shift | Keys.Z, Command.Redo); - scintilla.LexerName = "cpp"; + this.scintilla.LexerName = "cpp"; - SetScintillaStyles(scintilla); - AdjustLineNumberMargin(scintilla); - AdjustMarkerMargin(scintilla); - AdjustFoldMargin(scintilla); + SetScintillaStyles(this.scintilla); + AdjustLineNumberMargin(this.scintilla); + AdjustMarkerMargin(this.scintilla); + AdjustFoldMargin(this.scintilla); - Version scintillaNetVersion = scintilla.GetType().Assembly.GetName().Version; - string version = scintillaNetVersion.Revision == 0 ? scintillaNetVersion.ToString(3) : scintillaNetVersion.ToString(); - string scintillaVersion = scintilla.ScintillaVersion; - string lexillaVersion = scintilla.LexillaVersion; + Version scintillaNetVersion = this.scintilla.GetType().Assembly.GetName().Version; + string version = scintillaNetVersion.Revision == 0 ? scintillaNetVersion.ToString(3) : scintillaNetVersion.ToString(); + string scintillaVersion = this.scintilla.ScintillaVersion; + string lexillaVersion = this.scintilla.LexillaVersion; - toolStripStatusLabel_Version.Text = $"ScintillaNET v{version} (Scintilla v{scintillaVersion}, Lexilla v{lexillaVersion})"; + this.toolStripStatusLabel_Version.Text = $"ScintillaNET v{version} (Scintilla v{scintillaVersion}, Lexilla v{lexillaVersion})"; - foreach (var group in Lexilla.GetLexerNames().ToArray().OrderBy(x => x).GroupBy(x => char.ToUpperInvariant(x[0]))) - { - char first = group.Key; - - if (group.Count() > 1) + foreach (IGrouping group in Lexilla.GetLexerNames().ToArray().OrderBy(x => x).GroupBy(x => char.ToUpperInvariant(x[0]))) { - var item = (ToolStripMenuItem)lexersToolStripMenuItem.DropDownItems.Add(first.ToString()); - - foreach (string lexer in group) - item.DropDownItems.Add(lexer, null, Lexer_Click); + char first = group.Key; + + if (group.Count() > 1) + { + var item = (ToolStripMenuItem)this.lexersToolStripMenuItem.DropDownItems.Add(first.ToString()); + + foreach (string lexer in group) + item.DropDownItems.Add(lexer, null, Lexer_Click); + } + else + { + this.lexersToolStripMenuItem.DropDownItems.Add(group.Single(), null, Lexer_Click); + } } - else - lexersToolStripMenuItem.DropDownItems.Add(group.Single(), null, Lexer_Click); } - } - - private void Lexer_Click(object sender, EventArgs e) - { - ToolStripItem item = (ToolStripItem)sender; - scintilla.LexerName = item.Text; - SetScintillaStyles(scintilla); - scintilla.Colorize(0, scintilla.TextLength); - AdjustFoldMargin(scintilla); - } - - private void FormMain_Shown(object sender, EventArgs e) - { - scintilla.Select(); - } - - private static void SetScintillaStyles(Scintilla scintilla) - { - scintilla.StyleClearAll(); - - // Configure the CPP (C#) lexer styles - scintilla.Styles[1].ForeColor = Color.FromArgb(0x00, 0x80, 0x00); // COMMENT - scintilla.Styles[2].ForeColor = Color.FromArgb(0x00, 0x80, 0x00); // COMMENT LINE - scintilla.Styles[3].ForeColor = Color.FromArgb(0x00, 0x80, 0x80); // COMMENT DOC - scintilla.Styles[4].ForeColor = Color.FromArgb(0xFF, 0x80, 0x00); // NUMBER - scintilla.Styles[5].ForeColor = Color.FromArgb(0x00, 0x00, 0xFF); // INSTRUCTION WORD - scintilla.Styles[6].ForeColor = Color.FromArgb(0x80, 0x80, 0x80); // STRING - scintilla.Styles[7].ForeColor = Color.FromArgb(0x80, 0x80, 0x80); // CHARACTER - scintilla.Styles[9].ForeColor = Color.FromArgb(0x80, 0x40, 0x00); // PREPROCESSOR - scintilla.Styles[10].ForeColor = Color.FromArgb(0x00, 0x00, 0x80); // OPERATOR - scintilla.Styles[11].ForeColor = Color.FromArgb(0x00, 0x00, 0x00); // DEFAULT - scintilla.Styles[13].ForeColor = Color.FromArgb(0x00, 0x00, 0x00); // VERBATIM - scintilla.Styles[14].ForeColor = Color.FromArgb(0x00, 0x00, 0x00); // REGEX - scintilla.Styles[15].ForeColor = Color.FromArgb(0x00, 0x80, 0x80); // COMMENT LINE DOC - scintilla.Styles[16].ForeColor = Color.FromArgb(0x80, 0x00, 0xFF); // TYPE WORD - scintilla.Styles[17].ForeColor = Color.FromArgb(0x00, 0x80, 0x80); // COMMENT DOC KEYWORD - scintilla.Styles[18].ForeColor = Color.FromArgb(0x00, 0x80, 0x80); // COMMENT DOC KEYWORD ERROR - scintilla.Styles[23].ForeColor = Color.FromArgb(0x00, 0x80, 0x00); // PREPROCESSOR COMMENT - scintilla.Styles[24].ForeColor = Color.FromArgb(0x00, 0x80, 0x80); // PREPROCESSOR COMMENT DOC - scintilla.Styles[5].Bold = true; - scintilla.Styles[10].Bold = true; - scintilla.Styles[14].Bold = true; - scintilla.Styles[17].Bold = true; - - scintilla.SetKeywords(0, - "abstract add alias as ascending async await base break case catch checked continue default delegate descending do dynamic else event explicit extern false finally fixed for foreach from get global goto group if implicit in interface internal into is join let lock nameof namespace new null object operator orderby out override params partial private protected public readonly ref remove return sealed select set sizeof stackalloc switch this throw true try typeof unchecked unsafe using value virtual when where while yield"); - scintilla.SetKeywords(1, - "bool byte char class const decimal double enum float int long nint nuint sbyte short static string struct uint ulong ushort var void"); - } - private static byte CountDigits(int x) - { - if (x == 0) - return 1; + private void Lexer_Click(object sender, EventArgs e) + { + var item = (ToolStripItem)sender; + this.scintilla.LexerName = item.Text; + SetScintillaStyles(this.scintilla); + this.scintilla.Colorize(0, this.scintilla.TextLength); + AdjustFoldMargin(this.scintilla); + } - byte result = 0; - while (x > 0) + private void FormMain_Shown(object sender, EventArgs e) { - result++; - x /= 10; + this.scintilla.Select(); } - return result; - } + private static void SetScintillaStyles(Scintilla scintilla) + { + scintilla.StyleClearAll(); + + // Configure the CPP (C#) lexer styles + scintilla.Styles[1].ForeColor = Color.FromArgb(0x00, 0x80, 0x00); // COMMENT + scintilla.Styles[2].ForeColor = Color.FromArgb(0x00, 0x80, 0x00); // COMMENT LINE + scintilla.Styles[3].ForeColor = Color.FromArgb(0x00, 0x80, 0x80); // COMMENT DOC + scintilla.Styles[4].ForeColor = Color.FromArgb(0xFF, 0x80, 0x00); // NUMBER + scintilla.Styles[5].ForeColor = Color.FromArgb(0x00, 0x00, 0xFF); // INSTRUCTION WORD + scintilla.Styles[6].ForeColor = Color.FromArgb(0x80, 0x80, 0x80); // STRING + scintilla.Styles[7].ForeColor = Color.FromArgb(0x80, 0x80, 0x80); // CHARACTER + scintilla.Styles[9].ForeColor = Color.FromArgb(0x80, 0x40, 0x00); // PREPROCESSOR + scintilla.Styles[10].ForeColor = Color.FromArgb(0x00, 0x00, 0x80); // OPERATOR + scintilla.Styles[11].ForeColor = Color.FromArgb(0x00, 0x00, 0x00); // DEFAULT + scintilla.Styles[13].ForeColor = Color.FromArgb(0x00, 0x00, 0x00); // VERBATIM + scintilla.Styles[14].ForeColor = Color.FromArgb(0x00, 0x00, 0x00); // REGEX + scintilla.Styles[15].ForeColor = Color.FromArgb(0x00, 0x80, 0x80); // COMMENT LINE DOC + scintilla.Styles[16].ForeColor = Color.FromArgb(0x80, 0x00, 0xFF); // TYPE WORD + scintilla.Styles[17].ForeColor = Color.FromArgb(0x00, 0x80, 0x80); // COMMENT DOC KEYWORD + scintilla.Styles[18].ForeColor = Color.FromArgb(0x00, 0x80, 0x80); // COMMENT DOC KEYWORD ERROR + scintilla.Styles[23].ForeColor = Color.FromArgb(0x00, 0x80, 0x00); // PREPROCESSOR COMMENT + scintilla.Styles[24].ForeColor = Color.FromArgb(0x00, 0x80, 0x80); // PREPROCESSOR COMMENT DOC + scintilla.Styles[5].Bold = true; + scintilla.Styles[10].Bold = true; + scintilla.Styles[14].Bold = true; + scintilla.Styles[17].Bold = true; + + scintilla.SetKeywords(0, + "abstract add alias as ascending async await base break case catch checked continue default delegate descending do dynamic else event explicit extern false finally fixed for foreach from get global goto group if implicit in interface internal into is join let lock nameof namespace new null object operator orderby out override params partial private protected public readonly ref remove return sealed select set sizeof stackalloc switch this throw true try typeof unchecked unsafe using value virtual when where while yield"); + scintilla.SetKeywords(1, + "bool byte char class const decimal double enum float int long nint nuint sbyte short static string struct uint ulong ushort var void"); + } - private static readonly Dictionary maxLineNumberCharLengthMap = []; + private static byte CountDigits(int x) + { + if (x == 0) + return 1; - private static void AdjustLineNumberMargin(Scintilla scintilla) - { - int maxLineNumberCharLength = CountDigits(scintilla.Lines.Count); - if (maxLineNumberCharLength == (maxLineNumberCharLengthMap.TryGetValue(scintilla, out int charLen) ? charLen : 0)) - return; + byte result = 0; + while (x > 0) + { + result++; + x /= 10; + } - const int padding = 2; - scintilla.Margins[0].Width = scintilla.TextWidth(Style.LineNumber, new string('0', maxLineNumberCharLength + 1)) + padding; - maxLineNumberCharLengthMap[scintilla] = maxLineNumberCharLength; - } + return result; + } - private static void AdjustMarkerMargin(Scintilla scintilla) - { - scintilla.Margins[1].Width = 16; - scintilla.Margins[1].Sensitive = false; - //scintilla.Markers[Marker.HistoryRevertedToModified].SetForeColor(Color.Orange); - //scintilla.Markers[Marker.HistoryRevertedToModified].SetBackColor(scintilla.Margins[1].BackColor); - //scintilla.Markers[Marker.HistoryRevertedToOrigin].SetForeColor(Color.Orange); - //scintilla.Markers[Marker.HistoryRevertedToOrigin].SetBackColor(scintilla.Margins[1].BackColor); - } + private static readonly Dictionary maxLineNumberCharLengthMap = new Dictionary(); - private static void AdjustFoldMargin(Scintilla scintilla) - { - // Instruct the lexer to calculate folding - scintilla.SetProperty("fold", "1"); + private static void AdjustLineNumberMargin(Scintilla scintilla) + { + int maxLineNumberCharLength = CountDigits(scintilla.Lines.Count); + if (maxLineNumberCharLength == (maxLineNumberCharLengthMap.TryGetValue(scintilla, out int charLen) ? charLen : 0)) + return; - // Configure a margin to display folding symbols - scintilla.Margins[2].Type = MarginType.Symbol; - scintilla.Margins[2].Mask = Marker.MaskFolders; - scintilla.Margins[2].Sensitive = true; - scintilla.Margins[2].Width = 20; + const int padding = 2; + scintilla.Margins[0].Width = scintilla.TextWidth(Style.LineNumber, new string('0', maxLineNumberCharLength + 1)) + padding; + maxLineNumberCharLengthMap[scintilla] = maxLineNumberCharLength; + } - // Set colors for all folding markers - for (int i = 25; i <= 31; i++) + private static void AdjustMarkerMargin(Scintilla scintilla) { - scintilla.Markers[i].SetForeColor(SystemColors.ControlLightLight); - scintilla.Markers[i].SetBackColor(SystemColors.ControlDark); + scintilla.Margins[1].Width = 16; + scintilla.Margins[1].Sensitive = false; + //scintilla.Markers[Marker.HistoryRevertedToModified].SetForeColor(Color.Orange); + //scintilla.Markers[Marker.HistoryRevertedToModified].SetBackColor(scintilla.Margins[1].BackColor); + //scintilla.Markers[Marker.HistoryRevertedToOrigin].SetForeColor(Color.Orange); + //scintilla.Markers[Marker.HistoryRevertedToOrigin].SetBackColor(scintilla.Margins[1].BackColor); } - // Configure folding markers with respective symbols - scintilla.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus; - scintilla.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus; - scintilla.Markers[Marker.FolderEnd].Symbol = MarkerSymbol.BoxPlusConnected; - scintilla.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner; - scintilla.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected; - scintilla.Markers[Marker.FolderSub].Symbol = MarkerSymbol.VLine; - scintilla.Markers[Marker.FolderTail].Symbol = MarkerSymbol.LCorner; - - // Enable automatic folding - scintilla.AutomaticFold = AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change; - } - - private void openToolStripMenuItem_Click(object sender, EventArgs e) - { - if (openFileDialog.ShowDialog(this) == DialogResult.OK) + private static void AdjustFoldMargin(Scintilla scintilla) { - CurrentFileName = openFileDialog.FileName; - scintilla.Text = File.ReadAllText(CurrentFileName, Encoding.UTF8); - scintilla.ClearChangeHistory(); - scintilla.SetSavePoint(); - } - } + // Instruct the lexer to calculate folding + scintilla.SetProperty("fold", "1"); - private void saveToolStripMenuItem_Click(object sender, EventArgs e) - { - if (CurrentFileName is null && saveFileDialog.ShowDialog(this) == DialogResult.OK) - CurrentFileName = saveFileDialog.FileName; + // Configure a margin to display folding symbols + scintilla.Margins[2].Type = MarginType.Symbol; + scintilla.Margins[2].Mask = Marker.MaskFolders; + scintilla.Margins[2].Sensitive = true; + scintilla.Margins[2].Width = 20; - if (CurrentFileName is not null) + // Set colors for all folding markers + for (int i = 25; i <= 31; i++) + { + scintilla.Markers[i].SetForeColor(SystemColors.ControlLightLight); + scintilla.Markers[i].SetBackColor(SystemColors.ControlDark); + } + + // Configure folding markers with respective symbols + scintilla.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus; + scintilla.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus; + scintilla.Markers[Marker.FolderEnd].Symbol = MarkerSymbol.BoxPlusConnected; + scintilla.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner; + scintilla.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected; + scintilla.Markers[Marker.FolderSub].Symbol = MarkerSymbol.VLine; + scintilla.Markers[Marker.FolderTail].Symbol = MarkerSymbol.LCorner; + + // Enable automatic folding + scintilla.AutomaticFold = AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change; + } + + private void openToolStripMenuItem_Click(object sender, EventArgs e) { - File.WriteAllText(CurrentFileName, scintilla.Text, Encoding.UTF8); - scintilla.SetSavePoint(); + if (this.openFileDialog.ShowDialog(this) == DialogResult.OK) + { + CurrentFileName = this.openFileDialog.FileName; + this.scintilla.Text = File.ReadAllText(CurrentFileName, Encoding.UTF8); + this.scintilla.ClearChangeHistory(); + this.scintilla.SetSavePoint(); + } } - } - private void FormMain_FormClosing(object sender, FormClosingEventArgs e) - { - //if (scintilla.Modified) - //{ - // if (MessageBox.Show("You have unsaved changes, are you sure to exit?", "Scintilla", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel) - // e.Cancel = true; - //} - } + private void saveToolStripMenuItem_Click(object sender, EventArgs e) + { + if (CurrentFileName is null && this.saveFileDialog.ShowDialog(this) == DialogResult.OK) + CurrentFileName = this.saveFileDialog.FileName; - private void describeKeywordSetsToolStripMenuItem_Click(object sender, EventArgs e) - { - scintilla.ReplaceSelection(scintilla.DescribeKeywordSets()); - } + if (CurrentFileName != null) + { + File.WriteAllText(CurrentFileName, this.scintilla.Text, Encoding.UTF8); + this.scintilla.SetSavePoint(); + } + } - private void scintilla_TextChanged(object sender, EventArgs e) - { - AdjustLineNumberMargin(scintilla); - } + private void FormMain_FormClosing(object sender, FormClosingEventArgs e) + { + //if (scintilla.Modified) + //{ + // if (MessageBox.Show("You have unsaved changes, are you sure to exit?", "Scintilla", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel) + // e.Cancel = true; + //} + } - private void scintilla_SavePointLeft(object sender, EventArgs e) - { - Text = BaseTitle + " *"; - } + private void describeKeywordSetsToolStripMenuItem_Click(object sender, EventArgs e) + { + this.scintilla.ReplaceSelection(this.scintilla.DescribeKeywordSets()); + } - private void scintilla_SavePointReached(object sender, EventArgs e) - { - Text = BaseTitle; - } + private void scintilla_TextChanged(object sender, EventArgs e) + { + AdjustLineNumberMargin(this.scintilla); + } - private void toolStripMenuItem_Find_Click(object sender, EventArgs e) - { - Search(toolStripTextBox_Find.Text); - } + private void scintilla_SavePointLeft(object sender, EventArgs e) + { + Text = BaseTitle + " *"; + } - private void Search(string text, bool reverse = false) - { - if (string.IsNullOrEmpty(text)) - return; + private void scintilla_SavePointReached(object sender, EventArgs e) + { + Text = BaseTitle; + } + + private void toolStripMenuItem_Find_Click(object sender, EventArgs e) + { + Search(this.toolStripTextBox_Find.Text); + } - int start = reverse ? scintilla.AnchorPosition : scintilla.CurrentPosition; - int end = reverse ? 0 : scintilla.TextLength; - int pos = scintilla.FindText(SearchFlags.None, text, start, end); - if (pos == -1) + private void Search(string text, bool reverse = false) { - start = reverse ? scintilla.TextLength : 0; - end = reverse ? scintilla.AnchorPosition - text.Length : scintilla.CurrentPosition + text.Length; - pos = scintilla.FindText(SearchFlags.None, text, start, end); + if (string.IsNullOrEmpty(text)) + return; + + int start = reverse ? this.scintilla.AnchorPosition : this.scintilla.CurrentPosition; + int end = reverse ? 0 : this.scintilla.TextLength; + int pos = this.scintilla.FindText(SearchFlags.None, text, start, end); if (pos == -1) { - toolStripStatusLabel.Text = $"\"{text}\" not found in document."; - return; + start = reverse ? this.scintilla.TextLength : 0; + end = reverse ? this.scintilla.AnchorPosition - text.Length : this.scintilla.CurrentPosition + text.Length; + pos = this.scintilla.FindText(SearchFlags.None, text, start, end); + if (pos == -1) + { + this.toolStripStatusLabel.Text = $"\"{text}\" not found in document."; + return; + } + else + { + this.toolStripStatusLabel.Text = $"Search wrapped."; + } } else - toolStripStatusLabel.Text = $"Search wrapped."; - } - else - toolStripStatusLabel.Text = ""; + { + this.toolStripStatusLabel.Text = ""; + } - int caret = pos + text.Length, anchor = pos; - scintilla.SetSelection(caret, anchor); - scintilla.ScrollRange(anchor, caret); - } + int caret = pos + text.Length, anchor = pos; + this.scintilla.SetSelection(caret, anchor); + this.scintilla.ScrollRange(anchor, caret); + } - private void toolStripTextBox_Find_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter && (e.Modifiers & ~Keys.Shift) == 0) + private void toolStripTextBox_Find_KeyDown(object sender, KeyEventArgs e) { - Search(toolStripTextBox_Find.Text, e.Shift); - e.Handled = true; - e.SuppressKeyPress = true; + if (e.KeyCode == Keys.Enter && (e.Modifiers & ~Keys.Shift) == 0) + { + Search(this.toolStripTextBox_Find.Text, e.Shift); + e.Handled = true; + e.SuppressKeyPress = true; + } } } } diff --git a/Scintilla.NET.TestApp/Program.cs b/Scintilla.NET.TestApp/Program.cs index f12649f..b925d3a 100644 --- a/Scintilla.NET.TestApp/Program.cs +++ b/Scintilla.NET.TestApp/Program.cs @@ -1,18 +1,19 @@ using System; using System.Windows.Forms; -namespace ScintillaNET.TestApp; - -static class Program +namespace ScintillaNET.TestApp { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() + internal static class Program { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new FormMain()); + /// + /// The main entry point for the application. + /// + [STAThread] + private static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new FormMain()); + } } } diff --git a/Scintilla.NET.TestApp/Scintilla.NET.TestApp.csproj b/Scintilla.NET.TestApp/Scintilla.NET.TestApp.csproj index 08a1be7..b71e057 100644 --- a/Scintilla.NET.TestApp/Scintilla.NET.TestApp.csproj +++ b/Scintilla.NET.TestApp/Scintilla.NET.TestApp.csproj @@ -9,11 +9,9 @@ desjarlais A test application to validate that the ScintillaNET control is working. true - latest AnyCPU app.manifest ScintillaNET.TestApp - enable diff --git a/Scintilla.NET/Annotation.cs b/Scintilla.NET/Annotation.cs index d991b90..bc307c8 100644 --- a/Scintilla.NET/Annotation.cs +++ b/Scintilla.NET/Annotation.cs @@ -1,27 +1,28 @@ -namespace ScintillaNET; - -/// -/// Visibility and location of annotations in a control -/// -public enum Annotation +namespace ScintillaNET { /// - /// Annotations are not displayed. This is the default. + /// Visibility and location of annotations in a control /// - Hidden = NativeMethods.ANNOTATION_HIDDEN, + public enum Annotation + { + /// + /// Annotations are not displayed. This is the default. + /// + Hidden = NativeMethods.ANNOTATION_HIDDEN, - /// - /// Annotations are drawn left justified with no adornment. - /// - Standard = NativeMethods.ANNOTATION_STANDARD, + /// + /// Annotations are drawn left justified with no adornment. + /// + Standard = NativeMethods.ANNOTATION_STANDARD, - /// - /// Annotations are indented to match the text and are surrounded by a box. - /// - Boxed = NativeMethods.ANNOTATION_BOXED, + /// + /// Annotations are indented to match the text and are surrounded by a box. + /// + Boxed = NativeMethods.ANNOTATION_BOXED, - /// - /// Annotations are indented to match the text. - /// - Indented = NativeMethods.ANNOTATION_INDENTED + /// + /// Annotations are indented to match the text. + /// + Indented = NativeMethods.ANNOTATION_INDENTED + } } diff --git a/Scintilla.NET/AutoCSelectionChangeEventArgs.cs b/Scintilla.NET/AutoCSelectionChangeEventArgs.cs index 99fce0d..32965a1 100644 --- a/Scintilla.NET/AutoCSelectionChangeEventArgs.cs +++ b/Scintilla.NET/AutoCSelectionChangeEventArgs.cs @@ -27,7 +27,7 @@ public int Position { get { - this.position ??= this.scintilla.Lines.ByteToCharPosition(this.bytePosition); + this.position = this.position ?? this.scintilla.Lines.ByteToCharPosition(this.bytePosition); return (int)this.position; } diff --git a/Scintilla.NET/AutoCSelectionEventArgs.cs b/Scintilla.NET/AutoCSelectionEventArgs.cs index 83a86d3..d416765 100644 --- a/Scintilla.NET/AutoCSelectionEventArgs.cs +++ b/Scintilla.NET/AutoCSelectionEventArgs.cs @@ -1,81 +1,82 @@ using System; -namespace ScintillaNET; - -/// -/// Provides data for the event. -/// -public class AutoCSelectionEventArgs : EventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - private readonly IntPtr textPtr; - private readonly int bytePosition; - private int? position; - private string text; - /// - /// Gets the fillup character that caused the completion. + /// Provides data for the event. /// - /// The fillup character used to cause the completion; otherwise, 0. - /// Only a of will return a non-zero character. - /// - public int Char { get; private set; } + public class AutoCSelectionEventArgs : EventArgs + { + private readonly Scintilla scintilla; + private readonly IntPtr textPtr; + private readonly int bytePosition; + private int? position; + private string text; - /// - /// Gets a value indicating how the completion occurred. - /// - /// One of the enumeration values. - public ListCompletionMethod ListCompletionMethod { get; private set; } + /// + /// Gets the fillup character that caused the completion. + /// + /// The fillup character used to cause the completion; otherwise, 0. + /// Only a of will return a non-zero character. + /// + public int Char { get; private set; } - /// - /// Gets the start position of the word being completed. - /// - /// The zero-based document position of the word being completed. - public int Position - { - get + /// + /// Gets a value indicating how the completion occurred. + /// + /// One of the enumeration values. + public ListCompletionMethod ListCompletionMethod { get; private set; } + + /// + /// Gets the start position of the word being completed. + /// + /// The zero-based document position of the word being completed. + public int Position { - this.position ??= this.scintilla.Lines.ByteToCharPosition(this.bytePosition); + get + { + this.position = this.position ?? this.scintilla.Lines.ByteToCharPosition(this.bytePosition); - return (int)this.position; + return (int)this.position; + } } - } - /// - /// Gets the text of the selected autocompletion item. - /// - /// The selected autocompletion item text. - public unsafe string Text - { - get + /// + /// Gets the text of the selected autocompletion item. + /// + /// The selected autocompletion item text. + public unsafe string Text { - if (this.text == null) + get { - int len = 0; - while (((byte*)this.textPtr)[len] != 0) - len++; + if (this.text == null) + { + int len = 0; + while (((byte*)this.textPtr)[len] != 0) + len++; - this.text = Helpers.GetString(this.textPtr, len, this.scintilla.Encoding); - } + this.text = Helpers.GetString(this.textPtr, len, this.scintilla.Encoding); + } - return this.text; + return this.text; + } } - } - /// - /// Initializes a new instance of the class. - /// - /// The control that generated this event. - /// The zero-based byte position within the document of the word being completed. - /// A pointer to the selected autocompletion text. - /// The character that caused the completion. - /// A value indicating the way in which the completion occurred. - public AutoCSelectionEventArgs(Scintilla scintilla, int bytePosition, IntPtr text, int ch, ListCompletionMethod listCompletionMethod) - { - this.scintilla = scintilla; - this.bytePosition = bytePosition; - this.textPtr = text; - Char = ch; - ListCompletionMethod = listCompletionMethod; + /// + /// Initializes a new instance of the class. + /// + /// The control that generated this event. + /// The zero-based byte position within the document of the word being completed. + /// A pointer to the selected autocompletion text. + /// The character that caused the completion. + /// A value indicating the way in which the completion occurred. + public AutoCSelectionEventArgs(Scintilla scintilla, int bytePosition, IntPtr text, int ch, ListCompletionMethod listCompletionMethod) + { + this.scintilla = scintilla; + this.bytePosition = bytePosition; + this.textPtr = text; + Char = ch; + ListCompletionMethod = listCompletionMethod; + } } } diff --git a/Scintilla.NET/AutomaticFold.cs b/Scintilla.NET/AutomaticFold.cs index b1094b7..a7b90e7 100644 --- a/Scintilla.NET/AutomaticFold.cs +++ b/Scintilla.NET/AutomaticFold.cs @@ -1,31 +1,32 @@ using System; -namespace ScintillaNET; - -/// -/// Configuration options for automatic code folding. -/// -/// This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values. -[Flags] -public enum AutomaticFold +namespace ScintillaNET { /// - /// Automatic folding is disabled. This is the default. + /// Configuration options for automatic code folding. /// - None = 0, + /// This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values. + [Flags] + public enum AutomaticFold + { + /// + /// Automatic folding is disabled. This is the default. + /// + None = 0, - /// - /// Automatically show lines as needed. The event is not raised when this value is used. - /// - Show = NativeMethods.SC_AUTOMATICFOLD_SHOW, + /// + /// Automatically show lines as needed. The event is not raised when this value is used. + /// + Show = NativeMethods.SC_AUTOMATICFOLD_SHOW, - /// - /// Handle clicks in fold margin automatically. The event is not raised for folding margins when this value is used. - /// - Click = NativeMethods.SC_AUTOMATICFOLD_CLICK, + /// + /// Handle clicks in fold margin automatically. The event is not raised for folding margins when this value is used. + /// + Click = NativeMethods.SC_AUTOMATICFOLD_CLICK, - /// - /// Show lines as needed when the fold structure is changed. - /// - Change = NativeMethods.SC_AUTOMATICFOLD_CHANGE + /// + /// Show lines as needed when the fold structure is changed. + /// + Change = NativeMethods.SC_AUTOMATICFOLD_CHANGE + } } diff --git a/Scintilla.NET/BeforeModificationEventArgs.cs b/Scintilla.NET/BeforeModificationEventArgs.cs index ff5ff62..73d317d 100644 --- a/Scintilla.NET/BeforeModificationEventArgs.cs +++ b/Scintilla.NET/BeforeModificationEventArgs.cs @@ -1,84 +1,85 @@ using System; -namespace ScintillaNET; - -/// -/// Provides data for the and events. -/// -public class BeforeModificationEventArgs : EventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - private readonly int bytePosition; - private readonly int byteLength; - private readonly IntPtr textPtr; - - internal int? CachedPosition { get; set; } - internal string CachedText { get; set; } - /// - /// Gets the zero-based document position where the modification will occur. + /// Provides data for the and events. /// - /// The zero-based character position within the document where text will be inserted or deleted. - public int Position + public class BeforeModificationEventArgs : EventArgs { - get + private readonly Scintilla scintilla; + private readonly int bytePosition; + private readonly int byteLength; + private readonly IntPtr textPtr; + + internal int? CachedPosition { get; set; } + internal string CachedText { get; set; } + + /// + /// Gets the zero-based document position where the modification will occur. + /// + /// The zero-based character position within the document where text will be inserted or deleted. + public int Position { - CachedPosition ??= this.scintilla.Lines.ByteToCharPosition(this.bytePosition); + get + { + CachedPosition = CachedPosition ?? this.scintilla.Lines.ByteToCharPosition(this.bytePosition); - return (int)CachedPosition; + return (int)CachedPosition; + } } - } - /// - /// Gets the source of the modification. - /// - /// One of the enum values. - public ModificationSource Source { get; private set; } + /// + /// Gets the source of the modification. + /// + /// One of the enum values. + public ModificationSource Source { get; private set; } - /// - /// Gets the text being inserted or deleted. - /// - /// - /// The text about to be inserted or deleted. - /// - public virtual unsafe string Text - { - get + /// + /// Gets the text being inserted or deleted. + /// + /// + /// The text about to be inserted or deleted. + /// + public virtual unsafe string Text { - if (CachedText == null) + get { - // For some reason the Scintilla overlords don't provide text in - // SC_MOD_BEFOREDELETE... but we can get it from the document. - if (this.textPtr == IntPtr.Zero) - { - IntPtr ptr = this.scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, new IntPtr(this.bytePosition), new IntPtr(this.byteLength)); - CachedText = new string((sbyte*)ptr, 0, this.byteLength, this.scintilla.Encoding); - } - else + if (CachedText == null) { - CachedText = Helpers.GetString(this.textPtr, this.byteLength, this.scintilla.Encoding); + // For some reason the Scintilla overlords don't provide text in + // SC_MOD_BEFOREDELETE... but we can get it from the document. + if (this.textPtr == IntPtr.Zero) + { + IntPtr ptr = this.scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, new IntPtr(this.bytePosition), new IntPtr(this.byteLength)); + CachedText = new string((sbyte*)ptr, 0, this.byteLength, this.scintilla.Encoding); + } + else + { + CachedText = Helpers.GetString(this.textPtr, this.byteLength, this.scintilla.Encoding); + } } - } - return CachedText; + return CachedText; + } } - } - /// - /// Initializes a new instance of the class. - /// - /// The control that generated this event. - /// The source of the modification. - /// The zero-based byte position within the document where text is being modified. - /// The length in bytes of the text being modified. - /// A pointer to the text being inserted. - public BeforeModificationEventArgs(Scintilla scintilla, ModificationSource source, int bytePosition, int byteLength, IntPtr text) - { - this.scintilla = scintilla; - this.bytePosition = bytePosition; - this.byteLength = byteLength; - this.textPtr = text; + /// + /// Initializes a new instance of the class. + /// + /// The control that generated this event. + /// The source of the modification. + /// The zero-based byte position within the document where text is being modified. + /// The length in bytes of the text being modified. + /// A pointer to the text being inserted. + public BeforeModificationEventArgs(Scintilla scintilla, ModificationSource source, int bytePosition, int byteLength, IntPtr text) + { + this.scintilla = scintilla; + this.bytePosition = bytePosition; + this.byteLength = byteLength; + this.textPtr = text; - Source = source; + Source = source; + } } } diff --git a/Scintilla.NET/BiDirectionalDisplayType.cs b/Scintilla.NET/BiDirectionalDisplayType.cs index 3eabe66..5e6ca6c 100644 --- a/Scintilla.NET/BiDirectionalDisplayType.cs +++ b/Scintilla.NET/BiDirectionalDisplayType.cs @@ -1,22 +1,23 @@ -namespace ScintillaNET; - -/// -/// The display type for the property. -/// -public enum BiDirectionalDisplayType +namespace ScintillaNET { /// - /// The bi-directional display type is disabled. + /// The display type for the property. /// - Disabled = NativeMethods.SC_BIDIRECTIONAL_DISABLED, + public enum BiDirectionalDisplayType + { + /// + /// The bi-directional display type is disabled. + /// + Disabled = NativeMethods.SC_BIDIRECTIONAL_DISABLED, - /// - /// The bi-directional display type is left-to-right. - /// - LeftToRight = NativeMethods.SC_BIDIRECTIONAL_L2R, + /// + /// The bi-directional display type is left-to-right. + /// + LeftToRight = NativeMethods.SC_BIDIRECTIONAL_L2R, - /// - /// The bi-directional display type is right-to-left. - /// - RightToLeft = NativeMethods.SC_BIDIRECTIONAL_R2L + /// + /// The bi-directional display type is right-to-left. + /// + RightToLeft = NativeMethods.SC_BIDIRECTIONAL_R2L + } } diff --git a/Scintilla.NET/CallTipClickEventArgs.cs b/Scintilla.NET/CallTipClickEventArgs.cs index 43b9523..d6e7b5a 100644 --- a/Scintilla.NET/CallTipClickEventArgs.cs +++ b/Scintilla.NET/CallTipClickEventArgs.cs @@ -1,27 +1,28 @@ using System; -namespace ScintillaNET; - -/// -/// Provides data for the event. -/// -public class CallTipClickEventArgs : EventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - /// - /// Gets the type of the call tip click. + /// Provides data for the event. /// - public CallTipClickType CallTipClickType { get; internal set; } - - /// - /// Initializes a new instance of the class. - /// - /// The control that generated this event. - /// /// Type of the call tip click. - public CallTipClickEventArgs(Scintilla scintilla, CallTipClickType callTipClickType) + public class CallTipClickEventArgs : EventArgs { - this.scintilla = scintilla; - CallTipClickType = callTipClickType; + private readonly Scintilla scintilla; + + /// + /// Gets the type of the call tip click. + /// + public CallTipClickType CallTipClickType { get; internal set; } + + /// + /// Initializes a new instance of the class. + /// + /// The control that generated this event. + /// /// Type of the call tip click. + public CallTipClickEventArgs(Scintilla scintilla, CallTipClickType callTipClickType) + { + this.scintilla = scintilla; + CallTipClickType = callTipClickType; + } } } diff --git a/Scintilla.NET/CallTipClickType.cs b/Scintilla.NET/CallTipClickType.cs index b9ca2c5..0a79d87 100644 --- a/Scintilla.NET/CallTipClickType.cs +++ b/Scintilla.NET/CallTipClickType.cs @@ -1,22 +1,23 @@ -namespace ScintillaNET; - -/// -/// The type of a call tip click. -/// -public enum CallTipClickType +namespace ScintillaNET { /// - /// The call tip was clicked elsewhere; not the up or down arrows. + /// The type of a call tip click. /// - Elsewhere = 0, + public enum CallTipClickType + { + /// + /// The call tip was clicked elsewhere; not the up or down arrows. + /// + Elsewhere = 0, - /// - /// The call tip up arrow was clicked. - /// - UpArrow = 1, + /// + /// The call tip up arrow was clicked. + /// + UpArrow = 1, - /// - /// The call tip down arrow was clicked. - /// - DownArrow = 2, + /// + /// The call tip down arrow was clicked. + /// + DownArrow = 2, + } } diff --git a/Scintilla.NET/CaretStyle.cs b/Scintilla.NET/CaretStyle.cs index 137c227..a370f43 100644 --- a/Scintilla.NET/CaretStyle.cs +++ b/Scintilla.NET/CaretStyle.cs @@ -1,22 +1,23 @@ -namespace ScintillaNET; - -/// -/// The caret visual style. -/// -public enum CaretStyle +namespace ScintillaNET { /// - /// The caret is not displayed. + /// The caret visual style. /// - Invisible = NativeMethods.CARETSTYLE_INVISIBLE, + 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 vertical line. + /// + Line = NativeMethods.CARETSTYLE_LINE, - /// - /// The caret is drawn as a block. - /// - Block = NativeMethods.CARETSTYLE_BLOCK + /// + /// The caret is drawn as a block. + /// + Block = NativeMethods.CARETSTYLE_BLOCK + } } diff --git a/Scintilla.NET/ChangeAnnotationEventArgs.cs b/Scintilla.NET/ChangeAnnotationEventArgs.cs index 84c6575..65ad6d5 100644 --- a/Scintilla.NET/ChangeAnnotationEventArgs.cs +++ b/Scintilla.NET/ChangeAnnotationEventArgs.cs @@ -1,24 +1,25 @@ using System; -namespace ScintillaNET; - -/// -/// Provides data for the event. -/// -public class ChangeAnnotationEventArgs : EventArgs +namespace ScintillaNET { /// - /// Gets the line index where the annotation changed. + /// Provides data for the event. /// - /// The zero-based line index where the annotation change occurred. - public int Line { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// The zero-based line index of the annotation that changed. - public ChangeAnnotationEventArgs(int line) + public class ChangeAnnotationEventArgs : EventArgs { - Line = line; + /// + /// Gets the line index where the annotation changed. + /// + /// The zero-based line index where the annotation change occurred. + public int Line { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + /// The zero-based line index of the annotation that changed. + public ChangeAnnotationEventArgs(int line) + { + Line = line; + } } } diff --git a/Scintilla.NET/ChangeHistory.cs b/Scintilla.NET/ChangeHistory.cs index 41c1824..138773a 100644 --- a/Scintilla.NET/ChangeHistory.cs +++ b/Scintilla.NET/ChangeHistory.cs @@ -1,30 +1,31 @@ using System; -namespace ScintillaNET; - -/// -/// Bit-flags for whether Scintilla should keep track of document change history and in which ways it should display the difference. -/// -[Flags] -public enum ChangeHistory : int +namespace ScintillaNET { /// - /// The default: change history turned off. + /// Bit-flags for whether Scintilla should keep track of document change history and in which ways it should display the difference. /// - Disabled = NativeMethods.SC_CHANGE_HISTORY_DISABLED, + [Flags] + public enum ChangeHistory : int + { + /// + /// The default: change history turned off. + /// + Disabled = NativeMethods.SC_CHANGE_HISTORY_DISABLED, - /// - /// Track changes to the document. - /// - Enabled = NativeMethods.SC_CHANGE_HISTORY_ENABLED, + /// + /// Track changes to the document. + /// + Enabled = NativeMethods.SC_CHANGE_HISTORY_ENABLED, - /// - /// Display changes in the margin using the SC_MARKNUM_HISTORY markers. - /// - Markers = NativeMethods.SC_CHANGE_HISTORY_MARKERS, + /// + /// Display changes in the margin using the SC_MARKNUM_HISTORY markers. + /// + Markers = NativeMethods.SC_CHANGE_HISTORY_MARKERS, - /// - /// Display changes in the text using the INDICATOR_HISTORY indicators. - /// - Indicators = NativeMethods.SC_CHANGE_HISTORY_INDICATORS, + /// + /// Display changes in the text using the INDICATOR_HISTORY indicators. + /// + Indicators = NativeMethods.SC_CHANGE_HISTORY_INDICATORS, + } } diff --git a/Scintilla.NET/CharAddedEventArgs.cs b/Scintilla.NET/CharAddedEventArgs.cs index 442d0ab..4fe2a3e 100644 --- a/Scintilla.NET/CharAddedEventArgs.cs +++ b/Scintilla.NET/CharAddedEventArgs.cs @@ -1,24 +1,25 @@ using System; -namespace ScintillaNET; - -/// -/// Provides data for the event. -/// -public class CharAddedEventArgs : EventArgs +namespace ScintillaNET { /// - /// Gets the text character added to a control. + /// Provides data for the event. /// - /// The character added. - public int Char { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// The character added. - public CharAddedEventArgs(int ch) + public class CharAddedEventArgs : EventArgs { - Char = ch; + /// + /// 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/Scintilla.NET/ColorSpace.cs b/Scintilla.NET/ColorSpace.cs index 3667e13..c93fad6 100644 --- a/Scintilla.NET/ColorSpace.cs +++ b/Scintilla.NET/ColorSpace.cs @@ -1,97 +1,112 @@ using System; using System.Drawing; -namespace ScintillaNET; - -internal class ColorSpace -{ - public static float SrgbToLinearSrgb(float x) => - x >= 0.04045 ? (float)Math.Pow((x + 0.055f) / (1 + 0.055f), 2.4f) : x / 12.92f; - - public static float LinearSrgbToSrgb(float x) => - x >= 0.0031308 ? 1.055f * (float)Math.Pow(x, 1.0 / 2.4) - 0.055f : 12.92f * x; -} - -/// -/// OkLab color. -/// -/// Luminance (perceived lightness) in range [0.0, 1.0]. -/// How green/red the color is in range [-0.233887, +0.276216]. -/// How blue/yellow the color is in range [-0.311528, +0.198570]. -internal struct OkLab(float L, float a, float b) +namespace ScintillaNET { - public float L = L; - public float a = a; - public float b = b; - - public readonly Srgb ToLinearSrgb() + internal class ColorSpace { - float l_ = this.L + 0.3963377774f * this.a + 0.2158037573f * this.b; - float m_ = this.L - 0.1055613458f * this.a - 0.0638541728f * this.b; - float s_ = this.L - 0.0894841775f * this.a - 1.2914855480f * this.b; - - float l = l_ * l_ * l_; - float m = m_ * m_ * m_; - float s = s_ * s_ * s_; - - return new Srgb( - Helpers.Clamp(+4.0767416621f * l - 3.3077115913f * m + 0.2309699292f * s, 0, 1), - Helpers.Clamp(-1.2684380046f * l + 2.6097574011f * m - 0.3413193965f * s, 0, 1), - Helpers.Clamp(-0.0041960863f * l - 0.7034186147f * m + 1.7076147010f * s, 0, 1) - ); - } + public static float SrgbToLinearSrgb(float x) => + x >= 0.04045 ? (float)Math.Pow((x + 0.055f) / (1 + 0.055f), 2.4f) : x / 12.92f; - public override readonly string ToString() - { - return FormattableString.Invariant($"(L:{L}, a:{a}, b:{b})"); + public static float LinearSrgbToSrgb(float x) => + x >= 0.0031308 ? 1.055f * (float)Math.Pow(x, 1.0 / 2.4) - 0.055f : 12.92f * x; } -} - -/// -/// sRGB color. -/// -/// Red component. -/// Green component. -/// Blue component. -internal struct Srgb(float R, float G, float B) -{ - public float R = R; - public float G = G; - public float B = B; - public readonly OkLab ToOkLab() + /// + /// OkLab color. + /// + internal struct OkLab { - float l = 0.4122214708f * this.R + 0.5363325363f * this.G + 0.0514459929f * this.B; - float m = 0.2119034982f * this.R + 0.6806995451f * this.G + 0.1073969566f * this.B; - float s = 0.0883024619f * this.R + 0.2817188376f * this.G + 0.6299787005f * this.B; - - float l_ = (float)Math.Pow(l, 1.0 / 3.0); - float m_ = (float)Math.Pow(m, 1.0 / 3.0); - float s_ = (float)Math.Pow(s, 1.0 / 3.0); - - return new OkLab( - 0.2104542553f * l_ + 0.7936177850f * m_ - 0.0040720468f * s_, - 1.9779984951f * l_ - 2.4285922050f * m_ + 0.4505937099f * s_, - 0.0259040371f * l_ + 0.7827717662f * m_ - 0.8086757660f * s_ - ); + public float L; + public float a; + public float b; + + /// Luminance (perceived lightness) in range [0.0, 1.0]. + /// How green/red the color is in range [-0.233887, +0.276216]. + /// How blue/yellow the color is in range [-0.311528, +0.198570]. + public OkLab(float L, float a, float b) + { + this.L = L; + this.a = a; + this.b = b; + } + + public Srgb ToLinearSrgb() + { + float l_ = this.L + 0.3963377774f * this.a + 0.2158037573f * this.b; + float m_ = this.L - 0.1055613458f * this.a - 0.0638541728f * this.b; + float s_ = this.L - 0.0894841775f * this.a - 1.2914855480f * this.b; + + float l = l_ * l_ * l_; + float m = m_ * m_ * m_; + float s = s_ * s_ * s_; + + return new Srgb( + Helpers.Clamp(+4.0767416621f * l - 3.3077115913f * m + 0.2309699292f * s, 0, 1), + Helpers.Clamp(-1.2684380046f * l + 2.6097574011f * m - 0.3413193965f * s, 0, 1), + Helpers.Clamp(-0.0041960863f * l - 0.7034186147f * m + 1.7076147010f * s, 0, 1) + ); + } + + public override string ToString() + { + return FormattableString.Invariant($"(L:{this.L}, a:{this.a}, b:{this.b})"); + } } - public static Srgb FromColor(Color c) => new(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f); - - public readonly Color ToColor() => Color.FromArgb((byte)(this.R * 255), (byte)(this.G * 255), (byte)(this.B * 255)); - - public readonly Srgb ToLinearSrgb() => - new(Helpers.Clamp(ColorSpace.SrgbToLinearSrgb(R), 0f, 1f), - Helpers.Clamp(ColorSpace.SrgbToLinearSrgb(G), 0f, 1f), - Helpers.Clamp(ColorSpace.SrgbToLinearSrgb(B), 0f, 1f)); - - public readonly Srgb ToSrgb() => - new(Helpers.Clamp(ColorSpace.LinearSrgbToSrgb(R), 0f, 1f), - Helpers.Clamp(ColorSpace.LinearSrgbToSrgb(G), 0f, 1f), - Helpers.Clamp(ColorSpace.LinearSrgbToSrgb(B), 0f, 1f)); - - public override readonly string ToString() + /// + /// sRGB color. + /// + internal struct Srgb { - return FormattableString.Invariant($"(R:{R}, G:{G}, B:{B})"); + public float R; + public float G; + public float B; + + /// Red component. + /// Green component. + /// Blue component. + public Srgb(float R, float G, float B) + { + this.R = R; + this.G = G; + this.B = B; + } + + public OkLab ToOkLab() + { + float l = 0.4122214708f * this.R + 0.5363325363f * this.G + 0.0514459929f * this.B; + float m = 0.2119034982f * this.R + 0.6806995451f * this.G + 0.1073969566f * this.B; + float s = 0.0883024619f * this.R + 0.2817188376f * this.G + 0.6299787005f * this.B; + + float l_ = (float)Math.Pow(l, 1.0 / 3.0); + float m_ = (float)Math.Pow(m, 1.0 / 3.0); + float s_ = (float)Math.Pow(s, 1.0 / 3.0); + + return new OkLab( + 0.2104542553f * l_ + 0.7936177850f * m_ - 0.0040720468f * s_, + 1.9779984951f * l_ - 2.4285922050f * m_ + 0.4505937099f * s_, + 0.0259040371f * l_ + 0.7827717662f * m_ - 0.8086757660f * s_ + ); + } + + public static Srgb FromColor(Color c) => new Srgb(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f); + + public Color ToColor() => Color.FromArgb((byte)(this.R * 255), (byte)(this.G * 255), (byte)(this.B * 255)); + + public Srgb ToLinearSrgb() => + new Srgb(Helpers.Clamp(ColorSpace.SrgbToLinearSrgb(this.R), 0f, 1f), + Helpers.Clamp(ColorSpace.SrgbToLinearSrgb(this.G), 0f, 1f), + Helpers.Clamp(ColorSpace.SrgbToLinearSrgb(this.B), 0f, 1f)); + + public Srgb ToSrgb() => + new Srgb(Helpers.Clamp(ColorSpace.LinearSrgbToSrgb(this.R), 0f, 1f), + Helpers.Clamp(ColorSpace.LinearSrgbToSrgb(this.G), 0f, 1f), + Helpers.Clamp(ColorSpace.LinearSrgbToSrgb(this.B), 0f, 1f)); + + public override string ToString() + { + return FormattableString.Invariant($"(R:{this.R}, G:{this.G}, B:{this.B})"); + } } } diff --git a/Scintilla.NET/Command.cs b/Scintilla.NET/Command.cs index 3aa3b69..6a6396a 100644 --- a/Scintilla.NET/Command.cs +++ b/Scintilla.NET/Command.cs @@ -1,580 +1,581 @@ -namespace ScintillaNET; - -/// -/// Actions which can be performed by the application or bound to keys in a control. -/// -public enum Command +namespace ScintillaNET { /// - /// When bound to keys performs the standard platform behavior. - /// - Default = 0, - - /// - /// Performs no action and when bound to keys prevents them from propagating to the parent window. - /// - Null = NativeMethods.SCI_NULL, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret down one line. - /// - LineDown = NativeMethods.SCI_LINEDOWN, - - /// - /// Extends the selection down one line. - /// - LineDownExtend = NativeMethods.SCI_LINEDOWNEXTEND, - - /// - /// Extends the rectangular selection down one line. - /// - LineDownRectExtend = NativeMethods.SCI_LINEDOWNRECTEXTEND, - - /// - /// Scrolls down one line. - /// - LineScrollDown = NativeMethods.SCI_LINESCROLLDOWN, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret up one line. - /// - LineUp = NativeMethods.SCI_LINEUP, - - /// - /// Extends the selection up one line. - /// - LineUpExtend = NativeMethods.SCI_LINEUPEXTEND, - - /// - /// Extends the rectangular selection up one line. - /// - LineUpRectExtend = NativeMethods.SCI_LINEUPRECTEXTEND, - - /// - /// Scrolls up one line. - /// - LineScrollUp = NativeMethods.SCI_LINESCROLLUP, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret down one paragraph. - /// - ParaDown = NativeMethods.SCI_PARADOWN, - - /// - /// Extends the selection down one paragraph. - /// - ParaDownExtend = NativeMethods.SCI_PARADOWNEXTEND, - - /// - /// Moves the caret up one paragraph. - /// - ParaUp = NativeMethods.SCI_PARAUP, - - /// - /// Extends the selection up one paragraph. - /// - ParaUpExtend = NativeMethods.SCI_PARAUPEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret left one character. - /// - CharLeft = NativeMethods.SCI_CHARLEFT, - - /// - /// Extends the selection left one character. - /// - CharLeftExtend = NativeMethods.SCI_CHARLEFTEXTEND, - - /// - /// Extends the rectangular selection left one character. - /// - CharLeftRectExtend = NativeMethods.SCI_CHARLEFTRECTEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret right one character. - /// - CharRight = NativeMethods.SCI_CHARRIGHT, - - /// - /// Extends the selection right one character. - /// - CharRightExtend = NativeMethods.SCI_CHARRIGHTEXTEND, - - /// - /// Extends the rectangular selection right one character. - /// - CharRightRectExtend = NativeMethods.SCI_CHARRIGHTRECTEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret to the start of the previous word. - /// - WordLeft = NativeMethods.SCI_WORDLEFT, - - /// - /// Extends the selection to the start of the previous word. - /// - WordLeftExtend = NativeMethods.SCI_WORDLEFTEXTEND, - - /// - /// Moves the caret to the start of the next word. - /// - WordRight = NativeMethods.SCI_WORDRIGHT, - - /// - /// Extends the selection to the start of the next word. - /// - WordRightExtend = NativeMethods.SCI_WORDRIGHTEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret to the end of the previous word. - /// - WordLeftEnd = NativeMethods.SCI_WORDLEFTEND, - - /// - /// Extends the selection to the end of the previous word. - /// - WordLeftEndExtend = NativeMethods.SCI_WORDLEFTENDEXTEND, - - /// - /// Moves the caret to the end of the next word. - /// - WordRightEnd = NativeMethods.SCI_WORDRIGHTEND, - - /// - /// Extends the selection to the end of the next word. - /// - WordRightEndExtend = NativeMethods.SCI_WORDRIGHTENDEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret to the previous word segment (case change or underscore). - /// - WordPartLeft = NativeMethods.SCI_WORDPARTLEFT, - - /// - /// Extends the selection to the previous word segment (case change or underscore). - /// - WordPartLeftExtend = NativeMethods.SCI_WORDPARTLEFTEXTEND, - - /// - /// Moves the caret to the next word segment (case change or underscore). - /// - WordPartRight = NativeMethods.SCI_WORDPARTRIGHT, - - /// - /// Extends the selection to the next word segment (case change or underscore). - /// - WordPartRightExtend = NativeMethods.SCI_WORDPARTRIGHTEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret to the start of the line. - /// - Home = NativeMethods.SCI_HOME, - - /// - /// Extends the selection to the start of the line. - /// - HomeExtend = NativeMethods.SCI_HOMEEXTEND, - - /// - /// Extends the rectangular selection to the start of the line. - /// - HomeRectExtend = NativeMethods.SCI_HOMERECTEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret to the start of the display line. - /// - HomeDisplay = NativeMethods.SCI_HOMEDISPLAY, - - /// - /// Extends the selection to the start of the display line. - /// - HomeDisplayExtend = NativeMethods.SCI_HOMEDISPLAYEXTEND, - - /// - /// Moves the caret to the start of the display or document line. - /// - HomeWrap = NativeMethods.SCI_HOMEWRAP, - - /// - /// Extends the selection to the start of the display or document line. - /// - HomeWrapExtend = NativeMethods.SCI_HOMEWRAPEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret to the first non-whitespace character of the line. - /// - VcHome = NativeMethods.SCI_VCHOME, - - /// - /// Extends the selection to the first non-whitespace character of the line. - /// - VcHomeExtend = NativeMethods.SCI_VCHOMEEXTEND, - - /// - /// Extends the rectangular selection to the first non-whitespace character of the line. - /// - VcHomeRectExtend = NativeMethods.SCI_VCHOMERECTEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret to the first non-whitespace character of the display or document line. - /// - VcHomeWrap = NativeMethods.SCI_VCHOMEWRAP, - - /// - /// Extends the selection to the first non-whitespace character of the display or document line. - /// - VcHomeWrapExtend = NativeMethods.SCI_VCHOMEWRAPEXTEND, - - /// - /// Moves the caret to the first non-whitespace character of the display line. - /// - VcHomeDisplay = NativeMethods.SCI_VCHOMEDISPLAY, - - /// - /// Extends the selection to the first non-whitespace character of the display line. - /// - VcHomeDisplayExtend = NativeMethods.SCI_VCHOMEDISPLAYEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret to the end of the document line. - /// - LineEnd = NativeMethods.SCI_LINEEND, - - /// - /// Extends the selection to the end of the document line. - /// - LineEndExtend = NativeMethods.SCI_LINEENDEXTEND, - - /// - /// Extends the rectangular selection to the end of the document line. - /// - LineEndRectExtend = NativeMethods.SCI_LINEENDRECTEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret to the end of the display line. - /// - LineEndDisplay = NativeMethods.SCI_LINEENDDISPLAY, - - /// - /// Extends the selection to the end of the display line. - /// - LineEndDisplayExtend = NativeMethods.SCI_LINEENDDISPLAYEXTEND, - - /// - /// Moves the caret to the end of the display or document line. - /// - LineEndWrap = NativeMethods.SCI_LINEENDWRAP, - - /// - /// Extends the selection to the end of the display or document line. - /// - LineEndWrapExtend = NativeMethods.SCI_LINEENDWRAPEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret to the start of the document. - /// - DocumentStart = NativeMethods.SCI_DOCUMENTSTART, - - /// - /// Extends the selection to the start of the document. - /// - DocumentStartExtend = NativeMethods.SCI_DOCUMENTSTARTEXTEND, - - /// - /// Moves the caret to the end of the document. - /// - DocumentEnd = NativeMethods.SCI_DOCUMENTEND, - - /// - /// Extends the selection to the end of the document. - /// - DocumentEndExtend = NativeMethods.SCI_DOCUMENTENDEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret up one page. - /// - PageUp = NativeMethods.SCI_PAGEUP, - - /// - /// Extends the selection up one page. - /// - PageUpExtend = NativeMethods.SCI_PAGEUPEXTEND, - - /// - /// Extends the rectangular selection up one page. - /// - PageUpRectExtend = NativeMethods.SCI_PAGEUPRECTEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret down one page. - /// - PageDown = NativeMethods.SCI_PAGEDOWN, - - /// - /// Extends the selection down one page. - /// - PageDownExtend = NativeMethods.SCI_PAGEDOWNEXTEND, - - /// - /// Extends the rectangular selection down one page. - /// - PageDownRectExtend = NativeMethods.SCI_PAGEDOWNRECTEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret up one window or page. - /// - StutteredPageUp = NativeMethods.SCI_STUTTEREDPAGEUP, - - /// - /// Extends the selection up one window or page. - /// - StutteredPageUpExtend = NativeMethods.SCI_STUTTEREDPAGEUPEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Moves the caret down one window or page. - /// - StutteredPageDown = NativeMethods.SCI_STUTTEREDPAGEDOWN, - - /// - /// Extends the selection down one window or page. - /// - StutteredPageDownExtend = NativeMethods.SCI_STUTTEREDPAGEDOWNEXTEND, - - // -------------------------------------------------------------------- - - /// - /// Deletes the character left of the caret. - /// - DeleteBack = NativeMethods.SCI_DELETEBACK, - - /// - /// Deletes the character (excluding line breaks) left of the caret. - /// - DeleteBackNotLine = NativeMethods.SCI_DELETEBACKNOTLINE, - - // -------------------------------------------------------------------- - - /// - /// Deletes from the caret to the start of the previous word. - /// - DelWordLeft = NativeMethods.SCI_DELWORDLEFT, - - /// - /// Deletes from the caret to the start of the next word. - /// - DelWordRight = NativeMethods.SCI_DELWORDRIGHT, - - /// - /// Deletes from the caret to the end of the next word. - /// - DelWordRightEnd = NativeMethods.SCI_DELWORDRIGHTEND, - - // -------------------------------------------------------------------- - - /// - /// Deletes the characters left of the caret to the start of the line. - /// - DelLineLeft = NativeMethods.SCI_DELLINELEFT, - - /// - /// Deletes the characters right of the caret to the start of the line. - /// - DelLineRight = NativeMethods.SCI_DELLINERIGHT, - - /// - /// Deletes the current line. - /// - LineDelete = NativeMethods.SCI_LINEDELETE, - - // -------------------------------------------------------------------- - - /// - /// Removes the current line and places it on the clipboard. - /// - LineCut = NativeMethods.SCI_LINECUT, - - /// - /// Copies the current line and places it on the clipboard. - /// - LineCopy = NativeMethods.SCI_LINECOPY, - - /// - /// Transposes the current and previous lines. - /// - LineTranspose = NativeMethods.SCI_LINETRANSPOSE, - - /// - /// Reverses the current line. - /// - LineReverse = NativeMethods.SCI_LINEREVERSE, - - /// - /// Duplicates the current line. - /// - LineDuplicate = NativeMethods.SCI_LINEDUPLICATE, - - // -------------------------------------------------------------------- - - /// - /// Converts the selection to lowercase. - /// - Lowercase = NativeMethods.SCI_LOWERCASE, - - /// - /// Converts the selection to uppercase. - /// - Uppercase = NativeMethods.SCI_UPPERCASE, - - /// - /// Cancels autocompletion, calltip display, and drops any additional selections. - /// - Cancel = NativeMethods.SCI_CANCEL, - - /// - /// Toggles overtype. See . - /// - EditToggleOvertype = NativeMethods.SCI_EDITTOGGLEOVERTYPE, - - // -------------------------------------------------------------------- - - /// - /// Inserts a newline character. - /// - NewLine = NativeMethods.SCI_NEWLINE, - - /// - /// Inserts a form feed character. - /// - FormFeed = NativeMethods.SCI_FORMFEED, - - /// - /// Adds a tab (indent) character. - /// - Tab = NativeMethods.SCI_TAB, - - /// - /// Removes a tab (indent) character from the start of a line. - /// - BackTab = NativeMethods.SCI_BACKTAB, - - // -------------------------------------------------------------------- - - /// - /// Duplicates the current selection. - /// - SelectionDuplicate = NativeMethods.SCI_SELECTIONDUPLICATE, - - /// - /// Moves the caret vertically to the center of the screen. - /// - VerticalCenterCaret = NativeMethods.SCI_VERTICALCENTRECARET, - - // -------------------------------------------------------------------- - - /// - /// Moves the selected lines up. - /// - MoveSelectedLinesUp = NativeMethods.SCI_MOVESELECTEDLINESUP, - - /// - /// Moves the selected lines down. - /// - MoveSelectedLinesDown = NativeMethods.SCI_MOVESELECTEDLINESDOWN, - - // -------------------------------------------------------------------- - - /// - /// Scrolls to the start of the document without changing the selection. - /// - ScrollToStart = NativeMethods.SCI_SCROLLTOSTART, - - /// - /// Scrolls to the end of the document without changing the selection. - /// - ScrollToEnd = NativeMethods.SCI_SCROLLTOEND, - - // -------------------------------------------------------------------- - - /// - /// Command equivalent to . - /// - ZoomIn = NativeMethods.SCI_ZOOMIN, - - /// - /// Command equivalent to . - /// - ZoomOut = NativeMethods.SCI_ZOOMOUT, - - /// - /// Command equivalent to . - /// - Undo = NativeMethods.SCI_UNDO, - - /// - /// Command equivalent to . - /// - Redo = NativeMethods.SCI_REDO, - - /// - /// Command equivalent to - /// - SwapMainAnchorCaret = NativeMethods.SCI_SWAPMAINANCHORCARET, - - /// - /// Command equivalent to - /// - RotateSelection = NativeMethods.SCI_ROTATESELECTION, - - /// - /// Command equivalent to - /// - MultipleSelectAddNext = NativeMethods.SCI_MULTIPLESELECTADDNEXT, - - /// - /// Command equivalent to - /// - MultipleSelectAddEach = NativeMethods.SCI_MULTIPLESELECTADDEACH, - - /// - /// Command equivalent to - /// - SelectAll = NativeMethods.SCI_SELECTALL + /// Actions which can be performed by the application or bound to keys in a control. + /// + public enum Command + { + /// + /// When bound to keys performs the standard platform behavior. + /// + Default = 0, + + /// + /// Performs no action and when bound to keys prevents them from propagating to the parent window. + /// + Null = NativeMethods.SCI_NULL, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret down one line. + /// + LineDown = NativeMethods.SCI_LINEDOWN, + + /// + /// Extends the selection down one line. + /// + LineDownExtend = NativeMethods.SCI_LINEDOWNEXTEND, + + /// + /// Extends the rectangular selection down one line. + /// + LineDownRectExtend = NativeMethods.SCI_LINEDOWNRECTEXTEND, + + /// + /// Scrolls down one line. + /// + LineScrollDown = NativeMethods.SCI_LINESCROLLDOWN, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret up one line. + /// + LineUp = NativeMethods.SCI_LINEUP, + + /// + /// Extends the selection up one line. + /// + LineUpExtend = NativeMethods.SCI_LINEUPEXTEND, + + /// + /// Extends the rectangular selection up one line. + /// + LineUpRectExtend = NativeMethods.SCI_LINEUPRECTEXTEND, + + /// + /// Scrolls up one line. + /// + LineScrollUp = NativeMethods.SCI_LINESCROLLUP, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret down one paragraph. + /// + ParaDown = NativeMethods.SCI_PARADOWN, + + /// + /// Extends the selection down one paragraph. + /// + ParaDownExtend = NativeMethods.SCI_PARADOWNEXTEND, + + /// + /// Moves the caret up one paragraph. + /// + ParaUp = NativeMethods.SCI_PARAUP, + + /// + /// Extends the selection up one paragraph. + /// + ParaUpExtend = NativeMethods.SCI_PARAUPEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret left one character. + /// + CharLeft = NativeMethods.SCI_CHARLEFT, + + /// + /// Extends the selection left one character. + /// + CharLeftExtend = NativeMethods.SCI_CHARLEFTEXTEND, + + /// + /// Extends the rectangular selection left one character. + /// + CharLeftRectExtend = NativeMethods.SCI_CHARLEFTRECTEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret right one character. + /// + CharRight = NativeMethods.SCI_CHARRIGHT, + + /// + /// Extends the selection right one character. + /// + CharRightExtend = NativeMethods.SCI_CHARRIGHTEXTEND, + + /// + /// Extends the rectangular selection right one character. + /// + CharRightRectExtend = NativeMethods.SCI_CHARRIGHTRECTEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret to the start of the previous word. + /// + WordLeft = NativeMethods.SCI_WORDLEFT, + + /// + /// Extends the selection to the start of the previous word. + /// + WordLeftExtend = NativeMethods.SCI_WORDLEFTEXTEND, + + /// + /// Moves the caret to the start of the next word. + /// + WordRight = NativeMethods.SCI_WORDRIGHT, + + /// + /// Extends the selection to the start of the next word. + /// + WordRightExtend = NativeMethods.SCI_WORDRIGHTEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret to the end of the previous word. + /// + WordLeftEnd = NativeMethods.SCI_WORDLEFTEND, + + /// + /// Extends the selection to the end of the previous word. + /// + WordLeftEndExtend = NativeMethods.SCI_WORDLEFTENDEXTEND, + + /// + /// Moves the caret to the end of the next word. + /// + WordRightEnd = NativeMethods.SCI_WORDRIGHTEND, + + /// + /// Extends the selection to the end of the next word. + /// + WordRightEndExtend = NativeMethods.SCI_WORDRIGHTENDEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret to the previous word segment (case change or underscore). + /// + WordPartLeft = NativeMethods.SCI_WORDPARTLEFT, + + /// + /// Extends the selection to the previous word segment (case change or underscore). + /// + WordPartLeftExtend = NativeMethods.SCI_WORDPARTLEFTEXTEND, + + /// + /// Moves the caret to the next word segment (case change or underscore). + /// + WordPartRight = NativeMethods.SCI_WORDPARTRIGHT, + + /// + /// Extends the selection to the next word segment (case change or underscore). + /// + WordPartRightExtend = NativeMethods.SCI_WORDPARTRIGHTEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret to the start of the line. + /// + Home = NativeMethods.SCI_HOME, + + /// + /// Extends the selection to the start of the line. + /// + HomeExtend = NativeMethods.SCI_HOMEEXTEND, + + /// + /// Extends the rectangular selection to the start of the line. + /// + HomeRectExtend = NativeMethods.SCI_HOMERECTEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret to the start of the display line. + /// + HomeDisplay = NativeMethods.SCI_HOMEDISPLAY, + + /// + /// Extends the selection to the start of the display line. + /// + HomeDisplayExtend = NativeMethods.SCI_HOMEDISPLAYEXTEND, + + /// + /// Moves the caret to the start of the display or document line. + /// + HomeWrap = NativeMethods.SCI_HOMEWRAP, + + /// + /// Extends the selection to the start of the display or document line. + /// + HomeWrapExtend = NativeMethods.SCI_HOMEWRAPEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret to the first non-whitespace character of the line. + /// + VcHome = NativeMethods.SCI_VCHOME, + + /// + /// Extends the selection to the first non-whitespace character of the line. + /// + VcHomeExtend = NativeMethods.SCI_VCHOMEEXTEND, + + /// + /// Extends the rectangular selection to the first non-whitespace character of the line. + /// + VcHomeRectExtend = NativeMethods.SCI_VCHOMERECTEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret to the first non-whitespace character of the display or document line. + /// + VcHomeWrap = NativeMethods.SCI_VCHOMEWRAP, + + /// + /// Extends the selection to the first non-whitespace character of the display or document line. + /// + VcHomeWrapExtend = NativeMethods.SCI_VCHOMEWRAPEXTEND, + + /// + /// Moves the caret to the first non-whitespace character of the display line. + /// + VcHomeDisplay = NativeMethods.SCI_VCHOMEDISPLAY, + + /// + /// Extends the selection to the first non-whitespace character of the display line. + /// + VcHomeDisplayExtend = NativeMethods.SCI_VCHOMEDISPLAYEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret to the end of the document line. + /// + LineEnd = NativeMethods.SCI_LINEEND, + + /// + /// Extends the selection to the end of the document line. + /// + LineEndExtend = NativeMethods.SCI_LINEENDEXTEND, + + /// + /// Extends the rectangular selection to the end of the document line. + /// + LineEndRectExtend = NativeMethods.SCI_LINEENDRECTEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret to the end of the display line. + /// + LineEndDisplay = NativeMethods.SCI_LINEENDDISPLAY, + + /// + /// Extends the selection to the end of the display line. + /// + LineEndDisplayExtend = NativeMethods.SCI_LINEENDDISPLAYEXTEND, + + /// + /// Moves the caret to the end of the display or document line. + /// + LineEndWrap = NativeMethods.SCI_LINEENDWRAP, + + /// + /// Extends the selection to the end of the display or document line. + /// + LineEndWrapExtend = NativeMethods.SCI_LINEENDWRAPEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret to the start of the document. + /// + DocumentStart = NativeMethods.SCI_DOCUMENTSTART, + + /// + /// Extends the selection to the start of the document. + /// + DocumentStartExtend = NativeMethods.SCI_DOCUMENTSTARTEXTEND, + + /// + /// Moves the caret to the end of the document. + /// + DocumentEnd = NativeMethods.SCI_DOCUMENTEND, + + /// + /// Extends the selection to the end of the document. + /// + DocumentEndExtend = NativeMethods.SCI_DOCUMENTENDEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret up one page. + /// + PageUp = NativeMethods.SCI_PAGEUP, + + /// + /// Extends the selection up one page. + /// + PageUpExtend = NativeMethods.SCI_PAGEUPEXTEND, + + /// + /// Extends the rectangular selection up one page. + /// + PageUpRectExtend = NativeMethods.SCI_PAGEUPRECTEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret down one page. + /// + PageDown = NativeMethods.SCI_PAGEDOWN, + + /// + /// Extends the selection down one page. + /// + PageDownExtend = NativeMethods.SCI_PAGEDOWNEXTEND, + + /// + /// Extends the rectangular selection down one page. + /// + PageDownRectExtend = NativeMethods.SCI_PAGEDOWNRECTEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret up one window or page. + /// + StutteredPageUp = NativeMethods.SCI_STUTTEREDPAGEUP, + + /// + /// Extends the selection up one window or page. + /// + StutteredPageUpExtend = NativeMethods.SCI_STUTTEREDPAGEUPEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Moves the caret down one window or page. + /// + StutteredPageDown = NativeMethods.SCI_STUTTEREDPAGEDOWN, + + /// + /// Extends the selection down one window or page. + /// + StutteredPageDownExtend = NativeMethods.SCI_STUTTEREDPAGEDOWNEXTEND, + + // -------------------------------------------------------------------- + + /// + /// Deletes the character left of the caret. + /// + DeleteBack = NativeMethods.SCI_DELETEBACK, + + /// + /// Deletes the character (excluding line breaks) left of the caret. + /// + DeleteBackNotLine = NativeMethods.SCI_DELETEBACKNOTLINE, + + // -------------------------------------------------------------------- + + /// + /// Deletes from the caret to the start of the previous word. + /// + DelWordLeft = NativeMethods.SCI_DELWORDLEFT, + + /// + /// Deletes from the caret to the start of the next word. + /// + DelWordRight = NativeMethods.SCI_DELWORDRIGHT, + + /// + /// Deletes from the caret to the end of the next word. + /// + DelWordRightEnd = NativeMethods.SCI_DELWORDRIGHTEND, + + // -------------------------------------------------------------------- + + /// + /// Deletes the characters left of the caret to the start of the line. + /// + DelLineLeft = NativeMethods.SCI_DELLINELEFT, + + /// + /// Deletes the characters right of the caret to the start of the line. + /// + DelLineRight = NativeMethods.SCI_DELLINERIGHT, + + /// + /// Deletes the current line. + /// + LineDelete = NativeMethods.SCI_LINEDELETE, + + // -------------------------------------------------------------------- + + /// + /// Removes the current line and places it on the clipboard. + /// + LineCut = NativeMethods.SCI_LINECUT, + + /// + /// Copies the current line and places it on the clipboard. + /// + LineCopy = NativeMethods.SCI_LINECOPY, + + /// + /// Transposes the current and previous lines. + /// + LineTranspose = NativeMethods.SCI_LINETRANSPOSE, + + /// + /// Reverses the current line. + /// + LineReverse = NativeMethods.SCI_LINEREVERSE, + + /// + /// Duplicates the current line. + /// + LineDuplicate = NativeMethods.SCI_LINEDUPLICATE, + + // -------------------------------------------------------------------- + + /// + /// Converts the selection to lowercase. + /// + Lowercase = NativeMethods.SCI_LOWERCASE, + + /// + /// Converts the selection to uppercase. + /// + Uppercase = NativeMethods.SCI_UPPERCASE, + + /// + /// Cancels autocompletion, calltip display, and drops any additional selections. + /// + Cancel = NativeMethods.SCI_CANCEL, + + /// + /// Toggles overtype. See . + /// + EditToggleOvertype = NativeMethods.SCI_EDITTOGGLEOVERTYPE, + + // -------------------------------------------------------------------- + + /// + /// Inserts a newline character. + /// + NewLine = NativeMethods.SCI_NEWLINE, + + /// + /// Inserts a form feed character. + /// + FormFeed = NativeMethods.SCI_FORMFEED, + + /// + /// Adds a tab (indent) character. + /// + Tab = NativeMethods.SCI_TAB, + + /// + /// Removes a tab (indent) character from the start of a line. + /// + BackTab = NativeMethods.SCI_BACKTAB, + + // -------------------------------------------------------------------- + + /// + /// Duplicates the current selection. + /// + SelectionDuplicate = NativeMethods.SCI_SELECTIONDUPLICATE, + + /// + /// Moves the caret vertically to the center of the screen. + /// + VerticalCenterCaret = NativeMethods.SCI_VERTICALCENTRECARET, + + // -------------------------------------------------------------------- + + /// + /// Moves the selected lines up. + /// + MoveSelectedLinesUp = NativeMethods.SCI_MOVESELECTEDLINESUP, + + /// + /// Moves the selected lines down. + /// + MoveSelectedLinesDown = NativeMethods.SCI_MOVESELECTEDLINESDOWN, + + // -------------------------------------------------------------------- + + /// + /// Scrolls to the start of the document without changing the selection. + /// + ScrollToStart = NativeMethods.SCI_SCROLLTOSTART, + + /// + /// Scrolls to the end of the document without changing the selection. + /// + ScrollToEnd = NativeMethods.SCI_SCROLLTOEND, + + // -------------------------------------------------------------------- + + /// + /// Command equivalent to . + /// + ZoomIn = NativeMethods.SCI_ZOOMIN, + + /// + /// Command equivalent to . + /// + ZoomOut = NativeMethods.SCI_ZOOMOUT, + + /// + /// Command equivalent to . + /// + Undo = NativeMethods.SCI_UNDO, + + /// + /// Command equivalent to . + /// + Redo = NativeMethods.SCI_REDO, + + /// + /// Command equivalent to + /// + SwapMainAnchorCaret = NativeMethods.SCI_SWAPMAINANCHORCARET, + + /// + /// Command equivalent to + /// + RotateSelection = NativeMethods.SCI_ROTATESELECTION, + + /// + /// Command equivalent to + /// + MultipleSelectAddNext = NativeMethods.SCI_MULTIPLESELECTADDNEXT, + + /// + /// Command equivalent to + /// + MultipleSelectAddEach = NativeMethods.SCI_MULTIPLESELECTADDEACH, + + /// + /// Command equivalent to + /// + SelectAll = NativeMethods.SCI_SELECTALL + } } diff --git a/Scintilla.NET/CopyFormat.cs b/Scintilla.NET/CopyFormat.cs index 6672077..7486d81 100644 --- a/Scintilla.NET/CopyFormat.cs +++ b/Scintilla.NET/CopyFormat.cs @@ -1,25 +1,26 @@ using System; -namespace ScintillaNET; - -/// -/// Specifies the clipboard formats to copy. -/// -[Flags] -public enum CopyFormat +namespace ScintillaNET { /// - /// Copies text to the clipboard in Unicode format. + /// Specifies the clipboard formats to copy. /// - Text = 1 << 0, + [Flags] + public enum CopyFormat + { + /// + /// Copies text to the clipboard in Unicode format. + /// + Text = 1 << 0, - /// - /// Copies text to the clipboard in Rich Text Format (RTF). - /// - Rtf = 1 << 1, + /// + /// Copies text to the clipboard in Rich Text Format (RTF). + /// + Rtf = 1 << 1, - /// - /// Copies text to the clipboard in HyperText Markup Language (HTML) format. - /// - Html = 1 << 2 + /// + /// Copies text to the clipboard in HyperText Markup Language (HTML) format. + /// + Html = 1 << 2 + } } diff --git a/Scintilla.NET/Document.cs b/Scintilla.NET/Document.cs index 6c714fd..9df1815 100644 --- a/Scintilla.NET/Document.cs +++ b/Scintilla.NET/Document.cs @@ -1,61 +1,62 @@ using System; -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 +namespace ScintillaNET { - 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. + /// A document. /// - /// 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) + /// + /// 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 { - return obj is IntPtr && this.Value == ((Document)obj).Value; - } + internal IntPtr Value; - /// - /// Returns the hash code for this instance. - /// - /// A 32-bit signed integer hash code. - public override int GetHashCode() - { - return this.Value.GetHashCode(); - } + /// + /// A read-only field that represents an uninitialized document. + /// + public static readonly Document Empty; - /// - /// 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; - } + /// + /// 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 && this.Value == ((Document)obj).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; + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return this.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/Scintilla.NET/DoubleClickEventArgs.cs b/Scintilla.NET/DoubleClickEventArgs.cs index debb852..2268a90 100644 --- a/Scintilla.NET/DoubleClickEventArgs.cs +++ b/Scintilla.NET/DoubleClickEventArgs.cs @@ -1,61 +1,62 @@ using System; using System.Windows.Forms; -namespace ScintillaNET; - -/// -/// Provides data for the event. -/// -public class DoubleClickEventArgs : EventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - private readonly int bytePosition; - private int? position; - - /// - /// Gets the line double clicked. - /// - /// The zero-based index of the double clicked line. - public int Line { get; private set; } - - /// - /// Gets the modifier keys (SHIFT, CTRL, ALT) held down when double clicked. - /// - /// A bitwise combination of the Keys enumeration indicating the modifier keys. - public Keys Modifiers { get; private set; } - /// - /// Gets the zero-based document position of the text double clicked. + /// Provides data for the event. /// - /// - /// The zero-based character position within the document of the double clicked text; - /// otherwise, -1 if not a document position. - /// - public int Position + public class DoubleClickEventArgs : EventArgs { - get + private readonly Scintilla scintilla; + private readonly int bytePosition; + private int? position; + + /// + /// Gets the line double clicked. + /// + /// The zero-based index of the double clicked line. + public int Line { get; private set; } + + /// + /// Gets the modifier keys (SHIFT, CTRL, ALT) held down when double clicked. + /// + /// A bitwise combination of the Keys enumeration indicating the modifier keys. + public Keys Modifiers { get; private set; } + + /// + /// Gets the zero-based document position of the text double clicked. + /// + /// + /// The zero-based character position within the document of the double clicked text; + /// otherwise, -1 if not a document position. + /// + public int Position { - this.position ??= this.scintilla.Lines.ByteToCharPosition(this.bytePosition); + get + { + this.position = this.position ?? this.scintilla.Lines.ByteToCharPosition(this.bytePosition); - return (int)this.position; + return (int)this.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 double click. - /// The zero-based byte position of the double clicked text. - /// The zero-based line index of the double clicked text. - public DoubleClickEventArgs(Scintilla scintilla, Keys modifiers, int bytePosition, int line) - { - this.scintilla = scintilla; - this.bytePosition = bytePosition; - Modifiers = modifiers; - Line = line; + /// + /// 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 double click. + /// The zero-based byte position of the double clicked text. + /// The zero-based line index of the double clicked text. + public DoubleClickEventArgs(Scintilla scintilla, Keys modifiers, int bytePosition, int line) + { + this.scintilla = scintilla; + this.bytePosition = bytePosition; + Modifiers = modifiers; + Line = line; - if (bytePosition == -1) - this.position = -1; + if (bytePosition == -1) + this.position = -1; + } } } diff --git a/Scintilla.NET/DwellEventArgs.cs b/Scintilla.NET/DwellEventArgs.cs index 6201478..cdd21c5 100644 --- a/Scintilla.NET/DwellEventArgs.cs +++ b/Scintilla.NET/DwellEventArgs.cs @@ -1,58 +1,59 @@ using System; -namespace ScintillaNET; - -/// -/// Provides data for the and events. -/// -public class DwellEventArgs : EventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - private readonly int bytePosition; - private int? position; - /// - /// Gets the zero-based document position where the mouse pointer was lingering. + /// Provides data for the and events. /// - /// The nearest zero-based document position to where the mouse pointer was lingering. - public int Position + public class DwellEventArgs : EventArgs { - get + private readonly Scintilla scintilla; + private readonly int bytePosition; + private int? position; + + /// + /// Gets the zero-based document position where the mouse pointer was lingering. + /// + /// The nearest zero-based document position to where the mouse pointer was lingering. + public int Position { - this.position ??= this.scintilla.Lines.ByteToCharPosition(this.bytePosition); + get + { + this.position = this.position ?? this.scintilla.Lines.ByteToCharPosition(this.bytePosition); - return (int)this.position; + return (int)this.position; + } } - } - - /// - /// Gets the x-coordinate of the mouse pointer. - /// - /// The x-coordinate of the mouse pointer relative to the control. - public int X { get; private set; } - /// - /// Gets the y-coordinate of the mouse pointer. - /// - /// The y-coordinate of the mouse pointer relative to the control. - public int Y { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// The control that generated this event. - /// The zero-based byte position within the document where the mouse pointer was lingering. - /// The x-coordinate of the mouse pointer relative to the control. - /// The y-coordinate of the mouse pointer relative to the control. - public DwellEventArgs(Scintilla scintilla, int bytePosition, int x, int y) - { - this.scintilla = scintilla; - this.bytePosition = bytePosition; - X = x; - Y = y; - - // The position is not over text - if (bytePosition < 0) - this.position = bytePosition; + /// + /// Gets the x-coordinate of the mouse pointer. + /// + /// The x-coordinate of the mouse pointer relative to the control. + public int X { get; private set; } + + /// + /// Gets the y-coordinate of the mouse pointer. + /// + /// The y-coordinate of the mouse pointer relative to the control. + public int Y { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + /// The control that generated this event. + /// The zero-based byte position within the document where the mouse pointer was lingering. + /// The x-coordinate of the mouse pointer relative to the control. + /// The y-coordinate of the mouse pointer relative to the control. + public DwellEventArgs(Scintilla scintilla, int bytePosition, int x, int y) + { + this.scintilla = scintilla; + this.bytePosition = bytePosition; + X = x; + Y = y; + + // The position is not over text + if (bytePosition < 0) + this.position = bytePosition; + } } } diff --git a/Scintilla.NET/EdgeMode.cs b/Scintilla.NET/EdgeMode.cs index 4c4b660..d48eee9 100644 --- a/Scintilla.NET/EdgeMode.cs +++ b/Scintilla.NET/EdgeMode.cs @@ -1,28 +1,29 @@ -namespace ScintillaNET; - -/// -/// The long line edge display mode. -/// -public enum EdgeMode +namespace ScintillaNET { /// - /// Long lines are not indicated. This is the default. + /// The long line edge display mode. /// - None = NativeMethods.EDGE_NONE, + 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 vertical line. + /// + Line = NativeMethods.EDGE_LINE, - /// - /// Long lines are indicated with a background color. - /// - Background = NativeMethods.EDGE_BACKGROUND, + /// + /// Long lines are indicated with a background color. + /// + Background = NativeMethods.EDGE_BACKGROUND, - /// - /// Similar to except allows for multiple vertical lines to be visible using the method. - /// - /// and are completely independant of this mode. - MultiLine = NativeMethods.EDGE_MULTILINE + /// + /// Similar to except allows for multiple vertical lines to be visible using the method. + /// + /// and are completely independant of this mode. + MultiLine = NativeMethods.EDGE_MULTILINE + } } diff --git a/Scintilla.NET/Eol.cs b/Scintilla.NET/Eol.cs index 6e92d49..019c5a6 100644 --- a/Scintilla.NET/Eol.cs +++ b/Scintilla.NET/Eol.cs @@ -1,22 +1,23 @@ -namespace ScintillaNET; - -/// -/// End-of-line format. -/// -public enum Eol +namespace ScintillaNET { /// - /// Carriage Return, Line Feed pair "\r\n" (0x0D0A). + /// End-of-line format. /// - CrLf = NativeMethods.SC_EOL_CRLF, + public enum Eol + { + /// + /// Carriage Return, Line Feed pair "\r\n" (0x0D0A). + /// + CrLf = NativeMethods.SC_EOL_CRLF, - /// - /// Carriage Return '\r' (0x0D). - /// - Cr = NativeMethods.SC_EOL_CR, + /// + /// Carriage Return '\r' (0x0D). + /// + Cr = NativeMethods.SC_EOL_CR, - /// - /// Line Feed '\n' (0x0A). - /// - Lf = NativeMethods.SC_EOL_LF + /// + /// Line Feed '\n' (0x0A). + /// + Lf = NativeMethods.SC_EOL_LF + } } diff --git a/Scintilla.NET/FlagsConverter.cs b/Scintilla.NET/FlagsConverter.cs index 2d58163..422c6d7 100644 --- a/Scintilla.NET/FlagsConverter.cs +++ b/Scintilla.NET/FlagsConverter.cs @@ -4,81 +4,82 @@ using System.Globalization; using System.Linq; -namespace ScintillaNET; - -internal class FlagsConverter : TypeConverter +namespace ScintillaNET { - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + internal class FlagsConverter : TypeConverter { - return destinationType == typeof(string) || base.CanConvertTo(context, destinationType); - } + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { + return destinationType == typeof(string) || base.CanConvertTo(context, destinationType); + } - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - { - return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); - } + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) - { - if (value is Enum valueEnum && destinationType == typeof(string)) + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { - Type enumType = valueEnum.GetType(); - ulong valueBits = Convert.ToUInt64(valueEnum); - if (valueBits == 0) + if (value is Enum valueEnum && destinationType == typeof(string)) { - return Enum.ToObject(enumType, 0).ToString(); - } + Type enumType = valueEnum.GetType(); + ulong valueBits = Convert.ToUInt64(valueEnum); + if (valueBits == 0) + { + return Enum.ToObject(enumType, 0).ToString(); + } - ulong bits = 0; - List enums = []; - var items = Enum.GetValues(enumType).Cast() - .Select(e => new { @enum = e, bits = Convert.ToUInt64(e), bitCount = Helpers.PopCount(Convert.ToUInt64(e))}) - .Where(e => e.bits != 0 && e.bitCount > 0) - .ToList(); - int maxIterations = items.Count; - for (int i = 0; i < maxIterations && bits != valueBits && items.Count > 0; i++) - { - int maxIndex = items - .Select(e => new { contrib = Helpers.PopCount(e.bits & valueBits & ~bits), item = e}) - .MaxIndex( - (x, y) => // Select one that: - (x.contrib != y.contrib) ? (x.contrib - y.contrib) : // Contributes most bits - (x.item.bitCount != y.item.bitCount) ? (y.item.bitCount - x.item.bitCount) : // Has least amount of bits set - (x.item.bits < y.item.bits) ? -1 : (x.item.bits > y.item.bits ? 1 : 0) // With the highest integer value - ); + ulong bits = 0; + var enums = new List(); + var items = Enum.GetValues(enumType).Cast() + .Select(e => new { @enum = e, bits = Convert.ToUInt64(e), bitCount = Helpers.PopCount(Convert.ToUInt64(e)) }) + .Where(e => e.bits != 0 && e.bitCount > 0) + .ToList(); + int maxIterations = items.Count; + for (int i = 0; i < maxIterations && bits != valueBits && items.Count > 0; i++) + { + int maxIndex = items + .Select(e => new { contrib = Helpers.PopCount(e.bits & valueBits & ~bits), item = e }) + .MaxIndex( + (x, y) => // Select one that: + (x.contrib != y.contrib) ? (x.contrib - y.contrib) : // Contributes most bits + (x.item.bitCount != y.item.bitCount) ? (y.item.bitCount - x.item.bitCount) : // Has least amount of bits set + (x.item.bits < y.item.bits) ? -1 : (x.item.bits > y.item.bits ? 1 : 0) // With the highest integer value + ); - var item = items[maxIndex]; + var item = items[maxIndex]; - if ((valueBits & item.bits) == item.bits && (bits & item.bits) != item.bits) - { - bits |= item.bits; - items.RemoveAt(maxIndex); - enums.Add(item.@enum); + if ((valueBits & item.bits) == item.bits && (bits & item.bits) != item.bits) + { + bits |= item.bits; + items.RemoveAt(maxIndex); + enums.Add(item.@enum); + } } + + enums.Sort(); + return string.Join(" | ", enums); } - enums.Sort(); - return string.Join(" | ", enums); + return base.ConvertTo(context, culture, value, destinationType); } - return base.ConvertTo(context, culture, value, destinationType); - } - - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - { - if (value is string str) + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { - Type t = context.PropertyDescriptor.PropertyType; - ulong bits = 0; - IEnumerable nameList = str.Split('|').Select(x => x.Trim()); - foreach (string name in nameList) + if (value is string str) { - bits |= Convert.ToUInt64(Enum.Parse(t, name)); + Type t = context.PropertyDescriptor.PropertyType; + ulong bits = 0; + IEnumerable nameList = str.Split('|').Select(x => x.Trim()); + foreach (string name in nameList) + { + bits |= Convert.ToUInt64(Enum.Parse(t, name)); + } + + return Enum.ToObject(t, bits); } - return Enum.ToObject(t, bits); + return base.ConvertFrom(context, culture, value); } - - return base.ConvertFrom(context, culture, value); } } diff --git a/Scintilla.NET/FlagsEditor.cs b/Scintilla.NET/FlagsEditor.cs index 939e949..56204de 100644 --- a/Scintilla.NET/FlagsEditor.cs +++ b/Scintilla.NET/FlagsEditor.cs @@ -4,27 +4,28 @@ using System.Linq; using System.Windows.Forms.Design; -namespace ScintillaNET; - -internal class FlagsEditor : UITypeEditor +namespace ScintillaNET { - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown; + internal class FlagsEditor : UITypeEditor + { + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown; - public override bool IsDropDownResizable => true; + public override bool IsDropDownResizable => true; - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) - { - if (value is Enum e && context.PropertyDescriptor.Attributes.OfType().Any()) + public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { - var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); + if (value is Enum e && context.PropertyDescriptor.Attributes.OfType().Any()) + { + var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); - var control = new FlagsEditorControl(svc, e); - svc.DropDownControl(control); - return control.Value; - } - else - { - return base.EditValue(context, provider, value); + var control = new FlagsEditorControl(svc, e); + svc.DropDownControl(control); + return control.Value; + } + else + { + return base.EditValue(context, provider, value); + } } } } diff --git a/Scintilla.NET/FlagsEditorControl.Designer.cs b/Scintilla.NET/FlagsEditorControl.Designer.cs index e5cd15b..197955d 100644 --- a/Scintilla.NET/FlagsEditorControl.Designer.cs +++ b/Scintilla.NET/FlagsEditorControl.Designer.cs @@ -1,126 +1,127 @@ -namespace ScintillaNET; - -partial class FlagsEditorControl +namespace ScintillaNET { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) + partial class FlagsEditorControl { - if (disposing && (components != null)) + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { - components.Dispose(); + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); } - base.Dispose(disposing); - } - #region Component Designer generated code + #region Component Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.flowLayoutPanel_CheckBoxList = new System.Windows.Forms.FlowLayoutPanel(); - this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); - this.button_Ok = new System.Windows.Forms.Button(); - this.button_Cancel = new System.Windows.Forms.Button(); - this.tableLayoutPanel.SuspendLayout(); - this.SuspendLayout(); - // - // flowLayoutPanel_CheckBoxList - // - this.flowLayoutPanel_CheckBoxList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.flowLayoutPanel_CheckBoxList.AutoScroll = true; - this.flowLayoutPanel_CheckBoxList.AutoSize = true; - this.flowLayoutPanel_CheckBoxList.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.tableLayoutPanel.SetColumnSpan(this.flowLayoutPanel_CheckBoxList, 2); - this.flowLayoutPanel_CheckBoxList.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; - this.flowLayoutPanel_CheckBoxList.Location = new System.Drawing.Point(0, 0); - this.flowLayoutPanel_CheckBoxList.Margin = new System.Windows.Forms.Padding(0); - this.flowLayoutPanel_CheckBoxList.Name = "flowLayoutPanel_CheckBoxList"; - this.flowLayoutPanel_CheckBoxList.Size = new System.Drawing.Size(150, 124); - this.flowLayoutPanel_CheckBoxList.TabIndex = 0; - this.flowLayoutPanel_CheckBoxList.WrapContents = false; - // - // tableLayoutPanel - // - this.tableLayoutPanel.AutoSize = true; - this.tableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.tableLayoutPanel.ColumnCount = 2; - this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel.Controls.Add(this.flowLayoutPanel_CheckBoxList, 0, 0); - this.tableLayoutPanel.Controls.Add(this.button_Ok, 0, 1); - this.tableLayoutPanel.Controls.Add(this.button_Cancel, 1, 1); - this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel.Name = "tableLayoutPanel"; - this.tableLayoutPanel.RowCount = 2; - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel.Size = new System.Drawing.Size(150, 150); - this.tableLayoutPanel.TabIndex = 0; - // - // button_Ok - // - this.button_Ok.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.button_Ok.AutoSize = true; - this.button_Ok.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button_Ok.Location = new System.Drawing.Point(0, 124); - this.button_Ok.Margin = new System.Windows.Forms.Padding(0); - this.button_Ok.Name = "button_Ok"; - this.button_Ok.Size = new System.Drawing.Size(75, 26); - this.button_Ok.TabIndex = 1; - this.button_Ok.Text = "OK"; - this.button_Ok.UseVisualStyleBackColor = false; - this.button_Ok.Click += new System.EventHandler(this.button_Ok_Click); - // - // button_Cancel - // - this.button_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.button_Cancel.AutoSize = true; - this.button_Cancel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button_Cancel.Location = new System.Drawing.Point(75, 124); - this.button_Cancel.Margin = new System.Windows.Forms.Padding(0); - this.button_Cancel.Name = "button_Cancel"; - this.button_Cancel.Size = new System.Drawing.Size(75, 26); - this.button_Cancel.TabIndex = 1; - this.button_Cancel.Text = "Cancel"; - this.button_Cancel.UseVisualStyleBackColor = false; - this.button_Cancel.Click += new System.EventHandler(this.button_Cancel_Click); - // - // FlagsEditorControl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.Controls.Add(this.tableLayoutPanel); - this.Name = "FlagsEditorControl"; - this.tableLayoutPanel.ResumeLayout(false); - this.tableLayoutPanel.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.flowLayoutPanel_CheckBoxList = new System.Windows.Forms.FlowLayoutPanel(); + this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.button_Ok = new System.Windows.Forms.Button(); + this.button_Cancel = new System.Windows.Forms.Button(); + this.tableLayoutPanel.SuspendLayout(); + this.SuspendLayout(); + // + // flowLayoutPanel_CheckBoxList + // + this.flowLayoutPanel_CheckBoxList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.flowLayoutPanel_CheckBoxList.AutoScroll = true; + this.flowLayoutPanel_CheckBoxList.AutoSize = true; + this.flowLayoutPanel_CheckBoxList.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel.SetColumnSpan(this.flowLayoutPanel_CheckBoxList, 2); + this.flowLayoutPanel_CheckBoxList.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flowLayoutPanel_CheckBoxList.Location = new System.Drawing.Point(0, 0); + this.flowLayoutPanel_CheckBoxList.Margin = new System.Windows.Forms.Padding(0); + this.flowLayoutPanel_CheckBoxList.Name = "flowLayoutPanel_CheckBoxList"; + this.flowLayoutPanel_CheckBoxList.Size = new System.Drawing.Size(150, 124); + this.flowLayoutPanel_CheckBoxList.TabIndex = 0; + this.flowLayoutPanel_CheckBoxList.WrapContents = false; + // + // tableLayoutPanel + // + this.tableLayoutPanel.AutoSize = true; + this.tableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel.ColumnCount = 2; + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel.Controls.Add(this.flowLayoutPanel_CheckBoxList, 0, 0); + this.tableLayoutPanel.Controls.Add(this.button_Ok, 0, 1); + this.tableLayoutPanel.Controls.Add(this.button_Cancel, 1, 1); + this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel.Name = "tableLayoutPanel"; + this.tableLayoutPanel.RowCount = 2; + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel.Size = new System.Drawing.Size(150, 150); + this.tableLayoutPanel.TabIndex = 0; + // + // button_Ok + // + this.button_Ok.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.button_Ok.AutoSize = true; + this.button_Ok.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.button_Ok.Location = new System.Drawing.Point(0, 124); + this.button_Ok.Margin = new System.Windows.Forms.Padding(0); + this.button_Ok.Name = "button_Ok"; + this.button_Ok.Size = new System.Drawing.Size(75, 26); + this.button_Ok.TabIndex = 1; + this.button_Ok.Text = "OK"; + this.button_Ok.UseVisualStyleBackColor = false; + this.button_Ok.Click += new System.EventHandler(this.button_Ok_Click); + // + // button_Cancel + // + this.button_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.button_Cancel.AutoSize = true; + this.button_Cancel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.button_Cancel.Location = new System.Drawing.Point(75, 124); + this.button_Cancel.Margin = new System.Windows.Forms.Padding(0); + this.button_Cancel.Name = "button_Cancel"; + this.button_Cancel.Size = new System.Drawing.Size(75, 26); + this.button_Cancel.TabIndex = 1; + this.button_Cancel.Text = "Cancel"; + this.button_Cancel.UseVisualStyleBackColor = false; + this.button_Cancel.Click += new System.EventHandler(this.button_Cancel_Click); + // + // FlagsEditorControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.Controls.Add(this.tableLayoutPanel); + this.Name = "FlagsEditorControl"; + this.tableLayoutPanel.ResumeLayout(false); + this.tableLayoutPanel.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); - } + } - #endregion + #endregion - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel_CheckBoxList; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; - private System.Windows.Forms.Button button_Ok; - private System.Windows.Forms.Button button_Cancel; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel_CheckBoxList; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; + private System.Windows.Forms.Button button_Ok; + private System.Windows.Forms.Button button_Cancel; + } } diff --git a/Scintilla.NET/FlagsEditorControl.cs b/Scintilla.NET/FlagsEditorControl.cs index 598e6bf..2d0f386 100644 --- a/Scintilla.NET/FlagsEditorControl.cs +++ b/Scintilla.NET/FlagsEditorControl.cs @@ -5,173 +5,174 @@ using System.Windows.Forms; using System.Windows.Forms.Design; -namespace ScintillaNET; - -internal partial class FlagsEditorControl : UserControl +namespace ScintillaNET { - public FlagsEditorControl() + internal partial class FlagsEditorControl : UserControl { - InitializeComponent(); - this.button_Ok.Text = NativeMethods.GetMessageBoxString(0); - this.button_Cancel.Text = NativeMethods.GetMessageBoxString(1); - } + public FlagsEditorControl() + { + InitializeComponent(); + this.button_Ok.Text = NativeMethods.GetMessageBoxString(0); + this.button_Cancel.Text = NativeMethods.GetMessageBoxString(1); + } - private readonly Type enumType; - private readonly Enum initialValue; - public Enum Value { get; protected set; } + private readonly Type enumType; + private readonly Enum initialValue; + public Enum Value { get; protected set; } - private readonly IWindowsFormsEditorService editorService; + private readonly IWindowsFormsEditorService editorService; - private int inCheck; + private int inCheck; - public FlagsEditorControl(IWindowsFormsEditorService editorService, Enum value) : this() - { - this.editorService = editorService; + public FlagsEditorControl(IWindowsFormsEditorService editorService, Enum value) : this() + { + this.editorService = editorService; - this.enumType = value.GetType(); - Value = this.initialValue = value; + this.enumType = value.GetType(); + Value = this.initialValue = value; - this.inCheck++; - try - { - ulong allBits = CalculateEnumAllValue(this.enumType); - bool hasAll = false; - ulong valueBits = Convert.ToUInt64(Value); - foreach (string itemName in Enum.GetNames(this.enumType)) + this.inCheck++; + try { - var item = (Enum)Enum.Parse(this.enumType, itemName); - ulong itemBits = Convert.ToUInt64(item); - if (itemBits == allBits) - hasAll = true; - if (itemBits != 0) + ulong allBits = CalculateEnumAllValue(this.enumType); + bool hasAll = false; + ulong valueBits = Convert.ToUInt64(Value); + foreach (string itemName in Enum.GetNames(this.enumType)) + { + var item = (Enum)Enum.Parse(this.enumType, itemName); + ulong itemBits = Convert.ToUInt64(item); + if (itemBits == allBits) + hasAll = true; + if (itemBits != 0) + { + var checkBox = new CheckBox() { + Text = itemName, + CheckState = CheckStateFromBits(itemBits, valueBits), + AutoSize = true, + Tag = item, + Margin = new Padding(3, 0, 3, 0), + Padding = Padding.Empty, + }; + checkBox.CheckStateChanged += checkBox_CheckStateChanged; + this.flowLayoutPanel_CheckBoxList.Controls.Add(checkBox); + } + } + + if (!hasAll) { var checkBox = new CheckBox() { - Text = itemName, - CheckState = CheckStateFromBits(itemBits, valueBits), + Text = "All", + CheckState = CheckStateFromBits(allBits, valueBits), AutoSize = true, - Tag = item, + Tag = (Enum)Enum.ToObject(this.enumType, allBits), Margin = new Padding(3, 0, 3, 0), Padding = Padding.Empty, }; checkBox.CheckStateChanged += checkBox_CheckStateChanged; this.flowLayoutPanel_CheckBoxList.Controls.Add(checkBox); } - } - if (!hasAll) + AutoSize = true; + } + finally { - var checkBox = new CheckBox() { - Text = "All", - CheckState = CheckStateFromBits(allBits, valueBits), - AutoSize = true, - Tag = (Enum)Enum.ToObject(this.enumType, allBits), - Margin = new Padding(3, 0, 3, 0), - Padding = Padding.Empty, - }; - checkBox.CheckStateChanged += checkBox_CheckStateChanged; - this.flowLayoutPanel_CheckBoxList.Controls.Add(checkBox); + this.inCheck--; } - - AutoSize = true; } - finally + + protected override void OnBackColorChanged(EventArgs e) { - this.inCheck--; + base.OnBackColorChanged(e); + Helpers.ApplyToControlTree(this, c => { + var backColor = Srgb.FromColor(c.BackColor).ToLinearSrgb().ToOkLab(); + if (backColor.L < 0.5f) + c.ForeColor = Color.White; + else + c.ForeColor = Color.Black; + }); } - } - - protected override void OnBackColorChanged(EventArgs e) - { - base.OnBackColorChanged(e); - Helpers.ApplyToControlTree(this, c => { - OkLab backColor = Srgb.FromColor(c.BackColor).ToLinearSrgb().ToOkLab(); - if (backColor.L < 0.5f) - c.ForeColor = Color.White; - else - c.ForeColor = Color.Black; - }); - } - private static ulong CalculateEnumAllValue(Type enumType) - { - ulong all = 0; - foreach (Enum bits in Enum.GetValues(enumType)) + private static ulong CalculateEnumAllValue(Type enumType) { - all |= Convert.ToUInt64(bits); - } + ulong all = 0; + foreach (Enum bits in Enum.GetValues(enumType)) + { + all |= Convert.ToUInt64(bits); + } - return all; - } + return all; + } - private static ulong CombineEnumBits(IEnumerable checkBoxList) - { - ulong bits = 0; - foreach (CheckBox checkBox in checkBoxList.Where(c => c.CheckState == CheckState.Checked)) + private static ulong CombineEnumBits(IEnumerable checkBoxList) { - bits |= Convert.ToUInt64(checkBox.Tag); - } + ulong bits = 0; + foreach (CheckBox checkBox in checkBoxList.Where(c => c.CheckState == CheckState.Checked)) + { + bits |= Convert.ToUInt64(checkBox.Tag); + } - return bits; - } + return bits; + } - private void checkBox_CheckStateChanged(object sender, EventArgs e) - { - if (this.inCheck > 0) - return; - this.inCheck++; - try + private void checkBox_CheckStateChanged(object sender, EventArgs e) { - var checkTarget = (CheckBox)sender; - IEnumerable checkBoxList = this.flowLayoutPanel_CheckBoxList.Controls.OfType(); - ulong valueBits = CombineEnumBits(checkBoxList); - ulong changedBits = Convert.ToUInt64(checkTarget.Tag); - if (checkTarget.CheckState == CheckState.Checked) - valueBits |= changedBits; - else if (checkTarget.CheckState == CheckState.Unchecked) - valueBits &= ~changedBits; - Value = (Enum)Enum.ToObject(this.enumType, valueBits); - foreach (CheckBox checkBox in checkBoxList) + if (this.inCheck > 0) + return; + this.inCheck++; + try + { + var checkTarget = (CheckBox)sender; + IEnumerable checkBoxList = this.flowLayoutPanel_CheckBoxList.Controls.OfType(); + ulong valueBits = CombineEnumBits(checkBoxList); + ulong changedBits = Convert.ToUInt64(checkTarget.Tag); + if (checkTarget.CheckState == CheckState.Checked) + valueBits |= changedBits; + else if (checkTarget.CheckState == CheckState.Unchecked) + valueBits &= ~changedBits; + Value = (Enum)Enum.ToObject(this.enumType, valueBits); + foreach (CheckBox checkBox in checkBoxList) + { + ulong itemBits = Convert.ToUInt64(checkBox.Tag); + checkBox.CheckState = CheckStateFromBits(itemBits, valueBits); + } + } + finally { - ulong itemBits = Convert.ToUInt64(checkBox.Tag); - checkBox.CheckState = CheckStateFromBits(itemBits, valueBits); + this.inCheck--; } } - finally + + private static CheckState CheckStateFromBits(ulong itemBits, ulong valueBits) { - this.inCheck--; + return (itemBits & valueBits) == itemBits ? CheckState.Checked : (itemBits & valueBits) == 0 ? CheckState.Unchecked : CheckState.Indeterminate; } - } - private static CheckState CheckStateFromBits(ulong itemBits, ulong valueBits) - { - return (itemBits & valueBits) == itemBits ? CheckState.Checked : (itemBits & valueBits) == 0 ? CheckState.Unchecked : CheckState.Indeterminate; - } - - protected override bool ProcessDialogKey(Keys keyData) - { - if (keyData == Keys.Return) + protected override bool ProcessDialogKey(Keys keyData) { - button_Ok_Click(this.button_Ok, EventArgs.Empty); - return true; + if (keyData == Keys.Return) + { + button_Ok_Click(this.button_Ok, EventArgs.Empty); + return true; + } + + if (keyData == Keys.Escape) + { + button_Cancel_Click(this.button_Cancel, EventArgs.Empty); + return true; + } + + return base.ProcessDialogKey(keyData); } - if (keyData == Keys.Escape) + private void button_Ok_Click(object sender, EventArgs e) { - button_Cancel_Click(this.button_Cancel, EventArgs.Empty); - return true; + this.editorService.CloseDropDown(); } - return base.ProcessDialogKey(keyData); - } - - private void button_Ok_Click(object sender, EventArgs e) - { - this.editorService.CloseDropDown(); - } - - private void button_Cancel_Click(object sender, EventArgs e) - { - Value = this.initialValue; - this.editorService.CloseDropDown(); + private void button_Cancel_Click(object sender, EventArgs e) + { + Value = this.initialValue; + this.editorService.CloseDropDown(); + } } } diff --git a/Scintilla.NET/FlagsEnumConverter.cs b/Scintilla.NET/FlagsEnumConverter.cs index e1d80bb..8fc4719 100644 --- a/Scintilla.NET/FlagsEnumConverter.cs +++ b/Scintilla.NET/FlagsEnumConverter.cs @@ -5,188 +5,189 @@ using System.ComponentModel; using System.Reflection; -namespace FlagsEnumTypeConverter; - -/// -/// Flags enumeration type converter. -/// -internal class FlagsEnumConverter : EnumConverter +namespace FlagsEnumTypeConverter { /// - /// This class represents an enumeration field in the property grid. + /// Flags enumeration type converter. /// - protected class EnumFieldDescriptor : SimplePropertyDescriptor + internal class FlagsEnumConverter : EnumConverter { - #region Fields - /// - /// Stores the context which the enumeration field descriptor was created in. - /// - private readonly ITypeDescriptorContext fContext; - #endregion - - #region Methods /// - /// Creates an instance of the enumeration field descriptor class. + /// This class represents an enumeration field in the property grid. /// - /// The type of the enumeration. - /// The name of the enumeration field. - /// The current context. - public EnumFieldDescriptor(Type componentType, string name, ITypeDescriptorContext context) : base(componentType, name, typeof(bool)) + protected class EnumFieldDescriptor : SimplePropertyDescriptor { - this.fContext = context; - } + #region Fields + /// + /// Stores the context which the enumeration field descriptor was created in. + /// + private readonly ITypeDescriptorContext fContext; + #endregion + + #region Methods + /// + /// Creates an instance of the enumeration field descriptor class. + /// + /// The type of the enumeration. + /// The name of the enumeration field. + /// The current context. + public EnumFieldDescriptor(Type componentType, string name, ITypeDescriptorContext context) : base(componentType, name, typeof(bool)) + { + this.fContext = context; + } - /// - /// Retrieves the value of the enumeration field. - /// - /// - /// The instance of the enumeration type which to retrieve the field value for. - /// - /// - /// True if the enumeration field is included to the enumeration; - /// otherwise, False. - /// - public override object GetValue(object component) - { - ulong bits = Convert.ToUInt64(Enum.Parse(ComponentType, Name)); - return (Convert.ToUInt64(component) & bits) == bits; - } + /// + /// Retrieves the value of the enumeration field. + /// + /// + /// The instance of the enumeration type which to retrieve the field value for. + /// + /// + /// True if the enumeration field is included to the enumeration; + /// otherwise, False. + /// + public override object GetValue(object component) + { + ulong bits = Convert.ToUInt64(Enum.Parse(ComponentType, Name)); + return (Convert.ToUInt64(component) & bits) == bits; + } - /// - /// Sets the value of the enumeration field. - /// - /// - /// The instance of the enumeration type which to set the field value to. - /// - /// - /// True if the enumeration field should included to the enumeration; - /// otherwise, False. - /// - public override void SetValue(object component, object value) - { - bool myValue = (bool)value; - ulong myNewValue; - if (myValue) - myNewValue = Convert.ToUInt64(component) | Convert.ToUInt64(Enum.Parse(ComponentType, Name)); - else - myNewValue = Convert.ToUInt64(component) & ~Convert.ToUInt64(Enum.Parse(ComponentType, Name)); - - FieldInfo myField = component.GetType().GetField("value__", BindingFlags.Instance | BindingFlags.Public); - myField.SetValue(component, Convert.ChangeType(myNewValue, Enum.GetUnderlyingType(ComponentType))); - this.fContext.PropertyDescriptor.SetValue(this.fContext.Instance, component); - } + /// + /// Sets the value of the enumeration field. + /// + /// + /// The instance of the enumeration type which to set the field value to. + /// + /// + /// True if the enumeration field should included to the enumeration; + /// otherwise, False. + /// + public override void SetValue(object component, object value) + { + bool myValue = (bool)value; + ulong myNewValue; + if (myValue) + myNewValue = Convert.ToUInt64(component) | Convert.ToUInt64(Enum.Parse(ComponentType, Name)); + else + myNewValue = Convert.ToUInt64(component) & ~Convert.ToUInt64(Enum.Parse(ComponentType, Name)); + + FieldInfo myField = component.GetType().GetField("value__", BindingFlags.Instance | BindingFlags.Public); + myField.SetValue(component, Convert.ChangeType(myNewValue, Enum.GetUnderlyingType(ComponentType))); + this.fContext.PropertyDescriptor.SetValue(this.fContext.Instance, component); + } - /// - /// Retrieves a value indicating whether the enumeration - /// field is set to a non-default value. - /// - public override bool ShouldSerializeValue(object component) - { - return (bool)GetValue(component) != GetDefaultValue(); - } + /// + /// Retrieves a value indicating whether the enumeration + /// field is set to a non-default value. + /// + public override bool ShouldSerializeValue(object component) + { + return (bool)GetValue(component) != GetDefaultValue(); + } - /// - /// Resets the enumeration field to its default value. - /// - public override void ResetValue(object component) - { - SetValue(component, GetDefaultValue()); + /// + /// Resets the enumeration field to its default value. + /// + public override void ResetValue(object component) + { + SetValue(component, GetDefaultValue()); + } + + /// + /// Retrieves a value indicating whether the enumeration + /// field can be reset to the default value. + /// + public override bool CanResetValue(object component) + { + return ShouldSerializeValue(component); + } + + /// + /// Retrieves the enumerations field�s default value. + /// + private bool GetDefaultValue() + { + object myDefaultValue = null; + string myPropertyName = this.fContext.PropertyDescriptor.Name; + Type myComponentType = this.fContext.PropertyDescriptor.ComponentType; + + // Get DefaultValueAttribute + var myDefaultValueAttribute = (DefaultValueAttribute)Attribute.GetCustomAttribute( + myComponentType.GetProperty(myPropertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), + typeof(DefaultValueAttribute)); + if (myDefaultValueAttribute != null) + myDefaultValue = myDefaultValueAttribute.Value; + + if (myDefaultValue != null) + return (Convert.ToUInt64(myDefaultValue) & Convert.ToUInt64(Enum.Parse(ComponentType, Name))) != 0; + return false; + } + #endregion + + #region Properties + public override AttributeCollection Attributes + { + get + { + return new AttributeCollection(new Attribute[] { RefreshPropertiesAttribute.Repaint }); + } + } + #endregion } + #region Methods /// - /// Retrieves a value indicating whether the enumeration - /// field can be reset to the default value. + /// Creates an instance of the FlagsEnumConverter class. /// - public override bool CanResetValue(object component) - { - return ShouldSerializeValue(component); - } + /// The type of the enumeration. + public FlagsEnumConverter(Type type) : base(type) { } /// - /// Retrieves the enumerations field�s default value. + /// Retrieves the property descriptors for the enumeration fields. + /// These property descriptors will be used by the property grid + /// to show separate enumeration fields. /// - private bool GetDefaultValue() - { - object myDefaultValue = null; - string myPropertyName = this.fContext.PropertyDescriptor.Name; - Type myComponentType = this.fContext.PropertyDescriptor.ComponentType; - - // Get DefaultValueAttribute - var myDefaultValueAttribute = (DefaultValueAttribute)Attribute.GetCustomAttribute( - myComponentType.GetProperty(myPropertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), - typeof(DefaultValueAttribute)); - if (myDefaultValueAttribute != null) - myDefaultValue = myDefaultValueAttribute.Value; - - if (myDefaultValue != null) - return (Convert.ToUInt64(myDefaultValue) & Convert.ToUInt64(Enum.Parse(ComponentType, Name))) != 0; - return false; - } - #endregion - - #region Properties - public override AttributeCollection Attributes + /// The current context. + /// A value of an enumeration type. + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { - get + if (context != null) { - return new AttributeCollection(new Attribute[] { RefreshPropertiesAttribute.Repaint }); + Type myType = value.GetType(); + string[] myNames = Enum.GetNames(myType); + Array myValues = Enum.GetValues(myType); + if (myNames != null) + { + var myCollection = new PropertyDescriptorCollection(null); + for (int i = 0; i < myNames.Length; i++) + { + if (Convert.ToUInt64(myValues.GetValue(i)) != 0) + myCollection.Add(new EnumFieldDescriptor(myType, myNames[i], context)); + } + + return myCollection; + } } - } - #endregion - } - #region Methods - /// - /// Creates an instance of the FlagsEnumConverter class. - /// - /// The type of the enumeration. - public FlagsEnumConverter(Type type) : base(type) { } + return base.GetProperties(context, value, attributes); + } - /// - /// Retrieves the property descriptors for the enumeration fields. - /// These property descriptors will be used by the property grid - /// to show separate enumeration fields. - /// - /// The current context. - /// A value of an enumeration type. - public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) - { - if (context != null) + public override bool GetPropertiesSupported(ITypeDescriptorContext context) { - Type myType = value.GetType(); - string[] myNames = Enum.GetNames(myType); - Array myValues = Enum.GetValues(myType); - if (myNames != null) + if (context != null) { - var myCollection = new PropertyDescriptorCollection(null); - for (int i = 0; i < myNames.Length; i++) - { - if (Convert.ToUInt64(myValues.GetValue(i)) != 0) - myCollection.Add(new EnumFieldDescriptor(myType, myNames[i], context)); - } - - return myCollection; + return true; } - } - return base.GetProperties(context, value, attributes); - } + return base.GetPropertiesSupported(context); + } - public override bool GetPropertiesSupported(ITypeDescriptorContext context) - { - if (context != null) + public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { - return true; + return false; } - - return base.GetPropertiesSupported(context); - } - - public override bool GetStandardValuesSupported(ITypeDescriptorContext context) - { - return false; + #endregion } - #endregion -} #pragma warning restore 1573 +} diff --git a/Scintilla.NET/FoldAction.cs b/Scintilla.NET/FoldAction.cs index 8b92e74..c548efb 100644 --- a/Scintilla.NET/FoldAction.cs +++ b/Scintilla.NET/FoldAction.cs @@ -1,22 +1,23 @@ -namespace ScintillaNET; - -/// -/// Fold actions. -/// -public enum FoldAction +namespace ScintillaNET { /// - /// Contract the fold. + /// Fold actions. /// - Contract = NativeMethods.SC_FOLDACTION_CONTRACT, + public enum FoldAction + { + /// + /// Contract the fold. + /// + Contract = NativeMethods.SC_FOLDACTION_CONTRACT, - /// - /// Expand the fold. - /// - Expand = NativeMethods.SC_FOLDACTION_EXPAND, + /// + /// Expand the fold. + /// + Expand = NativeMethods.SC_FOLDACTION_EXPAND, - /// - /// Toggle between contracted and expanded. - /// - Toggle = NativeMethods.SC_FOLDACTION_TOGGLE + /// + /// Toggle between contracted and expanded. + /// + Toggle = NativeMethods.SC_FOLDACTION_TOGGLE + } } diff --git a/Scintilla.NET/FoldDisplayText.cs b/Scintilla.NET/FoldDisplayText.cs index 4bc3802..8f58421 100644 --- a/Scintilla.NET/FoldDisplayText.cs +++ b/Scintilla.NET/FoldDisplayText.cs @@ -1,22 +1,23 @@ -namespace ScintillaNET; - -/// -/// Display options for fold text tags. -/// -public enum FoldDisplayText +namespace ScintillaNET { /// - /// Do not display the text tags. This is the default. + /// Display options for fold text tags. /// - Hidden = NativeMethods.SC_FOLDDISPLAYTEXT_HIDDEN, + public enum FoldDisplayText + { + /// + /// Do not display the text tags. This is the default. + /// + Hidden = NativeMethods.SC_FOLDDISPLAYTEXT_HIDDEN, - /// - /// Display the text tags. - /// - Standard = NativeMethods.SC_FOLDDISPLAYTEXT_STANDARD, + /// + /// Display the text tags. + /// + Standard = NativeMethods.SC_FOLDDISPLAYTEXT_STANDARD, - /// - /// Display the text tags with a box drawn around them. - /// - Boxed = NativeMethods.SC_FOLDDISPLAYTEXT_BOXED + /// + /// Display the text tags with a box drawn around them. + /// + Boxed = NativeMethods.SC_FOLDDISPLAYTEXT_BOXED + } } diff --git a/Scintilla.NET/FoldFlags.cs b/Scintilla.NET/FoldFlags.cs index f09db23..17cb6d3 100644 --- a/Scintilla.NET/FoldFlags.cs +++ b/Scintilla.NET/FoldFlags.cs @@ -1,42 +1,43 @@ using System; -namespace ScintillaNET; - -/// -/// Additional display options for folds. -/// -[Flags] -public enum FoldFlags +namespace ScintillaNET { /// - /// A line is drawn above if expanded. + /// Additional display options for folds. /// - LineBeforeExpanded = NativeMethods.SC_FOLDFLAG_LINEBEFORE_EXPANDED, + [Flags] + public enum FoldFlags + { + /// + /// A line is drawn above if expanded. + /// + LineBeforeExpanded = NativeMethods.SC_FOLDFLAG_LINEBEFORE_EXPANDED, - /// - /// A line is drawn above if not expanded. - /// - LineBeforeContracted = NativeMethods.SC_FOLDFLAG_LINEBEFORE_CONTRACTED, + /// + /// A line is drawn above if not expanded. + /// + LineBeforeContracted = NativeMethods.SC_FOLDFLAG_LINEBEFORE_CONTRACTED, - /// - /// A line is drawn below if expanded. - /// - LineAfterExpanded = NativeMethods.SC_FOLDFLAG_LINEAFTER_EXPANDED, + /// + /// A line is drawn below if expanded. + /// + LineAfterExpanded = NativeMethods.SC_FOLDFLAG_LINEAFTER_EXPANDED, - /// - /// A line is drawn below if not expanded. - /// - LineAfterContracted = NativeMethods.SC_FOLDFLAG_LINEAFTER_CONTRACTED, + /// + /// A line is drawn below if not expanded. + /// + LineAfterContracted = NativeMethods.SC_FOLDFLAG_LINEAFTER_CONTRACTED, - /// - /// Displays the hexadecimal fold levels in the margin to aid with debugging. - /// This feature may change in the future. - /// - LevelNumbers = NativeMethods.SC_FOLDFLAG_LEVELNUMBERS, + /// + /// Displays the hexadecimal fold levels in the margin to aid with debugging. + /// This feature may change in the future. + /// + LevelNumbers = NativeMethods.SC_FOLDFLAG_LEVELNUMBERS, - /// - /// Displays the hexadecimal line state in the margin to aid with debugging. This flag - /// cannot be used at the same time as the flag. - /// - LineState = NativeMethods.SC_FOLDFLAG_LINESTATE + /// + /// Displays the hexadecimal line state in the margin to aid with debugging. This flag + /// cannot be used at the same time as the flag. + /// + LineState = NativeMethods.SC_FOLDFLAG_LINESTATE + } } diff --git a/Scintilla.NET/FoldLevelFlags.cs b/Scintilla.NET/FoldLevelFlags.cs index 1adb336..8eb5315 100644 --- a/Scintilla.NET/FoldLevelFlags.cs +++ b/Scintilla.NET/FoldLevelFlags.cs @@ -1,21 +1,22 @@ using System; -namespace ScintillaNET; - -/// -/// Flags for additional line fold level behavior. -/// -[Flags] -public enum FoldLevelFlags +namespace ScintillaNET { /// - /// Indicates that the line is blank and should be treated slightly different than its level may indicate; - /// otherwise, blank lines should generally not be fold points. + /// Flags for additional line fold level behavior. /// - White = NativeMethods.SC_FOLDLEVELWHITEFLAG, + [Flags] + public enum FoldLevelFlags + { + /// + /// Indicates that the line is blank and should be treated slightly different than its level may indicate; + /// otherwise, blank lines should generally not be fold points. + /// + White = NativeMethods.SC_FOLDLEVELWHITEFLAG, - /// - /// Indicates that the line is a header (fold point). - /// - Header = NativeMethods.SC_FOLDLEVELHEADERFLAG + /// + /// Indicates that the line is a header (fold point). + /// + Header = NativeMethods.SC_FOLDLEVELHEADERFLAG + } } diff --git a/Scintilla.NET/FontQuality.cs b/Scintilla.NET/FontQuality.cs index 281ee2d..8d5253d 100644 --- a/Scintilla.NET/FontQuality.cs +++ b/Scintilla.NET/FontQuality.cs @@ -1,28 +1,29 @@ -namespace ScintillaNET; - -/// -/// The font quality (antialiasing method) used to render text. -/// -public enum FontQuality +namespace ScintillaNET { /// - /// Specifies that the character quality of the font does not matter; so the lowest quality can be used. - /// This is the default. + /// The font quality (antialiasing method) used to render text. /// - Default = NativeMethods.SC_EFF_QUALITY_DEFAULT, + public enum FontQuality + { + /// + /// Specifies that the character quality of the font does not matter; so the lowest quality can be used. + /// This is the default. + /// + Default = NativeMethods.SC_EFF_QUALITY_DEFAULT, - /// - /// Specifies that anti-aliasing should not be used when rendering text. - /// - NonAntiAliased = NativeMethods.SC_EFF_QUALITY_NON_ANTIALIASED, + /// + /// Specifies that anti-aliasing should not be used when rendering text. + /// + NonAntiAliased = NativeMethods.SC_EFF_QUALITY_NON_ANTIALIASED, - /// - /// Specifies that anti-aliasing should be used when rendering text, if the font supports it. - /// - AntiAliased = NativeMethods.SC_EFF_QUALITY_ANTIALIASED, + /// + /// Specifies that anti-aliasing should be used when rendering text, if the font supports it. + /// + AntiAliased = NativeMethods.SC_EFF_QUALITY_ANTIALIASED, - /// - /// Specifies that ClearType anti-aliasing should be used when rendering text, if the font supports it. - /// - LcdOptimized = NativeMethods.SC_EFF_QUALITY_LCD_OPTIMIZED + /// + /// Specifies that ClearType anti-aliasing should be used when rendering text, if the font supports it. + /// + LcdOptimized = NativeMethods.SC_EFF_QUALITY_LCD_OPTIMIZED + } } diff --git a/Scintilla.NET/GapBuffer.cs b/Scintilla.NET/GapBuffer.cs index 2f2ea6e..2c710fe 100644 --- a/Scintilla.NET/GapBuffer.cs +++ b/Scintilla.NET/GapBuffer.cs @@ -3,179 +3,180 @@ using System.Collections.Generic; using System.Diagnostics; -namespace ScintillaNET; - -// Do error checking higher up -// http://www.codeproject.com/Articles/20910/Generic-Gap-Buffer -[DebuggerDisplay("Count = {Count}")] -internal sealed class GapBuffer : IEnumerable +namespace ScintillaNET { - private T[] buffer; - private int gapStart; - private int gapEnd; - - public void Add(T item) + // Do error checking higher up + // http://www.codeproject.com/Articles/20910/Generic-Gap-Buffer + [DebuggerDisplay("Count = {Count}")] + internal sealed class GapBuffer : IEnumerable { - Insert(Count, item); - } + private T[] buffer; + private int gapStart; + private int gapEnd; - public void AddRange(ICollection collection) - { - InsertRange(Count, collection); - } + public void Add(T item) + { + Insert(Count, item); + } - private void EnsureGapCapacity(int length) - { - if (length > this.gapEnd - this.gapStart) + public void AddRange(ICollection collection) { - // How much to grow the buffer is a tricky question. - // Our current algo will double the capacity unless that's not enough. - int minCapacity = Count + length; - int newCapacity = this.buffer.Length * 2; - if (newCapacity < minCapacity) + InsertRange(Count, collection); + } + + private void EnsureGapCapacity(int length) + { + if (length > this.gapEnd - this.gapStart) { - newCapacity = minCapacity; + // How much to grow the buffer is a tricky question. + // Our current algo will double the capacity unless that's not enough. + int minCapacity = Count + length; + int newCapacity = this.buffer.Length * 2; + if (newCapacity < minCapacity) + { + newCapacity = minCapacity; + } + + var newBuffer = new T[newCapacity]; + int newGapEnd = newBuffer.Length - (this.buffer.Length - this.gapEnd); + + Array.Copy(this.buffer, 0, newBuffer, 0, this.gapStart); + Array.Copy(this.buffer, this.gapEnd, newBuffer, newGapEnd, newBuffer.Length - newGapEnd); + this.buffer = newBuffer; + this.gapEnd = newGapEnd; } - - var newBuffer = new T[newCapacity]; - int newGapEnd = newBuffer.Length - (this.buffer.Length - this.gapEnd); - - Array.Copy(this.buffer, 0, newBuffer, 0, this.gapStart); - Array.Copy(this.buffer, this.gapEnd, newBuffer, newGapEnd, newBuffer.Length - newGapEnd); - this.buffer = newBuffer; - this.gapEnd = newGapEnd; } - } - - public IEnumerator GetEnumerator() - { - int count = Count; - for (int i = 0; i < count; i++) - yield return this[i]; - yield break; - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + public IEnumerator GetEnumerator() + { + int count = Count; + for (int i = 0; i < count; i++) + yield return this[i]; - public void Insert(int index, T item) - { - PlaceGapStart(index); - EnsureGapCapacity(1); + yield break; + } - this.buffer[index] = item; - this.gapStart++; - } + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } - public void InsertRange(int index, ICollection collection) - { - int count = collection.Count; - if (count > 0) + public void Insert(int index, T item) { PlaceGapStart(index); - EnsureGapCapacity(count); + EnsureGapCapacity(1); - collection.CopyTo(this.buffer, this.gapStart); - this.gapStart += count; + this.buffer[index] = item; + this.gapStart++; } - } - private void PlaceGapStart(int index) - { - if (index != this.gapStart) + public void InsertRange(int index, ICollection collection) { - if (this.gapEnd - this.gapStart == 0) + int count = collection.Count; + if (count > 0) { - // There is no gap - this.gapStart = index; - this.gapEnd = index; - } - else if (index < this.gapStart) - { - // Move gap left (copy contents right) - int length = this.gapStart - index; - int deltaLength = this.gapEnd - this.gapStart < length ? this.gapEnd - this.gapStart : length; - Array.Copy(this.buffer, index, this.buffer, this.gapEnd - length, length); - this.gapStart -= length; - this.gapEnd -= length; - - Array.Clear(this.buffer, index, deltaLength); + PlaceGapStart(index); + EnsureGapCapacity(count); + + collection.CopyTo(this.buffer, this.gapStart); + this.gapStart += count; } - else + } + + private void PlaceGapStart(int index) + { + if (index != this.gapStart) { - // Move gap right (copy contents left) - int length = index - this.gapStart; - int deltaIndex = index > this.gapEnd ? index : this.gapEnd; - Array.Copy(this.buffer, this.gapEnd, this.buffer, this.gapStart, length); - this.gapStart += length; - this.gapEnd += length; - - Array.Clear(this.buffer, deltaIndex, this.gapEnd - deltaIndex); + if (this.gapEnd - this.gapStart == 0) + { + // There is no gap + this.gapStart = index; + this.gapEnd = index; + } + else if (index < this.gapStart) + { + // Move gap left (copy contents right) + int length = this.gapStart - index; + int deltaLength = this.gapEnd - this.gapStart < length ? this.gapEnd - this.gapStart : length; + Array.Copy(this.buffer, index, this.buffer, this.gapEnd - length, length); + this.gapStart -= length; + this.gapEnd -= length; + + Array.Clear(this.buffer, index, deltaLength); + } + else + { + // Move gap right (copy contents left) + int length = index - this.gapStart; + int deltaIndex = index > this.gapEnd ? index : this.gapEnd; + Array.Copy(this.buffer, this.gapEnd, this.buffer, this.gapStart, length); + this.gapStart += length; + this.gapEnd += length; + + Array.Clear(this.buffer, deltaIndex, this.gapEnd - deltaIndex); + } } } - } - - public void RemoveAt(int index) - { - PlaceGapStart(index); - this.buffer[this.gapEnd] = default; - this.gapEnd++; - } - public void RemoveRange(int index, int count) - { - if (count > 0) + public void RemoveAt(int index) { PlaceGapStart(index); - Array.Clear(this.buffer, this.gapEnd, count); - this.gapEnd += count; + this.buffer[this.gapEnd] = default; + this.gapEnd++; } - } - public int Count - { - get + public void RemoveRange(int index, int count) { - return this.buffer.Length - (this.gapEnd - this.gapStart); + if (count > 0) + { + PlaceGapStart(index); + Array.Clear(this.buffer, this.gapEnd, count); + this.gapEnd += count; + } + } + + public int Count + { + get + { + return this.buffer.Length - (this.gapEnd - this.gapStart); + } } - } #if DEBUG - // Poor man's DebuggerTypeProxy because I can't seem to get that working - private List Debug - { - get + // Poor man's DebuggerTypeProxy because I can't seem to get that working + private List Debug { - var list = new List(this); - return list; + get + { + var list = new List(this); + return list; + } } - } #endif - public T this[int index] - { - get + public T this[int index] { - if (index < this.gapStart) - return this.buffer[index]; + get + { + if (index < this.gapStart) + return this.buffer[index]; - return this.buffer[index + (this.gapEnd - this.gapStart)]; - } - set - { - if (index >= this.gapStart) - index += this.gapEnd - this.gapStart; + return this.buffer[index + (this.gapEnd - this.gapStart)]; + } + set + { + if (index >= this.gapStart) + index += this.gapEnd - this.gapStart; - this.buffer[index] = value; + this.buffer[index] = value; + } } - } - public GapBuffer(int capacity = 0) - { - this.buffer = new T[capacity]; - this.gapEnd = this.buffer.Length; + public GapBuffer(int capacity = 0) + { + this.buffer = new T[capacity]; + this.gapEnd = this.buffer.Length; + } } } diff --git a/Scintilla.NET/HelperMethods.cs b/Scintilla.NET/HelperMethods.cs index d1d3eb7..74bed10 100644 --- a/Scintilla.NET/HelperMethods.cs +++ b/Scintilla.NET/HelperMethods.cs @@ -3,110 +3,111 @@ using System.Drawing; using System.Linq; -namespace ScintillaNET; - -/// -/// Helper methods for the control. -/// -public static class HelperMethods +namespace ScintillaNET { - private static readonly Dictionary knownColorMap = []; - - static HelperMethods() + /// + /// Helper methods for the control. + /// + public static class HelperMethods { - foreach (KnownColor knownColor in Enum.GetValues(typeof(KnownColor)).Cast().Where(k => k is >= KnownColor.Transparent and < KnownColor.ButtonFace)) + private static readonly Dictionary knownColorMap = new Dictionary(); + + static HelperMethods() { - var color = Color.FromKnownColor(knownColor); - knownColorMap[ToWin32Color(color)] = color; + foreach (KnownColor knownColor in Enum.GetValues(typeof(KnownColor)).Cast().Where(k => k >= KnownColor.Transparent && k < KnownColor.ButtonFace)) + { + var color = Color.FromKnownColor(knownColor); + knownColorMap[ToWin32Color(color)] = color; + } } - } - /// - /// Converts an ABGR WinAPI color to . - /// - /// The color value to convert. - /// A equivalent of the ABGR WinAPI color. - public static Color FromWin32Color(int color) - { - if ((color & 0xFF_00_00_00) == 0) - return Color.Transparent; + /// + /// Converts an ABGR WinAPI color to . + /// + /// The color value to convert. + /// A equivalent of the ABGR WinAPI color. + public static Color FromWin32Color(int color) + { + if ((color & 0xFF_00_00_00) == 0) + return Color.Transparent; - if (knownColorMap.TryGetValue(color, out Color result)) - // We do all this nonsense because Visual Studio designer does not - // mark raw colors as default if there exists a known color - // with the same value. - return result; + if (knownColorMap.TryGetValue(color, out Color result)) + // We do all this nonsense because Visual Studio designer does not + // mark raw colors as default if there exists a known color + // with the same value. + return result; - return Color.FromArgb((color >> 24) & 0xFF, (color >> 0) & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF); - } + return Color.FromArgb((color >> 24) & 0xFF, (color >> 0) & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF); + } - /// - /// Converts a to ABGR WinAPI color. - /// - /// The instance to convert. - /// ABGR WinAPI color value of the instance. - public static int ToWin32Color(Color color) - { - return (color.A << 24) | (color.R << 0) | (color.G << 8) | (color.B << 16); - } + /// + /// Converts a to ABGR WinAPI color. + /// + /// The instance to convert. + /// ABGR WinAPI color value of the instance. + public static int ToWin32Color(Color color) + { + return (color.A << 24) | (color.R << 0) | (color.G << 8) | (color.B << 16); + } - /// - /// Converts an ABGR WinAPI color to while ignoring the alpha channel. - /// - /// The color value to convert. - /// A equivalent of the ABGR WinAPI color with alpha channel value set to max (opaque). - public static Color FromWin32ColorOpaque(int color) - { - color |= unchecked((int)0xFF_00_00_00); + /// + /// Converts an ABGR WinAPI color to while ignoring the alpha channel. + /// + /// The color value to convert. + /// A equivalent of the ABGR WinAPI color with alpha channel value set to max (opaque). + public static Color FromWin32ColorOpaque(int color) + { + color |= unchecked((int)0xFF_00_00_00); - if (knownColorMap.TryGetValue(color, out Color result)) - // We do all this nonsense because Visual Studio designer does not - // mark raw colors as default if there exists a known color - // with the same value. - return result; + if (knownColorMap.TryGetValue(color, out Color result)) + // We do all this nonsense because Visual Studio designer does not + // mark raw colors as default if there exists a known color + // with the same value. + return result; - return Color.FromArgb((color >> 0) & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF); - } + return Color.FromArgb((color >> 0) & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF); + } - /// - /// Converts a to ABGR WinAPI color while ignoring the alpha channel. - /// - /// The instance to convert. - /// ABGR WinAPI color value of the instance with alpha channel value set to max (opaque). - public static int ToWin32ColorOpaque(Color color) - { - return (0xFF << 24) | (color.R << 0) | (color.G << 8) | (color.B << 16); - } + /// + /// Converts a to ABGR WinAPI color while ignoring the alpha channel. + /// + /// The instance to convert. + /// ABGR WinAPI color value of the instance with alpha channel value set to max (opaque). + public static int ToWin32ColorOpaque(Color color) + { + return (0xFF << 24) | (color.R << 0) | (color.G << 8) | (color.B << 16); + } - /// - /// Gets the folding state of the control as a delimited string containing line indexes. - /// - /// The control instance. - /// The string to use as a separator. - /// The folding state of the control. - public static string GetFoldingState(this Scintilla scintilla, string separator = ";") - { - return string.Join(separator, - scintilla.Lines.Where(f => !f.Expanded).Select(f => f.Index).OrderBy(f => f).ToArray()); - } + /// + /// Gets the folding state of the control as a delimited string containing line indexes. + /// + /// The control instance. + /// The string to use as a separator. + /// The folding state of the control. + public static string GetFoldingState(this Scintilla scintilla, string separator = ";") + { + return string.Join(separator, + scintilla.Lines.Where(f => !f.Expanded).Select(f => f.Index).OrderBy(f => f).ToArray()); + } - /// - /// Sets the folding state of the state of the control with specified index string. - /// - /// The control instance. - /// A string containing the folded line indexes separated with the to restore the folding. - /// The string to use as a separator. - public static void SetFoldingState(this Scintilla scintilla, string foldingState, string separator = ";") - { - scintilla.FoldAll(FoldAction.Expand); - foreach (int index in foldingState.Split(new[] { separator }, System.StringSplitOptions.None).Select(int.Parse)) + /// + /// Sets the folding state of the state of the control with specified index string. + /// + /// The control instance. + /// A string containing the folded line indexes separated with the to restore the folding. + /// The string to use as a separator. + public static void SetFoldingState(this Scintilla scintilla, string foldingState, string separator = ";") { - if (index < 0 || index >= scintilla.Lines.Count) + scintilla.FoldAll(FoldAction.Expand); + foreach (int index in foldingState.Split(new[] { separator }, System.StringSplitOptions.None).Select(int.Parse)) { - continue; - } + if (index < 0 || index >= scintilla.Lines.Count) + { + continue; + } - scintilla.Lines[index].ToggleFold(); + scintilla.Lines[index].ToggleFold(); + } } } } diff --git a/Scintilla.NET/Helpers.cs b/Scintilla.NET/Helpers.cs index cd6be8f..48fcf99 100644 --- a/Scintilla.NET/Helpers.cs +++ b/Scintilla.NET/Helpers.cs @@ -7,1239 +7,1227 @@ using System.Text; using System.Windows.Forms; -namespace ScintillaNET; - -internal static class Helpers +namespace ScintillaNET { - #region Fields - - private static bool registeredFormats; - private static uint CF_HTML; - private static uint CF_RTF; - private static uint CF_LINESELECT; - private static uint CF_VSLINETAG; - - #endregion Fields - - #region Methods - - public static long CopyTo(this Stream source, Stream destination) + internal static class Helpers { - byte[] buffer = new byte[2048]; - int bytesRead; - long totalBytes = 0; - while ((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0) - { - destination.Write(buffer, 0, bytesRead); - totalBytes += bytesRead; - } + #region Fields - return totalBytes; - } + private static bool registeredFormats; + private static uint CF_HTML; + private static uint CF_RTF; + private static uint CF_LINESELECT; + private static uint CF_VSLINETAG; - public static unsafe byte[] BitmapToArgb(Bitmap image) - { - // This code originally used Image.LockBits and some fast byte copying, however, the endianness - // of the image formats was making my brain hurt. For now I'm going to use the slow but simple - // GetPixel approach. + #endregion Fields - byte[] bytes = new byte[4 * image.Width * image.Height]; + #region Methods - int i = 0; - for (int y = 0; y < image.Height; y++) + public static long CopyTo(this Stream source, Stream destination) { - for (int x = 0; x < image.Width; x++) + byte[] buffer = new byte[2048]; + int bytesRead; + long totalBytes = 0; + while ((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0) { - Color color = image.GetPixel(x, y); - bytes[i++] = color.R; - bytes[i++] = color.G; - bytes[i++] = color.B; - bytes[i++] = color.A; + destination.Write(buffer, 0, bytesRead); + totalBytes += bytesRead; } - } - return bytes; - } + return totalBytes; + } - public static unsafe byte[] ByteToCharStyles(byte* styles, byte* text, int length, Encoding encoding) - { - // This is used by annotations and margins to get all the styles in one call. - // It converts an array of styles where each element corresponds to a BYTE - // to an array of styles where each element corresponds to a CHARACTER. + public static unsafe byte[] BitmapToArgb(Bitmap image) + { + // This code originally used Image.LockBits and some fast byte copying, however, the endianness + // of the image formats was making my brain hurt. For now I'm going to use the slow but simple + // GetPixel approach. - int bytePos = 0; // Position within text BYTES and style BYTES (should be the same) - int charPos = 0; // Position within style CHARACTERS - Decoder decoder = encoding.GetDecoder(); - byte[] result = new byte[encoding.GetCharCount(text, length)]; + byte[] bytes = new byte[4 * image.Width * image.Height]; - while (bytePos < length) - { - if (decoder.GetCharCount(text + bytePos, 1, false) > 0) - result[charPos++] = *(styles + bytePos); // New char + int i = 0; + for (int y = 0; y < image.Height; y++) + { + for (int x = 0; x < image.Width; x++) + { + Color color = image.GetPixel(x, y); + bytes[i++] = color.R; + bytes[i++] = color.G; + bytes[i++] = color.B; + bytes[i++] = color.A; + } + } - bytePos++; + return bytes; } - return result; - } + public static unsafe byte[] ByteToCharStyles(byte* styles, byte* text, int length, Encoding encoding) + { + // This is used by annotations and margins to get all the styles in one call. + // It converts an array of styles where each element corresponds to a BYTE + // to an array of styles where each element corresponds to a CHARACTER. - public static unsafe byte[] CharToByteStyles(byte[] styles, byte* text, int length, Encoding encoding) - { - // This is used by annotations and margins to style all the text in one call. - // It converts an array of styles where each element corresponds to a CHARACTER - // to an array of styles where each element corresponds to a BYTE. + int bytePos = 0; // Position within text BYTES and style BYTES (should be the same) + int charPos = 0; // Position within style CHARACTERS + Decoder decoder = encoding.GetDecoder(); + byte[] result = new byte[encoding.GetCharCount(text, length)]; - int bytePos = 0; // Position within text BYTES and style BYTES (should be the same) - int charPos = 0; // Position within style CHARACTERS - Decoder decoder = encoding.GetDecoder(); - byte[] result = new byte[length]; + while (bytePos < length) + { + if (decoder.GetCharCount(text + bytePos, 1, false) > 0) + result[charPos++] = *(styles + bytePos); // New char - while (bytePos < length && charPos < styles.Length) - { - result[bytePos] = styles[charPos]; - if (decoder.GetCharCount(text + bytePos, 1, false) > 0) - charPos++; // Move a char + bytePos++; + } - bytePos++; + return result; } - return result; - } - - public static float Clamp(float f, float min, float max) - { - return f < min ? min : f > max ? max : f; - } - - public static int Clamp(int value, int min, int max) - { - if (value < min) - return min; + public static unsafe byte[] CharToByteStyles(byte[] styles, byte* text, int length, Encoding encoding) + { + // This is used by annotations and margins to style all the text in one call. + // It converts an array of styles where each element corresponds to a CHARACTER + // to an array of styles where each element corresponds to a BYTE. - if (value > max) - return max; + int bytePos = 0; // Position within text BYTES and style BYTES (should be the same) + int charPos = 0; // Position within style CHARACTERS + Decoder decoder = encoding.GetDecoder(); + byte[] result = new byte[length]; - return value; - } + while (bytePos < length && charPos < styles.Length) + { + result[bytePos] = styles[charPos]; + if (decoder.GetCharCount(text + bytePos, 1, false) > 0) + charPos++; // Move a char - public static int ClampMin(int value, int min) - { - if (value < min) - return min; + bytePos++; + } - return value; - } + return result; + } - public static void Copy(Scintilla scintilla, CopyFormat format, bool useSelection, bool allowLine, int startBytePos, int endBytePos) - { - // Plain text - if ((format & CopyFormat.Text) > 0) + public static float Clamp(float f, float min, float max) { - if (useSelection) - { - if (allowLine) - scintilla.DirectMessage(NativeMethods.SCI_COPYALLOWLINE); - else - scintilla.DirectMessage(NativeMethods.SCI_COPY); - } - else - { - scintilla.DirectMessage(NativeMethods.SCI_COPYRANGE, new IntPtr(startBytePos), new IntPtr(endBytePos)); - } + return f < min ? min : f > max ? max : f; } - // RTF and/or HTML - if ((format & (CopyFormat.Rtf | CopyFormat.Html)) > 0) + public static int Clamp(int value, int min, int max) { - // If we ever allow more than UTF-8, this will have to be revisited - Debug.Assert(scintilla.DirectMessage(NativeMethods.SCI_GETCODEPAGE).ToInt32() == NativeMethods.SC_CP_UTF8); + if (value < min) + return min; - if (!registeredFormats) - { - // Register non-standard clipboard formats. - // Scintilla -> ScintillaWin.cxx - // NppExport -> HTMLExporter.h - // NppExport -> RTFExporter.h - - CF_LINESELECT = NativeMethods.RegisterClipboardFormat("MSDEVLineSelect"); - CF_VSLINETAG = NativeMethods.RegisterClipboardFormat("VisualStudioEditorOperationsLineCutCopyClipboardTag"); - CF_HTML = NativeMethods.RegisterClipboardFormat("HTML Format"); - CF_RTF = NativeMethods.RegisterClipboardFormat("Rich Text Format"); - registeredFormats = true; - } + if (value > max) + return max; + + return value; + } + + public static int ClampMin(int value, int min) + { + if (value < min) + return min; - bool lineCopy = false; - StyleData[] styles = null; - List> styledSegments = null; + return value; + } - if (useSelection) + public static void Copy(Scintilla scintilla, CopyFormat format, bool useSelection, bool allowLine, int startBytePos, int endBytePos) + { + // Plain text + if ((format & CopyFormat.Text) > 0) { - bool selIsEmpty = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONEMPTY) != IntPtr.Zero; - if (selIsEmpty) + if (useSelection) { if (allowLine) - { - // Get the current line - styledSegments = GetStyledSegments(scintilla, false, true, 0, 0, out styles); - lineCopy = true; - } + scintilla.DirectMessage(NativeMethods.SCI_COPYALLOWLINE); + else + scintilla.DirectMessage(NativeMethods.SCI_COPY); } else { - // Get every selection - styledSegments = GetStyledSegments(scintilla, true, false, 0, 0, out styles); + scintilla.DirectMessage(NativeMethods.SCI_COPYRANGE, new IntPtr(startBytePos), new IntPtr(endBytePos)); } } - else if (startBytePos != endBytePos) - { - // User-specified range - styledSegments = GetStyledSegments(scintilla, false, false, startBytePos, endBytePos, out styles); - } - // If we have segments and can open the clipboard - if (styledSegments != null && styledSegments.Count > 0 && NativeMethods.OpenClipboard(scintilla.Handle)) + // RTF and/or HTML + if ((format & (CopyFormat.Rtf | CopyFormat.Html)) > 0) { - if ((format & CopyFormat.Text) == 0) + // If we ever allow more than UTF-8, this will have to be revisited + Debug.Assert(scintilla.DirectMessage(NativeMethods.SCI_GETCODEPAGE).ToInt32() == NativeMethods.SC_CP_UTF8); + + if (!registeredFormats) { - // Do the things default (plain text) processing would normally give us - NativeMethods.EmptyClipboard(); + // Register non-standard clipboard formats. + // Scintilla -> ScintillaWin.cxx + // NppExport -> HTMLExporter.h + // NppExport -> RTFExporter.h + + CF_LINESELECT = NativeMethods.RegisterClipboardFormat("MSDEVLineSelect"); + CF_VSLINETAG = NativeMethods.RegisterClipboardFormat("VisualStudioEditorOperationsLineCutCopyClipboardTag"); + CF_HTML = NativeMethods.RegisterClipboardFormat("HTML Format"); + CF_RTF = NativeMethods.RegisterClipboardFormat("Rich Text Format"); + registeredFormats = true; + } + + bool lineCopy = false; + StyleData[] styles = null; + List> styledSegments = null; - if (lineCopy) + if (useSelection) + { + bool selIsEmpty = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONEMPTY) != IntPtr.Zero; + if (selIsEmpty) { - // Clipboard tags - NativeMethods.SetClipboardData(CF_LINESELECT, IntPtr.Zero); - NativeMethods.SetClipboardData(CF_VSLINETAG, IntPtr.Zero); + if (allowLine) + { + // Get the current line + styledSegments = GetStyledSegments(scintilla, false, true, 0, 0, out styles); + lineCopy = true; + } + } + else + { + // Get every selection + styledSegments = GetStyledSegments(scintilla, true, false, 0, 0, out styles); } } + else if (startBytePos != endBytePos) + { + // User-specified range + styledSegments = GetStyledSegments(scintilla, false, false, startBytePos, endBytePos, out styles); + } - // RTF - if ((format & CopyFormat.Rtf) > 0) - CopyRtf(scintilla, styles, styledSegments); + // If we have segments and can open the clipboard + if (styledSegments != null && styledSegments.Count > 0 && NativeMethods.OpenClipboard(scintilla.Handle)) + { + if ((format & CopyFormat.Text) == 0) + { + // Do the things default (plain text) processing would normally give us + NativeMethods.EmptyClipboard(); - // HTML - if ((format & CopyFormat.Html) > 0) - CopyHtml(scintilla, styles, styledSegments); + if (lineCopy) + { + // Clipboard tags + NativeMethods.SetClipboardData(CF_LINESELECT, IntPtr.Zero); + NativeMethods.SetClipboardData(CF_VSLINETAG, IntPtr.Zero); + } + } - NativeMethods.CloseClipboard(); - } - } - } + // RTF + if ((format & CopyFormat.Rtf) > 0) + CopyRtf(scintilla, styles, styledSegments); - private static unsafe void CopyHtml(Scintilla scintilla, StyleData[] styles, List> styledSegments) - { - // NppExport -> NppExport.cpp - // NppExport -> HTMLExporter.cpp - // http://blogs.msdn.com/b/jmstall/archive/2007/01/21/html-clipboard.aspx - // http://blogs.msdn.com/b/jmstall/archive/2007/01/21/sample-code-html-clipboard.aspx - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms649015.aspx + // HTML + if ((format & CopyFormat.Html) > 0) + CopyHtml(scintilla, styles, styledSegments); - try - { - long pos = 0; - byte[] bytes; - - // Write HTML - using var ms = new NativeMemoryStream(styledSegments.Sum(s => s.Count)); - using var tw = new StreamWriter(ms, new UTF8Encoding(false)); - const int INDEX_START_HTML = 23; - const int INDEX_START_FRAGMENT = 65; - const int INDEX_END_FRAGMENT = 87; - const int INDEX_END_HTML = 41; - - tw.WriteLine("Version:0.9"); - tw.WriteLine("StartHTML:00000000"); - tw.WriteLine("EndHTML:00000000"); - tw.WriteLine("StartFragment:00000000"); - tw.WriteLine("EndFragment:00000000"); - tw.Flush(); - - // Patch header - pos = ms.Position; - ms.Seek(INDEX_START_HTML, SeekOrigin.Begin); - ms.Write(bytes = Encoding.ASCII.GetBytes(ms.Length.ToString("D8")), 0, bytes.Length); - ms.Seek(pos, SeekOrigin.Begin); - - tw.WriteLine(""); - tw.WriteLine(""); - tw.WriteLine(@""); - tw.WriteLine(@"ScintillaNET v{0}", scintilla.GetType().Assembly.GetName().Version.ToString(3)); - tw.WriteLine(""); - tw.WriteLine(""); - tw.Flush(); - - // Patch header - pos = ms.Position; - ms.Seek(INDEX_START_FRAGMENT, SeekOrigin.Begin); - ms.Write(bytes = Encoding.ASCII.GetBytes(ms.Length.ToString("D8")), 0, bytes.Length); - ms.Seek(pos, SeekOrigin.Begin); - tw.WriteLine(""); - - // Write the styles. - // We're doing the style tag in the body to include it in the "fragment". - tw.WriteLine(@""); - tw.Write(@"
", Style.Default); - tw.Flush(); - - int tabSize = scintilla.DirectMessage(NativeMethods.SCI_GETTABWIDTH).ToInt32(); - string tab = new(' ', tabSize); + private static unsafe void CopyHtml(Scintilla scintilla, StyleData[] styles, List> styledSegments) + { + // NppExport -> NppExport.cpp + // NppExport -> HTMLExporter.cpp + // http://blogs.msdn.com/b/jmstall/archive/2007/01/21/html-clipboard.aspx + // http://blogs.msdn.com/b/jmstall/archive/2007/01/21/sample-code-html-clipboard.aspx + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms649015.aspx - tw.AutoFlush = true; - int lastStyle = Style.Default; - bool unicodeLineEndings = (scintilla.DirectMessage(NativeMethods.SCI_GETLINEENDTYPESACTIVE).ToInt32() & NativeMethods.SC_LINE_END_TYPE_UNICODE) > 0; - foreach (ArraySegment seg in styledSegments) + try { - int endOffset = seg.Offset + seg.Count; - for (int i = seg.Offset; i < endOffset; i += 2) - { - byte ch = seg.Array[i]; - byte style = seg.Array[i + 1]; + long pos = 0; + byte[] bytes; - if (lastStyle != style) - { - tw.Write(@"", style); - lastStyle = style; - } + // Write HTML + const int INDEX_START_HTML = 23; + const int INDEX_START_FRAGMENT = 65; + const int INDEX_END_FRAGMENT = 87; + const int INDEX_END_HTML = 41; - switch (ch) + using (var ms = new NativeMemoryStream(styledSegments.Sum(s => s.Count))) + { + using (var tw = new StreamWriter(ms, new UTF8Encoding(false))) { - case (byte)'<': - tw.Write("<"); - break; - - case (byte)'>': - tw.Write(">"); - break; - - case (byte)'&': - tw.Write("&"); - break; - - case (byte)'\t': - tw.Write(tab); - break; - - case (byte)'\r': - if (i + 2 < endOffset) + tw.WriteLine("Version:0.9"); + tw.WriteLine("StartHTML:00000000"); + tw.WriteLine("EndHTML:00000000"); + tw.WriteLine("StartFragment:00000000"); + tw.WriteLine("EndFragment:00000000"); + tw.Flush(); + + // Patch header + pos = ms.Position; + ms.Seek(INDEX_START_HTML, SeekOrigin.Begin); + ms.Write(bytes = Encoding.ASCII.GetBytes(ms.Length.ToString("D8")), 0, bytes.Length); + ms.Seek(pos, SeekOrigin.Begin); + + tw.WriteLine(""); + tw.WriteLine(""); + tw.WriteLine(@""); + tw.WriteLine(@"ScintillaNET v{0}", scintilla.GetType().Assembly.GetName().Version.ToString(3)); + tw.WriteLine(""); + tw.WriteLine(""); + tw.Flush(); + + // Patch header + pos = ms.Position; + ms.Seek(INDEX_START_FRAGMENT, SeekOrigin.Begin); + ms.Write(bytes = Encoding.ASCII.GetBytes(ms.Length.ToString("D8")), 0, bytes.Length); + ms.Seek(pos, SeekOrigin.Begin); + tw.WriteLine(""); + + // Write the styles. + // We're doing the style tag in the body to include it in the "fragment". + tw.WriteLine(@""); + tw.Write(@"
", Style.Default); + tw.Flush(); - // Not a Unicode line break - goto default; + int tabSize = scintilla.DirectMessage(NativeMethods.SCI_GETTABWIDTH).ToInt32(); + string tab = new string(' ', tabSize); - case 0xE2: - if (unicodeLineEndings && i + 4 < endOffset) + tw.AutoFlush = true; + int lastStyle = Style.Default; + bool unicodeLineEndings = (scintilla.DirectMessage(NativeMethods.SCI_GETLINEENDTYPESACTIVE).ToInt32() & NativeMethods.SC_LINE_END_TYPE_UNICODE) > 0; + foreach (ArraySegment seg in styledSegments) + { + int endOffset = seg.Offset + seg.Count; + for (int i = seg.Offset; i < endOffset; i += 2) { - if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA8) // LS \u2028 + byte ch = seg.Array[i]; + byte style = seg.Array[i + 1]; + + if (lastStyle != style) { - i += 4; - goto case (byte)'\n'; + tw.Write(@"", style); + lastStyle = style; } - else if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA9) // PS \u2029 + + switch (ch) { - i += 4; - goto case (byte)'\n'; + case (byte)'<': + tw.Write("<"); + break; + + case (byte)'>': + tw.Write(">"); + break; + + case (byte)'&': + tw.Write("&"); + break; + + case (byte)'\t': + tw.Write(tab); + break; + + case (byte)'\r': + if (i + 2 < endOffset) + { + if (seg.Array[i + 2] == (byte)'\n') + i += 2; + } + + // Either way, this is a line break + goto case (byte)'\n'; + + case 0xC2: + if (unicodeLineEndings && i + 2 < endOffset) + { + if (seg.Array[i + 2] == 0x85) // NEL \u0085 + { + i += 2; + goto case (byte)'\n'; + } + } + + // Not a Unicode line break + goto default; + + case 0xE2: + if (unicodeLineEndings && i + 4 < endOffset) + { + if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA8) // LS \u2028 + { + i += 4; + goto case (byte)'\n'; + } + else if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA9) // PS \u2029 + { + i += 4; + goto case (byte)'\n'; + } + } + + // Not a Unicode line break + goto default; + + case (byte)'\n': + // All your line breaks are belong to us + tw.Write("\r\n"); + break; + + default: + + if (ch == 0) + { + // Scintilla behavior is to allow control characters except for + // NULL which will cause the Clipboard to truncate the string. + tw.Write(" "); // Replace with space + break; + } + + ms.WriteByte(ch); + break; } } + } - // Not a Unicode line break - goto default; - - case (byte)'\n': - // All your line breaks are belong to us - tw.Write("\r\n"); - break; - - default: - - if (ch == 0) - { - // Scintilla behavior is to allow control characters except for - // NULL which will cause the Clipboard to truncate the string. - tw.Write(" "); // Replace with space - break; - } - - ms.WriteByte(ch); - break; + tw.AutoFlush = false; + tw.WriteLine("
"); + tw.Flush(); + + // Patch header + pos = ms.Position; + ms.Seek(INDEX_END_FRAGMENT, SeekOrigin.Begin); + ms.Write(bytes = Encoding.ASCII.GetBytes(ms.Length.ToString("D8")), 0, bytes.Length); + ms.Seek(pos, SeekOrigin.Begin); + tw.WriteLine(""); + + tw.WriteLine(""); + tw.WriteLine(""); + tw.Flush(); + + // Patch header + pos = ms.Position; + ms.Seek(INDEX_END_HTML, SeekOrigin.Begin); + ms.Write(bytes = Encoding.ASCII.GetBytes(ms.Length.ToString("D8")), 0, bytes.Length); + ms.Seek(pos, SeekOrigin.Begin); + + // Terminator + ms.WriteByte(0); + + string str = GetString(ms.Pointer, (int)ms.Length, Encoding.UTF8); + if (NativeMethods.SetClipboardData(CF_HTML, ms.Pointer) != IntPtr.Zero) + ms.FreeOnDispose = false; // Clipboard will free memory } } } - - tw.AutoFlush = false; - tw.WriteLine("
"); - tw.Flush(); - - // Patch header - pos = ms.Position; - ms.Seek(INDEX_END_FRAGMENT, SeekOrigin.Begin); - ms.Write(bytes = Encoding.ASCII.GetBytes(ms.Length.ToString("D8")), 0, bytes.Length); - ms.Seek(pos, SeekOrigin.Begin); - tw.WriteLine(""); - - tw.WriteLine(""); - tw.WriteLine(""); - tw.Flush(); - - // Patch header - pos = ms.Position; - ms.Seek(INDEX_END_HTML, SeekOrigin.Begin); - ms.Write(bytes = Encoding.ASCII.GetBytes(ms.Length.ToString("D8")), 0, bytes.Length); - ms.Seek(pos, SeekOrigin.Begin); - - // Terminator - ms.WriteByte(0); - - string str = GetString(ms.Pointer, (int)ms.Length, Encoding.UTF8); - if (NativeMethods.SetClipboardData(CF_HTML, ms.Pointer) != IntPtr.Zero) - ms.FreeOnDispose = false; // Clipboard will free memory - } - catch (Exception ex) - { - // Yes, we swallow any exceptions. That may seem like code smell but this matches - // the behavior of the Clipboard class, Windows Forms controls, and native Scintilla. - Debug.Fail(ex.Message, ex.ToString()); - } - } - - private static unsafe void CopyRtf(Scintilla scintilla, StyleData[] styles, List> styledSegments) - { - // NppExport -> NppExport.cpp - // NppExport -> RTFExporter.cpp - // http://en.wikipedia.org/wiki/Rich_Text_Format - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms649013.aspx - // http://forums.codeguru.com/showthread.php?242982-Converting-pixels-to-twips - // http://en.wikipedia.org/wiki/UTF-8 - - try - { - // Calculate twips per space - int twips; - FontStyle fontStyle = FontStyle.Regular; - if (styles[Style.Default].Weight >= 700) - fontStyle |= FontStyle.Bold; - if (styles[Style.Default].Italic != 0) - fontStyle |= FontStyle.Italic; - if (styles[Style.Default].Underline != 0) - fontStyle |= FontStyle.Underline; - - using (Graphics graphics = scintilla.CreateGraphics()) - using (var font = new Font(styles[Style.Default].FontName, styles[Style.Default].SizeF, fontStyle)) + catch (Exception ex) { - float width = graphics.MeasureString(" ", font).Width; - twips = (int)(width / graphics.DpiX * 1440); - // TODO The twips value calculated seems too small on my computer - } - - // Write RTF - using var ms = new NativeMemoryStream(styledSegments.Sum(s => s.Count)); - using var tw = new StreamWriter(ms, Encoding.ASCII); - int tabWidth = scintilla.DirectMessage(NativeMethods.SCI_GETTABWIDTH).ToInt32(); - int deftab = tabWidth * twips; - - tw.WriteLine(@"{{\rtf1\ansi\deff0\deftab{0}", deftab); - tw.Flush(); - - // Build the font table - tw.Write(@"{\fonttbl"); - tw.Write(@"{{\f0 {0};}}", styles[Style.Default].FontName); - int fontIndex = 1; - for (int i = 0; i < styles.Length; i++) - { - if (!styles[i].Used) - continue; - - if (i == Style.Default) - continue; - - // Not a completely unique list, but close enough - if (styles[i].FontName != styles[Style.Default].FontName) - { - styles[i].FontIndex = fontIndex++; - tw.Write(@"{{\f{0} {1};}}", styles[i].FontIndex, styles[i].FontName); - } + // Yes, we swallow any exceptions. That may seem like code smell but this matches + // the behavior of the Clipboard class, Windows Forms controls, and native Scintilla. + Debug.Fail(ex.Message, ex.ToString()); } + } - tw.WriteLine("}"); // fonttbl - tw.Flush(); - - // Build the color table - tw.Write(@"{\colortbl"); - tw.Write(@"\red{0}\green{1}\blue{2};", (styles[Style.Default].ForeColor >> 0) & 0xFF, (styles[Style.Default].ForeColor >> 8) & 0xFF, (styles[Style.Default].ForeColor >> 16) & 0xFF); - tw.Write(@"\red{0}\green{1}\blue{2};", (styles[Style.Default].BackColor >> 0) & 0xFF, (styles[Style.Default].BackColor >> 8) & 0xFF, (styles[Style.Default].BackColor >> 16) & 0xFF); - styles[Style.Default].ForeColorIndex = 0; - styles[Style.Default].BackColorIndex = 1; - int colorIndex = 2; - for (int i = 0; i < styles.Length; i++) + private static unsafe void CopyRtf(Scintilla scintilla, StyleData[] styles, List> styledSegments) + { + // NppExport -> NppExport.cpp + // NppExport -> RTFExporter.cpp + // http://en.wikipedia.org/wiki/Rich_Text_Format + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms649013.aspx + // http://forums.codeguru.com/showthread.php?242982-Converting-pixels-to-twips + // http://en.wikipedia.org/wiki/UTF-8 + + try { - if (!styles[i].Used) - continue; - - if (i == Style.Default) - continue; - - // Not a completely unique list, but close enough - if (styles[i].ForeColor != styles[Style.Default].ForeColor) - { - styles[i].ForeColorIndex = colorIndex++; - tw.Write(@"\red{0}\green{1}\blue{2};", (styles[i].ForeColor >> 0) & 0xFF, (styles[i].ForeColor >> 8) & 0xFF, (styles[i].ForeColor >> 16) & 0xFF); - } - else - { - styles[i].ForeColorIndex = styles[Style.Default].ForeColorIndex; - } - - if (styles[i].BackColor != styles[Style.Default].BackColor) - { - styles[i].BackColorIndex = colorIndex++; - tw.Write(@"\red{0}\green{1}\blue{2};", (styles[i].BackColor >> 0) & 0xFF, (styles[i].BackColor >> 8) & 0xFF, (styles[i].BackColor >> 16) & 0xFF); - } - else + // Calculate twips per space + int twips; + FontStyle fontStyle = FontStyle.Regular; + if (styles[Style.Default].Weight >= 700) + fontStyle |= FontStyle.Bold; + if (styles[Style.Default].Italic != 0) + fontStyle |= FontStyle.Italic; + if (styles[Style.Default].Underline != 0) + fontStyle |= FontStyle.Underline; + + using (Graphics graphics = scintilla.CreateGraphics()) + using (var font = new Font(styles[Style.Default].FontName, styles[Style.Default].SizeF, fontStyle)) { - styles[i].BackColorIndex = styles[Style.Default].BackColorIndex; + float width = graphics.MeasureString(" ", font).Width; + twips = (int)(width / graphics.DpiX * 1440); + // TODO The twips value calculated seems too small on my computer } - } - tw.WriteLine("}"); // colortbl - tw.Flush(); - - // Start with the default style - tw.Write(@"\f{0}\fs{1}\cf{2}\chshdng0\chcbpat{3}\cb{3} ", styles[Style.Default].FontIndex, (int)(styles[Style.Default].SizeF * 2), styles[Style.Default].ForeColorIndex, styles[Style.Default].BackColorIndex); - if (styles[Style.Default].Italic != 0) - tw.Write(@"\i"); - if (styles[Style.Default].Underline != 0) - tw.Write(@"\ul"); - if (styles[Style.Default].Weight >= 700) - tw.Write(@"\b"); - - tw.AutoFlush = true; - int lastStyle = Style.Default; - bool unicodeLineEndings = (scintilla.DirectMessage(NativeMethods.SCI_GETLINEENDTYPESACTIVE).ToInt32() & NativeMethods.SC_LINE_END_TYPE_UNICODE) > 0; - foreach (ArraySegment seg in styledSegments) - { - int endOffset = seg.Offset + seg.Count; - for (int i = seg.Offset; i < endOffset; i += 2) + // Write RTF + using (var ms = new NativeMemoryStream(styledSegments.Sum(s => s.Count))) { - byte ch = seg.Array[i]; - byte style = seg.Array[i + 1]; - - if (lastStyle != style) + using (var tw = new StreamWriter(ms, Encoding.ASCII)) { - // Change the style - if (styles[lastStyle].FontIndex != styles[style].FontIndex) - tw.Write(@"\f{0}", styles[style].FontIndex); - if (styles[lastStyle].SizeF != styles[style].SizeF) - tw.Write(@"\fs{0}", (int)(styles[style].SizeF * 2)); - if (styles[lastStyle].ForeColorIndex != styles[style].ForeColorIndex) - tw.Write(@"\cf{0}", styles[style].ForeColorIndex); - if (styles[lastStyle].BackColorIndex != styles[style].BackColorIndex) - tw.Write(@"\chshdng0\chcbpat{0}\cb{0}", styles[style].BackColorIndex); - if (styles[lastStyle].Italic != styles[style].Italic) - tw.Write(@"\i{0}", styles[style].Italic != 0 ? "" : "0"); - if (styles[lastStyle].Underline != styles[style].Underline) - tw.Write(@"\ul{0}", styles[style].Underline != 0 ? "" : "0"); - if (styles[lastStyle].Weight != styles[style].Weight) - { - if (styles[style].Weight >= 700 && styles[lastStyle].Weight < 700) - tw.Write(@"\b"); - else if (styles[style].Weight < 700 && styles[lastStyle].Weight >= 700) - tw.Write(@"\b0"); - } + int tabWidth = scintilla.DirectMessage(NativeMethods.SCI_GETTABWIDTH).ToInt32(); + int deftab = tabWidth * twips; - // NOTE: We don't support StyleData.Visible and StyleData.Case in RTF + tw.WriteLine(@"{{\rtf1\ansi\deff0\deftab{0}", deftab); + tw.Flush(); - lastStyle = style; - tw.Write("\n"); // Delimiter - } + // Build the font table + tw.Write(@"{\fonttbl"); + tw.Write(@"{{\f0 {0};}}", styles[Style.Default].FontName); + int fontIndex = 1; + for (int i = 0; i < styles.Length; i++) + { + if (!styles[i].Used) + continue; - switch (ch) - { - case (byte)'{': - tw.Write(@"\{"); - break; + if (i == Style.Default) + continue; - case (byte)'}': - tw.Write(@"\}"); - break; + // Not a completely unique list, but close enough + if (styles[i].FontName != styles[Style.Default].FontName) + { + styles[i].FontIndex = fontIndex++; + tw.Write(@"{{\f{0} {1};}}", styles[i].FontIndex, styles[i].FontName); + } + } - case (byte)'\\': - tw.Write(@"\\"); - break; + tw.WriteLine("}"); // fonttbl + tw.Flush(); + + // Build the color table + tw.Write(@"{\colortbl"); + tw.Write(@"\red{0}\green{1}\blue{2};", (styles[Style.Default].ForeColor >> 0) & 0xFF, (styles[Style.Default].ForeColor >> 8) & 0xFF, (styles[Style.Default].ForeColor >> 16) & 0xFF); + tw.Write(@"\red{0}\green{1}\blue{2};", (styles[Style.Default].BackColor >> 0) & 0xFF, (styles[Style.Default].BackColor >> 8) & 0xFF, (styles[Style.Default].BackColor >> 16) & 0xFF); + styles[Style.Default].ForeColorIndex = 0; + styles[Style.Default].BackColorIndex = 1; + int colorIndex = 2; + for (int i = 0; i < styles.Length; i++) + { + if (!styles[i].Used) + continue; - case (byte)'\t': - tw.Write(@"\tab "); - break; + if (i == Style.Default) + continue; - case (byte)'\r': - if (i + 2 < endOffset) + // Not a completely unique list, but close enough + if (styles[i].ForeColor != styles[Style.Default].ForeColor) { - if (seg.Array[i + 2] == (byte)'\n') - i += 2; + styles[i].ForeColorIndex = colorIndex++; + tw.Write(@"\red{0}\green{1}\blue{2};", (styles[i].ForeColor >> 0) & 0xFF, (styles[i].ForeColor >> 8) & 0xFF, (styles[i].ForeColor >> 16) & 0xFF); } - - // Either way, this is a line break - goto case (byte)'\n'; - - case 0xC2: - if (unicodeLineEndings && i + 2 < endOffset) + else { - if (seg.Array[i + 2] == 0x85) // NEL \u0085 - { - i += 2; - goto case (byte)'\n'; - } + styles[i].ForeColorIndex = styles[Style.Default].ForeColorIndex; } - // Not a Unicode line break - goto default; - - case 0xE2: - if (unicodeLineEndings && i + 4 < endOffset) + if (styles[i].BackColor != styles[Style.Default].BackColor) { - if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA8) // LS \u2028 - { - i += 4; - goto case (byte)'\n'; - } - else if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA9) // PS \u2029 - { - i += 4; - goto case (byte)'\n'; - } + styles[i].BackColorIndex = colorIndex++; + tw.Write(@"\red{0}\green{1}\blue{2};", (styles[i].BackColor >> 0) & 0xFF, (styles[i].BackColor >> 8) & 0xFF, (styles[i].BackColor >> 16) & 0xFF); } - - // Not a Unicode line break - goto default; - - case (byte)'\n': - // All your line breaks are belong to us - tw.WriteLine(@"\par"); - break; - - default: - - if (ch == 0) + else { - // Scintilla behavior is to allow control characters except for - // NULL which will cause the Clipboard to truncate the string. - tw.Write(" "); // Replace with space - break; + styles[i].BackColorIndex = styles[Style.Default].BackColorIndex; } + } - if (ch > 0x7F) + tw.WriteLine("}"); // colortbl + tw.Flush(); + + // Start with the default style + tw.Write(@"\f{0}\fs{1}\cf{2}\chshdng0\chcbpat{3}\cb{3} ", styles[Style.Default].FontIndex, (int)(styles[Style.Default].SizeF * 2), styles[Style.Default].ForeColorIndex, styles[Style.Default].BackColorIndex); + if (styles[Style.Default].Italic != 0) + tw.Write(@"\i"); + if (styles[Style.Default].Underline != 0) + tw.Write(@"\ul"); + if (styles[Style.Default].Weight >= 700) + tw.Write(@"\b"); + + tw.AutoFlush = true; + int lastStyle = Style.Default; + bool unicodeLineEndings = (scintilla.DirectMessage(NativeMethods.SCI_GETLINEENDTYPESACTIVE).ToInt32() & NativeMethods.SC_LINE_END_TYPE_UNICODE) > 0; + foreach (ArraySegment seg in styledSegments) + { + int endOffset = seg.Offset + seg.Count; + for (int i = seg.Offset; i < endOffset; i += 2) { - // Treat as UTF-8 code point - int unicode = 0; - if (ch < 0xE0 && i + 2 < endOffset) - { - unicode |= (0x1F & ch) << 6; - unicode |= 0x3F & seg.Array[i + 2]; - tw.Write(@"\u{0}?", unicode); - i += 2; - break; - } - else if (ch < 0xF0 && i + 4 < endOffset) + byte ch = seg.Array[i]; + byte style = seg.Array[i + 1]; + + if (lastStyle != style) { - unicode |= (0xF & ch) << 12; - unicode |= (0x3F & seg.Array[i + 2]) << 6; - unicode |= 0x3F & seg.Array[i + 4]; - tw.Write(@"\u{0}?", unicode); - i += 4; - break; + // Change the style + if (styles[lastStyle].FontIndex != styles[style].FontIndex) + tw.Write(@"\f{0}", styles[style].FontIndex); + if (styles[lastStyle].SizeF != styles[style].SizeF) + tw.Write(@"\fs{0}", (int)(styles[style].SizeF * 2)); + if (styles[lastStyle].ForeColorIndex != styles[style].ForeColorIndex) + tw.Write(@"\cf{0}", styles[style].ForeColorIndex); + if (styles[lastStyle].BackColorIndex != styles[style].BackColorIndex) + tw.Write(@"\chshdng0\chcbpat{0}\cb{0}", styles[style].BackColorIndex); + if (styles[lastStyle].Italic != styles[style].Italic) + tw.Write(@"\i{0}", styles[style].Italic != 0 ? "" : "0"); + if (styles[lastStyle].Underline != styles[style].Underline) + tw.Write(@"\ul{0}", styles[style].Underline != 0 ? "" : "0"); + if (styles[lastStyle].Weight != styles[style].Weight) + { + if (styles[style].Weight >= 700 && styles[lastStyle].Weight < 700) + tw.Write(@"\b"); + else if (styles[style].Weight < 700 && styles[lastStyle].Weight >= 700) + tw.Write(@"\b0"); + } + + // NOTE: We don't support StyleData.Visible and StyleData.Case in RTF + + lastStyle = style; + tw.Write("\n"); // Delimiter } - else if (ch < 0xF8 && i + 6 < endOffset) + + switch (ch) { - unicode |= (0x7 & ch) << 18; - unicode |= (0x3F & seg.Array[i + 2]) << 12; - unicode |= (0x3F & seg.Array[i + 4]) << 6; - unicode |= 0x3F & seg.Array[i + 6]; - tw.Write(@"\u{0}?", unicode); - i += 6; - break; + case (byte)'{': + tw.Write(@"\{"); + break; + + case (byte)'}': + tw.Write(@"\}"); + break; + + case (byte)'\\': + tw.Write(@"\\"); + break; + + case (byte)'\t': + tw.Write(@"\tab "); + break; + + case (byte)'\r': + if (i + 2 < endOffset) + { + if (seg.Array[i + 2] == (byte)'\n') + i += 2; + } + + // Either way, this is a line break + goto case (byte)'\n'; + + case 0xC2: + if (unicodeLineEndings && i + 2 < endOffset) + { + if (seg.Array[i + 2] == 0x85) // NEL \u0085 + { + i += 2; + goto case (byte)'\n'; + } + } + + // Not a Unicode line break + goto default; + + case 0xE2: + if (unicodeLineEndings && i + 4 < endOffset) + { + if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA8) // LS \u2028 + { + i += 4; + goto case (byte)'\n'; + } + else if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA9) // PS \u2029 + { + i += 4; + goto case (byte)'\n'; + } + } + + // Not a Unicode line break + goto default; + + case (byte)'\n': + // All your line breaks are belong to us + tw.WriteLine(@"\par"); + break; + + default: + + if (ch == 0) + { + // Scintilla behavior is to allow control characters except for + // NULL which will cause the Clipboard to truncate the string. + tw.Write(" "); // Replace with space + break; + } + + if (ch > 0x7F) + { + // Treat as UTF-8 code point + int unicode = 0; + if (ch < 0xE0 && i + 2 < endOffset) + { + unicode |= (0x1F & ch) << 6; + unicode |= 0x3F & seg.Array[i + 2]; + tw.Write(@"\u{0}?", unicode); + i += 2; + break; + } + else if (ch < 0xF0 && i + 4 < endOffset) + { + unicode |= (0xF & ch) << 12; + unicode |= (0x3F & seg.Array[i + 2]) << 6; + unicode |= 0x3F & seg.Array[i + 4]; + tw.Write(@"\u{0}?", unicode); + i += 4; + break; + } + else if (ch < 0xF8 && i + 6 < endOffset) + { + unicode |= (0x7 & ch) << 18; + unicode |= (0x3F & seg.Array[i + 2]) << 12; + unicode |= (0x3F & seg.Array[i + 4]) << 6; + unicode |= 0x3F & seg.Array[i + 6]; + tw.Write(@"\u{0}?", unicode); + i += 6; + break; + } + } + + // Regular ANSI char + ms.WriteByte(ch); + break; } } + } + + tw.AutoFlush = false; + tw.WriteLine("}"); // rtf1 + tw.Flush(); - // Regular ANSI char - ms.WriteByte(ch); - break; + // Terminator + ms.WriteByte(0); + + // var str = GetString(ms.Pointer, (int)ms.Length, Encoding.ASCII); + if (NativeMethods.SetClipboardData(CF_RTF, ms.Pointer) != IntPtr.Zero) + ms.FreeOnDispose = false; // Clipboard will free memory } } } - - tw.AutoFlush = false; - tw.WriteLine("}"); // rtf1 - tw.Flush(); - - // Terminator - ms.WriteByte(0); - - // var str = GetString(ms.Pointer, (int)ms.Length, Encoding.ASCII); - if (NativeMethods.SetClipboardData(CF_RTF, ms.Pointer) != IntPtr.Zero) - ms.FreeOnDispose = false; // Clipboard will free memory - } - catch (Exception ex) - { - // Yes, we swallow any exceptions. That may seem like code smell but this matches - // the behavior of the Clipboard class, Windows Forms controls, and native Scintilla. - Debug.Fail(ex.Message, ex.ToString()); + catch (Exception ex) + { + // Yes, we swallow any exceptions. That may seem like code smell but this matches + // the behavior of the Clipboard class, Windows Forms controls, and native Scintilla. + Debug.Fail(ex.Message, ex.ToString()); + } } - } - public static unsafe byte[] GetBytes(string text, Encoding encoding, bool zeroTerminated) - { - if (string.IsNullOrEmpty(text)) - return zeroTerminated ? new byte[] { 0 } : new byte[0]; - - int count = encoding.GetByteCount(text); - byte[] buffer = new byte[count + (zeroTerminated ? 1 : 0)]; - - fixed (byte* bp = buffer) - fixed (char* ch = text) + public static unsafe byte[] GetBytes(string text, Encoding encoding, bool zeroTerminated) { - encoding.GetBytes(ch, text.Length, bp, count); - } - - if (zeroTerminated) - buffer[buffer.Length - 1] = 0; - - return buffer; - } + if (string.IsNullOrEmpty(text)) + return zeroTerminated ? new byte[] { 0 } : new byte[0]; - public static unsafe byte[] GetBytes(char[] text, int length, Encoding encoding, bool zeroTerminated) - { - fixed (char* cp = text) - { - int count = encoding.GetByteCount(cp, length); + int count = encoding.GetByteCount(text); byte[] buffer = new byte[count + (zeroTerminated ? 1 : 0)]; + fixed (byte* bp = buffer) - encoding.GetBytes(cp, length, bp, buffer.Length); + fixed (char* ch = text) + { + encoding.GetBytes(ch, text.Length, bp, count); + } if (zeroTerminated) buffer[buffer.Length - 1] = 0; return buffer; } - } - public static string GetHtml(Scintilla scintilla, int startBytePos, int endBytePos) - { - // If we ever allow more than UTF-8, this will have to be revisited - Debug.Assert(scintilla.DirectMessage(NativeMethods.SCI_GETCODEPAGE).ToInt32() == NativeMethods.SC_CP_UTF8); - - if (startBytePos == endBytePos) - return string.Empty; - - List> styledSegments = GetStyledSegments(scintilla, false, false, startBytePos, endBytePos, out StyleData[] styles); - - using var ms = new NativeMemoryStream(styledSegments.Sum(s => s.Count)); // Hint - using var sw = new StreamWriter(ms, new UTF8Encoding(false)); - // Write the styles - sw.WriteLine(@""); + public static string GetHtml(Scintilla scintilla, int startBytePos, int endBytePos) + { + // If we ever allow more than UTF-8, this will have to be revisited + Debug.Assert(scintilla.DirectMessage(NativeMethods.SCI_GETCODEPAGE).ToInt32() == NativeMethods.SC_CP_UTF8); - bool unicodeLineEndings = (scintilla.DirectMessage(NativeMethods.SCI_GETLINEENDTYPESACTIVE).ToInt32() & NativeMethods.SC_LINE_END_TYPE_UNICODE) > 0; - int tabSize = scintilla.DirectMessage(NativeMethods.SCI_GETTABWIDTH).ToInt32(); - string tab = new(' ', tabSize); - int lastStyle = Style.Default; + if (startBytePos == endBytePos) + return string.Empty; - // Write the styled text - sw.Write(@"
", Style.Default); - sw.Flush(); - sw.AutoFlush = true; + List> styledSegments = GetStyledSegments(scintilla, false, false, startBytePos, endBytePos, out StyleData[] styles); - foreach (ArraySegment seg in styledSegments) - { - int endOffset = seg.Offset + seg.Count; - for (int i = seg.Offset; i < endOffset; i += 2) + using (var ms = new NativeMemoryStream(styledSegments.Sum(s => s.Count))) // Hint { - byte ch = seg.Array[i]; - byte style = seg.Array[i + 1]; - - if (lastStyle != style) + using (var sw = new StreamWriter(ms, new UTF8Encoding(false))) { - sw.Write(@"", style); - lastStyle = style; - } - - switch (ch) - { - case (byte)'<': - sw.Write("<"); - break; + // Write the styles + sw.WriteLine(@""); - case (byte)'\r': - if (i + 2 < endOffset) - { - if (seg.Array[i + 2] == (byte)'\n') - i += 2; - } + bool unicodeLineEndings = (scintilla.DirectMessage(NativeMethods.SCI_GETLINEENDTYPESACTIVE).ToInt32() & NativeMethods.SC_LINE_END_TYPE_UNICODE) > 0; + int tabSize = scintilla.DirectMessage(NativeMethods.SCI_GETTABWIDTH).ToInt32(); + string tab = new string(' ', tabSize); + int lastStyle = Style.Default; - // Either way, this is a line break - goto case (byte)'\n'; + // Write the styled text + sw.Write(@"
", Style.Default); + sw.Flush(); + sw.AutoFlush = true; - case 0xC2: - if (unicodeLineEndings && i + 2 < endOffset) + foreach (ArraySegment seg in styledSegments) + { + int endOffset = seg.Offset + seg.Count; + for (int i = seg.Offset; i < endOffset; i += 2) { - if (seg.Array[i + 2] == 0x85) // NEL \u0085 - { - i += 2; - goto case (byte)'\n'; - } - } - - // Not a Unicode line break - goto default; + byte ch = seg.Array[i]; + byte style = seg.Array[i + 1]; - case 0xE2: - if (unicodeLineEndings && i + 4 < endOffset) - { - if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA8) // LS \u2028 + if (lastStyle != style) { - i += 4; - goto case (byte)'\n'; + sw.Write(@"", style); + lastStyle = style; } - else if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA9) // PS \u2029 + + switch (ch) { - i += 4; - goto case (byte)'\n'; - } - } + case (byte)'<': + sw.Write("<"); + break; + + case (byte)'>': + sw.Write(">"); + break; - // Not a Unicode line break - goto default; + case (byte)'&': + sw.Write("&"); + break; - case (byte)'\n': - // All your line breaks are belong to us - sw.Write("\r\n"); - break; + case (byte)'\t': + sw.Write(tab); + break; - default: + case (byte)'\r': + if (i + 2 < endOffset) + { + if (seg.Array[i + 2] == (byte)'\n') + i += 2; + } - if (ch == 0) - { - // Replace NUL with space - sw.Write(" "); - break; + // Either way, this is a line break + goto case (byte)'\n'; + + case 0xC2: + if (unicodeLineEndings && i + 2 < endOffset) + { + if (seg.Array[i + 2] == 0x85) // NEL \u0085 + { + i += 2; + goto case (byte)'\n'; + } + } + + // Not a Unicode line break + goto default; + + case 0xE2: + if (unicodeLineEndings && i + 4 < endOffset) + { + if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA8) // LS \u2028 + { + i += 4; + goto case (byte)'\n'; + } + else if (seg.Array[i + 2] == 0x80 && seg.Array[i + 4] == 0xA9) // PS \u2029 + { + i += 4; + goto case (byte)'\n'; + } + } + + // Not a Unicode line break + goto default; + + case (byte)'\n': + // All your line breaks are belong to us + sw.Write("\r\n"); + break; + + default: + + if (ch == 0) + { + // Replace NUL with space + sw.Write(" "); + break; + } + + ms.WriteByte(ch); + break; + } } + } - ms.WriteByte(ch); - break; + sw.AutoFlush = false; + sw.WriteLine("
"); + sw.Flush(); + + return GetString(ms.Pointer, (int)ms.Length, Encoding.UTF8); } } } - sw.AutoFlush = false; - sw.WriteLine("
"); - sw.Flush(); - - return GetString(ms.Pointer, (int)ms.Length, Encoding.UTF8); - } - - public static unsafe string GetString(IntPtr bytes, int length, Encoding encoding) - { - sbyte* ptr = (sbyte*)bytes; - string str = new(ptr, 0, length, encoding); + public static unsafe string GetString(IntPtr bytes, int length, Encoding encoding) + { + sbyte* ptr = (sbyte*)bytes; + string str = new string(ptr, 0, length, encoding); - return str; - } + return str; + } - private static unsafe List> GetStyledSegments(Scintilla scintilla, bool currentSelection, bool currentLine, int startBytePos, int endBytePos, out StyleData[] styles) - { - var segments = new List>(); - if (currentSelection) + private static unsafe List> GetStyledSegments(Scintilla scintilla, bool currentSelection, bool currentLine, int startBytePos, int endBytePos, out StyleData[] styles) { - // Get each selection as a segment. - // Rectangular selections are ordered top to bottom and have line breaks appended. - var ranges = new List>(); - int selCount = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONS).ToInt32(); - for (int i = 0; i < selCount; i++) + var segments = new List>(); + if (currentSelection) { - int selStartBytePos = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNSTART, new IntPtr(i)).ToInt32(); - int selEndBytePos = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNEND, new IntPtr(i)).ToInt32(); + // Get each selection as a segment. + // Rectangular selections are ordered top to bottom and have line breaks appended. + var ranges = new List>(); + int selCount = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONS).ToInt32(); + for (int i = 0; i < selCount; i++) + { + int selStartBytePos = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNSTART, new IntPtr(i)).ToInt32(); + int selEndBytePos = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNEND, new IntPtr(i)).ToInt32(); - ranges.Add(Tuple.Create(selStartBytePos, selEndBytePos)); - } + ranges.Add(Tuple.Create(selStartBytePos, selEndBytePos)); + } - bool selIsRect = scintilla.DirectMessage(NativeMethods.SCI_SELECTIONISRECTANGLE) != IntPtr.Zero; - if (selIsRect) - ranges.OrderBy(r => r.Item1); // Sort top to bottom + bool selIsRect = scintilla.DirectMessage(NativeMethods.SCI_SELECTIONISRECTANGLE) != IntPtr.Zero; + if (selIsRect) + ranges.OrderBy(r => r.Item1); // Sort top to bottom - foreach (Tuple range in ranges) + foreach (Tuple range in ranges) + { + ArraySegment styledText = GetStyledText(scintilla, range.Item1, range.Item2, selIsRect); + segments.Add(styledText); + } + } + else if (currentLine) { - ArraySegment styledText = GetStyledText(scintilla, range.Item1, range.Item2, selIsRect); + // Get the current line + int mainSelection = scintilla.DirectMessage(NativeMethods.SCI_GETMAINSELECTION).ToInt32(); + int mainCaretPos = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNCARET, new IntPtr(mainSelection)).ToInt32(); + int lineIndex = scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, new IntPtr(mainCaretPos)).ToInt32(); + int lineStartBytePos = scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(lineIndex)).ToInt32(); + int lineLength = scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(lineIndex)).ToInt32(); + + ArraySegment styledText = GetStyledText(scintilla, lineStartBytePos, lineStartBytePos + lineLength, false); + segments.Add(styledText); + } + else // User-specified range + { + Debug.Assert(startBytePos != endBytePos); + ArraySegment styledText = GetStyledText(scintilla, startBytePos, endBytePos, false); segments.Add(styledText); } - } - else if (currentLine) - { - // Get the current line - int mainSelection = scintilla.DirectMessage(NativeMethods.SCI_GETMAINSELECTION).ToInt32(); - int mainCaretPos = scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNCARET, new IntPtr(mainSelection)).ToInt32(); - int lineIndex = scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, new IntPtr(mainCaretPos)).ToInt32(); - int lineStartBytePos = scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(lineIndex)).ToInt32(); - int lineLength = scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(lineIndex)).ToInt32(); - - ArraySegment styledText = GetStyledText(scintilla, lineStartBytePos, lineStartBytePos + lineLength, false); - segments.Add(styledText); - } - else // User-specified range - { - Debug.Assert(startBytePos != endBytePos); - ArraySegment styledText = GetStyledText(scintilla, startBytePos, endBytePos, false); - segments.Add(styledText); - } - // Build a list of (used) styles - styles = new StyleData[NativeMethods.STYLE_MAX + 1]; - - styles[Style.Default].Used = true; - styles[Style.Default].FontName = scintilla.Styles[Style.Default].Font; - styles[Style.Default].SizeF = scintilla.Styles[Style.Default].SizeF; - styles[Style.Default].Weight = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETWEIGHT, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); - styles[Style.Default].Italic = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETITALIC, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); - styles[Style.Default].Underline = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETUNDERLINE, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); - styles[Style.Default].BackColor = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETBACK, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); - styles[Style.Default].ForeColor = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFORE, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); - styles[Style.Default].Case = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETCASE, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); - styles[Style.Default].Visible = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETVISIBLE, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); - - foreach (ArraySegment seg in segments) - { - for (int i = 0; i < seg.Count; i += 2) + // Build a list of (used) styles + styles = new StyleData[NativeMethods.STYLE_MAX + 1]; + + styles[Style.Default].Used = true; + styles[Style.Default].FontName = scintilla.Styles[Style.Default].Font; + styles[Style.Default].SizeF = scintilla.Styles[Style.Default].SizeF; + styles[Style.Default].Weight = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETWEIGHT, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); + styles[Style.Default].Italic = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETITALIC, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); + styles[Style.Default].Underline = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETUNDERLINE, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); + styles[Style.Default].BackColor = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETBACK, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); + styles[Style.Default].ForeColor = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFORE, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); + styles[Style.Default].Case = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETCASE, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); + styles[Style.Default].Visible = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETVISIBLE, new IntPtr(Style.Default), IntPtr.Zero).ToInt32(); + + foreach (ArraySegment seg in segments) { - byte style = seg.Array[i + 1]; - if (!styles[style].Used) + for (int i = 0; i < seg.Count; i += 2) { - styles[style].Used = true; - styles[style].FontName = scintilla.Styles[style].Font; - styles[style].SizeF = scintilla.Styles[style].SizeF; - styles[style].Weight = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETWEIGHT, new IntPtr(style), IntPtr.Zero).ToInt32(); - styles[style].Italic = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETITALIC, new IntPtr(style), IntPtr.Zero).ToInt32(); - styles[style].Underline = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETUNDERLINE, new IntPtr(style), IntPtr.Zero).ToInt32(); - styles[style].BackColor = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETBACK, new IntPtr(style), IntPtr.Zero).ToInt32(); - styles[style].ForeColor = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFORE, new IntPtr(style), IntPtr.Zero).ToInt32(); - styles[style].Case = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETCASE, new IntPtr(style), IntPtr.Zero).ToInt32(); - styles[style].Visible = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETVISIBLE, new IntPtr(style), IntPtr.Zero).ToInt32(); + byte style = seg.Array[i + 1]; + if (!styles[style].Used) + { + styles[style].Used = true; + styles[style].FontName = scintilla.Styles[style].Font; + styles[style].SizeF = scintilla.Styles[style].SizeF; + styles[style].Weight = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETWEIGHT, new IntPtr(style), IntPtr.Zero).ToInt32(); + styles[style].Italic = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETITALIC, new IntPtr(style), IntPtr.Zero).ToInt32(); + styles[style].Underline = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETUNDERLINE, new IntPtr(style), IntPtr.Zero).ToInt32(); + styles[style].BackColor = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETBACK, new IntPtr(style), IntPtr.Zero).ToInt32(); + styles[style].ForeColor = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFORE, new IntPtr(style), IntPtr.Zero).ToInt32(); + styles[style].Case = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETCASE, new IntPtr(style), IntPtr.Zero).ToInt32(); + styles[style].Visible = scintilla.DirectMessage(NativeMethods.SCI_STYLEGETVISIBLE, new IntPtr(style), IntPtr.Zero).ToInt32(); + } } } + + return segments; } - return segments; - } + private static unsafe ArraySegment GetStyledText(Scintilla scintilla, int startBytePos, int endBytePos, bool addLineBreak) + { + Debug.Assert(endBytePos > startBytePos); - private static unsafe ArraySegment GetStyledText(Scintilla scintilla, int startBytePos, int endBytePos, bool addLineBreak) - { - Debug.Assert(endBytePos > startBytePos); + // Make sure the range is styled + scintilla.DirectMessage(NativeMethods.SCI_COLOURISE, new IntPtr(startBytePos), new IntPtr(endBytePos)); - // Make sure the range is styled - scintilla.DirectMessage(NativeMethods.SCI_COLOURISE, new IntPtr(startBytePos), new IntPtr(endBytePos)); + int byteLength = endBytePos - startBytePos; + byte[] buffer = new byte[byteLength * 2 + (addLineBreak ? 4 : 0) + 2]; + fixed (byte* bp = buffer) + { + NativeMethods.Sci_TextRange* tr = stackalloc NativeMethods.Sci_TextRange[1]; + tr->chrg.cpMin = startBytePos; + tr->chrg.cpMax = endBytePos; + tr->lpstrText = new IntPtr(bp); - int byteLength = endBytePos - startBytePos; - byte[] buffer = new byte[byteLength * 2 + (addLineBreak ? 4 : 0) + 2]; - fixed (byte* bp = buffer) - { - NativeMethods.Sci_TextRange* tr = stackalloc NativeMethods.Sci_TextRange[1]; - tr->chrg.cpMin = startBytePos; - tr->chrg.cpMax = endBytePos; - tr->lpstrText = new IntPtr(bp); + scintilla.DirectMessage(NativeMethods.SCI_GETSTYLEDTEXT, IntPtr.Zero, new IntPtr(tr)); + byteLength *= 2; + } - scintilla.DirectMessage(NativeMethods.SCI_GETSTYLEDTEXT, IntPtr.Zero, new IntPtr(tr)); - byteLength *= 2; - } + // Add a line break? + // We do this when this range is part of a rectangular selection. + if (addLineBreak) + { + byte style = buffer[byteLength - 1]; - // Add a line break? - // We do this when this range is part of a rectangular selection. - if (addLineBreak) - { - byte style = buffer[byteLength - 1]; + buffer[byteLength++] = (byte)'\r'; + buffer[byteLength++] = style; + buffer[byteLength++] = (byte)'\n'; + buffer[byteLength++] = style; - buffer[byteLength++] = (byte)'\r'; - buffer[byteLength++] = style; - buffer[byteLength++] = (byte)'\n'; - buffer[byteLength++] = style; + // Fix-up the NULL terminator just in case + buffer[byteLength] = 0; + buffer[byteLength + 1] = 0; + } - // Fix-up the NULL terminator just in case - buffer[byteLength] = 0; - buffer[byteLength + 1] = 0; + return new ArraySegment(buffer, 0, byteLength); } - return new ArraySegment(buffer, 0, byteLength); - } - - public static int TranslateKeys(Keys keys) - { - int keyCode; - - // For some reason Scintilla uses different values for these keys... - switch (keys & Keys.KeyCode) + public static int TranslateKeys(Keys keys) { - case Keys.Down: - keyCode = NativeMethods.SCK_DOWN; - break; - case Keys.Up: - keyCode = NativeMethods.SCK_UP; - break; - case Keys.Left: - keyCode = NativeMethods.SCK_LEFT; - break; - case Keys.Right: - keyCode = NativeMethods.SCK_RIGHT; - break; - case Keys.Home: - keyCode = NativeMethods.SCK_HOME; - break; - case Keys.End: - keyCode = NativeMethods.SCK_END; - break; - case Keys.Prior: - keyCode = NativeMethods.SCK_PRIOR; - break; - case Keys.Next: - keyCode = NativeMethods.SCK_NEXT; - break; - case Keys.Delete: - keyCode = NativeMethods.SCK_DELETE; - break; - case Keys.Insert: - keyCode = NativeMethods.SCK_INSERT; - break; - case Keys.Escape: - keyCode = NativeMethods.SCK_ESCAPE; - break; - case Keys.Back: - keyCode = NativeMethods.SCK_BACK; - break; - case Keys.Tab: - keyCode = NativeMethods.SCK_TAB; - break; - case Keys.Return: - keyCode = NativeMethods.SCK_RETURN; - break; - case Keys.Add: - keyCode = NativeMethods.SCK_ADD; - break; - case Keys.Subtract: - keyCode = NativeMethods.SCK_SUBTRACT; - break; - case Keys.Divide: - keyCode = NativeMethods.SCK_DIVIDE; - break; - case Keys.LWin: - keyCode = NativeMethods.SCK_WIN; - break; - case Keys.RWin: - keyCode = NativeMethods.SCK_RWIN; - break; - case Keys.Apps: - keyCode = NativeMethods.SCK_MENU; - break; - case Keys.Oem2: - keyCode = (byte)'/'; - break; - case Keys.Oem3: - keyCode = (byte)'`'; - break; - case Keys.Oem4: - keyCode = '['; - break; - case Keys.Oem5: - keyCode = '\\'; - break; - case Keys.Oem6: - keyCode = ']'; - break; - default: - keyCode = (int)(keys & Keys.KeyCode); - break; - } + int keyCode; - // No translation necessary for the modifiers. Just add them back in. - int keyDefinition = keyCode | (int)(keys & Keys.Modifiers); - return keyDefinition; - } + // For some reason Scintilla uses different values for these keys... + switch (keys & Keys.KeyCode) + { + case Keys.Down: + keyCode = NativeMethods.SCK_DOWN; + break; + case Keys.Up: + keyCode = NativeMethods.SCK_UP; + break; + case Keys.Left: + keyCode = NativeMethods.SCK_LEFT; + break; + case Keys.Right: + keyCode = NativeMethods.SCK_RIGHT; + break; + case Keys.Home: + keyCode = NativeMethods.SCK_HOME; + break; + case Keys.End: + keyCode = NativeMethods.SCK_END; + break; + case Keys.Prior: + keyCode = NativeMethods.SCK_PRIOR; + break; + case Keys.Next: + keyCode = NativeMethods.SCK_NEXT; + break; + case Keys.Delete: + keyCode = NativeMethods.SCK_DELETE; + break; + case Keys.Insert: + keyCode = NativeMethods.SCK_INSERT; + break; + case Keys.Escape: + keyCode = NativeMethods.SCK_ESCAPE; + break; + case Keys.Back: + keyCode = NativeMethods.SCK_BACK; + break; + case Keys.Tab: + keyCode = NativeMethods.SCK_TAB; + break; + case Keys.Return: + keyCode = NativeMethods.SCK_RETURN; + break; + case Keys.Add: + keyCode = NativeMethods.SCK_ADD; + break; + case Keys.Subtract: + keyCode = NativeMethods.SCK_SUBTRACT; + break; + case Keys.Divide: + keyCode = NativeMethods.SCK_DIVIDE; + break; + case Keys.LWin: + keyCode = NativeMethods.SCK_WIN; + break; + case Keys.RWin: + keyCode = NativeMethods.SCK_RWIN; + break; + case Keys.Apps: + keyCode = NativeMethods.SCK_MENU; + break; + case Keys.Oem2: + keyCode = (byte)'/'; + break; + case Keys.Oem3: + keyCode = (byte)'`'; + break; + case Keys.Oem4: + keyCode = '['; + break; + case Keys.Oem5: + keyCode = '\\'; + break; + case Keys.Oem6: + keyCode = ']'; + break; + default: + keyCode = (int)(keys & Keys.KeyCode); + break; + } - // https://stackoverflow.com/questions/2709430/count-number-of-bits-in-a-64-bit-long-big-integer/2709523#2709523 - public static byte PopCount(ulong i) - { - i -= ((i >> 1) & 0x5555555555555555UL); - i = (i & 0x3333333333333333UL) + ((i >> 2) & 0x3333333333333333UL); - return (byte)((((i + (i >> 4)) & 0xF0F0F0F0F0F0F0FUL) * 0x101010101010101UL) >> 56); - } + // No translation necessary for the modifiers. Just add them back in. + int keyDefinition = keyCode | (int)(keys & Keys.Modifiers); + return keyDefinition; + } - public static int MaxIndex(this IEnumerable source) => MaxIndex(source, comparer: null); - - /// Returns index of the maximum value in a generic sequence. - /// The type of the elements of . - /// A sequence of values to determine the index of the maximum value of. - /// The to compare values. - /// The index of the maximum value in the sequence. - /// is . - /// No object in implements the or interface. - /// - /// If type implements , the method uses that implementation to compare values. Otherwise, if type implements , that implementation is used to compare values. - /// If is a reference type and the source sequence is empty or contains only values that are , this method returns -1. - /// - public static int MaxIndex(this IEnumerable source, Func comparer) - { - if (source == null) + // https://stackoverflow.com/questions/2709430/count-number-of-bits-in-a-64-bit-long-big-integer/2709523#2709523 + public static byte PopCount(ulong i) { - throw new ArgumentNullException(nameof(source)); + i -= (i >> 1) & 0x5555555555555555UL; + i = (i & 0x3333333333333333UL) + ((i >> 2) & 0x3333333333333333UL); + return (byte)((((i + (i >> 4)) & 0xF0F0F0F0F0F0F0FUL) * 0x101010101010101UL) >> 56); } - comparer ??= Comparer.Default.Compare; - - int index = -1; - int maxIndex = index; - TSource value = default; - using (IEnumerator e = source.GetEnumerator()) + public static int MaxIndex(this IEnumerable source) => MaxIndex(source, comparer: null); + + /// Returns index of the maximum value in a generic sequence. + /// The type of the elements of . + /// A sequence of values to determine the index of the maximum value of. + /// The to compare values. + /// The index of the maximum value in the sequence. + /// is . + /// No object in implements the or interface. + /// + /// If type implements , the method uses that implementation to compare values. Otherwise, if type implements , that implementation is used to compare values. + /// If is a reference type and the source sequence is empty or contains only values that are , this method returns -1. + /// + public static int MaxIndex(this IEnumerable source, Func comparer) { - if (value == null) + if (source == null) { - do - { - if (!e.MoveNext()) - { - return maxIndex; - } - - index++; + throw new ArgumentNullException(nameof(source)); + } - value = e.Current; - maxIndex = index; - } - while (value == null); + comparer = comparer ?? Comparer.Default.Compare; - while (e.MoveNext()) + int index = -1; + int maxIndex = index; + TSource value = default; + using (IEnumerator e = source.GetEnumerator()) + { + if (value == null) { - index++; - TSource next = e.Current; - if (next != null && comparer(next, value) > 0) + do { - value = next; + if (!e.MoveNext()) + { + return maxIndex; + } + + index++; + + value = e.Current; maxIndex = index; } - } - } - else - { - if (!e.MoveNext()) - { - throw new InvalidOperationException("Sequence contains no elements"); - } + while (value == null); - index++; - - value = e.Current; - maxIndex = index; - if (comparer == Comparer.Default.Compare) - { while (e.MoveNext()) { index++; TSource next = e.Current; - if (Comparer.Default.Compare(next, value) > 0) + if (next != null && comparer(next, value) > 0) { value = next; maxIndex = index; @@ -1248,52 +1236,78 @@ public static int MaxIndex(this IEnumerable source, Func 0) + throw new InvalidOperationException("Sequence contains no elements"); + } + + index++; + + value = e.Current; + maxIndex = index; + if (comparer == Comparer.Default.Compare) + { + while (e.MoveNext()) { - value = next; - maxIndex = index; + index++; + TSource next = e.Current; + if (Comparer.Default.Compare(next, value) > 0) + { + value = next; + maxIndex = index; + } + } + } + else + { + while (e.MoveNext()) + { + index++; + TSource next = e.Current; + if (comparer(next, value) > 0) + { + value = next; + maxIndex = index; + } } } } } - } - return maxIndex; - } + return maxIndex; + } - public static void ApplyToControlTree(Control control, Action action) - { - foreach (Control child in control.Controls) + public static void ApplyToControlTree(Control control, Action action) { - ApplyToControlTree(child, action); + foreach (Control child in control.Controls) + { + ApplyToControlTree(child, action); + } + + action(control); } - action(control); - } - #endregion Methods + #endregion Methods - #region Types + #region Types - private struct StyleData - { - public bool Used; - public string FontName; - public int FontIndex; // RTF Only - public float SizeF; - public int Weight; - public int Italic; - public int Underline; - public int BackColor; - public int BackColorIndex; // RTF Only - public int ForeColor; - public int ForeColorIndex; // RTF Only - public int Case; // HTML only - public int Visible; // HTML only - } + private struct StyleData + { + public bool Used; + public string FontName; + public int FontIndex; // RTF Only + public float SizeF; + public int Weight; + public int Italic; + public int Underline; + public int BackColor; + public int BackColorIndex; // RTF Only + public int ForeColor; + public int ForeColorIndex; // RTF Only + public int Case; // HTML only + public int Visible; // HTML only + } - #endregion Types + #endregion Types + } } diff --git a/Scintilla.NET/HotspotClickEventArgs.cs b/Scintilla.NET/HotspotClickEventArgs.cs index aacc53c..a4ef058 100644 --- a/Scintilla.NET/HotspotClickEventArgs.cs +++ b/Scintilla.NET/HotspotClickEventArgs.cs @@ -1,49 +1,50 @@ using System; using System.Windows.Forms; -namespace ScintillaNET; - -/// -/// Provides data for the , , -/// and events. -/// -public class HotspotClickEventArgs : EventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - private readonly int bytePosition; - private int? position; - /// - /// Gets the modifier keys (SHIFT, CTRL, ALT) held down when clicked. + /// Provides data for the , , + /// and events. /// - /// A bitwise combination of the Keys enumeration indicating the modifier keys. - /// Only the state of the CTRL key is reported in the event. - public Keys Modifiers { get; private set; } - - /// - /// Gets the zero-based document position of the text clicked. - /// - /// The zero-based character position within the document of the clicked text. - public int Position + public class HotspotClickEventArgs : EventArgs { - get + private readonly Scintilla scintilla; + private readonly int bytePosition; + private int? position; + + /// + /// Gets the modifier keys (SHIFT, CTRL, ALT) held down when clicked. + /// + /// A bitwise combination of the Keys enumeration indicating the modifier keys. + /// Only the state of the CTRL key is reported in the event. + public Keys Modifiers { get; private set; } + + /// + /// Gets the zero-based document position of the text clicked. + /// + /// The zero-based character position within the document of the clicked text. + public int Position { - this.position ??= this.scintilla.Lines.ByteToCharPosition(this.bytePosition); + get + { + this.position = this.position ?? this.scintilla.Lines.ByteToCharPosition(this.bytePosition); - return (int)this.position; + return (int)this.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 click. - /// The zero-based byte position of the clicked text. - public HotspotClickEventArgs(Scintilla scintilla, Keys modifiers, int bytePosition) - { - this.scintilla = scintilla; - this.bytePosition = bytePosition; - Modifiers = modifiers; + /// + /// 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 click. + /// The zero-based byte position of the clicked text. + public HotspotClickEventArgs(Scintilla scintilla, Keys modifiers, int bytePosition) + { + this.scintilla = scintilla; + this.bytePosition = bytePosition; + Modifiers = modifiers; + } } } diff --git a/Scintilla.NET/ILoader.cs b/Scintilla.NET/ILoader.cs index 4996c9d..c6b11f0 100644 --- a/Scintilla.NET/ILoader.cs +++ b/Scintilla.NET/ILoader.cs @@ -1,37 +1,38 @@ -namespace ScintillaNET; - -/// -/// Provides methods for loading and creating a on a background (non-UI) thread. -/// -/// -/// Internally an maintains a instance with a reference count of 1. -/// You are responsible for ensuring the reference count eventually reaches 0 or memory leaks will occur. -/// -public interface ILoader +namespace ScintillaNET { /// - /// Adds the data specified to the internal document. + /// Provides methods for loading and creating a on a background (non-UI) thread. /// - /// The character buffer to copy to the new document. - /// The number of characters in to copy. - /// - /// true if the data was added successfully; otherwise, false. - /// A return value of false should be followed by a call to . - /// - bool AddData(char[] data, int length); + /// + /// Internally an maintains a instance with a reference count of 1. + /// You are responsible for ensuring the reference count eventually reaches 0 or memory leaks will occur. + /// + public interface ILoader + { + /// + /// Adds the data specified to the internal document. + /// + /// The character buffer to copy to the new document. + /// The number of characters in to copy. + /// + /// true if the data was added successfully; otherwise, false. + /// A return value of false should be followed by a call to . + /// + bool AddData(char[] data, int length); - /// - /// Returns the internal document. - /// - /// A containing the added text. The document has a reference count of 1. - Document ConvertToDocument(); + /// + /// Returns the internal document. + /// + /// A containing the added text. The document has a reference count of 1. + Document ConvertToDocument(); - /// - /// Called to release the internal document when an error occurs using or to abandon loading. - /// - /// - /// The internal document reference count. - /// A return value of 0 indicates that the document has been destroyed and all associated memory released. - /// - int Release(); + /// + /// Called to release the internal document when an error occurs using or to abandon loading. + /// + /// + /// The internal document reference count. + /// A return value of 0 indicates that the document has been destroyed and all associated memory released. + /// + int Release(); + } } diff --git a/Scintilla.NET/IdleStyling.cs b/Scintilla.NET/IdleStyling.cs index ea7d075..0e1e6f4 100644 --- a/Scintilla.NET/IdleStyling.cs +++ b/Scintilla.NET/IdleStyling.cs @@ -1,32 +1,33 @@ -namespace ScintillaNET; - -/// -/// Possible strategies for styling text using application idle time. -/// -/// -public enum IdleStyling +namespace ScintillaNET { /// - /// Syntax styling is performed for all the currently visible text before displaying it. - /// This is the default. + /// Possible strategies for styling text using application idle time. /// - None = NativeMethods.SC_IDLESTYLING_NONE, + /// + public enum IdleStyling + { + /// + /// Syntax styling is performed for all the currently visible text before displaying it. + /// This is the default. + /// + None = NativeMethods.SC_IDLESTYLING_NONE, - /// - /// A small amount of styling is performed before display and then further styling is performed incrementally in the background as an idle-time task. - /// This can improve initial display/scroll performance, but may result in the text initially appearing uncolored and then, some time later, it is colored. - /// - ToVisible = NativeMethods.SC_IDLESTYLING_TOVISIBLE, + /// + /// A small amount of styling is performed before display and then further styling is performed incrementally in the background as an idle-time task. + /// This can improve initial display/scroll performance, but may result in the text initially appearing uncolored and then, some time later, it is colored. + /// + ToVisible = NativeMethods.SC_IDLESTYLING_TOVISIBLE, - /// - /// Text after the currently visible portion may be styled as an idle-time task. - /// This will not improve initial display/scroll performance, but may improve subsequent display/scroll performance. - /// - AfterVisible = NativeMethods.SC_IDLESTYLING_AFTERVISIBLE, + /// + /// Text after the currently visible portion may be styled as an idle-time task. + /// This will not improve initial display/scroll performance, but may improve subsequent display/scroll performance. + /// + AfterVisible = NativeMethods.SC_IDLESTYLING_AFTERVISIBLE, - /// - /// Text before and after the current visible text. - /// This is a combination of and . - /// - All = NativeMethods.SC_IDLESTYLING_ALL + /// + /// Text before and after the current visible text. + /// This is a combination of and . + /// + All = NativeMethods.SC_IDLESTYLING_ALL + } } diff --git a/Scintilla.NET/IndentView.cs b/Scintilla.NET/IndentView.cs index 30fd2ae..70b8c4f 100644 --- a/Scintilla.NET/IndentView.cs +++ b/Scintilla.NET/IndentView.cs @@ -1,31 +1,32 @@ -namespace ScintillaNET; - -/// -/// Options for displaying indentation guides in a control. -/// -/// Indentation guides can be styled using the style. -public enum IndentView +namespace ScintillaNET { /// - /// No indentation guides are shown. This is the default. + /// Options for displaying indentation guides in a control. /// - None = NativeMethods.SC_IV_NONE, + /// Indentation guides can be styled using the style. + public enum IndentView + { + /// + /// No indentation guides are shown. This is the default. + /// + None = NativeMethods.SC_IV_NONE, - /// - /// Indentation guides are shown inside real indentation whitespace. - /// - Real = NativeMethods.SC_IV_REAL, + /// + /// Indentation guides are shown inside real indentation whitespace. + /// + Real = NativeMethods.SC_IV_REAL, - /// - /// Indentation guides are shown beyond the actual indentation up to the level of the next non-empty line. - /// If the previous non-empty line was a fold header then indentation guides are shown for one more level of indent than that line. - /// This setting is good for Python. - /// - LookForward = NativeMethods.SC_IV_LOOKFORWARD, + /// + /// Indentation guides are shown beyond the actual indentation up to the level of the next non-empty line. + /// If the previous non-empty line was a fold header then indentation guides are shown for one more level of indent than that line. + /// This setting is good for Python. + /// + LookForward = NativeMethods.SC_IV_LOOKFORWARD, - /// - /// Indentation guides are shown beyond the actual indentation up to the level of the next non-empty line or previous non-empty line whichever is the greater. - /// This setting is good for most languages. - /// - LookBoth = NativeMethods.SC_IV_LOOKBOTH + /// + /// Indentation guides are shown beyond the actual indentation up to the level of the next non-empty line or previous non-empty line whichever is the greater. + /// This setting is good for most languages. + /// + LookBoth = NativeMethods.SC_IV_LOOKBOTH + } } diff --git a/Scintilla.NET/Indicator.cs b/Scintilla.NET/Indicator.cs index 1dc8857..3bba087 100644 --- a/Scintilla.NET/Indicator.cs +++ b/Scintilla.NET/Indicator.cs @@ -1,273 +1,274 @@ using System; using System.Drawing; -namespace ScintillaNET; - -/// -/// Represents an indicator in a control. -/// -public class Indicator +namespace ScintillaNET { - #region Fields - - private readonly Scintilla scintilla; - - #endregion Fields - - #region Constants - /// - /// An OR mask to use with and to indicate - /// that the user-defined indicator value should be treated as a RGB color. + /// Represents an indicator in a control. /// - 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; - - #endregion Constants + public class Indicator + { + #region Fields - #region Methods + private readonly Scintilla scintilla; - /// - /// Given a document position which is filled with this indicator, will return the document position - /// where the use of this indicator ends. - /// - /// A zero-based document position using this indicator. - /// The zero-based document position where the use of this indicator ends. - /// - /// Specifying a which is not filled with this indicator will cause this method - /// to return the end position of the range where this indicator is not in use (the negative space). If this - /// indicator is not in use anywhere within the document the return value will be 0. - /// - public int End(int position) - { - position = Helpers.Clamp(position, 0, this.scintilla.TextLength); - position = this.scintilla.Lines.CharToBytePosition(position); - position = this.scintilla.DirectMessage(NativeMethods.SCI_INDICATOREND, new IntPtr(Index), new IntPtr(position)).ToInt32(); - return this.scintilla.Lines.ByteToCharPosition(position); - } + #endregion Fields - /// - /// Given a document position which is filled with this indicator, will return the document position - /// where the use of this indicator starts. - /// - /// A zero-based document position using this indicator. - /// The zero-based document position where the use of this indicator starts. - /// - /// Specifying a which is not filled with this indicator will cause this method - /// to return the start position of the range where this indicator is not in use (the negative space). If this - /// indicator is not in use anywhere within the document the return value will be 0. - /// - public int Start(int position) - { - position = Helpers.Clamp(position, 0, this.scintilla.TextLength); - position = this.scintilla.Lines.CharToBytePosition(position); - position = this.scintilla.DirectMessage(NativeMethods.SCI_INDICATORSTART, new IntPtr(Index), new IntPtr(position)).ToInt32(); - return this.scintilla.Lines.ByteToCharPosition(position); - } + #region Constants - /// - /// 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, this.scintilla.TextLength); - position = this.scintilla.Lines.CharToBytePosition(position); + /// + /// 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; - return this.scintilla.DirectMessage(NativeMethods.SCI_INDICATORVALUEAT, new IntPtr(Index), new IntPtr(position)).ToInt32(); - } + /// + /// 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; - #endregion Methods + #endregion Constants - #region Properties + #region Methods - /// - /// 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 + /// + /// Given a document position which is filled with this indicator, will return the document position + /// where the use of this indicator ends. + /// + /// A zero-based document position using this indicator. + /// The zero-based document position where the use of this indicator ends. + /// + /// Specifying a which is not filled with this indicator will cause this method + /// to return the end position of the range where this indicator is not in use (the negative space). If this + /// indicator is not in use anywhere within the document the return value will be 0. + /// + public int End(int position) { - return this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETALPHA, new IntPtr(Index)).ToInt32(); + position = Helpers.Clamp(position, 0, this.scintilla.TextLength); + position = this.scintilla.Lines.CharToBytePosition(position); + position = this.scintilla.DirectMessage(NativeMethods.SCI_INDICATOREND, new IntPtr(Index), new IntPtr(position)).ToInt32(); + return this.scintilla.Lines.ByteToCharPosition(position); } - set - { - value = Helpers.Clamp(value, 0, 255); - this.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)this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETFLAGS, new IntPtr(Index)); - } - set + /// + /// Given a document position which is filled with this indicator, will return the document position + /// where the use of this indicator starts. + /// + /// A zero-based document position using this indicator. + /// The zero-based document position where the use of this indicator starts. + /// + /// Specifying a which is not filled with this indicator will cause this method + /// to return the start position of the range where this indicator is not in use (the negative space). If this + /// indicator is not in use anywhere within the document the return value will be 0. + /// + public int Start(int position) { - int flags = (int)value; - this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETFLAGS, new IntPtr(Index), new IntPtr(flags)); + position = Helpers.Clamp(position, 0, this.scintilla.TextLength); + position = this.scintilla.Lines.CharToBytePosition(position); + position = this.scintilla.DirectMessage(NativeMethods.SCI_INDICATORSTART, new IntPtr(Index), new IntPtr(position)).ToInt32(); + return this.scintilla.Lines.ByteToCharPosition(position); } - } - /// - /// 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 + /// + /// 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) { - int color = this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETFORE, new IntPtr(Index)).ToInt32(); - return HelperMethods.FromWin32ColorOpaque(color); + position = Helpers.Clamp(position, 0, this.scintilla.TextLength); + position = this.scintilla.Lines.CharToBytePosition(position); + + return this.scintilla.DirectMessage(NativeMethods.SCI_INDICATORVALUEAT, new IntPtr(Index), new IntPtr(position)).ToInt32(); } - set + + #endregion Methods + + #region Properties + + /// + /// 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 { - int color = HelperMethods.ToWin32ColorOpaque(value); - this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETFORE, new IntPtr(Index), new IntPtr(color)); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETALPHA, new IntPtr(Index)).ToInt32(); + } + set + { + value = Helpers.Clamp(value, 0, 255); + this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETALPHA, new IntPtr(Index), new IntPtr(value)); + } } - } - /// - /// 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 + /// + /// Gets or sets the indicator flags. + /// + /// + /// A bitwise combination of the enumeration. + /// The default is . + /// + public IndicatorFlags Flags { - int color = this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETHOVERFORE, new IntPtr(Index)).ToInt32(); - return HelperMethods.FromWin32ColorOpaque(color); + get + { + return (IndicatorFlags)this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETFLAGS, new IntPtr(Index)); + } + set + { + int flags = (int)value; + this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETFLAGS, new IntPtr(Index), new IntPtr(flags)); + } } - set + + /// + /// 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 { - int color = HelperMethods.ToWin32ColorOpaque(value); - this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETHOVERFORE, new IntPtr(Index), new IntPtr(color)); + get + { + int color = this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETFORE, new IntPtr(Index)).ToInt32(); + return HelperMethods.FromWin32ColorOpaque(color); + } + set + { + int color = HelperMethods.ToWin32ColorOpaque(value); + this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETFORE, 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 + /// + /// 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 { - return (IndicatorStyle)this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETHOVERSTYLE, new IntPtr(Index)); + get + { + int color = this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETHOVERFORE, new IntPtr(Index)).ToInt32(); + return HelperMethods.FromWin32ColorOpaque(color); + } + set + { + int color = HelperMethods.ToWin32ColorOpaque(value); + this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETHOVERFORE, new IntPtr(Index), new IntPtr(color)); + } } - set + + /// + /// 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 { - int style = (int)value; - this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETHOVERSTYLE, new IntPtr(Index), new IntPtr(style)); + get + { + return (IndicatorStyle)this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETHOVERSTYLE, new IntPtr(Index)); + } + set + { + int style = (int)value; + this.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 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 + /// + /// 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 { - return this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETOUTLINEALPHA, new IntPtr(Index)).ToInt32(); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETOUTLINEALPHA, new IntPtr(Index)).ToInt32(); + } + set + { + value = Helpers.Clamp(value, 0, 255); + this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETOUTLINEALPHA, new IntPtr(Index), new IntPtr(value)); + } } - set - { - value = Helpers.Clamp(value, 0, 255); - this.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)this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETSTYLE, new IntPtr(Index)); - } - set + /// + /// Gets or sets the indicator style. + /// + /// One of the enumeration values. The default varies. + /// Changing the property will reset the . + /// + public IndicatorStyle Style { - int style = (int)value; - this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETSTYLE, new IntPtr(Index), new IntPtr(style)); + get + { + return (IndicatorStyle)this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETSTYLE, new IntPtr(Index)); + } + set + { + int style = (int)value; + this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETSTYLE, new IntPtr(Index), new IntPtr(style)); + } } - } - /// - /// Gets or sets whether indicators are drawn under or over text. - /// - /// true to draw the indicator under text; otherwise, false. The default is false. - /// Drawing indicators under text requires or drawing. - public bool Under - { - get + /// + /// Gets or sets whether indicators are drawn under or over text. + /// + /// true to draw the indicator under text; otherwise, false. The default is false. + /// Drawing indicators under text requires or drawing. + public bool Under { - return this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETUNDER, new IntPtr(Index)) != IntPtr.Zero; + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_INDICGETUNDER, new IntPtr(Index)) != IntPtr.Zero; + } + set + { + IntPtr under = value ? new IntPtr(1) : IntPtr.Zero; + this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETUNDER, new IntPtr(Index), under); + } } - set - { - IntPtr under = value ? new IntPtr(1) : IntPtr.Zero; - this.scintilla.DirectMessage(NativeMethods.SCI_INDICSETUNDER, new IntPtr(Index), under); - } - } - #endregion Properties + #endregion Properties - #region Constructors + #region Constructors - /// - /// 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; - } + /// + /// 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; + } - #endregion Constructors + #endregion Constructors + } } diff --git a/Scintilla.NET/IndicatorClickEventArgs.cs b/Scintilla.NET/IndicatorClickEventArgs.cs index 3987bd8..5db413f 100644 --- a/Scintilla.NET/IndicatorClickEventArgs.cs +++ b/Scintilla.NET/IndicatorClickEventArgs.cs @@ -1,26 +1,27 @@ using System.Windows.Forms; -namespace ScintillaNET; - -/// -/// Provides data for the event. -/// -public class IndicatorClickEventArgs : IndicatorReleaseEventArgs +namespace ScintillaNET { /// - /// Gets the modifier keys (SHIFT, CTRL, ALT) held down when clicked. + /// Provides data for the event. /// - /// A bitwise combination of the Keys enumeration indicating the modifier keys. - public Keys Modifiers { get; private set; } - - /// - /// 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 click. - /// The zero-based byte position of the clicked text. - public IndicatorClickEventArgs(Scintilla scintilla, Keys modifiers, int bytePosition) : base(scintilla, bytePosition) + public class IndicatorClickEventArgs : IndicatorReleaseEventArgs { - Modifiers = modifiers; + /// + /// Gets the modifier keys (SHIFT, CTRL, ALT) held down when clicked. + /// + /// A bitwise combination of the Keys enumeration indicating the modifier keys. + public Keys Modifiers { get; private set; } + + /// + /// 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 click. + /// The zero-based byte position of the clicked text. + public IndicatorClickEventArgs(Scintilla scintilla, Keys modifiers, int bytePosition) : base(scintilla, bytePosition) + { + Modifiers = modifiers; + } } } diff --git a/Scintilla.NET/IndicatorCollection.cs b/Scintilla.NET/IndicatorCollection.cs index bcb73cb..5a8c7eb 100644 --- a/Scintilla.NET/IndicatorCollection.cs +++ b/Scintilla.NET/IndicatorCollection.cs @@ -2,73 +2,74 @@ using System.Collections.Generic; using System.ComponentModel; -namespace ScintillaNET; - -/// -/// An immutable collection of indicators in a control. -/// -public class IndicatorCollection : IEnumerable +namespace ScintillaNET { - private readonly Scintilla scintilla; - /// - /// Provides an enumerator that iterates through the collection. + /// An immutable collection of indicators in a control. /// - /// An object that contains all objects within the . - public IEnumerator GetEnumerator() + public class IndicatorCollection : IEnumerable { - int count = Count; - for (int i = 0; i < count; i++) - yield return this[i]; + private readonly Scintilla scintilla; - yield break; - } + /// + /// 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]; - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + yield break; + } - /// - /// Gets the number of indicators. - /// - /// The number of indicators in the . - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int Count - { - get + IEnumerator IEnumerable.GetEnumerator() { - return NativeMethods.INDICATOR_MAX + 1; + return GetEnumerator(); } - } - /// - /// 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 + /// + /// Gets the number of indicators. + /// + /// The number of indicators in the . + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public int Count { - index = Helpers.Clamp(index, 0, Count - 1); - return new Indicator(this.scintilla, index); + get + { + return NativeMethods.INDICATOR_MAX + 1; + } } - } - /// - /// Initializes a new instance of the class. - /// - /// The control that created this collection. - public IndicatorCollection(Scintilla scintilla) - { - this.scintilla = scintilla; + /// + /// 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(this.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/Scintilla.NET/IndicatorFlags.cs b/Scintilla.NET/IndicatorFlags.cs index ce11d07..9462292 100644 --- a/Scintilla.NET/IndicatorFlags.cs +++ b/Scintilla.NET/IndicatorFlags.cs @@ -1,23 +1,24 @@ using System; -namespace ScintillaNET; - -/// -/// Flags associated with a . -/// -/// This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values. -[Flags] -public enum IndicatorFlags +namespace ScintillaNET { /// - /// No flags. This is the default. + /// Flags associated with a . /// - None = 0, + /// This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values. + [Flags] + public enum IndicatorFlags + { + /// + /// No flags. This is the default. + /// + None = 0, - /// - /// When set, will treat an indicator value as a RGB color that has been OR'd with - /// and will use that instead of the value specified in the property. This allows - /// an indicator to display more than one color. - /// - ValueFore = NativeMethods.SC_INDICFLAG_VALUEFORE + /// + /// When set, will treat an indicator value as a RGB color that has been OR'd with + /// and will use that instead of the value specified in the property. This allows + /// an indicator to display more than one color. + /// + ValueFore = NativeMethods.SC_INDICFLAG_VALUEFORE + } } diff --git a/Scintilla.NET/IndicatorReleaseEventArgs.cs b/Scintilla.NET/IndicatorReleaseEventArgs.cs index 25d25da..e96bcbd 100644 --- a/Scintilla.NET/IndicatorReleaseEventArgs.cs +++ b/Scintilla.NET/IndicatorReleaseEventArgs.cs @@ -1,38 +1,39 @@ using System; -namespace ScintillaNET; - -/// -/// Provides data for the event. -/// -public class IndicatorReleaseEventArgs : EventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - private readonly int bytePosition; - private int? position; - /// - /// Gets the zero-based document position of the text clicked. + /// Provides data for the event. /// - /// The zero-based character position within the document of the clicked text. - public int Position + public class IndicatorReleaseEventArgs : EventArgs { - get + private readonly Scintilla scintilla; + private readonly int bytePosition; + private int? position; + + /// + /// Gets the zero-based document position of the text clicked. + /// + /// The zero-based character position within the document of the clicked text. + public int Position { - this.position ??= this.scintilla.Lines.ByteToCharPosition(this.bytePosition); + get + { + this.position = this.position ?? this.scintilla.Lines.ByteToCharPosition(this.bytePosition); - return (int)this.position; + return (int)this.position; + } } - } - /// - /// Initializes a new instance of the class. - /// - /// The control that generated this event. - /// The zero-based byte position of the clicked text. - public IndicatorReleaseEventArgs(Scintilla scintilla, int bytePosition) - { - this.scintilla = scintilla; - this.bytePosition = bytePosition; + /// + /// Initializes a new instance of the class. + /// + /// The control that generated this event. + /// The zero-based byte position of the clicked text. + public IndicatorReleaseEventArgs(Scintilla scintilla, int bytePosition) + { + this.scintilla = scintilla; + this.bytePosition = bytePosition; + } } } diff --git a/Scintilla.NET/IndicatorStyle.cs b/Scintilla.NET/IndicatorStyle.cs index 95d52f6..785bc0c 100644 --- a/Scintilla.NET/IndicatorStyle.cs +++ b/Scintilla.NET/IndicatorStyle.cs @@ -1,128 +1,129 @@ -namespace ScintillaNET; - -/// -/// The visual appearance of an indicator. -/// -public enum IndicatorStyle +namespace ScintillaNET { /// - /// 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, - - /// - /// A version of Squiggle that draws using a pixmap instead of as a series of line segments for performance. - /// - SquigglePixmap = NativeMethods.INDIC_SQUIGGLEPIXMAP, - - // 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, - - /// - /// A triangle below the start of the indicator range. - /// - Point = NativeMethods.INDIC_POINT, - - /// - /// A triangle below the center of the first character of the indicator range. - /// - PointCharacter = NativeMethods.INDIC_POINTCHARACTER, - - /// - /// A vertical gradient between a color and alpha at top to fully transparent at bottom. - /// - Gradient = NativeMethods.INDIC_GRADIENT, - - /// - /// A vertical gradient with color and alpha in the mid-line fading to fully transparent at top and bottom. - /// - GradientCenter = NativeMethods.INDIC_GRADIENTCENTRE, - - /// - /// A triangle above the start of the indicator range. - /// - PointTop = NativeMethods.INDIC_POINT_TOP, + /// 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, + + /// + /// A version of Squiggle that draws using a pixmap instead of as a series of line segments for performance. + /// + SquigglePixmap = NativeMethods.INDIC_SQUIGGLEPIXMAP, + + // 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, + + /// + /// A triangle below the start of the indicator range. + /// + Point = NativeMethods.INDIC_POINT, + + /// + /// A triangle below the center of the first character of the indicator range. + /// + PointCharacter = NativeMethods.INDIC_POINTCHARACTER, + + /// + /// A vertical gradient between a color and alpha at top to fully transparent at bottom. + /// + Gradient = NativeMethods.INDIC_GRADIENT, + + /// + /// A vertical gradient with color and alpha in the mid-line fading to fully transparent at top and bottom. + /// + GradientCenter = NativeMethods.INDIC_GRADIENTCENTRE, + + /// + /// A triangle above the start of the indicator range. + /// + PointTop = NativeMethods.INDIC_POINT_TOP, + } } diff --git a/Scintilla.NET/InsertCheckEventArgs.cs b/Scintilla.NET/InsertCheckEventArgs.cs index 99d4296..819b5ed 100644 --- a/Scintilla.NET/InsertCheckEventArgs.cs +++ b/Scintilla.NET/InsertCheckEventArgs.cs @@ -1,68 +1,69 @@ using System; -namespace ScintillaNET; - -/// -/// Provides data for the event. -/// -public class InsertCheckEventArgs : EventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - private readonly int bytePosition; - private readonly int byteLength; - private readonly IntPtr textPtr; - - internal int? CachedPosition { get; set; } - internal string CachedText { get; set; } - /// - /// Gets the zero-based document position where text will be inserted. + /// Provides data for the event. /// - /// The zero-based character position within the document where text will be inserted. - public int Position + public class InsertCheckEventArgs : EventArgs { - get - { - CachedPosition ??= this.scintilla.Lines.ByteToCharPosition(this.bytePosition); + private readonly Scintilla scintilla; + private readonly int bytePosition; + private readonly int byteLength; + private readonly IntPtr textPtr; - return (int)CachedPosition; - } - } + internal int? CachedPosition { get; set; } + internal string CachedText { get; set; } - /// - /// Gets or sets the text being inserted. - /// - /// The text being inserted into the document. - public unsafe string Text - { - get + /// + /// Gets the zero-based document position where text will be inserted. + /// + /// The zero-based character position within the document where text will be inserted. + public int Position { - CachedText ??= Helpers.GetString(this.textPtr, this.byteLength, this.scintilla.Encoding); + get + { + CachedPosition = CachedPosition ?? this.scintilla.Lines.ByteToCharPosition(this.bytePosition); - return CachedText; + return (int)CachedPosition; + } } - set + + /// + /// Gets or sets the text being inserted. + /// + /// The text being inserted into the document. + public unsafe string Text { - CachedText = value ?? string.Empty; + get + { + CachedText = CachedText ?? Helpers.GetString(this.textPtr, this.byteLength, this.scintilla.Encoding); + + return CachedText; + } + set + { + CachedText = value ?? string.Empty; - byte[] bytes = Helpers.GetBytes(CachedText, this.scintilla.Encoding, zeroTerminated: false); - fixed (byte* bp = bytes) - this.scintilla.DirectMessage(NativeMethods.SCI_CHANGEINSERTION, new IntPtr(bytes.Length), new IntPtr(bp)); + byte[] bytes = Helpers.GetBytes(CachedText, this.scintilla.Encoding, zeroTerminated: false); + fixed (byte* bp = bytes) + this.scintilla.DirectMessage(NativeMethods.SCI_CHANGEINSERTION, new IntPtr(bytes.Length), new IntPtr(bp)); + } } - } - /// - /// Initializes a new instance of the class. - /// - /// The control that generated this event. - /// The zero-based byte position within the document where text is being inserted. - /// The length in bytes of the inserted text. - /// A pointer to the text being inserted. - public InsertCheckEventArgs(Scintilla scintilla, int bytePosition, int byteLength, IntPtr text) - { - this.scintilla = scintilla; - this.bytePosition = bytePosition; - this.byteLength = byteLength; - this.textPtr = text; + /// + /// Initializes a new instance of the class. + /// + /// The control that generated this event. + /// The zero-based byte position within the document where text is being inserted. + /// The length in bytes of the inserted text. + /// A pointer to the text being inserted. + public InsertCheckEventArgs(Scintilla scintilla, int bytePosition, int byteLength, IntPtr text) + { + this.scintilla = scintilla; + this.bytePosition = bytePosition; + this.byteLength = byteLength; + this.textPtr = text; + } } } diff --git a/Scintilla.NET/Layer.cs b/Scintilla.NET/Layer.cs index f2d2c65..c548518 100644 --- a/Scintilla.NET/Layer.cs +++ b/Scintilla.NET/Layer.cs @@ -1,23 +1,24 @@ -namespace ScintillaNET; - -/// -/// The layer on which a control will draw elements like for example the text selection. -/// -public enum Layer +namespace ScintillaNET { /// - /// Draw the selection background opaquely on the base layer. + /// The layer on which a control will draw elements like for example the text selection. /// - Base = NativeMethods.SC_LAYER_BASE, + public enum Layer + { + /// + /// Draw the selection background opaquely on the base layer. + /// + Base = NativeMethods.SC_LAYER_BASE, - /// - /// Draw the selection background translucently under the text. This will not work in single phase drawing mode. - /// () as there is no under-text phase. - /// - UnderText = NativeMethods.SC_LAYER_UNDER_TEXT, + /// + /// Draw the selection background translucently under the text. This will not work in single phase drawing mode. + /// () as there is no under-text phase. + /// + UnderText = NativeMethods.SC_LAYER_UNDER_TEXT, - /// - /// Draw the selection background translucently over the text. - /// - OverText = NativeMethods.SC_LAYER_OVER_TEXT + /// + /// Draw the selection background translucently over the text. + /// + OverText = NativeMethods.SC_LAYER_OVER_TEXT + } } diff --git a/Scintilla.NET/Lexer.cs b/Scintilla.NET/Lexer.cs index bdcf3b8..c11525f 100644 --- a/Scintilla.NET/Lexer.cs +++ b/Scintilla.NET/Lexer.cs @@ -1,558 +1,559 @@ -namespace ScintillaNET; - -/// -/// Supported lexer names helper. -/// -public enum Lexer +namespace ScintillaNET { /// - /// Lexer for Assembler, just for the MASM syntax - /// - SCLEX_A68K, - /// - /// Lexer for APDL. Based on the lexer for Assembler by The Black Horus. - /// - SCLEX_ADPL, - /// - /// This lexer is for the Asymptote vector graphics language - /// - SCLEX_ASYMPTOTE, - /// - /// Lexer for AutoIt3 - /// - SCLEX_AU3, - /// - /// Lexer for Avenue - /// - SCLEX_AVE, - /// - /// Lexer for AviSynth - /// - SCLEX_AVS, - /// - /// Lexer for ABAQUS. Based on the lexer for APDL by Hadar Raz. - /// - SCLEX_ABAQUS, - /// - /// Lexer for Ada 95 - /// - SCLEX_ADA, - /// - /// Lexer for Asciidoc - /// - SCLEX_ASCIIDOC, - /// - /// Lexer for Assembler, just for the MASM syntax - /// - SCLEX_ASM, - /// - /// Lexer for Assembler - /// - SCLEX_AS, - /// - /// Lexer for ASN.1 - /// - SCLEX_ASN1, - /// - /// Lexer for Baan. - /// - SCLEX_BAAN, - /// - /// Lexer for Bash. - /// - SCLEX_BASH, - /// - /// Lexer for BlitzBasic. - /// - SCLEX_BLITZBASIC, - /// - /// Lexer for PureBasic. - /// - SCLEX_PUREBASIC, - /// - /// Lexer for FreeBasic. - /// - SCLEX_FREEBASIC, - /// - /// Lexer for batch files - /// - SCLEX_BATCH, - /// - /// Lexer for BibTeX coloring scheme. - /// - SCLEX_BIBTEX, - /// - /// Lexer for Bullant - /// - SCLEX_BULLANT, - /// - /// Lexer for Common Intermediate Language (CIL) - /// - SCLEX_CIL, - /// - /// Case Sensitive Clarion Language Lexer - /// - SCLEX_CLW, - /// - /// Lexer for Clarion with no case sensitivity. - /// - SCLEX_CLWNOCASE, - /// - /// Lexer for COBOL - /// - SCLEX_COBOL, - /// - /// Lexer for Case Sensitive C++ - /// - SCLEX_CPP, - /// - /// Lexer for no case sensitivity C++ - /// - SCLEX_CPPNOCASE, - /// - /// Lexer for C# - /// - SCLEX_CSHARP, - /// - /// Lexer for Cascading Style Sheets - /// - SCLEX_CSS, - /// - /// Lexer for Java - /// - SCLEX_JAVA, - /// - /// Lexer for JavaScript - /// - SCLEX_JAVASCRIPT, - /// - /// Lexer for Objective Caml. - /// - SCLEX_CAML, - /// - /// Lexer for Cmake - /// - SCLEX_CMAKE, - /// - /// Lexer for CoffeeScript. - /// - SCLEX_COFFEESCRIPT, - /// - /// Apache Configuration Files - /// - SCLEX_CONF, - /// - /// Lexer to use with extended crontab files used by a powerful - /// Windows scheduler/event monitor/automation manager nnCron. - /// - SCLEX_NNCRONTAB, - /// - /// Lexer for Csound (Orchestra and Score) - /// - SCLEX_CSOUND, - /// - /// Lexer for D - /// - SCLEX_D, - /// - /// Lexer for MSC Nastran DMAP. - /// - SCLEX_DMAP, - /// - /// Lexer for DMIS. - /// - SCLEX_DMIS, - /// - /// Lexer for DataFlex. - /// - SCLEX_DATAFLEX, - /// - /// Lexer for diff results. - /// - SCLEX_DIFF, - /// - /// Lexer for ECL. - /// - SCLEX_ECL, - /// - /// Lexer for EDIFACT - /// - SCLEX_EDIFACT, - /// - /// Lexer for ESCRIPT - /// - SCLEX_ESCRIPT, - /// - /// Lexer for Eiffel. - /// - SCLEX_EIFFEL, - /// - /// Lexer for EiffelKW - /// - SCLEX_EIFFELKW, - /// - /// Lexer for Erlang. - /// - SCLEX_ERLANG, - /// - /// Lexer for error lists. Used for the output pane in SciTE - /// - SCLEX_ERRORLIST, - /// - /// Lexer for F# 5.0 - /// - SCLEX_FSHARP, - /// - /// Lexer for Harbour and FlagShip. - /// - SCLEX_FLAGSHIP, - /// - /// Lexer for Forth - /// - SCLEX_FORTH, - /// - /// Lexer for Fortran - /// - SCLEX_FORTRAN, - /// - /// Lexer for Fortran 77 - /// - SCLEX_F77, - /// - /// Lexer for the GAP language. (The GAP System for Computational Discrete Algebra) - /// - SCLEX_GAP, - /// - /// Lexer for GDScript. - /// - SCLEX_GDSCRIPT, - /// - /// This is the Lexer for Gui4Cli, included in SciLexer.dll - /// - SCLEX_GUI4CLI, - /// - /// Lexer for HTML - /// - SCLEX_HTML, - /// - /// Lexer for XML - /// - SCLEX_XML, - /// - /// Lexer for PHPScript - /// - SCLEX_PHPSCRIPT, - /// - /// A haskell lexer for the scintilla code control. - /// - SCLEX_HASKELL, - /// - /// Lexer for Literate Haskell - /// - SCLEX_LITERATEHASKELL, - /// - /// Lexer for Motorola S-Record. - /// - SCLEX_SREC, - /// - /// Lexer for Intel HEX - /// - SCLEX_IHEX, - /// - /// Lexer for Tektronix extended HEX - /// - SCLEX_TEHEX, - /// - /// Lexer for Hollywood - /// - SCLEX_HOLLYWOOD, - /// - /// Lexer for no language. Used for indentation-based folding of files. - /// - SCLEX_INDENT, - /// - /// Lexer for Inno Setup scripts. - /// - SCLEX_INNOSETUP, - /// - /// Lexer for JSON and JSON-LD formats - /// - SCLEX_JSON, - /// - /// Lexer for Julia - /// - SCLEX_JULIA, - /// - /// Lexer for KIX-Scripts. - /// - SCLEX_KIX, - /// - /// Lexer for KVIrc script. - /// - SCLEX_KVIRC, - /// - /// Lexer for LaTeX2e. - /// - SCLEX_LATEX, - /// - /// Lexer for Lisp - /// - SCLEX_LISP, - /// - /// Lexer for the Basser Lout (>= version 3) typesetting language - /// - SCLEX_LOUT, - /// - /// Lexer for Lua language - /// - SCLEX_LUA, - /// - /// Lexer for MMIX Assembler Language. - /// - SCLEX_MMIXAL, - /// - /// Lexer for MPT specific files. Based on LexOthers.cxx - /// LOT = the text log file created by the MPT application while running a test program - /// - SCLEX_LOT, - /// - /// Lexer for MSSQL - /// - SCLEX_MSSQL, - /// - /// Lexer for GE(r) Smallworld(tm) MagikSF - /// - SCLEX_MAGIK, - /// - /// Lexer for make files. - /// - SCLEX_MAKEFILE, - /// - /// A simple Markdown lexer for scintilla. - /// - SCLEX_MARKDOWN, - /// - /// Lexer for Matlab. - /// - SCLEX_MATLAB, - /// - /// Lexer for Octave - /// - SCLEX_OCTAVE, - /// - /// Lexer for Maxima - /// - SCLEX_MAXIMA, - /// - /// Lexer for general context conformant metapost coloring scheme - /// - SCLEX_METAPOST, - /// - /// Lexer for Modula-2/3 documents. - /// - SCLEX_MODULA, - /// - /// Lexer for MySQL - /// - SCLEX_MYSQL, - /// - /// Lexer for NIM - /// - SCLEX_NIM, - /// - /// Lexer for NIMROD - /// - SCLEX_NIMROD, - /// - /// Lexer for NSIS - /// - SCLEX_NSIS, - /// - /// Lexer for no language. Used for plain text and unrecognized files. - /// - SCLEX_NULL, - /// - /// Lexer for OScript sources; ocx files and/or OSpace dumps. - /// - SCLEX_OSCRIPT, - /// - /// Lexer for OPAL (functional language similar to Haskell) - /// - SCLEX_OPAL, - /// - /// Lexer for PowerBasic - /// - SCLEX_POWERBASIC, - /// - /// Lexer for PL/M - /// - SCLEX_PLM, - /// - /// Lexer for GetText Translation (PO) files. - /// - SCLEX_PO, - /// - /// Lexer for POV-Ray SDL - /// - SCLEX_POV, - /// - /// Lexer for PostScript - /// - SCLEX_POSTSCRIPT, - /// - /// Lexer for Pascal - /// - SCLEX_PASCAL, - /// - /// Lexer for Perl - /// - SCLEX_PERL, - /// - /// Lexer for PowerPro - /// - SCLEX_POWERPRO, - /// - /// Lexer for PowerShellj scripts - /// - SCLEX_POWERSHELL, - /// - /// Lexer for Progress 4GL. - /// - SCLEX_PROGRESS, - /// - /// Lexer for properties files. - /// - SCLEX_PROPERTIES, - /// - /// Lexer for Python - /// - SCLEX_PYTHON, - /// - /// Lexer for R. - /// - SCLEX_R, - /// - /// Lexer for S. - /// - SCLEX_S, - /// - /// Lexer for SPlus Statistics Program. - /// - SCLEX_SPLUS, - /// - /// Lexer for Raku - /// - SCLEX_RAKU, - /// - /// Lexer for REBOL - /// - SCLEX_REBOL, - /// - /// Lexer for Windows registration files(.reg) - /// - SCLEX_REGISTRY, - /// - /// Lexer for Ruby - /// - SCLEX_RUBY, - /// - /// Lexer for Rust - /// - SCLEX_RUST, - /// - /// Lexer for SAS - /// - SCLEX_SAS, - /// - /// Lexer for SML - /// - SCLEX_SML, - /// - /// Lexer for SQL, including PL/SQL and SQL*Plus. - /// - SCLEX_SQL, - /// - /// Lexer for Structured Text language. - /// - SCLEX_STTXT, - /// - /// Lexer for Scriptol - /// - SCLEX_SCRIPTOL, - /// - /// Lexer for SmallTalk - /// - SCLEX_SMALLTALK, - /// - /// Lexer for SORCUS installation files - /// - SCLEX_SORCUS, - /// - /// Lexer for Specman E language. - /// - SCLEX_SPECMAN, - /// - /// Lexer for SPICE - /// - SCLEX_SPICE, - /// - /// Lexer for Stata - /// - SCLEX_STATA, - /// - /// Lexer for TACL - /// - SCLEX_TACL, - /// - /// Lexer for TADS3 - /// - SCLEX_TADS3, - /// - /// Lexer for TAL - /// - SCLEX_TAL, - /// - /// Lexer for TCL - /// - SCLEX_TCL, - /// - /// Lexer for Take Command / TCC batch scripts (.bat, .btm, .cmd). - /// - SCLEX_TCMD, - /// - /// Lexer for LaTeX general context conformant tex coloring scheme - /// - SCLEX_TEX, - /// - /// A simple Txt2tags lexer for scintilla. - /// - SCLEX_TXT2TAGS, - /// - /// Visual Basic - /// - SCLEX_VB, - /// - /// Visual Basic Script - /// - SCLEX_VBSCRIPT, - /// - /// Lexer for vhdl - /// - SCLEX_VHDL, - /// - /// Lexer for Verilog - /// - SCLEX_VERILOG, - /// - /// Lexer for Visual Prolog - /// - SCLEX_VISUALPROLOG, - /// - /// Lexer for X12 - /// - SCLEX_X12, - /// - /// Lexer for Yaml - /// - SCLEX_YAML, + /// Supported lexer names helper. + /// + public enum Lexer + { + /// + /// Lexer for Assembler, just for the MASM syntax + /// + SCLEX_A68K, + /// + /// Lexer for APDL. Based on the lexer for Assembler by The Black Horus. + /// + SCLEX_ADPL, + /// + /// This lexer is for the Asymptote vector graphics language + /// + SCLEX_ASYMPTOTE, + /// + /// Lexer for AutoIt3 + /// + SCLEX_AU3, + /// + /// Lexer for Avenue + /// + SCLEX_AVE, + /// + /// Lexer for AviSynth + /// + SCLEX_AVS, + /// + /// Lexer for ABAQUS. Based on the lexer for APDL by Hadar Raz. + /// + SCLEX_ABAQUS, + /// + /// Lexer for Ada 95 + /// + SCLEX_ADA, + /// + /// Lexer for Asciidoc + /// + SCLEX_ASCIIDOC, + /// + /// Lexer for Assembler, just for the MASM syntax + /// + SCLEX_ASM, + /// + /// Lexer for Assembler + /// + SCLEX_AS, + /// + /// Lexer for ASN.1 + /// + SCLEX_ASN1, + /// + /// Lexer for Baan. + /// + SCLEX_BAAN, + /// + /// Lexer for Bash. + /// + SCLEX_BASH, + /// + /// Lexer for BlitzBasic. + /// + SCLEX_BLITZBASIC, + /// + /// Lexer for PureBasic. + /// + SCLEX_PUREBASIC, + /// + /// Lexer for FreeBasic. + /// + SCLEX_FREEBASIC, + /// + /// Lexer for batch files + /// + SCLEX_BATCH, + /// + /// Lexer for BibTeX coloring scheme. + /// + SCLEX_BIBTEX, + /// + /// Lexer for Bullant + /// + SCLEX_BULLANT, + /// + /// Lexer for Common Intermediate Language (CIL) + /// + SCLEX_CIL, + /// + /// Case Sensitive Clarion Language Lexer + /// + SCLEX_CLW, + /// + /// Lexer for Clarion with no case sensitivity. + /// + SCLEX_CLWNOCASE, + /// + /// Lexer for COBOL + /// + SCLEX_COBOL, + /// + /// Lexer for Case Sensitive C++ + /// + SCLEX_CPP, + /// + /// Lexer for no case sensitivity C++ + /// + SCLEX_CPPNOCASE, + /// + /// Lexer for C# + /// + SCLEX_CSHARP, + /// + /// Lexer for Cascading Style Sheets + /// + SCLEX_CSS, + /// + /// Lexer for Java + /// + SCLEX_JAVA, + /// + /// Lexer for JavaScript + /// + SCLEX_JAVASCRIPT, + /// + /// Lexer for Objective Caml. + /// + SCLEX_CAML, + /// + /// Lexer for Cmake + /// + SCLEX_CMAKE, + /// + /// Lexer for CoffeeScript. + /// + SCLEX_COFFEESCRIPT, + /// + /// Apache Configuration Files + /// + SCLEX_CONF, + /// + /// Lexer to use with extended crontab files used by a powerful + /// Windows scheduler/event monitor/automation manager nnCron. + /// + SCLEX_NNCRONTAB, + /// + /// Lexer for Csound (Orchestra and Score) + /// + SCLEX_CSOUND, + /// + /// Lexer for D + /// + SCLEX_D, + /// + /// Lexer for MSC Nastran DMAP. + /// + SCLEX_DMAP, + /// + /// Lexer for DMIS. + /// + SCLEX_DMIS, + /// + /// Lexer for DataFlex. + /// + SCLEX_DATAFLEX, + /// + /// Lexer for diff results. + /// + SCLEX_DIFF, + /// + /// Lexer for ECL. + /// + SCLEX_ECL, + /// + /// Lexer for EDIFACT + /// + SCLEX_EDIFACT, + /// + /// Lexer for ESCRIPT + /// + SCLEX_ESCRIPT, + /// + /// Lexer for Eiffel. + /// + SCLEX_EIFFEL, + /// + /// Lexer for EiffelKW + /// + SCLEX_EIFFELKW, + /// + /// Lexer for Erlang. + /// + SCLEX_ERLANG, + /// + /// Lexer for error lists. Used for the output pane in SciTE + /// + SCLEX_ERRORLIST, + /// + /// Lexer for F# 5.0 + /// + SCLEX_FSHARP, + /// + /// Lexer for Harbour and FlagShip. + /// + SCLEX_FLAGSHIP, + /// + /// Lexer for Forth + /// + SCLEX_FORTH, + /// + /// Lexer for Fortran + /// + SCLEX_FORTRAN, + /// + /// Lexer for Fortran 77 + /// + SCLEX_F77, + /// + /// Lexer for the GAP language. (The GAP System for Computational Discrete Algebra) + /// + SCLEX_GAP, + /// + /// Lexer for GDScript. + /// + SCLEX_GDSCRIPT, + /// + /// This is the Lexer for Gui4Cli, included in SciLexer.dll + /// + SCLEX_GUI4CLI, + /// + /// Lexer for HTML + /// + SCLEX_HTML, + /// + /// Lexer for XML + /// + SCLEX_XML, + /// + /// Lexer for PHPScript + /// + SCLEX_PHPSCRIPT, + /// + /// A haskell lexer for the scintilla code control. + /// + SCLEX_HASKELL, + /// + /// Lexer for Literate Haskell + /// + SCLEX_LITERATEHASKELL, + /// + /// Lexer for Motorola S-Record. + /// + SCLEX_SREC, + /// + /// Lexer for Intel HEX + /// + SCLEX_IHEX, + /// + /// Lexer for Tektronix extended HEX + /// + SCLEX_TEHEX, + /// + /// Lexer for Hollywood + /// + SCLEX_HOLLYWOOD, + /// + /// Lexer for no language. Used for indentation-based folding of files. + /// + SCLEX_INDENT, + /// + /// Lexer for Inno Setup scripts. + /// + SCLEX_INNOSETUP, + /// + /// Lexer for JSON and JSON-LD formats + /// + SCLEX_JSON, + /// + /// Lexer for Julia + /// + SCLEX_JULIA, + /// + /// Lexer for KIX-Scripts. + /// + SCLEX_KIX, + /// + /// Lexer for KVIrc script. + /// + SCLEX_KVIRC, + /// + /// Lexer for LaTeX2e. + /// + SCLEX_LATEX, + /// + /// Lexer for Lisp + /// + SCLEX_LISP, + /// + /// Lexer for the Basser Lout (>= version 3) typesetting language + /// + SCLEX_LOUT, + /// + /// Lexer for Lua language + /// + SCLEX_LUA, + /// + /// Lexer for MMIX Assembler Language. + /// + SCLEX_MMIXAL, + /// + /// Lexer for MPT specific files. Based on LexOthers.cxx + /// LOT = the text log file created by the MPT application while running a test program + /// + SCLEX_LOT, + /// + /// Lexer for MSSQL + /// + SCLEX_MSSQL, + /// + /// Lexer for GE(r) Smallworld(tm) MagikSF + /// + SCLEX_MAGIK, + /// + /// Lexer for make files. + /// + SCLEX_MAKEFILE, + /// + /// A simple Markdown lexer for scintilla. + /// + SCLEX_MARKDOWN, + /// + /// Lexer for Matlab. + /// + SCLEX_MATLAB, + /// + /// Lexer for Octave + /// + SCLEX_OCTAVE, + /// + /// Lexer for Maxima + /// + SCLEX_MAXIMA, + /// + /// Lexer for general context conformant metapost coloring scheme + /// + SCLEX_METAPOST, + /// + /// Lexer for Modula-2/3 documents. + /// + SCLEX_MODULA, + /// + /// Lexer for MySQL + /// + SCLEX_MYSQL, + /// + /// Lexer for NIM + /// + SCLEX_NIM, + /// + /// Lexer for NIMROD + /// + SCLEX_NIMROD, + /// + /// Lexer for NSIS + /// + SCLEX_NSIS, + /// + /// Lexer for no language. Used for plain text and unrecognized files. + /// + SCLEX_NULL, + /// + /// Lexer for OScript sources; ocx files and/or OSpace dumps. + /// + SCLEX_OSCRIPT, + /// + /// Lexer for OPAL (functional language similar to Haskell) + /// + SCLEX_OPAL, + /// + /// Lexer for PowerBasic + /// + SCLEX_POWERBASIC, + /// + /// Lexer for PL/M + /// + SCLEX_PLM, + /// + /// Lexer for GetText Translation (PO) files. + /// + SCLEX_PO, + /// + /// Lexer for POV-Ray SDL + /// + SCLEX_POV, + /// + /// Lexer for PostScript + /// + SCLEX_POSTSCRIPT, + /// + /// Lexer for Pascal + /// + SCLEX_PASCAL, + /// + /// Lexer for Perl + /// + SCLEX_PERL, + /// + /// Lexer for PowerPro + /// + SCLEX_POWERPRO, + /// + /// Lexer for PowerShellj scripts + /// + SCLEX_POWERSHELL, + /// + /// Lexer for Progress 4GL. + /// + SCLEX_PROGRESS, + /// + /// Lexer for properties files. + /// + SCLEX_PROPERTIES, + /// + /// Lexer for Python + /// + SCLEX_PYTHON, + /// + /// Lexer for R. + /// + SCLEX_R, + /// + /// Lexer for S. + /// + SCLEX_S, + /// + /// Lexer for SPlus Statistics Program. + /// + SCLEX_SPLUS, + /// + /// Lexer for Raku + /// + SCLEX_RAKU, + /// + /// Lexer for REBOL + /// + SCLEX_REBOL, + /// + /// Lexer for Windows registration files(.reg) + /// + SCLEX_REGISTRY, + /// + /// Lexer for Ruby + /// + SCLEX_RUBY, + /// + /// Lexer for Rust + /// + SCLEX_RUST, + /// + /// Lexer for SAS + /// + SCLEX_SAS, + /// + /// Lexer for SML + /// + SCLEX_SML, + /// + /// Lexer for SQL, including PL/SQL and SQL*Plus. + /// + SCLEX_SQL, + /// + /// Lexer for Structured Text language. + /// + SCLEX_STTXT, + /// + /// Lexer for Scriptol + /// + SCLEX_SCRIPTOL, + /// + /// Lexer for SmallTalk + /// + SCLEX_SMALLTALK, + /// + /// Lexer for SORCUS installation files + /// + SCLEX_SORCUS, + /// + /// Lexer for Specman E language. + /// + SCLEX_SPECMAN, + /// + /// Lexer for SPICE + /// + SCLEX_SPICE, + /// + /// Lexer for Stata + /// + SCLEX_STATA, + /// + /// Lexer for TACL + /// + SCLEX_TACL, + /// + /// Lexer for TADS3 + /// + SCLEX_TADS3, + /// + /// Lexer for TAL + /// + SCLEX_TAL, + /// + /// Lexer for TCL + /// + SCLEX_TCL, + /// + /// Lexer for Take Command / TCC batch scripts (.bat, .btm, .cmd). + /// + SCLEX_TCMD, + /// + /// Lexer for LaTeX general context conformant tex coloring scheme + /// + SCLEX_TEX, + /// + /// A simple Txt2tags lexer for scintilla. + /// + SCLEX_TXT2TAGS, + /// + /// Visual Basic + /// + SCLEX_VB, + /// + /// Visual Basic Script + /// + SCLEX_VBSCRIPT, + /// + /// Lexer for vhdl + /// + SCLEX_VHDL, + /// + /// Lexer for Verilog + /// + SCLEX_VERILOG, + /// + /// Lexer for Visual Prolog + /// + SCLEX_VISUALPROLOG, + /// + /// Lexer for X12 + /// + SCLEX_X12, + /// + /// Lexer for Yaml + /// + SCLEX_YAML, + } } diff --git a/Scintilla.NET/Lexilla.cs b/Scintilla.NET/Lexilla.cs index 7d8aeaf..d059960 100644 --- a/Scintilla.NET/Lexilla.cs +++ b/Scintilla.NET/Lexilla.cs @@ -3,151 +3,152 @@ using System.ComponentModel; using System.Runtime.InteropServices; -namespace ScintillaNET; - -/// -/// A class containing methods for interacting with the Lexilla library. -/// -public class Lexilla +namespace ScintillaNET { /// - /// Initializes the Lexilla.dll library. + /// A class containing methods for interacting with the Lexilla library. /// - /// The handle to the Lexilla.dll file. - internal Lexilla(IntPtr lexillaHandle) + public class Lexilla { - const string win32Error = "The Scintilla module has no export for the '{0}' procedure."; + /// + /// Initializes the Lexilla.dll library. + /// + /// The handle to the Lexilla.dll file. + internal Lexilla(IntPtr lexillaHandle) + { + const string win32Error = "The Scintilla module has no export for the '{0}' procedure."; - string lpProcName = nameof(NativeMethods.CreateLexer); + string lpProcName = nameof(NativeMethods.CreateLexer); - // Get the Lexilla functions needed to define lexers and create managed callbacks... + // Get the Lexilla functions needed to define lexers and create managed callbacks... - IntPtr functionPointer = NativeMethods.GetProcAddress(new HandleRef(this, lexillaHandle), lpProcName); - if (functionPointer == IntPtr.Zero) - { - throw new Win32Exception(string.Format(win32Error, lpProcName), - new Win32Exception()); // Calls GetLastError - } + IntPtr functionPointer = NativeMethods.GetProcAddress(new HandleRef(this, lexillaHandle), lpProcName); + if (functionPointer == IntPtr.Zero) + { + throw new Win32Exception(string.Format(win32Error, lpProcName), + new Win32Exception()); // Calls GetLastError + } - createLexer = (NativeMethods.CreateLexer)Marshal.GetDelegateForFunctionPointer( - functionPointer, typeof(NativeMethods.CreateLexer)); + createLexer = (NativeMethods.CreateLexer)Marshal.GetDelegateForFunctionPointer( + functionPointer, typeof(NativeMethods.CreateLexer)); - lpProcName = nameof(NativeMethods.GetLexerName); + lpProcName = nameof(NativeMethods.GetLexerName); - functionPointer = NativeMethods.GetProcAddress(new HandleRef(this, lexillaHandle), lpProcName); - if (functionPointer == IntPtr.Zero) - { - throw new Win32Exception(string.Format(win32Error, lpProcName), - new Win32Exception()); // Calls GetLastError - } + functionPointer = NativeMethods.GetProcAddress(new HandleRef(this, lexillaHandle), lpProcName); + if (functionPointer == IntPtr.Zero) + { + throw new Win32Exception(string.Format(win32Error, lpProcName), + new Win32Exception()); // Calls GetLastError + } - getLexerName = (NativeMethods.GetLexerName)Marshal.GetDelegateForFunctionPointer( - functionPointer, typeof(NativeMethods.GetLexerName)); + getLexerName = (NativeMethods.GetLexerName)Marshal.GetDelegateForFunctionPointer( + functionPointer, typeof(NativeMethods.GetLexerName)); - lpProcName = nameof(NativeMethods.GetLexerCount); + lpProcName = nameof(NativeMethods.GetLexerCount); - functionPointer = NativeMethods.GetProcAddress(new HandleRef(this, lexillaHandle), lpProcName); - if (functionPointer == IntPtr.Zero) - { - throw new Win32Exception(string.Format(win32Error, lpProcName), - new Win32Exception()); // Calls GetLastError - } + functionPointer = NativeMethods.GetProcAddress(new HandleRef(this, lexillaHandle), lpProcName); + if (functionPointer == IntPtr.Zero) + { + throw new Win32Exception(string.Format(win32Error, lpProcName), + new Win32Exception()); // Calls GetLastError + } - getLexerCount = (NativeMethods.GetLexerCount)Marshal.GetDelegateForFunctionPointer( - functionPointer, typeof(NativeMethods.GetLexerCount)); + getLexerCount = (NativeMethods.GetLexerCount)Marshal.GetDelegateForFunctionPointer( + functionPointer, typeof(NativeMethods.GetLexerCount)); - lpProcName = nameof(NativeMethods.LexerNameFromID); + lpProcName = nameof(NativeMethods.LexerNameFromID); - functionPointer = NativeMethods.GetProcAddress(new HandleRef(this, lexillaHandle), lpProcName); - if (functionPointer == IntPtr.Zero) - { - throw new Win32Exception(string.Format(win32Error, lpProcName), - new Win32Exception()); // Calls GetLastError - } + functionPointer = NativeMethods.GetProcAddress(new HandleRef(this, lexillaHandle), lpProcName); + if (functionPointer == IntPtr.Zero) + { + throw new Win32Exception(string.Format(win32Error, lpProcName), + new Win32Exception()); // Calls GetLastError + } - lexerNameFromId = (NativeMethods.LexerNameFromID)Marshal.GetDelegateForFunctionPointer( - functionPointer, typeof(NativeMethods.LexerNameFromID)); + lexerNameFromId = (NativeMethods.LexerNameFromID)Marshal.GetDelegateForFunctionPointer( + functionPointer, typeof(NativeMethods.LexerNameFromID)); - //initialized = true; - } + //initialized = true; + } - #region Fields + #region Fields - //private static bool initialized; + //private static bool initialized; - #endregion + #endregion - #region DllCalls - private static NativeMethods.GetLexerCount getLexerCount; + #region DllCalls + private static NativeMethods.GetLexerCount getLexerCount; - private static NativeMethods.GetLexerName getLexerName; + private static NativeMethods.GetLexerName getLexerName; - private static NativeMethods.CreateLexer createLexer; + private static NativeMethods.CreateLexer createLexer; - private static NativeMethods.LexerNameFromID lexerNameFromId; - #endregion + private static NativeMethods.LexerNameFromID lexerNameFromId; + #endregion - #region DllWrapping + #region DllWrapping - /// - /// Gets the lexer count in the Lexilla library. - /// - /// Amount of lexers defined in the Lexilla library. - public static int GetLexerCount() - { - return (int)getLexerCount(); - } - - /// - /// Creates a lexer with the specified name. - /// - /// The name of the lexer to create. - /// A containing the lexer interface pointer. - public static IntPtr CreateLexer(string lexerName) - { - return createLexer(lexerName); - } + /// + /// Gets the lexer count in the Lexilla library. + /// + /// Amount of lexers defined in the Lexilla library. + public static int GetLexerCount() + { + return (int)getLexerCount(); + } - /// - /// Gets the name of the lexer specified by an index number. - /// - /// The index. - /// The name of the lexer if one was found with the specified index; null otherwise. - public static string GetLexerName(int index) - { - IntPtr pointer = Marshal.AllocHGlobal(1024); - try + /// + /// Creates a lexer with the specified name. + /// + /// The name of the lexer to create. + /// A containing the lexer interface pointer. + public static IntPtr CreateLexer(string lexerName) { - getLexerName((UIntPtr)index, pointer, new IntPtr(1024)); - return Marshal.PtrToStringAnsi(pointer); + return createLexer(lexerName); } - finally + + /// + /// Gets the name of the lexer specified by an index number. + /// + /// The index. + /// The name of the lexer if one was found with the specified index; null otherwise. + public static string GetLexerName(int index) { - Marshal.FreeHGlobal(pointer); + IntPtr pointer = Marshal.AllocHGlobal(1024); + try + { + getLexerName((UIntPtr)index, pointer, new IntPtr(1024)); + return Marshal.PtrToStringAnsi(pointer); + } + finally + { + Marshal.FreeHGlobal(pointer); + } } - } - /// - /// Returns a lexer name with the specified identifier. - /// - /// The lexer identifier. - /// The name of the lexer if one was found with the specified identifier; null otherwise. - public static string LexerNameFromId(int identifier) - { - return lexerNameFromId(new IntPtr(identifier)); - } + /// + /// Returns a lexer name with the specified identifier. + /// + /// The lexer identifier. + /// The name of the lexer if one was found with the specified identifier; null otherwise. + public static string LexerNameFromId(int identifier) + { + return lexerNameFromId(new IntPtr(identifier)); + } - /// - /// Gets the lexer names contained in the Lexilla library. - /// - /// An IEnumerable<System.String> value with the lexer names. - public static IEnumerable GetLexerNames() - { - int count = GetLexerCount(); - for (int i = 0; i < count; i++) + /// + /// Gets the lexer names contained in the Lexilla library. + /// + /// An IEnumerable<System.String> value with the lexer names. + public static IEnumerable GetLexerNames() { - yield return GetLexerName(i); + int count = GetLexerCount(); + for (int i = 0; i < count; i++) + { + yield return GetLexerName(i); + } } + #endregion } - #endregion } diff --git a/Scintilla.NET/Line.cs b/Scintilla.NET/Line.cs index 3169ca1..088d384 100644 --- a/Scintilla.NET/Line.cs +++ b/Scintilla.NET/Line.cs @@ -1,648 +1,649 @@ using System; -namespace ScintillaNET; - -/// -/// Represents a line of text in a control. -/// -public class Line +namespace ScintillaNET { - #region Fields - - private readonly Scintilla scintilla; - - #endregion Fields - - #region Methods - /// - /// Expands any parent folds to ensure the line is visible. + /// Represents a line of text in a control. /// - public void EnsureVisible() + public class Line { - this.scintilla.DirectMessage(NativeMethods.SCI_ENSUREVISIBLE, new IntPtr(Index)); - } + #region Fields - //public void ExpandChildren(int level) - //{ - //} + private readonly Scintilla scintilla; - /// - /// Performs the specified fold action on the current line and all child lines. - /// - /// One of the enumeration values. - public void FoldChildren(FoldAction action) - { - this.scintilla.DirectMessage(NativeMethods.SCI_FOLDCHILDREN, new IntPtr(Index), new IntPtr((int)action)); - } + #endregion Fields - /// - /// Performs the specified fold action on the current line. - /// - /// One of the enumeration values. - public void FoldLine(FoldAction action) - { - this.scintilla.DirectMessage(NativeMethods.SCI_FOLDLINE, new IntPtr(Index), new IntPtr((int)action)); - } + #region Methods - /// - /// Searches for the next line that has a folding level that is less than or equal to - /// and returns the previous line index. - /// - /// The level of the line to search for. A value of -1 will use the current line . - /// - /// The zero-based index of the next line that has a less than or equal - /// to . If the current line is a fold point and is -1 the - /// index returned is the last line that would be made visible or hidden by toggling the fold state. - /// - public int GetLastChild(int level) - { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETLASTCHILD, new IntPtr(Index), new IntPtr(level)).ToInt32(); - } - - /// - /// Navigates the caret to the start of the line. - /// - /// Any selection is discarded. - public void Goto() - { - this.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, this.scintilla.Markers.Count - 1); - IntPtr handle = this.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) - { - int mask = unchecked((int)markerMask); - this.scintilla.DirectMessage(NativeMethods.SCI_MARKERADDSET, new IntPtr(Index), new IntPtr(mask)); - } + /// + /// Expands any parent folds to ensure the line is visible. + /// + public void EnsureVisible() + { + this.scintilla.DirectMessage(NativeMethods.SCI_ENSUREVISIBLE, new IntPtr(Index)); + } - /// - /// 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, this.scintilla.Markers.Count - 1); - this.scintilla.DirectMessage(NativeMethods.SCI_MARKERDELETE, new IntPtr(Index), new IntPtr(marker)); - } + //public void ExpandChildren(int level) + //{ + //} - /// - /// 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() - { - int mask = this.scintilla.DirectMessage(NativeMethods.SCI_MARKERGET, new IntPtr(Index)).ToInt32(); - return unchecked((uint)mask); - } + /// + /// Performs the specified fold action on the current line and all child lines. + /// + /// One of the enumeration values. + public void FoldChildren(FoldAction action) + { + this.scintilla.DirectMessage(NativeMethods.SCI_FOLDCHILDREN, new IntPtr(Index), new IntPtr((int)action)); + } - /// - /// 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) - { - int mask = unchecked((int)markerMask); - return this.scintilla.DirectMessage(NativeMethods.SCI_MARKERNEXT, new IntPtr(Index), new IntPtr(mask)).ToInt32(); - } + /// + /// Performs the specified fold action on the current line. + /// + /// One of the enumeration values. + public void FoldLine(FoldAction action) + { + this.scintilla.DirectMessage(NativeMethods.SCI_FOLDLINE, new IntPtr(Index), new IntPtr((int)action)); + } - /// - /// 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) - { - int mask = unchecked((int)markerMask); - return this.scintilla.DirectMessage(NativeMethods.SCI_MARKERPREVIOUS, new IntPtr(Index), new IntPtr(mask)).ToInt32(); - } + /// + /// Searches for the next line that has a folding level that is less than or equal to + /// and returns the previous line index. + /// + /// The level of the line to search for. A value of -1 will use the current line . + /// + /// The zero-based index of the next line that has a less than or equal + /// to . If the current line is a fold point and is -1 the + /// index returned is the last line that would be made visible or hidden by toggling the fold state. + /// + public int GetLastChild(int level) + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETLASTCHILD, new IntPtr(Index), new IntPtr(level)).ToInt32(); + } - /// - /// Toggles the folding state of the line; expanding or contracting all child lines. - /// - /// The line must be set as a . - /// - public void ToggleFold() - { - this.scintilla.DirectMessage(NativeMethods.SCI_TOGGLEFOLD, new IntPtr(Index)); - } + /// + /// Navigates the caret to the start of the line. + /// + /// Any selection is discarded. + public void Goto() + { + this.scintilla.DirectMessage(NativeMethods.SCI_GOTOLINE, new IntPtr(Index)); + } - /// - /// Toggles the folding state of the line; expanding or contracting all child lines, and specifies the text tag to display to the right of the fold. - /// - /// The text tag to show to the right of the folded text. - /// The display of fold text tags are determined by the method. - /// - public unsafe void ToggleFoldShowText(string text) - { - if (string.IsNullOrEmpty(text)) + /// + /// 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) { - this.scintilla.DirectMessage(NativeMethods.SCI_TOGGLEFOLDSHOWTEXT, new IntPtr(Index), IntPtr.Zero); + marker = Helpers.Clamp(marker, 0, this.scintilla.Markers.Count - 1); + IntPtr handle = this.scintilla.DirectMessage(NativeMethods.SCI_MARKERADD, new IntPtr(Index), new IntPtr(marker)); + return new MarkerHandle { Value = handle }; } - else + + /// + /// 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) { - byte[] bytes = Helpers.GetBytes(text, this.scintilla.Encoding, zeroTerminated: true); - fixed (byte* bp = bytes) - this.scintilla.DirectMessage(NativeMethods.SCI_TOGGLEFOLDSHOWTEXT, new IntPtr(Index), new IntPtr(bp)); + int mask = unchecked((int)markerMask); + this.scintilla.DirectMessage(NativeMethods.SCI_MARKERADDSET, new IntPtr(Index), new IntPtr(mask)); } - } - #endregion Methods + /// + /// 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, this.scintilla.Markers.Count - 1); + this.scintilla.DirectMessage(NativeMethods.SCI_MARKERDELETE, new IntPtr(Index), new IntPtr(marker)); + } - #region Properties + /// + /// 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() + { + int mask = this.scintilla.DirectMessage(NativeMethods.SCI_MARKERGET, new IntPtr(Index)).ToInt32(); + return unchecked((uint)mask); + } - /// - /// Gets the number of annotation lines of text. - /// - /// The number of annotation lines. - public int AnnotationLines - { - get + /// + /// 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) { - return this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETLINES, new IntPtr(Index)).ToInt32(); + int mask = unchecked((int)markerMask); + return this.scintilla.DirectMessage(NativeMethods.SCI_MARKERNEXT, new IntPtr(Index), new IntPtr(mask)).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 + /// + /// 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) { - return this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETSTYLE, new IntPtr(Index)).ToInt32(); + int mask = unchecked((int)markerMask); + return this.scintilla.DirectMessage(NativeMethods.SCI_MARKERPREVIOUS, new IntPtr(Index), new IntPtr(mask)).ToInt32(); } - set + + /// + /// Toggles the folding state of the line; expanding or contracting all child lines. + /// + /// The line must be set as a . + /// + public void ToggleFold() { - value = Helpers.Clamp(value, 0, this.scintilla.Styles.Count - 1); - this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETSTYLE, new IntPtr(Index), new IntPtr(value)); + this.scintilla.DirectMessage(NativeMethods.SCI_TOGGLEFOLD, new IntPtr(Index)); } - } - /// - /// 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 + /// + /// Toggles the folding state of the line; expanding or contracting all child lines, and specifies the text tag to display to the right of the fold. + /// + /// The text tag to show to the right of the folded text. + /// The display of fold text tags are determined by the method. + /// + public unsafe void ToggleFoldShowText(string text) { - int length = this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return new byte[0]; + if (string.IsNullOrEmpty(text)) + { + this.scintilla.DirectMessage(NativeMethods.SCI_TOGGLEFOLDSHOWTEXT, new IntPtr(Index), IntPtr.Zero); + } + else + { + byte[] bytes = Helpers.GetBytes(text, this.scintilla.Encoding, zeroTerminated: true); + fixed (byte* bp = bytes) + this.scintilla.DirectMessage(NativeMethods.SCI_TOGGLEFOLDSHOWTEXT, new IntPtr(Index), new IntPtr(bp)); + } + } - byte[] text = new byte[length + 1]; - byte[] styles = new byte[length + 1]; + #endregion Methods - fixed (byte* textPtr = text) - fixed (byte* stylePtr = styles) - { - this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); - this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); + #region Properties - return Helpers.ByteToCharStyles(stylePtr, textPtr, length, this.scintilla.Encoding); + /// + /// Gets the number of annotation lines of text. + /// + /// The number of annotation lines. + public int AnnotationLines + { + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETLINES, new IntPtr(Index)).ToInt32(); } } - set - { - int length = this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return; - byte[] text = new byte[length + 1]; - fixed (byte* textPtr = text) + /// + /// 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 { - this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); - - byte[] styles = Helpers.CharToByteStyles(value ?? new byte[0], textPtr, length, this.scintilla.Encoding); - fixed (byte* stylePtr = styles) - this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); + return this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETSTYLE, new IntPtr(Index)).ToInt32(); + } + set + { + value = Helpers.Clamp(value, 0, this.scintilla.Styles.Count - 1); + this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETSTYLE, new IntPtr(Index), new IntPtr(value)); } } - } - /// - /// Gets or sets the line annotation text. - /// - /// A String representing the line annotation text. - public unsafe string AnnotationText - { - get - { - int length = this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return string.Empty; + /// + /// 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 + { + int length = this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index)).ToInt32(); + if (length == 0) + return new byte[0]; - byte[] bytes = new byte[length + 1]; - fixed (byte* bp = bytes) + byte[] text = new byte[length + 1]; + byte[] styles = new byte[length + 1]; + + fixed (byte* textPtr = text) + fixed (byte* stylePtr = styles) + { + this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); + this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); + + return Helpers.ByteToCharStyles(stylePtr, textPtr, length, this.scintilla.Encoding); + } + } + set { - this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index), new IntPtr(bp)); - return Helpers.GetString(new IntPtr(bp), length, this.scintilla.Encoding); + int length = this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index)).ToInt32(); + if (length == 0) + return; + + byte[] text = new byte[length + 1]; + fixed (byte* textPtr = text) + { + this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); + + byte[] styles = Helpers.CharToByteStyles(value ?? new byte[0], textPtr, length, this.scintilla.Encoding); + fixed (byte* stylePtr = styles) + this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); + } } } - set + + /// + /// Gets or sets the line annotation text. + /// + /// A String representing the line annotation text. + public unsafe string AnnotationText { - // allow empty annotation, set to null to remove - if (value == null) + get { - // Scintilla docs suggest that setting to NULL rather than an empty string will free memory - this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETTEXT, new IntPtr(Index), IntPtr.Zero); + int length = this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index)).ToInt32(); + if (length == 0) + return string.Empty; + + byte[] bytes = new byte[length + 1]; + fixed (byte* bp = bytes) + { + this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONGETTEXT, new IntPtr(Index), new IntPtr(bp)); + return Helpers.GetString(new IntPtr(bp), length, this.scintilla.Encoding); + } } - else + set { - byte[] bytes = Helpers.GetBytes(value, this.scintilla.Encoding, zeroTerminated: true); - fixed (byte* bp = bytes) - this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETTEXT, new IntPtr(Index), new IntPtr(bp)); + // allow empty annotation, set to null to remove + if (value == null) + { + // Scintilla docs suggest that setting to NULL rather than an empty string will free memory + this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETTEXT, new IntPtr(Index), IntPtr.Zero); + } + else + { + byte[] bytes = Helpers.GetBytes(value, this.scintilla.Encoding, zeroTerminated: true); + fixed (byte* bp = bytes) + this.scintilla.DirectMessage(NativeMethods.SCI_ANNOTATIONSETTEXT, new IntPtr(Index), new IntPtr(bp)); + } } } - } - /// - /// Searches from the current line to find the index of the next contracted fold header. - /// - /// The zero-based line index of the next contracted folder header. - /// If the current line is contracted the current line index is returned. - public int ContractedFoldNext - { - get + /// + /// Searches from the current line to find the index of the next contracted fold header. + /// + /// The zero-based line index of the next contracted folder header. + /// If the current line is contracted the current line index is returned. + public int ContractedFoldNext { - return this.scintilla.DirectMessage(NativeMethods.SCI_CONTRACTEDFOLDNEXT, new IntPtr(Index)).ToInt32(); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_CONTRACTEDFOLDNEXT, new IntPtr(Index)).ToInt32(); + } } - } - /// - /// Gets the zero-based index of the line as displayed in a control - /// taking into consideration folded (hidden) lines. - /// - /// The zero-based display line index. - /// - public int DisplayIndex - { - get + /// + /// Gets the zero-based index of the line as displayed in a control + /// taking into consideration folded (hidden) lines. + /// + /// The zero-based display line index. + /// + public int DisplayIndex { - return this.scintilla.DirectMessage(NativeMethods.SCI_VISIBLEFROMDOCLINE, new IntPtr(Index)).ToInt32(); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_VISIBLEFROMDOCLINE, new IntPtr(Index)).ToInt32(); + } } - } - /// - /// Gets the zero-based character position in the document where the line ends (exclusive). - /// - /// The equivalent of + . - public int EndPosition - { - get + /// + /// Gets the zero-based character position in the document where the line ends (exclusive). + /// + /// The equivalent of + . + public int EndPosition { - return Position + Length; + get + { + return Position + Length; + } } - } - /// - /// Gets or sets the expanded state (not the visible state) of the line. - /// - /// - /// For toggling the fold state of a single line the method should be used. - /// This property is useful for toggling the state of many folds without updating the display until finished. - /// - /// - public bool Expanded - { - get + /// + /// Gets or sets the expanded state (not the visible state) of the line. + /// + /// + /// For toggling the fold state of a single line the method should be used. + /// This property is useful for toggling the state of many folds without updating the display until finished. + /// + /// + public bool Expanded { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETFOLDEXPANDED, new IntPtr(Index)) != IntPtr.Zero; - } - set - { - IntPtr expanded = value ? new IntPtr(1) : IntPtr.Zero; - this.scintilla.DirectMessage(NativeMethods.SCI_SETFOLDEXPANDED, new IntPtr(Index), expanded); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETFOLDEXPANDED, new IntPtr(Index)) != IntPtr.Zero; + } + set + { + IntPtr expanded = value ? new IntPtr(1) : IntPtr.Zero; + this.scintilla.DirectMessage(NativeMethods.SCI_SETFOLDEXPANDED, new IntPtr(Index), expanded); + } } - } - /// - /// Gets or sets the fold level of the line. - /// - /// The fold level ranging from 0 to 4095. The default is 1024. - public int FoldLevel - { - get - { - int level = this.scintilla.DirectMessage(NativeMethods.SCI_GETFOLDLEVEL, new IntPtr(Index)).ToInt32(); - return level & NativeMethods.SC_FOLDLEVELNUMBERMASK; - } - set + /// + /// Gets or sets the fold level of the line. + /// + /// The fold level ranging from 0 to 4095. The default is 1024. + public int FoldLevel { - int bits = (int)FoldLevelFlags; - bits |= value; + get + { + int level = this.scintilla.DirectMessage(NativeMethods.SCI_GETFOLDLEVEL, new IntPtr(Index)).ToInt32(); + return level & NativeMethods.SC_FOLDLEVELNUMBERMASK; + } + set + { + int bits = (int)FoldLevelFlags; + bits |= value; - this.scintilla.DirectMessage(NativeMethods.SCI_SETFOLDLEVEL, new IntPtr(Index), new IntPtr(bits)); + this.scintilla.DirectMessage(NativeMethods.SCI_SETFOLDLEVEL, new IntPtr(Index), new IntPtr(bits)); + } } - } - /// - /// Gets or sets the fold level flags. - /// - /// A bitwise combination of the enumeration. - public FoldLevelFlags FoldLevelFlags - { - get + /// + /// Gets or sets the fold level flags. + /// + /// A bitwise combination of the enumeration. + public FoldLevelFlags FoldLevelFlags { - int flags = this.scintilla.DirectMessage(NativeMethods.SCI_GETFOLDLEVEL, new IntPtr(Index)).ToInt32(); - return (FoldLevelFlags)(flags & ~NativeMethods.SC_FOLDLEVELNUMBERMASK); - } - set - { - int bits = FoldLevel; - bits |= (int)value; + get + { + int flags = this.scintilla.DirectMessage(NativeMethods.SCI_GETFOLDLEVEL, new IntPtr(Index)).ToInt32(); + return (FoldLevelFlags)(flags & ~NativeMethods.SC_FOLDLEVELNUMBERMASK); + } + set + { + int bits = FoldLevel; + bits |= (int)value; - this.scintilla.DirectMessage(NativeMethods.SCI_SETFOLDLEVEL, new IntPtr(Index), new IntPtr(bits)); + this.scintilla.DirectMessage(NativeMethods.SCI_SETFOLDLEVEL, new IntPtr(Index), new IntPtr(bits)); + } } - } - /// - /// Gets the zero-based line index of the first line before the current line that is marked as - /// and has a less than the current line. - /// - /// The zero-based line index of the fold parent if present; otherwise, -1. - public int FoldParent - { - get + /// + /// Gets the zero-based line index of the first line before the current line that is marked as + /// and has a less than the current line. + /// + /// The zero-based line index of the fold parent if present; otherwise, -1. + public int FoldParent { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETFOLDPARENT, new IntPtr(Index)).ToInt32(); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETFOLDPARENT, new IntPtr(Index)).ToInt32(); + } } - } - /// - /// Gets the height of the line in pixels. - /// - /// The height in pixels of the line. - /// Currently all lines are the same height. - public int Height - { - get + /// + /// Gets the height of the line in pixels. + /// + /// The height in pixels of the line. + /// Currently all lines are the same height. + public int Height { - return this.scintilla.DirectMessage(NativeMethods.SCI_TEXTHEIGHT, new IntPtr(Index)).ToInt32(); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_TEXTHEIGHT, new IntPtr(Index)).ToInt32(); + } } - } - /// - /// Gets the line index. - /// - /// The zero-based line index within the that created it. - public int Index { get; private set; } + /// + /// 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 + /// + /// Gets the length of the line. + /// + /// The number of characters in the line including any end of line characters. + public int Length { - return this.scintilla.Lines.CharLineLength(Index); + get + { + return this.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 this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETSTYLE, new IntPtr(Index)).ToInt32(); - } - set + /// + /// 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 { - value = Helpers.Clamp(value, 0, this.scintilla.Styles.Count - 1); - this.scintilla.DirectMessage(NativeMethods.SCI_MARGINSETSTYLE, new IntPtr(Index), new IntPtr(value)); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETSTYLE, new IntPtr(Index)).ToInt32(); + } + set + { + value = Helpers.Clamp(value, 0, this.scintilla.Styles.Count - 1); + this.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 - { - int length = this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return new byte[0]; + /// + /// 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 + { + int length = this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index)).ToInt32(); + if (length == 0) + return new byte[0]; - byte[] text = new byte[length + 1]; - byte[] styles = new byte[length + 1]; + byte[] text = new byte[length + 1]; + byte[] styles = new byte[length + 1]; - fixed (byte* textPtr = text) - fixed (byte* stylePtr = styles) - { - this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); - this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); + fixed (byte* textPtr = text) + fixed (byte* stylePtr = styles) + { + this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); + this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); - return Helpers.ByteToCharStyles(stylePtr, textPtr, length, this.scintilla.Encoding); + return Helpers.ByteToCharStyles(stylePtr, textPtr, length, this.scintilla.Encoding); + } + } + set + { + int length = this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index)).ToInt32(); + if (length == 0) + return; + + byte[] text = new byte[length + 1]; + fixed (byte* textPtr = text) + { + this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); + + byte[] styles = Helpers.CharToByteStyles(value ?? new byte[0], textPtr, length, this.scintilla.Encoding); + fixed (byte* stylePtr = styles) + this.scintilla.DirectMessage(NativeMethods.SCI_MARGINSETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); + } } } - set - { - int length = this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return; - byte[] text = new byte[length + 1]; - fixed (byte* textPtr = text) + /// + /// Gets or sets the text displayed in the line margin when the margin type is + /// or . + /// + /// The text displayed in the line margin. + public unsafe string MarginText + { + get { - this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index), new IntPtr(textPtr)); + int length = this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index)).ToInt32(); + if (length == 0) + return string.Empty; - byte[] styles = Helpers.CharToByteStyles(value ?? new byte[0], textPtr, length, this.scintilla.Encoding); - fixed (byte* stylePtr = styles) - this.scintilla.DirectMessage(NativeMethods.SCI_MARGINSETSTYLES, new IntPtr(Index), new IntPtr(stylePtr)); + byte[] bytes = new byte[length + 1]; + fixed (byte* bp = bytes) + { + this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index), new IntPtr(bp)); + return Helpers.GetString(new IntPtr(bp), length, this.scintilla.Encoding); + } + } + set + { + if (string.IsNullOrEmpty(value)) + { + // Scintilla docs suggest that setting to NULL rather than an empty string will free memory + this.scintilla.DirectMessage(NativeMethods.SCI_MARGINSETTEXT, new IntPtr(Index), IntPtr.Zero); + } + else + { + byte[] bytes = Helpers.GetBytes(value, this.scintilla.Encoding, zeroTerminated: true); + fixed (byte* bp = bytes) + this.scintilla.DirectMessage(NativeMethods.SCI_MARGINSETTEXT, new IntPtr(Index), new IntPtr(bp)); + } } } - } - /// - /// Gets or sets the text displayed in the line margin when the margin type is - /// or . - /// - /// The text displayed in the line margin. - public unsafe string MarginText - { - get + /// + /// 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 { - int length = this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index)).ToInt32(); - if (length == 0) - return string.Empty; + get + { + return this.scintilla.Lines.CharPositionFromLine(Index); + } + } - byte[] bytes = new byte[length + 1]; - fixed (byte* bp = bytes) + /// + /// Gets the line text. + /// + /// A string representing the document line. + /// The returned text includes any end of line characters. + public unsafe string Text + { + get { - this.scintilla.DirectMessage(NativeMethods.SCI_MARGINGETTEXT, new IntPtr(Index), new IntPtr(bp)); - return Helpers.GetString(new IntPtr(bp), length, this.scintilla.Encoding); + IntPtr start = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(Index)); + IntPtr length = this.scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(Index)); + IntPtr ptr = this.scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, start, length); + if (ptr == IntPtr.Zero) + return string.Empty; + + string text = new string((sbyte*)ptr, 0, length.ToInt32(), this.scintilla.Encoding); + return text; } } - set + + /// + /// Sets or gets the line indentation. + /// + /// The indentation measured in character columns, which corresponds to the width of space characters. + public int Indentation { - if (string.IsNullOrEmpty(value)) + get { - // Scintilla docs suggest that setting to NULL rather than an empty string will free memory - this.scintilla.DirectMessage(NativeMethods.SCI_MARGINSETTEXT, new IntPtr(Index), IntPtr.Zero); + return this.scintilla.DirectMessage(NativeMethods.SCI_GETLINEINDENTATION, new IntPtr(Index)).ToInt32(); } - else + set { - byte[] bytes = Helpers.GetBytes(value, this.scintilla.Encoding, zeroTerminated: true); - fixed (byte* bp = bytes) - this.scintilla.DirectMessage(NativeMethods.SCI_MARGINSETTEXT, new IntPtr(Index), new IntPtr(bp)); + this.scintilla.DirectMessage(NativeMethods.SCI_SETLINEINDENTATION, new IntPtr(Index), new IntPtr(value)); } } - } - /// - /// 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 + /// + /// This returns the position at the end of indentation of a line. + /// + public int IndentPosition { - return this.scintilla.Lines.CharPositionFromLine(Index); + get + { + IntPtr pos = this.scintilla.DirectMessage(NativeMethods.SCI_GETLINEINDENTPOSITION, new IntPtr(Index)); + return this.scintilla.Lines.ByteToCharPosition(pos.ToInt32()); + } } - } - /// - /// Gets the line text. - /// - /// A string representing the document line. - /// The returned text includes any end of line characters. - public unsafe string Text - { - get + /// + /// Gets a value indicating whether the line is visible. + /// + /// true if the line is visible; otherwise, false. + /// + /// + public bool Visible { - IntPtr start = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(Index)); - IntPtr length = this.scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(Index)); - IntPtr ptr = this.scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, start, length); - if (ptr == IntPtr.Zero) - return string.Empty; - - string text = new((sbyte*)ptr, 0, length.ToInt32(), this.scintilla.Encoding); - return text; + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETLINEVISIBLE, new IntPtr(Index)) != IntPtr.Zero; + } } - } - /// - /// Sets or gets the line indentation. - /// - /// The indentation measured in character columns, which corresponds to the width of space characters. - public int Indentation - { - get - { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETLINEINDENTATION, new IntPtr(Index)).ToInt32(); - } - set + /// + /// 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 { - this.scintilla.DirectMessage(NativeMethods.SCI_SETLINEINDENTATION, new IntPtr(Index), new IntPtr(value)); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_WRAPCOUNT, new IntPtr(Index)).ToInt32(); + } } - } - /// - /// This returns the position at the end of indentation of a line. - /// - public int IndentPosition - { - get - { - IntPtr pos = this.scintilla.DirectMessage(NativeMethods.SCI_GETLINEINDENTPOSITION, new IntPtr(Index)); - return this.scintilla.Lines.ByteToCharPosition(pos.ToInt32()); - } - } + #endregion Properties - /// - /// Gets a value indicating whether the line is visible. - /// - /// true if the line is visible; otherwise, false. - /// - /// - public bool Visible - { - get - { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETLINEVISIBLE, new IntPtr(Index)) != IntPtr.Zero; - } - } + #region Constructors - /// - /// 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 + /// + /// 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) { - return this.scintilla.DirectMessage(NativeMethods.SCI_WRAPCOUNT, new IntPtr(Index)).ToInt32(); + this.scintilla = scintilla; + Index = index; } - } - - #endregion Properties - - #region Constructors - /// - /// 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; + #endregion Constructors } - - #endregion Constructors } diff --git a/Scintilla.NET/LineCollection.cs b/Scintilla.NET/LineCollection.cs index b6ebfc9..4482c9e 100644 --- a/Scintilla.NET/LineCollection.cs +++ b/Scintilla.NET/LineCollection.cs @@ -5,567 +5,569 @@ using System.IO; using System.Text; -namespace ScintillaNET; -// TODO Revisit this following Scintilla v3.7.0 because is said to be better about character handling - -/// -/// An immutable collection of lines of text in a control. -/// -public class LineCollection : IEnumerable +namespace ScintillaNET { - #region Fields + // TODO Revisit this following Scintilla v3.7.0 because is said to be better about character handling - private readonly Scintilla scintilla; - private GapBuffer perLineData; + /// + /// An immutable collection of lines of text in a control. + /// + public class LineCollection : IEnumerable + { + #region Fields - // The 'step' is a break in the continuity of our line starts. It allows us - // to delay the updating of every line start when text is inserted/deleted. - private int stepLine; - private int stepLength; + private readonly Scintilla scintilla; + private GapBuffer perLineData; - #endregion Fields + // The 'step' is a break in the continuity of our line starts. It allows us + // to delay the updating of every line start when text is inserted/deleted. + private int stepLine; + private int stepLength; - #region Methods + #endregion Fields - /// - /// Adjust the number of CHARACTERS in a line. - /// - private void AdjustLineLength(int index, int delta) - { - MoveStep(index); - this.stepLength += delta; + #region Methods - // Invalidate multibyte flag - PerLine perLine = this.perLineData[index]; - perLine.ContainsMultibyte = ContainsMultibyte.Unkown; - this.perLineData[index] = perLine; - } + /// + /// Adjust the number of CHARACTERS in a line. + /// + private void AdjustLineLength(int index, int delta) + { + MoveStep(index); + this.stepLength += delta; - /// - /// Converts a BYTE offset to a CHARACTER offset. - /// - internal int ByteToCharPosition(int pos) - { - Debug.Assert(pos >= 0); - Debug.Assert(pos <= this.scintilla.DirectMessage(NativeMethods.SCI_GETLENGTH).ToInt32()); + // Invalidate multibyte flag + PerLine perLine = this.perLineData[index]; + perLine.ContainsMultibyte = ContainsMultibyte.Unkown; + this.perLineData[index] = perLine; + } - int line = this.scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, new IntPtr(pos)).ToInt32(); - int byteStart = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(line)).ToInt32(); - int count = CharPositionFromLine(line) + GetCharCount(byteStart, pos - byteStart); + /// + /// Converts a BYTE offset to a CHARACTER offset. + /// + internal int ByteToCharPosition(int pos) + { + Debug.Assert(pos >= 0); + Debug.Assert(pos <= this.scintilla.DirectMessage(NativeMethods.SCI_GETLENGTH).ToInt32()); - return count; - } + int line = this.scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, new IntPtr(pos)).ToInt32(); + int byteStart = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(line)).ToInt32(); + int count = CharPositionFromLine(line) + GetCharCount(byteStart, pos - byteStart); - /// - /// Returns the number of CHARACTERS in a line. - /// - internal int CharLineLength(int index) - { - Debug.Assert(index >= 0); - Debug.Assert(index < Count); - - // A line's length is calculated by subtracting its start offset from - // the start of the line following. We keep a terminal (faux) line at - // the end of the list so we can calculate the length of the last line. - - if (index + 1 <= this.stepLine) - return this.perLineData[index + 1].Start - this.perLineData[index].Start; - else if (index <= this.stepLine) - return this.perLineData[index + 1].Start + this.stepLength - this.perLineData[index].Start; - else - return this.perLineData[index + 1].Start + this.stepLength - (this.perLineData[index].Start + this.stepLength); - } + return count; + } - /// - /// Returns the CHARACTER offset where the line begins. - /// - internal int CharPositionFromLine(int index) - { - Debug.Assert(index >= 0); - Debug.Assert(index < this.perLineData.Count); // Allow query of terminal line start + /// + /// Returns the number of CHARACTERS in a line. + /// + internal int CharLineLength(int index) + { + Debug.Assert(index >= 0); + Debug.Assert(index < Count); - int start = this.perLineData[index].Start; - if (index > this.stepLine) - start += this.stepLength; + // A line's length is calculated by subtracting its start offset from + // the start of the line following. We keep a terminal (faux) line at + // the end of the list so we can calculate the length of the last line. - return start; - } + if (index + 1 <= this.stepLine) + return this.perLineData[index + 1].Start - this.perLineData[index].Start; + else if (index <= this.stepLine) + return this.perLineData[index + 1].Start + this.stepLength - this.perLineData[index].Start; + else + return this.perLineData[index + 1].Start + this.stepLength - (this.perLineData[index].Start + this.stepLength); + } - internal int CharToWideBytePosition(int pos) - { - Debug.Assert(pos >= 0); - Debug.Assert(pos <= TextLength); + /// + /// Returns the CHARACTER offset where the line begins. + /// + internal int CharPositionFromLine(int index) + { + Debug.Assert(index >= 0); + Debug.Assert(index < this.perLineData.Count); // Allow query of terminal line start - // Adjust to the nearest line start - int line = LineFromCharPosition(pos); - int bytePos = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(line)).ToInt32(); - pos -= CharPositionFromLine(line); + int start = this.perLineData[index].Start; + if (index > this.stepLine) + start += this.stepLength; - // Optimization when the line contains NO multibyte characters - if (!LineContainsMultibyteChar(line)) - return bytePos + pos; + return start; + } - int prevBytePos; - while (pos > 0) + internal int CharToWideBytePosition(int pos) { - // hang onto the prev byte position so we can determine if we are single or multi byte - prevBytePos = bytePos; - bytePos = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONRELATIVE, new IntPtr(bytePos), new IntPtr(1)).ToInt32(); + Debug.Assert(pos >= 0); + Debug.Assert(pos <= TextLength); - if (bytePos - prevBytePos == 1) - { - // if the byte position is 1, we are single byte - pos--; - } - else + // Adjust to the nearest line start + int line = LineFromCharPosition(pos); + int bytePos = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(line)).ToInt32(); + pos -= CharPositionFromLine(line); + + // Optimization when the line contains NO multibyte characters + if (!LineContainsMultibyteChar(line)) + return bytePos + pos; + + int prevBytePos; + while (pos > 0) { - // if the byte position > 1, we are multi byte - pos -= 2; + // hang onto the prev byte position so we can determine if we are single or multi byte + prevBytePos = bytePos; + bytePos = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONRELATIVE, new IntPtr(bytePos), new IntPtr(1)).ToInt32(); + + if (bytePos - prevBytePos == 1) + { + // if the byte position is 1, we are single byte + pos--; + } + else + { + // if the byte position > 1, we are multi byte + pos -= 2; + } } + + return bytePos; } - return bytePos; - } + internal int CharToBytePosition(int pos) + { + Debug.Assert(pos >= 0); + Debug.Assert(pos <= TextLength); - internal int CharToBytePosition(int pos) - { - Debug.Assert(pos >= 0); - Debug.Assert(pos <= TextLength); + // Adjust to the nearest line start + int line = LineFromCharPosition(pos); + int bytePos = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(line)).ToInt32(); + pos -= CharPositionFromLine(line); - // Adjust to the nearest line start - int line = LineFromCharPosition(pos); - int bytePos = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(line)).ToInt32(); - pos -= CharPositionFromLine(line); + // Optimization when the line contains NO multibyte characters + if (!LineContainsMultibyteChar(line)) + return bytePos + pos; - // Optimization when the line contains NO multibyte characters - if (!LineContainsMultibyteChar(line)) - return bytePos + pos; + while (pos > 0) + { + // Move char-by-char + bytePos = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONRELATIVE, new IntPtr(bytePos), + new IntPtr(1)).ToInt32(); + pos--; + } - while (pos > 0) - { - // Move char-by-char - bytePos = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONRELATIVE, new IntPtr(bytePos), - new IntPtr(1)).ToInt32(); - pos--; + return bytePos; } - return bytePos; - } - - private void DeletePerLine(int index) - { - Debug.Assert(index != 0); + private void DeletePerLine(int index) + { + Debug.Assert(index != 0); - MoveStep(index); + MoveStep(index); - // Subtract the line length - this.stepLength -= CharLineLength(index); + // Subtract the line length + this.stepLength -= CharLineLength(index); - // Remove the line - this.perLineData.RemoveAt(index); + // Remove the line + this.perLineData.RemoveAt(index); - // Move the step to the line before the one removed - this.stepLine--; - } + // Move the step to the line before the one removed + this.stepLine--; + } #if DEBUG - /// - /// Dumps the line buffer to a string. - /// - /// A string representing the line buffer. - public string Dump() - { - using var writer = new StringWriter(); - this.scintilla.Lines.Dump(writer); - return writer.ToString(); - } - - /// - /// Dumps the line buffer to the specified TextWriter. - /// - /// The writer to use for dumping the line buffer. - public unsafe void Dump(TextWriter writer) - { - int totalChars = 0; - - for (int i = 0; i < this.perLineData.Count; i++) + /// + /// Dumps the line buffer to a string. + /// + /// A string representing the line buffer. + public string Dump() { - string error = totalChars == CharPositionFromLine(i) ? null : "*"; - if (i == this.perLineData.Count - 1) + using (var writer = new StringWriter()) { - writer.WriteLine("{0}[{1}] {2} (terminal)", error, i, CharPositionFromLine(i)); + this.scintilla.Lines.Dump(writer); + return writer.ToString(); } - else - { - int len = this.scintilla.DirectMessage(NativeMethods.SCI_GETLINE, new IntPtr(i)).ToInt32(); - byte[] bytes = new byte[len]; - - fixed (byte* ptr = bytes) - this.scintilla.DirectMessage(NativeMethods.SCI_GETLINE, new IntPtr(i), new IntPtr(ptr)); + } - string str = this.scintilla.Encoding.GetString(bytes); - string containsMultibyte = "U"; - if (this.perLineData[i].ContainsMultibyte == ContainsMultibyte.Yes) - containsMultibyte = "Y"; - else if (this.perLineData[i].ContainsMultibyte == ContainsMultibyte.No) - containsMultibyte = "N"; + /// + /// Dumps the line buffer to the specified TextWriter. + /// + /// The writer to use for dumping the line buffer. + public unsafe void Dump(TextWriter writer) + { + int totalChars = 0; - writer.WriteLine("{0}[{1}] {2}:{3}:{4} {5}", error, i, CharPositionFromLine(i), str.Length, containsMultibyte, str.Replace("\r", "\\r").Replace("\n", "\\n")); - totalChars += str.Length; + for (int i = 0; i < this.perLineData.Count; i++) + { + string error = totalChars == CharPositionFromLine(i) ? null : "*"; + if (i == this.perLineData.Count - 1) + { + writer.WriteLine("{0}[{1}] {2} (terminal)", error, i, CharPositionFromLine(i)); + } + else + { + int len = this.scintilla.DirectMessage(NativeMethods.SCI_GETLINE, new IntPtr(i)).ToInt32(); + byte[] bytes = new byte[len]; + + fixed (byte* ptr = bytes) + this.scintilla.DirectMessage(NativeMethods.SCI_GETLINE, new IntPtr(i), new IntPtr(ptr)); + + string str = this.scintilla.Encoding.GetString(bytes); + string containsMultibyte = "U"; + if (this.perLineData[i].ContainsMultibyte == ContainsMultibyte.Yes) + containsMultibyte = "Y"; + else if (this.perLineData[i].ContainsMultibyte == ContainsMultibyte.No) + containsMultibyte = "N"; + + writer.WriteLine("{0}[{1}] {2}:{3}:{4} {5}", error, i, CharPositionFromLine(i), str.Length, containsMultibyte, str.Replace("\r", "\\r").Replace("\n", "\\n")); + totalChars += str.Length; + } } } - } #endif - /// - /// Gets the number of CHARACTERS int a BYTE range. - /// - private int GetCharCount(int pos, int length) - { - IntPtr ptr = this.scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, new IntPtr(pos), new IntPtr(length)); - return GetCharCount(ptr, length, this.scintilla.Encoding); - } - - /// - /// Gets the number of CHARACTERS in a BYTE range. - /// - private static unsafe int GetCharCount(IntPtr text, int length, Encoding encoding) - { - if (text == IntPtr.Zero || length == 0) - return 0; - - // Never use SCI_COUNTCHARACTERS. It counts CRLF as 1 char! - int count = encoding.GetCharCount((byte*)text, length); - return count; - } - - /// - /// 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 GetEnumerator(); - } - - private bool LineContainsMultibyteChar(int index) - { - PerLine perLine = this.perLineData[index]; - if (perLine.ContainsMultibyte == ContainsMultibyte.Unkown) + /// + /// Gets the number of CHARACTERS int a BYTE range. + /// + private int GetCharCount(int pos, int length) { - perLine.ContainsMultibyte = - (this.scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(index)).ToInt32() == CharLineLength(index)) - ? ContainsMultibyte.No - : ContainsMultibyte.Yes; - - this.perLineData[index] = perLine; + IntPtr ptr = this.scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, new IntPtr(pos), new IntPtr(length)); + return GetCharCount(ptr, length, this.scintilla.Encoding); } - return perLine.ContainsMultibyte == ContainsMultibyte.Yes; - } + /// + /// Gets the number of CHARACTERS in a BYTE range. + /// + private static unsafe int GetCharCount(IntPtr text, int length, Encoding encoding) + { + if (text == IntPtr.Zero || length == 0) + return 0; - /// - /// Returns the line index containing the CHARACTER position. - /// - internal int LineFromCharPosition(int pos) - { - Debug.Assert(pos >= 0); + // Never use SCI_COUNTCHARACTERS. It counts CRLF as 1 char! + int count = encoding.GetCharCount((byte*)text, length); + return count; + } - // Iterative binary search - // http://en.wikipedia.org/wiki/Binary_search_algorithm - // System.Collections.Generic.ArraySortHelper.InternalBinarySearch + /// + /// 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]; - int low = 0; - int high = Count - 1; + yield break; + } - while (low <= high) + IEnumerator IEnumerable.GetEnumerator() { - int mid = low + (high - low) / 2; - int start = CharPositionFromLine(mid); - - if (pos == start) - return mid; - else if (start < pos) - low = mid + 1; - else - high = mid - 1; + return GetEnumerator(); } - // After while exit, 'low' will point to the index where 'pos' should be - // inserted (if we were creating a new line start). The line containing - // 'pos' then would be 'low - 1'. - return low - 1; - } + private bool LineContainsMultibyteChar(int index) + { + PerLine perLine = this.perLineData[index]; + if (perLine.ContainsMultibyte == ContainsMultibyte.Unkown) + { + perLine.ContainsMultibyte = + (this.scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(index)).ToInt32() == CharLineLength(index)) + ? ContainsMultibyte.No + : ContainsMultibyte.Yes; - /// - /// Tracks a new line with the given CHARACTER length. - /// - private void InsertPerLine(int index, int length = 0) - { - MoveStep(index); + this.perLineData[index] = perLine; + } - PerLine data; - int lineStart = 0; + return perLine.ContainsMultibyte == ContainsMultibyte.Yes; + } - // Add the new line length to the existing line start - data = this.perLineData[index]; - lineStart = data.Start; - data.Start += length; - this.perLineData[index] = data; + /// + /// Returns the line index containing the CHARACTER position. + /// + internal int LineFromCharPosition(int pos) + { + Debug.Assert(pos >= 0); - // Insert the new line - data = new PerLine { Start = lineStart }; - this.perLineData.Insert(index, data); + // Iterative binary search + // http://en.wikipedia.org/wiki/Binary_search_algorithm + // System.Collections.Generic.ArraySortHelper.InternalBinarySearch - // Move the step - this.stepLength += length; - this.stepLine++; - } + int low = 0; + int high = Count - 1; - private void MoveStep(int line) - { - if (this.stepLength == 0) - { - this.stepLine = line; - } - else if (this.stepLine < line) - { - PerLine data; - while (this.stepLine < line) + while (low <= high) { - this.stepLine++; - data = this.perLineData[this.stepLine]; - data.Start += this.stepLength; - this.perLineData[this.stepLine] = data; + int mid = low + (high - low) / 2; + int start = CharPositionFromLine(mid); + + if (pos == start) + return mid; + else if (start < pos) + low = mid + 1; + else + high = mid - 1; } + + // After while exit, 'low' will point to the index where 'pos' should be + // inserted (if we were creating a new line start). The line containing + // 'pos' then would be 'low - 1'. + return low - 1; } - else if (this.stepLine > line) + + /// + /// Tracks a new line with the given CHARACTER length. + /// + private void InsertPerLine(int index, int length = 0) { + MoveStep(index); + PerLine data; - while (this.stepLine > line) - { - data = this.perLineData[this.stepLine]; - data.Start -= this.stepLength; - this.perLineData[this.stepLine] = data; - this.stepLine--; - } - } - } + int lineStart = 0; - internal void RebuildLineData() - { - this.stepLine = 0; - this.stepLength = 0; - - this.perLineData = - [ - new PerLine { Start = 0 }, - new PerLine { Start = 0 }, // Terminal - ]; - - // Fake an insert notification - var scn = new NativeMethods.SCNotification(); - int adjustedLines = this.scintilla.DirectMessage(NativeMethods.SCI_GETLINECOUNT).ToInt32() - 1; - scn.linesAdded = new IntPtr(adjustedLines); - scn.position = IntPtr.Zero; - scn.length = this.scintilla.DirectMessage(NativeMethods.SCI_GETLENGTH); - scn.text = this.scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, scn.position, scn.length); - TrackInsertText(scn); - } + // Add the new line length to the existing line start + data = this.perLineData[index]; + lineStart = data.Start; + data.Start += length; + this.perLineData[index] = data; - private void scintilla_SCNotification(object sender, SCNotificationEventArgs e) - { - NativeMethods.SCNotification scn = e.SCNotification; - switch (scn.nmhdr.code) - { - case NativeMethods.SCN_MODIFIED: - ScnModified(scn); - break; + // Insert the new line + data = new PerLine { Start = lineStart }; + this.perLineData.Insert(index, data); + + // Move the step + this.stepLength += length; + this.stepLine++; } - } - private void ScnModified(NativeMethods.SCNotification scn) - { - if ((scn.modificationType & NativeMethods.SC_MOD_DELETETEXT) > 0) + private void MoveStep(int line) { - TrackDeleteText(scn); + if (this.stepLength == 0) + { + this.stepLine = line; + } + else if (this.stepLine < line) + { + PerLine data; + while (this.stepLine < line) + { + this.stepLine++; + data = this.perLineData[this.stepLine]; + data.Start += this.stepLength; + this.perLineData[this.stepLine] = data; + } + } + else if (this.stepLine > line) + { + PerLine data; + while (this.stepLine > line) + { + data = this.perLineData[this.stepLine]; + data.Start -= this.stepLength; + this.perLineData[this.stepLine] = data; + this.stepLine--; + } + } } - if ((scn.modificationType & NativeMethods.SC_MOD_INSERTTEXT) > 0) + internal void RebuildLineData() { + this.stepLine = 0; + this.stepLength = 0; + + this.perLineData = new GapBuffer() { + new PerLine { Start = 0 }, + new PerLine { Start = 0 }, // Terminal + }; + + // Fake an insert notification + var scn = new NativeMethods.SCNotification(); + int adjustedLines = this.scintilla.DirectMessage(NativeMethods.SCI_GETLINECOUNT).ToInt32() - 1; + scn.linesAdded = new IntPtr(adjustedLines); + scn.position = IntPtr.Zero; + scn.length = this.scintilla.DirectMessage(NativeMethods.SCI_GETLENGTH); + scn.text = this.scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, scn.position, scn.length); TrackInsertText(scn); } - } - private void TrackDeleteText(NativeMethods.SCNotification scn) - { - int startLine = this.scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, scn.position).ToInt32(); - if (scn.linesAdded == IntPtr.Zero) + private void scintilla_SCNotification(object sender, SCNotificationEventArgs e) { - // That was easy - int delta = GetCharCount(scn.text, scn.length.ToInt32(), this.scintilla.Encoding); - AdjustLineLength(startLine, delta * -1); + NativeMethods.SCNotification scn = e.SCNotification; + switch (scn.nmhdr.code) + { + case NativeMethods.SCN_MODIFIED: + ScnModified(scn); + break; + } } - else + + private void ScnModified(NativeMethods.SCNotification scn) { - // Adjust the existing line - int lineByteStart = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(startLine)).ToInt32(); - int lineByteLength = this.scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(startLine)).ToInt32(); - AdjustLineLength(startLine, GetCharCount(lineByteStart, lineByteLength) - CharLineLength(startLine)); + if ((scn.modificationType & NativeMethods.SC_MOD_DELETETEXT) > 0) + { + TrackDeleteText(scn); + } - int linesRemoved = scn.linesAdded.ToInt32() * -1; - for (int i = 0; i < linesRemoved; i++) + if ((scn.modificationType & NativeMethods.SC_MOD_INSERTTEXT) > 0) { - // Deleted line - DeletePerLine(startLine + 1); + TrackInsertText(scn); } } - } - private void TrackInsertText(NativeMethods.SCNotification scn) - { - int startLine = this.scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, scn.position).ToInt32(); - if (scn.linesAdded == IntPtr.Zero) + private void TrackDeleteText(NativeMethods.SCNotification scn) { - // That was easy - int delta = GetCharCount(scn.position.ToInt32(), scn.length.ToInt32()); - AdjustLineLength(startLine, delta); + int startLine = this.scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, scn.position).ToInt32(); + if (scn.linesAdded == IntPtr.Zero) + { + // That was easy + int delta = GetCharCount(scn.text, scn.length.ToInt32(), this.scintilla.Encoding); + AdjustLineLength(startLine, delta * -1); + } + else + { + // Adjust the existing line + int lineByteStart = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(startLine)).ToInt32(); + int lineByteLength = this.scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(startLine)).ToInt32(); + AdjustLineLength(startLine, GetCharCount(lineByteStart, lineByteLength) - CharLineLength(startLine)); + + int linesRemoved = scn.linesAdded.ToInt32() * -1; + for (int i = 0; i < linesRemoved; i++) + { + // Deleted line + DeletePerLine(startLine + 1); + } + } } - else - { - int lineByteStart = 0; - int lineByteLength = 0; - - // Adjust existing line - lineByteStart = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(startLine)).ToInt32(); - lineByteLength = this.scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(startLine)).ToInt32(); - AdjustLineLength(startLine, GetCharCount(lineByteStart, lineByteLength) - CharLineLength(startLine)); - for (int i = 1; i <= scn.linesAdded.ToInt32(); i++) + private void TrackInsertText(NativeMethods.SCNotification scn) + { + int startLine = this.scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, scn.position).ToInt32(); + if (scn.linesAdded == IntPtr.Zero) { - int line = startLine + i; - - // Insert new line - lineByteStart += lineByteLength; - lineByteLength = this.scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(line)).ToInt32(); - InsertPerLine(line, GetCharCount(lineByteStart, lineByteLength)); + // That was easy + int delta = GetCharCount(scn.position.ToInt32(), scn.length.ToInt32()); + AdjustLineLength(startLine, delta); + } + else + { + int lineByteStart = 0; + int lineByteLength = 0; + + // Adjust existing line + lineByteStart = this.scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(startLine)).ToInt32(); + lineByteLength = this.scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(startLine)).ToInt32(); + AdjustLineLength(startLine, GetCharCount(lineByteStart, lineByteLength) - CharLineLength(startLine)); + + for (int i = 1; i <= scn.linesAdded.ToInt32(); i++) + { + int line = startLine + i; + + // Insert new line + lineByteStart += lineByteLength; + lineByteLength = this.scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(line)).ToInt32(); + InsertPerLine(line, GetCharCount(lineByteStart, lineByteLength)); + } } } - } - #endregion Methods + #endregion Methods - #region Properties + #region Properties - /// - /// Gets a value indicating whether all the document lines are visible (not hidden). - /// - /// true if all the lines are visible; otherwise, false. - public bool AllLinesVisible - { - get + /// + /// Gets a value indicating whether all the document lines are visible (not hidden). + /// + /// true if all the lines are visible; otherwise, false. + public bool AllLinesVisible { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETALLLINESVISIBLE) != IntPtr.Zero; + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETALLLINESVISIBLE) != IntPtr.Zero; + } } - } - /// - /// Gets the number of lines. - /// - /// The number of lines in the . - public int Count - { - get + /// + /// Gets the number of lines. + /// + /// The number of lines in the . + public int Count { - // Subtract the terminal line - return this.perLineData.Count - 1; + get + { + // Subtract the terminal line + return this.perLineData.Count - 1; + } } - } - /// - /// Gets the number of CHARACTERS in the document. - /// - internal int TextLength - { - get + /// + /// Gets the number of CHARACTERS in the document. + /// + internal int TextLength { - // Where the terminal line begins - return CharPositionFromLine(this.perLineData.Count - 1); + get + { + // Where the terminal line begins + return CharPositionFromLine(this.perLineData.Count - 1); + } } - } - /// - /// Gets the at the specified zero-based index. - /// - /// The zero-based index of the to get. - /// The at the specified index. - public Line this[int index] - { - get + /// + /// Gets the at the specified zero-based index. + /// + /// The zero-based index of the to get. + /// The at the specified index. + public Line this[int index] { - index = Helpers.Clamp(index, 0, Count - 1); - return new Line(this.scintilla, index); + get + { + index = Helpers.Clamp(index, 0, Count - 1); + return new Line(this.scintilla, index); + } } - } - #endregion Properties + #endregion Properties - #region Constructors + #region Constructors - /// - /// Initializes a new instance of the class. - /// - /// The control that created this collection. - public LineCollection(Scintilla scintilla) - { - this.scintilla = scintilla; - this.scintilla.SCNotification += scintilla_SCNotification; - - this.perLineData = - [ - new PerLine { Start = 0 }, - new PerLine { Start = 0 }, // Terminal - ]; - } + /// + /// Initializes a new instance of the class. + /// + /// The control that created this collection. + public LineCollection(Scintilla scintilla) + { + this.scintilla = scintilla; + this.scintilla.SCNotification += scintilla_SCNotification; - #endregion Constructors + this.perLineData = new GapBuffer() { + new PerLine { Start = 0 }, + new PerLine { Start = 0 }, // Terminal + }; + } - #region Types + #endregion Constructors - /// - /// Stuff we track for each line. - /// - private struct PerLine - { - /// - /// The CHARACTER position where the line begins. - /// - public int Start; + #region Types /// - /// 1 if the line contains multibyte (Unicode) characters; -1 if not; 0 if undetermined. + /// Stuff we track for each line. /// - /// Using an enum instead of Nullable because it uses less memory per line... - public ContainsMultibyte ContainsMultibyte; - } + private struct PerLine + { + /// + /// The CHARACTER position where the line begins. + /// + public int Start; + + /// + /// 1 if the line contains multibyte (Unicode) characters; -1 if not; 0 if undetermined. + /// + /// Using an enum instead of Nullable because it uses less memory per line... + public ContainsMultibyte ContainsMultibyte; + } - private enum ContainsMultibyte - { - No = -1, - Unkown, - Yes - } + private enum ContainsMultibyte + { + No = -1, + Unkown, + Yes + } - #endregion Types + #endregion Types + } } diff --git a/Scintilla.NET/LineEndType.cs b/Scintilla.NET/LineEndType.cs index 46b1e09..6fb97d9 100644 --- a/Scintilla.NET/LineEndType.cs +++ b/Scintilla.NET/LineEndType.cs @@ -1,23 +1,24 @@ using System; -namespace ScintillaNET; - -/// -/// Line endings types supported by lexers and allowed by a control. -/// -/// -/// -/// -[Flags] -public enum LineEndType +namespace ScintillaNET { /// - /// ASCII line endings. Carriage Return, Line Feed pair "\r\n" (0x0D0A); Carriage Return '\r' (0x0D); Line Feed '\n' (0x0A). + /// Line endings types supported by lexers and allowed by a control. /// - Default = NativeMethods.SC_LINE_END_TYPE_DEFAULT, + /// + /// + /// + [Flags] + public enum LineEndType + { + /// + /// ASCII line endings. Carriage Return, Line Feed pair "\r\n" (0x0D0A); Carriage Return '\r' (0x0D); Line Feed '\n' (0x0A). + /// + Default = NativeMethods.SC_LINE_END_TYPE_DEFAULT, - /// - /// Unicode line endings. Next Line (0x0085); Line Separator (0x2028); Paragraph Separator (0x2029). - /// - Unicode = NativeMethods.SC_LINE_END_TYPE_UNICODE + /// + /// Unicode line endings. Next Line (0x0085); Line Separator (0x2028); Paragraph Separator (0x2029). + /// + Unicode = NativeMethods.SC_LINE_END_TYPE_UNICODE + } } diff --git a/Scintilla.NET/ListCompletionMethod.cs b/Scintilla.NET/ListCompletionMethod.cs index 05e29d1..50122b9 100644 --- a/Scintilla.NET/ListCompletionMethod.cs +++ b/Scintilla.NET/ListCompletionMethod.cs @@ -1,33 +1,34 @@ -namespace ScintillaNET; - -/// -/// Indicates how an autocompletion occurred. -/// -public enum ListCompletionMethod +namespace ScintillaNET { /// - /// A fillup character (see ) triggered the completion. - /// The character used is indicated by the property. + /// Indicates how an autocompletion occurred. /// - FillUp = NativeMethods.SC_AC_FILLUP, + public enum ListCompletionMethod + { + /// + /// A fillup character (see ) triggered the completion. + /// The character used is indicated by the property. + /// + FillUp = NativeMethods.SC_AC_FILLUP, - /// - /// A double-click triggered the completion. - /// - DoubleClick = NativeMethods.SC_AC_DOUBLECLICK, + /// + /// A double-click triggered the completion. + /// + DoubleClick = NativeMethods.SC_AC_DOUBLECLICK, - /// - /// A tab key or the command triggered the completion. - /// - Tab = NativeMethods.SC_AC_TAB, + /// + /// A tab key or the command triggered the completion. + /// + Tab = NativeMethods.SC_AC_TAB, - /// - /// A new line or command triggered the completion. - /// - NewLine = NativeMethods.SC_AC_NEWLINE, + /// + /// A new line or command triggered the completion. + /// + NewLine = NativeMethods.SC_AC_NEWLINE, - /// - /// The method triggered the completion. - /// - Command = NativeMethods.SC_AC_COMMAND + /// + /// The method triggered the completion. + /// + Command = NativeMethods.SC_AC_COMMAND + } } diff --git a/Scintilla.NET/Loader.cs b/Scintilla.NET/Loader.cs index 90fc7e7..df30635 100644 --- a/Scintilla.NET/Loader.cs +++ b/Scintilla.NET/Loader.cs @@ -2,66 +2,67 @@ using System.Runtime.InteropServices; using System.Text; -namespace ScintillaNET; - -internal sealed class Loader : ILoader +namespace ScintillaNET { - private readonly IntPtr self; - private readonly NativeMethods.ILoaderVTable32 loader32; - private readonly NativeMethods.ILoaderVTable64 loader64; - private readonly Encoding encoding; - - public unsafe bool AddData(char[] data, int length) + internal sealed class Loader : ILoader { - if (data != null) + private readonly IntPtr self; + private readonly NativeMethods.ILoaderVTable32 loader32; + private readonly NativeMethods.ILoaderVTable64 loader64; + private readonly Encoding encoding; + + public unsafe bool AddData(char[] data, int length) { - length = Helpers.Clamp(length, 0, data.Length); - byte[] bytes = Helpers.GetBytes(data, length, this.encoding, zeroTerminated: false); - fixed (byte* bp = bytes) + if (data != null) { - int status = IntPtr.Size == 4 ? this.loader32.AddData(this.self, bp, bytes.Length) : this.loader64.AddData(this.self, bp, bytes.Length); - if (status != NativeMethods.SC_STATUS_OK) - return false; + length = Helpers.Clamp(length, 0, data.Length); + byte[] bytes = Helpers.GetBytes(data, length, this.encoding, zeroTerminated: false); + fixed (byte* bp = bytes) + { + int status = IntPtr.Size == 4 ? this.loader32.AddData(this.self, bp, bytes.Length) : this.loader64.AddData(this.self, bp, bytes.Length); + if (status != NativeMethods.SC_STATUS_OK) + return false; + } } - } - return true; - } + return true; + } - public Document ConvertToDocument() - { - IntPtr ptr = IntPtr.Size == 4 ? this.loader32.ConvertToDocument(this.self) : this.loader64.ConvertToDocument(this.self); - var document = new Document { Value = ptr }; - return document; - } + public Document ConvertToDocument() + { + IntPtr ptr = IntPtr.Size == 4 ? this.loader32.ConvertToDocument(this.self) : this.loader64.ConvertToDocument(this.self); + var document = new Document { Value = ptr }; + return document; + } - public int Release() - { - int count = IntPtr.Size == 4 ? this.loader32.Release(this.self) : this.loader64.Release(this.self); - return count; - } + public int Release() + { + int count = IntPtr.Size == 4 ? this.loader32.Release(this.self) : this.loader64.Release(this.self); + return count; + } - public unsafe Loader(IntPtr ptr, Encoding encoding) - { - this.self = ptr; - this.encoding = encoding; + public unsafe Loader(IntPtr ptr, Encoding encoding) + { + this.self = ptr; + this.encoding = encoding; - // http://stackoverflow.com/a/985820/2073621 - // http://stackoverflow.com/a/2094715/2073621 - // http://en.wikipedia.org/wiki/Virtual_method_table - // http://www.openrce.org/articles/full_view/23 - // Because I know that I'm not going to remember all this... In C++, the first - // variable of an object is a pointer (v[f]ptr) to the virtual table (v[f]table) - // containing the addresses of each function. The first call below gets the vtable - // address by following the object ptr to the vptr to the vtable. The second call - // casts the vtable to a structure with the same memory layout so we can easily - // invoke each function without having to do any pointer arithmetic. Depending on the - // architecture, the function calling conventions can be different. + // http://stackoverflow.com/a/985820/2073621 + // http://stackoverflow.com/a/2094715/2073621 + // http://en.wikipedia.org/wiki/Virtual_method_table + // http://www.openrce.org/articles/full_view/23 + // Because I know that I'm not going to remember all this... In C++, the first + // variable of an object is a pointer (v[f]ptr) to the virtual table (v[f]table) + // containing the addresses of each function. The first call below gets the vtable + // address by following the object ptr to the vptr to the vtable. The second call + // casts the vtable to a structure with the same memory layout so we can easily + // invoke each function without having to do any pointer arithmetic. Depending on the + // architecture, the function calling conventions can be different. - IntPtr vfptr = *(IntPtr*)ptr; - if (IntPtr.Size == 4) - this.loader32 = (NativeMethods.ILoaderVTable32)Marshal.PtrToStructure(vfptr, typeof(NativeMethods.ILoaderVTable32)); - else - this.loader64 = (NativeMethods.ILoaderVTable64)Marshal.PtrToStructure(vfptr, typeof(NativeMethods.ILoaderVTable64)); + IntPtr vfptr = *(IntPtr*)ptr; + if (IntPtr.Size == 4) + this.loader32 = (NativeMethods.ILoaderVTable32)Marshal.PtrToStructure(vfptr, typeof(NativeMethods.ILoaderVTable32)); + else + this.loader64 = (NativeMethods.ILoaderVTable64)Marshal.PtrToStructure(vfptr, typeof(NativeMethods.ILoaderVTable64)); + } } } diff --git a/Scintilla.NET/Margin.cs b/Scintilla.NET/Margin.cs index 1e591f9..40acb45 100644 --- a/Scintilla.NET/Margin.cs +++ b/Scintilla.NET/Margin.cs @@ -1,157 +1,158 @@ using System; using System.Drawing; -namespace ScintillaNET; - -/// -/// Represents a margin displayed on the left edge of a control. -/// -public class Margin +namespace ScintillaNET { - #region Fields - - private readonly Scintilla scintilla; - - #endregion Fields - - #region Properties - /// - /// Gets or sets the background color of the margin when the property is set to . + /// Represents a margin displayed on the left edge of a control. /// - /// A Color object representing the margin background color. The default is Black. - /// Alpha color values are ignored. - public Color BackColor + public class Margin { - get - { - int color = this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINBACKN, new IntPtr(Index)).ToInt32(); - return HelperMethods.FromWin32ColorOpaque(color); - } - set - { - if (value.IsEmpty) - value = Color.Black; + #region Fields - int color = HelperMethods.ToWin32ColorOpaque(value); - this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINBACKN, new IntPtr(Index), new IntPtr(color)); - } - } + 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)this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINCURSORN, new IntPtr(Index)); - } - set - { - int cursor = (int)value; - this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINCURSORN, new IntPtr(Index), new IntPtr(cursor)); - } - } + #endregion Fields - /// - /// Gets the zero-based margin index this object represents. - /// - /// The margin index within the . - public int Index { get; private set; } + #region Properties - /// - /// 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 this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINSENSITIVEN, new IntPtr(Index)) != IntPtr.Zero; - } - set + /// + /// Gets or sets the background color of the margin when the property is set to . + /// + /// A Color object representing the margin background color. The default is Black. + /// Alpha color values are ignored. + public Color BackColor { - IntPtr sensitive = value ? new IntPtr(1) : IntPtr.Zero; - this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINSENSITIVEN, new IntPtr(Index), sensitive); + get + { + int color = this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINBACKN, new IntPtr(Index)).ToInt32(); + return HelperMethods.FromWin32ColorOpaque(color); + } + set + { + if (value.IsEmpty) + value = Color.Black; + + int color = HelperMethods.ToWin32ColorOpaque(value); + this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINBACKN, new IntPtr(Index), new IntPtr(color)); + } } - } - /// - /// Gets or sets the margin type. - /// - /// One of the enumeration values. The default is . - public MarginType Type - { - get - { - return (MarginType)this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINTYPEN, new IntPtr(Index)); - } - set + /// + /// Gets or sets the mouse cursor style when over the margin. + /// + /// One of the enumeration values. The default is . + public MarginCursor Cursor { - int type = (int)value; - this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINTYPEN, new IntPtr(Index), new IntPtr(type)); + get + { + return (MarginCursor)this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINCURSORN, new IntPtr(Index)); + } + set + { + int cursor = (int)value; + this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINCURSORN, new IntPtr(Index), new IntPtr(cursor)); + } } - } - /// - /// 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 + /// + /// 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 { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINWIDTHN, new IntPtr(Index)).ToInt32(); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINSENSITIVEN, new IntPtr(Index)) != IntPtr.Zero; + } + set + { + IntPtr sensitive = value ? new IntPtr(1) : IntPtr.Zero; + this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINSENSITIVEN, new IntPtr(Index), sensitive); + } } - set + + /// + /// Gets or sets the margin type. + /// + /// One of the enumeration values. The default is . + public MarginType Type { - value = Helpers.ClampMin(value, 0); - this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINWIDTHN, new IntPtr(Index), new IntPtr(value)); + get + { + return (MarginType)this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINTYPEN, new IntPtr(Index)); + } + set + { + int type = (int)value; + this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINTYPEN, new IntPtr(Index), new IntPtr(type)); + } } - } - /// - /// 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 + /// + /// 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 { - return unchecked((uint)this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINMASKN, new IntPtr(Index)).ToInt32()); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINWIDTHN, new IntPtr(Index)).ToInt32(); + } + set + { + value = Helpers.ClampMin(value, 0); + this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINWIDTHN, new IntPtr(Index), new IntPtr(value)); + } } - set + + /// + /// 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 { - int mask = unchecked((int)value); - this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINMASKN, new IntPtr(Index), new IntPtr(mask)); + get + { + return unchecked((uint)this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINMASKN, new IntPtr(Index)).ToInt32()); + } + set + { + int mask = unchecked((int)value); + this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINMASKN, new IntPtr(Index), new IntPtr(mask)); + } } - } - #endregion Properties + #endregion Properties - #region Constructors + #region Constructors - /// - /// 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; - } + /// + /// 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; + } - #endregion Constructors + #endregion Constructors + } } diff --git a/Scintilla.NET/MarginClickEventArgs.cs b/Scintilla.NET/MarginClickEventArgs.cs index f05c2f9..a7285f8 100644 --- a/Scintilla.NET/MarginClickEventArgs.cs +++ b/Scintilla.NET/MarginClickEventArgs.cs @@ -1,55 +1,56 @@ using System; using System.Windows.Forms; -namespace ScintillaNET; - -/// -/// Provides data for the event. -/// -public class MarginClickEventArgs : EventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - private readonly int bytePosition; - private int? position; - /// - /// Gets the margin clicked. + /// Provides data for the event. /// - /// The zero-based index of the clicked margin. - public int Margin { get; private set; } + public class MarginClickEventArgs : EventArgs + { + private readonly Scintilla scintilla; + private readonly int bytePosition; + private int? position; - /// - /// 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 margin clicked. + /// + /// The zero-based index of the clicked margin. + public int Margin { 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 + /// + /// 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 { - this.position ??= this.scintilla.Lines.ByteToCharPosition(this.bytePosition); + get + { + this.position = this.position ?? this.scintilla.Lines.ByteToCharPosition(this.bytePosition); - return (int)this.position; + return (int)this.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; + /// + /// 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/Scintilla.NET/MarginCollection.cs b/Scintilla.NET/MarginCollection.cs index a7cfbf3..afd0d0d 100644 --- a/Scintilla.NET/MarginCollection.cs +++ b/Scintilla.NET/MarginCollection.cs @@ -3,163 +3,164 @@ using System.Collections.Generic; using System.ComponentModel; -namespace ScintillaNET; - -/// -/// An immutable collection of margins in a control. -/// -public class MarginCollection : IEnumerable +namespace ScintillaNET { - private readonly Scintilla scintilla; - - /// - /// Removes all text displayed in every and margins. - /// - public void ClearAllText() - { - this.scintilla.DirectMessage(NativeMethods.SCI_MARGINTEXTCLEARALL); - } - /// - /// Provides an enumerator that iterates through the collection. + /// An immutable collection of margins in a control. /// - /// 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() + public class MarginCollection : IEnumerable { - return GetEnumerator(); - } + private readonly Scintilla scintilla; - /// - /// Gets or sets the number of margins in the . - /// - /// The number of margins in the collection. The default is 5. - [DefaultValue(NativeMethods.SC_MAX_MARGIN + 1)] - [Description("The maximum number of margins.")] - public int Capacity - { - get + /// + /// Removes all text displayed in every and margins. + /// + public void ClearAllText() { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINS).ToInt32(); + this.scintilla.DirectMessage(NativeMethods.SCI_MARGINTEXTCLEARALL); } - set + + /// + /// Provides an enumerator that iterates through the collection. + /// + /// An object that contains all objects within the . + public IEnumerator GetEnumerator() { - value = Helpers.ClampMin(value, 0); - this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINS, new IntPtr(value)); + int count = Count; + for (int i = 0; i < count; i++) + yield return this[i]; + + yield break; } - } - /// - /// Gets the number of margins in the . - /// - /// The number of margins in the collection. - /// This property is kept for convenience. The return value will always be equal to . - /// - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int Count - { - get + IEnumerator IEnumerable.GetEnumerator() { - return Capacity; + return GetEnumerator(); } - } - /// - /// 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 + /// + /// Gets or sets the number of margins in the . + /// + /// The number of margins in the collection. The default is 5. + [DefaultValue(NativeMethods.SC_MAX_MARGIN + 1)] + [Description("The maximum number of margins.")] + public int Capacity { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINLEFT).ToInt32(); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINS).ToInt32(); + } + set + { + value = Helpers.ClampMin(value, 0); + this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINS, new IntPtr(value)); + } } - set + + /// + /// Gets the number of margins in the . + /// + /// The number of margins in the collection. + /// This property is kept for convenience. The return value will always be equal to . + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public int Count { - value = Helpers.ClampMin(value, 0); - this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINLEFT, IntPtr.Zero, new IntPtr(value)); + get + { + return Capacity; + } } - } - // TODO Why is this commented out? - /* - /// - /// 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 + /// + /// 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 { - return (MarginOptions)scintilla.DirectMessage(NativeMethods.SCI_GETMARGINOPTIONS); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINLEFT).ToInt32(); + } + set + { + value = Helpers.ClampMin(value, 0); + this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINLEFT, IntPtr.Zero, new IntPtr(value)); + } } - set + + // TODO Why is this commented out? + /* + /// + /// 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 { - var options = (int)value; - scintilla.DirectMessage(NativeMethods.SCI_SETMARGINOPTIONS, new IntPtr(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 + /// + /// 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 { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINRIGHT).ToInt32(); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETMARGINRIGHT).ToInt32(); + } + set + { + value = Helpers.ClampMin(value, 0); + this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINRIGHT, IntPtr.Zero, new IntPtr(value)); + } } - set + + /// + /// 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] { - value = Helpers.ClampMin(value, 0); - this.scintilla.DirectMessage(NativeMethods.SCI_SETMARGINRIGHT, IntPtr.Zero, new IntPtr(value)); + get + { + index = Helpers.Clamp(index, 0, Count - 1); + return new Margin(this.scintilla, index); + } } - } - /// - /// 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 + /// + /// Initializes a new instance of the class. + /// + /// The control that created this collection. + public MarginCollection(Scintilla scintilla) { - index = Helpers.Clamp(index, 0, Count - 1); - return new Margin(this.scintilla, index); + this.scintilla = scintilla; } } - - /// - /// Initializes a new instance of the class. - /// - /// The control that created this collection. - public MarginCollection(Scintilla scintilla) - { - this.scintilla = scintilla; - } } diff --git a/Scintilla.NET/MarginCursor.cs b/Scintilla.NET/MarginCursor.cs index 2e9f7ca..e85216c 100644 --- a/Scintilla.NET/MarginCursor.cs +++ b/Scintilla.NET/MarginCursor.cs @@ -1,17 +1,18 @@ -namespace ScintillaNET; - -/// -/// The display of a cursor when over a margin. -/// -public enum MarginCursor +namespace ScintillaNET { /// - /// A normal arrow. + /// The display of a cursor when over a margin. /// - Arrow = NativeMethods.SC_CURSORARROW, + public enum MarginCursor + { + /// + /// A normal arrow. + /// + Arrow = NativeMethods.SC_CURSORARROW, - /// - /// A reversed arrow. - /// - ReverseArrow = NativeMethods.SC_CURSORREVERSEARROW + /// + /// A reversed arrow. + /// + ReverseArrow = NativeMethods.SC_CURSORREVERSEARROW + } } diff --git a/Scintilla.NET/MarginOptions.cs b/Scintilla.NET/MarginOptions.cs index a36fd66..94c3b85 100644 --- a/Scintilla.NET/MarginOptions.cs +++ b/Scintilla.NET/MarginOptions.cs @@ -1,21 +1,22 @@ using System; -namespace ScintillaNET; - -/// -/// Flags used to define margin options. -/// -/// This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values. -[Flags] -public enum MarginOptions +namespace ScintillaNET { /// - /// No options. This is the default. + /// Flags used to define margin options. /// - None = NativeMethods.SC_MARGINOPTION_NONE, + /// This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values. + [Flags] + public enum MarginOptions + { + /// + /// No options. This is the default. + /// + None = NativeMethods.SC_MARGINOPTION_NONE, - /// - /// Lines selected by clicking on the margin will select only the subline of wrapped text. - /// - SublineSelect = NativeMethods.SC_MARGINOPTION_SUBLINESELECT + /// + /// Lines selected by clicking on the margin will select only the subline of wrapped text. + /// + SublineSelect = NativeMethods.SC_MARGINOPTION_SUBLINESELECT + } } diff --git a/Scintilla.NET/MarginType.cs b/Scintilla.NET/MarginType.cs index 7d10241..26466ee 100644 --- a/Scintilla.NET/MarginType.cs +++ b/Scintilla.NET/MarginType.cs @@ -1,42 +1,43 @@ -namespace ScintillaNET; - -/// -/// The behavior and appearance of a margin. -/// -public enum MarginType +namespace ScintillaNET { /// - /// Margin can display symbols. + /// The behavior and appearance of a margin. /// - Symbol = NativeMethods.SC_MARGIN_SYMBOL, + public enum MarginType + { + /// + /// Margin can display symbols. + /// + Symbol = NativeMethods.SC_MARGIN_SYMBOL, - /// - /// Margin displays line numbers. - /// - Number = NativeMethods.SC_MARGIN_NUMBER, + /// + /// Margin displays line numbers. + /// + Number = NativeMethods.SC_MARGIN_NUMBER, - /// - /// Margin can display symbols and has a background color equivalent to background color. - /// - BackColor = NativeMethods.SC_MARGIN_BACK, + /// + /// Margin can display symbols and has a background color equivalent to background color. + /// + BackColor = NativeMethods.SC_MARGIN_BACK, - /// - /// Margin can display symbols and has a background color equivalent to foreground color. - /// - ForeColor = NativeMethods.SC_MARGIN_FORE, + /// + /// Margin can display symbols and has a background color equivalent to foreground color. + /// + ForeColor = NativeMethods.SC_MARGIN_FORE, - /// - /// Margin can display application defined text. - /// - Text = NativeMethods.SC_MARGIN_TEXT, + /// + /// Margin can display application defined text. + /// + Text = NativeMethods.SC_MARGIN_TEXT, - /// - /// Margin can display application defined text right-justified. - /// - RightText = NativeMethods.SC_MARGIN_RTEXT, + /// + /// Margin can display application defined text right-justified. + /// + RightText = NativeMethods.SC_MARGIN_RTEXT, - /// - /// Margin can display symbols and has a background color specified using the property. - /// - Color = NativeMethods.SC_MARGIN_COLOUR + /// + /// Margin can display symbols and has a background color specified using the property. + /// + Color = NativeMethods.SC_MARGIN_COLOUR + } } diff --git a/Scintilla.NET/Marker.cs b/Scintilla.NET/Marker.cs index 2a7b0f3..d2443aa 100644 --- a/Scintilla.NET/Marker.cs +++ b/Scintilla.NET/Marker.cs @@ -1,184 +1,185 @@ using System; using System.Drawing; -namespace ScintillaNET; - -/// -/// Represents a margin marker in a control. -/// -public class Marker +namespace ScintillaNET { - 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 history indexes (21 through 24) where each bit cooresponds to a margin index. - /// - /// - public const uint MaskHistory = (1 << HistoryRevertedToOrigin) | (1 << HistorySaved) | (1 << HistoryModified) | (1 << HistoryRevertedToModified); - - /// - /// A change was made to this line and saved but then reverted to its original state. - /// - public const int HistoryRevertedToOrigin = NativeMethods.SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN; - - /// - /// This line was modified and saved. - /// - public const int HistorySaved = NativeMethods.SC_MARKNUM_HISTORY_SAVED; - - /// - /// This line was modified but not yet saved. - /// - public const int HistoryModified = NativeMethods.SC_MARKNUM_HISTORY_MODIFIED; - - /// - /// A change was made to this line and saved but then reverted but not to its original state. - /// - public const int HistoryRevertedToModified = NativeMethods.SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED; - - /// - /// 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. + /// Represents a margin marker in a control. /// - 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) + public class Marker { - if (image == null) - return; - - this.scintilla.DirectMessage(NativeMethods.SCI_RGBAIMAGESETWIDTH, new IntPtr(image.Width)); - this.scintilla.DirectMessage(NativeMethods.SCI_RGBAIMAGESETHEIGHT, new IntPtr(image.Height)); + 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 history indexes (21 through 24) where each bit cooresponds to a margin index. + /// + /// + public const uint MaskHistory = (1 << HistoryRevertedToOrigin) | (1 << HistorySaved) | (1 << HistoryModified) | (1 << HistoryRevertedToModified); + + /// + /// A change was made to this line and saved but then reverted to its original state. + /// + public const int HistoryRevertedToOrigin = NativeMethods.SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN; + + /// + /// This line was modified and saved. + /// + public const int HistorySaved = NativeMethods.SC_MARKNUM_HISTORY_SAVED; + + /// + /// This line was modified but not yet saved. + /// + public const int HistoryModified = NativeMethods.SC_MARKNUM_HISTORY_MODIFIED; + + /// + /// A change was made to this line and saved but then reverted but not to its original state. + /// + public const int HistoryRevertedToModified = NativeMethods.SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED; + + /// + /// 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; - byte[] bytes = Helpers.BitmapToArgb(image); - fixed (byte* bp = bytes) - this.scintilla.DirectMessage(NativeMethods.SCI_MARKERDEFINERGBAIMAGE, new IntPtr(Index), new IntPtr(bp)); - } + this.scintilla.DirectMessage(NativeMethods.SCI_RGBAIMAGESETWIDTH, new IntPtr(image.Width)); + this.scintilla.DirectMessage(NativeMethods.SCI_RGBAIMAGESETHEIGHT, new IntPtr(image.Height)); - /// - /// Removes this marker from all lines. - /// - public void DeleteAll() - { - this.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); - this.scintilla.DirectMessage(NativeMethods.SCI_MARKERSETALPHA, new IntPtr(Index), new IntPtr(alpha)); - } + byte[] bytes = Helpers.BitmapToArgb(image); + fixed (byte* bp = bytes) + this.scintilla.DirectMessage(NativeMethods.SCI_MARKERDEFINERGBAIMAGE, new IntPtr(Index), new IntPtr(bp)); + } - /// - /// 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) - { - int colour = HelperMethods.ToWin32Color(color); - this.scintilla.DirectMessage(NativeMethods.SCI_MARKERSETBACKTRANSLUCENT, new IntPtr(Index), new IntPtr(colour)); - } + /// + /// Removes this marker from all lines. + /// + public void DeleteAll() + { + this.scintilla.MarkerDeleteAll(Index); + } - /// - /// Sets the foreground color of the marker. - /// - /// The foreground Color. The default is Black. - public void SetForeColor(Color color) - { - int colour = HelperMethods.ToWin32Color(color); - this.scintilla.DirectMessage(NativeMethods.SCI_MARKERSETFORETRANSLUCENT, new IntPtr(Index), new IntPtr(colour)); - } + /// + /// 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); + this.scintilla.DirectMessage(NativeMethods.SCI_MARKERSETALPHA, new IntPtr(Index), new IntPtr(alpha)); + } - /// - /// Gets the zero-based marker index this object represents. - /// - /// The marker index within the . - public int Index { get; private set; } + /// + /// 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) + { + int colour = HelperMethods.ToWin32Color(color); + this.scintilla.DirectMessage(NativeMethods.SCI_MARKERSETBACKTRANSLUCENT, new IntPtr(Index), new IntPtr(colour)); + } - /// - /// Gets or sets the marker symbol. - /// - /// - /// One of the enumeration values. - /// The default is . - /// - public MarkerSymbol Symbol - { - get + /// + /// Sets the foreground color of the marker. + /// + /// The foreground Color. The default is Black. + public void SetForeColor(Color color) { - return (MarkerSymbol)this.scintilla.DirectMessage(NativeMethods.SCI_MARKERSYMBOLDEFINED, new IntPtr(Index)); + int colour = HelperMethods.ToWin32Color(color); + this.scintilla.DirectMessage(NativeMethods.SCI_MARKERSETFORETRANSLUCENT, new IntPtr(Index), new IntPtr(colour)); } - set + + /// + /// 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 { - int markerSymbol = (int)value; - this.scintilla.DirectMessage(NativeMethods.SCI_MARKERDEFINE, new IntPtr(Index), new IntPtr(markerSymbol)); + get + { + return (MarkerSymbol)this.scintilla.DirectMessage(NativeMethods.SCI_MARKERSYMBOLDEFINED, new IntPtr(Index)); + } + set + { + int markerSymbol = (int)value; + this.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; + /// + /// 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/Scintilla.NET/MarkerCollection.cs b/Scintilla.NET/MarkerCollection.cs index 145c866..4e74577 100644 --- a/Scintilla.NET/MarkerCollection.cs +++ b/Scintilla.NET/MarkerCollection.cs @@ -1,66 +1,67 @@ using System.Collections; using System.Collections.Generic; -namespace ScintillaNET; - -/// -/// An immutable collection of markers in a control. -/// -public class MarkerCollection : IEnumerable +namespace ScintillaNET { - private readonly Scintilla scintilla; - /// - /// Provides an enumerator that iterates through the collection. + /// An immutable collection of markers in a control. /// - /// An object for enumerating all objects within the . - public IEnumerator GetEnumerator() + public class MarkerCollection : IEnumerable { - int count = Count; - for (int i = 0; i < count; i++) - yield return this[i]; + private readonly Scintilla scintilla; - yield break; - } + /// + /// 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]; - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + yield break; + } - /// - /// Gets the number of markers in the . - /// - /// This property always returns 32. - public int Count - { - get + IEnumerator IEnumerable.GetEnumerator() { - return NativeMethods.MARKER_MAX + 1; + return GetEnumerator(); } - } - /// - /// 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 + /// + /// Gets the number of markers in the . + /// + /// This property always returns 32. + public int Count { - index = Helpers.Clamp(index, 0, Count - 1); - return new Marker(this.scintilla, index); + get + { + return NativeMethods.MARKER_MAX + 1; + } } - } - /// - /// Initializes a new instance of the class. - /// - /// The control that created this collection. - public MarkerCollection(Scintilla scintilla) - { - this.scintilla = scintilla; + /// + /// 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(this.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/Scintilla.NET/MarkerHandle.cs b/Scintilla.NET/MarkerHandle.cs index b0a9600..ce1190e 100644 --- a/Scintilla.NET/MarkerHandle.cs +++ b/Scintilla.NET/MarkerHandle.cs @@ -1,61 +1,62 @@ using System; -namespace ScintillaNET; - -/// -/// A handle. -/// -/// -/// This is an opaque type, meaning it can be used by a control but -/// otherwise has no public members of its own. -/// -public struct MarkerHandle +namespace ScintillaNET { - internal IntPtr Value; - - /// - /// A read-only field that represents an uninitialized handle. - /// - public static readonly MarkerHandle Zero; - /// - /// Returns a value indicating whether this instance is equal to a specified object. + /// A handle. /// - /// 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) + /// + /// This is an opaque type, meaning it can be used by a control but + /// otherwise has no public members of its own. + /// + public struct MarkerHandle { - return obj is IntPtr && this.Value == ((MarkerHandle)obj).Value; - } + internal IntPtr Value; - /// - /// Returns the hash code for this instance. - /// - /// A 32-bit signed integer hash code. - public override int GetHashCode() - { - return this.Value.GetHashCode(); - } + /// + /// A read-only field that represents an uninitialized handle. + /// + public static readonly MarkerHandle Zero; - /// - /// Determines whether two specified instances of are equal. - /// - /// The first handle to compare. - /// The second handle to compare. - /// true if equals ; otherwise, false. - public static bool operator ==(MarkerHandle a, MarkerHandle b) - { - return a.Value == b.Value; - } + /// + /// 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 && this.Value == ((MarkerHandle)obj).Value; + } - /// - /// Determines whether two specified instances of are not equal. - /// - /// The first handle to compare. - /// The second handle to compare. - /// true if does not equal ; otherwise, false. - public static bool operator !=(MarkerHandle a, MarkerHandle b) - { - return a.Value != b.Value; + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return this.Value.GetHashCode(); + } + + /// + /// Determines whether two specified instances of are equal. + /// + /// The first handle to compare. + /// The second handle to compare. + /// true if equals ; otherwise, false. + public static bool operator ==(MarkerHandle a, MarkerHandle b) + { + return a.Value == b.Value; + } + + /// + /// Determines whether two specified instances of are not equal. + /// + /// The first handle to compare. + /// The second handle to compare. + /// true if does not equal ; otherwise, false. + public static bool operator !=(MarkerHandle a, MarkerHandle b) + { + return a.Value != b.Value; + } } } diff --git a/Scintilla.NET/MarkerSymbol.cs b/Scintilla.NET/MarkerSymbol.cs index 34e5377..69ff94a 100644 --- a/Scintilla.NET/MarkerSymbol.cs +++ b/Scintilla.NET/MarkerSymbol.cs @@ -1,176 +1,177 @@ -namespace ScintillaNET; - -/// -/// The symbol displayed by a -/// -public enum MarkerSymbol +namespace ScintillaNET { /// - /// 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, - - /// - /// A bookmark. - /// - VerticalBookmark = NativeMethods.SC_MARK_VERTICALBOOKMARK, - - /// - /// A slim rectangular vertical bar. - /// - Bar = NativeMethods.SC_MARK_BAR, - - // Character = NativeMethods.SC_MARK_CHARACTER + /// 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, + + /// + /// A bookmark. + /// + VerticalBookmark = NativeMethods.SC_MARK_VERTICALBOOKMARK, + + /// + /// A slim rectangular vertical bar. + /// + Bar = NativeMethods.SC_MARK_BAR, + + // Character = NativeMethods.SC_MARK_CHARACTER + } } diff --git a/Scintilla.NET/ModificationEventArgs.cs b/Scintilla.NET/ModificationEventArgs.cs index c869489..e90e32c 100644 --- a/Scintilla.NET/ModificationEventArgs.cs +++ b/Scintilla.NET/ModificationEventArgs.cs @@ -1,54 +1,55 @@ using System; -namespace ScintillaNET; - -/// -/// Provides data for the and events. -/// -public class ModificationEventArgs : BeforeModificationEventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - private readonly int bytePosition; - private readonly int byteLength; - private readonly IntPtr textPtr; - /// - /// Gets the number of lines added or removed. + /// Provides data for the and events. /// - /// The number of lines added to the document when text is inserted, or the number of lines removed from the document when text is deleted. - /// When lines are deleted the return value will be negative. - public int LinesAdded { get; private set; } - - /// - /// Gets the text that was inserted or deleted. - /// - /// The text inserted or deleted from the document. - public override unsafe string Text + public class ModificationEventArgs : BeforeModificationEventArgs { - get + private readonly Scintilla scintilla; + private readonly int bytePosition; + private readonly int byteLength; + private readonly IntPtr textPtr; + + /// + /// Gets the number of lines added or removed. + /// + /// The number of lines added to the document when text is inserted, or the number of lines removed from the document when text is deleted. + /// When lines are deleted the return value will be negative. + public int LinesAdded { get; private set; } + + /// + /// Gets the text that was inserted or deleted. + /// + /// The text inserted or deleted from the document. + public override unsafe string Text { - CachedText ??= Helpers.GetString(this.textPtr, this.byteLength, this.scintilla.Encoding); + get + { + CachedText = CachedText ?? Helpers.GetString(this.textPtr, this.byteLength, this.scintilla.Encoding); - return CachedText; + return CachedText; + } } - } - /// - /// Initializes a new instance of the class. - /// - /// The control that generated this event. - /// The source of the modification. - /// The zero-based byte position within the document where text was modified. - /// The length in bytes of the inserted or deleted text. - /// >A pointer to the text inserted or deleted. - /// The number of lines added or removed (delta). - public ModificationEventArgs(Scintilla scintilla, ModificationSource source, int bytePosition, int byteLength, IntPtr text, int linesAdded) : base(scintilla, source, bytePosition, byteLength, text) - { - this.scintilla = scintilla; - this.bytePosition = bytePosition; - this.byteLength = byteLength; - this.textPtr = text; + /// + /// Initializes a new instance of the class. + /// + /// The control that generated this event. + /// The source of the modification. + /// The zero-based byte position within the document where text was modified. + /// The length in bytes of the inserted or deleted text. + /// >A pointer to the text inserted or deleted. + /// The number of lines added or removed (delta). + public ModificationEventArgs(Scintilla scintilla, ModificationSource source, int bytePosition, int byteLength, IntPtr text, int linesAdded) : base(scintilla, source, bytePosition, byteLength, text) + { + this.scintilla = scintilla; + this.bytePosition = bytePosition; + this.byteLength = byteLength; + this.textPtr = text; - LinesAdded = linesAdded; + LinesAdded = linesAdded; + } } } diff --git a/Scintilla.NET/ModificationSource.cs b/Scintilla.NET/ModificationSource.cs index 3c4a7b9..ff2d8de 100644 --- a/Scintilla.NET/ModificationSource.cs +++ b/Scintilla.NET/ModificationSource.cs @@ -1,22 +1,23 @@ -namespace ScintillaNET; - -/// -/// The source of a modification -/// -public enum ModificationSource +namespace ScintillaNET { /// - /// Modification is the result of a user operation. + /// The source of a modification /// - User = NativeMethods.SC_PERFORMED_USER, + public enum ModificationSource + { + /// + /// Modification is the result of a user operation. + /// + User = NativeMethods.SC_PERFORMED_USER, - /// - /// Modification is the result of an undo operation. - /// - Undo = NativeMethods.SC_PERFORMED_UNDO, + /// + /// Modification is the result of an undo operation. + /// + Undo = NativeMethods.SC_PERFORMED_UNDO, - /// - /// Modification is the result of a redo operation. - /// - Redo = NativeMethods.SC_PERFORMED_REDO + /// + /// Modification is the result of a redo operation. + /// + Redo = NativeMethods.SC_PERFORMED_REDO + } } diff --git a/Scintilla.NET/MultiPaste.cs b/Scintilla.NET/MultiPaste.cs index 3f84f7c..2ce2614 100644 --- a/Scintilla.NET/MultiPaste.cs +++ b/Scintilla.NET/MultiPaste.cs @@ -1,17 +1,18 @@ -namespace ScintillaNET; - -/// -/// Specifies the behavior of pasting into multiple selections. -/// -public enum MultiPaste +namespace ScintillaNET { /// - /// Pasting into multiple selections only pastes to the main selection. This is the default. + /// Specifies the behavior of pasting into multiple selections. /// - Once = NativeMethods.SC_MULTIPASTE_ONCE, + public enum MultiPaste + { + /// + /// Pasting into multiple selections only pastes to the main selection. This is the default. + /// + Once = NativeMethods.SC_MULTIPASTE_ONCE, - /// - /// Pasting into multiple selections pastes into each selection. - /// - Each = NativeMethods.SC_MULTIPASTE_EACH + /// + /// Pasting into multiple selections pastes into each selection. + /// + Each = NativeMethods.SC_MULTIPASTE_EACH + } } diff --git a/Scintilla.NET/NativeMemoryStream.cs b/Scintilla.NET/NativeMemoryStream.cs index 6061782..d374a3b 100644 --- a/Scintilla.NET/NativeMemoryStream.cs +++ b/Scintilla.NET/NativeMemoryStream.cs @@ -2,149 +2,150 @@ using System.IO; using System.Runtime.InteropServices; -namespace ScintillaNET; - -/// -/// Like an UnmanagedMemoryStream execpt it can grow. -/// -internal sealed unsafe class NativeMemoryStream : Stream +namespace ScintillaNET { - #region Fields + /// + /// Like an UnmanagedMemoryStream execpt it can grow. + /// + internal sealed unsafe class NativeMemoryStream : Stream + { + #region Fields - private int capacity; - private int position; - private int length; + private int capacity; + private int position; + private int length; - #endregion Fields + #endregion Fields - #region Methods + #region Methods - protected override void Dispose(bool disposing) - { - if (FreeOnDispose && Pointer != IntPtr.Zero) + protected override void Dispose(bool disposing) { - Marshal.FreeHGlobal(Pointer); - Pointer = IntPtr.Zero; - } + if (FreeOnDispose && Pointer != IntPtr.Zero) + { + Marshal.FreeHGlobal(Pointer); + Pointer = IntPtr.Zero; + } - base.Dispose(disposing); - } - - public override void Flush() - { - // NOP - } - - public override int Read(byte[] buffer, int offset, int count) - { - throw new NotImplementedException(); - } + base.Dispose(disposing); + } - public override long Seek(long offset, SeekOrigin origin) - { - switch (origin) + public override void Flush() { - case SeekOrigin.Begin: - this.position = (int)offset; - break; + // NOP + } - default: - throw new NotImplementedException(); + public override int Read(byte[] buffer, int offset, int count) + { + throw new NotImplementedException(); } - return this.position; - } + public override long Seek(long offset, SeekOrigin origin) + { + switch (origin) + { + case SeekOrigin.Begin: + this.position = (int)offset; + break; - public override void SetLength(long value) - { - throw new NotImplementedException(); - } + default: + throw new NotImplementedException(); + } - public override void Write(byte[] buffer, int offset, int count) - { - if (this.position + count > this.capacity) - { - // Realloc buffer - int minCapacity = this.position + count; - int newCapacity = this.capacity * 2; - if (newCapacity < minCapacity) - newCapacity = minCapacity; - - IntPtr newPtr = Marshal.AllocHGlobal(newCapacity); - NativeMethods.MoveMemory(newPtr, Pointer, this.length); - Marshal.FreeHGlobal(Pointer); - - Pointer = newPtr; - this.capacity = newCapacity; + return this.position; } - Marshal.Copy(buffer, offset, (IntPtr)((long)Pointer + this.position), count); - this.position += count; - this.length = Math.Max(this.length, this.position); - } + public override void SetLength(long value) + { + throw new NotImplementedException(); + } - #endregion Methods + public override void Write(byte[] buffer, int offset, int count) + { + if (this.position + count > this.capacity) + { + // Realloc buffer + int minCapacity = this.position + count; + int newCapacity = this.capacity * 2; + if (newCapacity < minCapacity) + newCapacity = minCapacity; + + IntPtr newPtr = Marshal.AllocHGlobal(newCapacity); + NativeMethods.MoveMemory(newPtr, Pointer, this.length); + Marshal.FreeHGlobal(Pointer); + + Pointer = newPtr; + this.capacity = newCapacity; + } + + Marshal.Copy(buffer, offset, (IntPtr)((long)Pointer + this.position), count); + this.position += count; + this.length = Math.Max(this.length, this.position); + } - #region Properties + #endregion Methods - public override bool CanRead - { - get { throw new NotImplementedException(); } - } + #region Properties - public override bool CanSeek - { - get + public override bool CanRead { - return true; + get { throw new NotImplementedException(); } } - } - public override bool CanWrite - { - get + public override bool CanSeek { - return true; + get + { + return true; + } } - } - public bool FreeOnDispose { get; set; } - - public override long Length - { - get + public override bool CanWrite { - return this.length; + get + { + return true; + } } - } - public IntPtr Pointer { get; private set; } + public bool FreeOnDispose { get; set; } - public override long Position - { - get + public override long Length { - return this.position; + get + { + return this.length; + } } - set + + public IntPtr Pointer { get; private set; } + + public override long Position { - throw new NotImplementedException(); + get + { + return this.position; + } + set + { + throw new NotImplementedException(); + } } - } - #endregion Properties + #endregion Properties - #region Constructors + #region Constructors - public NativeMemoryStream(int capacity) - { - if (capacity < 4) - capacity = 4; + public NativeMemoryStream(int capacity) + { + if (capacity < 4) + capacity = 4; - this.capacity = capacity; - Pointer = Marshal.AllocHGlobal(capacity); - FreeOnDispose = true; - } + this.capacity = capacity; + Pointer = Marshal.AllocHGlobal(capacity); + FreeOnDispose = true; + } - #endregion Constructors + #endregion Constructors + } } diff --git a/Scintilla.NET/NativeMethods.cs b/Scintilla.NET/NativeMethods.cs index 04dcc80..865ddb4 100644 --- a/Scintilla.NET/NativeMethods.cs +++ b/Scintilla.NET/NativeMethods.cs @@ -2,1228 +2,1228 @@ using System.Collections.Generic; using System.Runtime.InteropServices; -namespace ScintillaNET; - +namespace ScintillaNET +{ #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -public static class NativeMethods -{ - #region Constants - - private const string DLL_NAME_GDI32 = "gdi32.dll"; - private const string DLL_NAME_KERNEL32 = "kernel32.dll"; - private const string DLL_NAME_OLE32 = "ole32.dll"; - private const string DLL_NAME_USER32 = "user32.dll"; - - public const int INVALID_POSITION = -1; - - // Autocompletions - public const int SC_AC_FILLUP = 1; - public const int SC_AC_DOUBLECLICK = 2; - public const int SC_AC_TAB = 3; - public const int SC_AC_NEWLINE = 4; - public const int SC_AC_COMMAND = 5; - - // 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; - - // Clipboard formats - public const string CF_HTML = "HTML Format"; - - // Idle styling - public const int SC_IDLESTYLING_NONE = 0; - public const int SC_IDLESTYLING_TOVISIBLE = 1; - public const int SC_IDLESTYLING_AFTERVISIBLE = 2; - public const int SC_IDLESTYLING_ALL = 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 policy flags - public const int CARET_SLOP = 0x01; - public const int CARET_STRICT = 0x04; - public const int CARET_JUMPS = 0x10; - public const int CARET_EVEN = 0x08; - - // 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; - public const int EDGE_MULTILINE = 3; - - // Message-only window - public const int HWND_MESSAGE = -3; - - // Indicator styles - 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_POINT = 18; - public const int INDIC_POINTCHARACTER = 19; - public const int INDIC_GRADIENT = 20; - public const int INDIC_GRADIENTCENTRE = 21; - public const int INDIC_POINT_TOP = 22; - - [Obsolete("Use INDICATOR_CONTAINER instead.")] - public const int INDIC_CONTAINER = 8; - [Obsolete("Use INDICATOR_MAX instead.")] - public const int INDIC_MAX = 31; - - // Indicators - public const int INDICATOR_CONTAINER = 8; - public const int INDICATOR_IME = 32; - public const int INDICATOR_IME_MAX = 35; - public const int INDICATOR_HISTORY_REVERTED_TO_ORIGIN_INSERTION = 36; - public const int INDICATOR_HISTORY_REVERTED_TO_ORIGIN_DELETION = 37; - public const int INDICATOR_HISTORY_SAVED_INSERTION = 38; - public const int INDICATOR_HISTORY_SAVED_DELETION = 39; - public const int INDICATOR_HISTORY_MODIFIED_INSERTION = 40; - public const int INDICATOR_HISTORY_MODIFIED_DELETION = 41; - public const int INDICATOR_HISTORY_REVERTED_TO_MODIFIED_INSERTION = 42; - public const int INDICATOR_HISTORY_REVERTED_TO_MODIFIED_DELETION = 43; - public const int INDICATOR_MAX = 43; - - // Phases - public const int SC_PHASES_ONE = 0; - public const int SC_PHASES_TWO = 1; - public const int SC_PHASES_MULTIPLE = 2; - - // 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; - - // Font quality - public const int SC_EFF_QUALITY_DEFAULT = 0; - public const int SC_EFF_QUALITY_NON_ANTIALIASED = 1; - public const int SC_EFF_QUALITY_ANTIALIASED = 2; - public const int SC_EFF_QUALITY_LCD_OPTIMIZED = 3; - - // End-of-line - public const int SC_EOL_CRLF = 0; - public const int SC_EOL_CR = 1; - public const int SC_EOL_LF = 2; - - // Fold action - public const int SC_FOLDACTION_CONTRACT = 0; - public const int SC_FOLDACTION_EXPAND = 1; - public const int SC_FOLDACTION_TOGGLE = 2; - - // Fold level - public const int SC_FOLDLEVELBASE = 0x400; - public const int SC_FOLDLEVELWHITEFLAG = 0x1000; - public const int SC_FOLDLEVELHEADERFLAG = 0x2000; - public const int SC_FOLDLEVELNUMBERMASK = 0x0FFF; - - // Fold flags - public const int SC_FOLDFLAG_LINEBEFORE_EXPANDED = 0x0002; - public const int SC_FOLDFLAG_LINEBEFORE_CONTRACTED = 0x0004; - public const int SC_FOLDFLAG_LINEAFTER_EXPANDED = 0x0008; - public const int SC_FOLDFLAG_LINEAFTER_CONTRACTED = 0x0010; - public const int SC_FOLDFLAG_LEVELNUMBERS = 0x0040; - public const int SC_FOLDFLAG_LINESTATE = 0x0080; - - // Fold display text - public const int SC_FOLDDISPLAYTEXT_HIDDEN = 0; - public const int SC_FOLDDISPLAYTEXT_STANDARD = 1; - public const int SC_FOLDDISPLAYTEXT_BOXED = 2; - - // Line end type - public const int SC_LINE_END_TYPE_DEFAULT = 0; - public const int SC_LINE_END_TYPE_UNICODE = 1; - - //Line layers - public const int SC_LAYER_BASE = 0; - public const int SC_LAYER_UNDER_TEXT = 1; - public const int SC_LAYER_OVER_TEXT = 2; - - // 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_MARGIN_COLOUR = 6; - - 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_VERTICALBOOKMARK = 32; - public const int SC_MARK_BAR = 33; - public const int SC_MARK_CHARACTER = 10000; - public const int SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN = 21; - public const int SC_MARKNUM_HISTORY_SAVED = 22; - public const int SC_MARKNUM_HISTORY_MODIFIED = 23; - public const int SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED = 24; - 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; - public const int SC_STATUS_WARN_START = 1000; - public const int SC_STATUS_WARN_REGEX = 1001; - - // 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_NONE = 0x0; - 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; - - // 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; - - // Change history - public const int SC_CHANGE_HISTORY_DISABLED = 0; - public const int SC_CHANGE_HISTORY_ENABLED = 1; - public const int SC_CHANGE_HISTORY_MARKERS = 2; - public const int SC_CHANGE_HISTORY_INDICATORS = 4; - - // 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_MARKERSETFORETRANSLUCENT = 2294; - public const int SCI_MARKERSETBACKTRANSLUCENT = 2295; - 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_SETMARGINBACKN = 2250; - public const int SCI_GETMARGINBACKN = 2251; - public const int SCI_SETMARGINS = 2252; - public const int SCI_GETMARGINS = 2253; - 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_FINDTEXTFULL = 2196; - 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_ISRANGEWORD = 2691; - 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_TARGETWHOLEDOCUMENT = 2690; - 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_LINEREVERSE = 2354; - 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; // Bad, bad, bad. Don't use these... - // public const int SCI_POSITIONAFTER = 2418; // they treat \r\n as one character. - 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_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_GETTABDRAWMODE = 2698; - public const int SCI_SETTABDRAWMODE = 2699; - 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_MULTIPLESELECTADDNEXT = 2688; - public const int SCI_MULTIPLESELECTADDEACH = 2689; - 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_SETIDLESTYLING = 2692; - public const int SCI_GETIDLESTYLING = 2693; - public const int SCI_MULTIEDGEADDLINE = 2694; - public const int SCI_MULTIEDGECLEARALL = 2695; - public const int SCI_SETMOUSEWHEELCAPTURES = 2696; - public const int SCI_GETMOUSEWHEELCAPTURES = 2697; - public const int SCI_TOGGLEFOLDSHOWTEXT = 2700; - 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; - public const int SCI_SETCARETLINELAYER = 2765; - public const int SCI_SETCHANGEHISTORY = 2780; - public const int SCI_GETCHANGEHISTORY = 2781; - 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; - public const int SC_BIDIRECTIONAL_DISABLED = 0; - public const int SC_BIDIRECTIONAL_L2R = 1; - public const int SC_BIDIRECTIONAL_R2L = 2; - public const int SCI_GETBIDIRECTIONAL = 2708; - public const int SCI_SETBIDIRECTIONAL = 2709; - public const int SCI_SETILEXER = 4033; - - // Keys - public const int SCK_DOWN = 300; - public const int SCK_UP = 301; - public const int SCK_LEFT = 302; - public const int SCK_RIGHT = 303; - public const int SCK_HOME = 304; - public const int SCK_END = 305; - public const int SCK_PRIOR = 306; - public const int SCK_NEXT = 307; - public const int SCK_DELETE = 308; - public const int SCK_INSERT = 309; - public const int SCK_ESCAPE = 7; - public const int SCK_BACK = 8; - public const int SCK_TAB = 9; - public const int SCK_RETURN = 13; - public const int SCK_ADD = 310; - public const int SCK_SUBTRACT = 311; - public const int SCK_DIVIDE = 312; - public const int SCK_WIN = 313; - public const int SCK_RWIN = 314; - public const int SCK_MENU = 315; - - // 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; - public const int SCN_AUTOCCOMPLETED = 2030; - public const int SCN_MARGINRIGHTCLICK = 2031; - public const int SCN_AUTOCSELECTIONCHANGE = 2032; - - // Popup - public const int SC_POPUP_NEVER = 0; - public const int SC_POPUP_ALL = 1; - public const int SC_POPUP_TEXT = 2; - - // 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; - public const int SCVS_NOWRAPLINESTART = 4; - - // 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_FOLDDISPLAYTEXT = 39; - 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; - public const int SC_CASE_CAMEL = 3; - - // Technology - public const int SC_TECHNOLOGY_DEFAULT = 0; - public const int SC_TECHNOLOGY_DIRECTWRITE = 1; - public const int SC_TECHNOLOGY_DIRECTWRITERETAIN = 2; - public const int SC_TECHNOLOGY_DIRECTWRITEDC = 3; - - // Tab draw - public const int SCTD_LONGARROW = 0; - public const int SCTD_STRIKEOUT = 1; - - // 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; - public const int SCWS_VISIBLEONLYININDENT = 3; - - // Window messages - public const int WM_CREATE = 0x0001; - public const int WM_DESTROY = 0x0002; - public const int WM_SETCURSOR = 0x0020; - public const int WM_NOTIFY = 0x004E; - public const int WM_NCPAINT = 0x0085; - public const int WM_LBUTTONDBLCLK = 0x0203; - public const int WM_RBUTTONDBLCLK = 0x0206; - public const int WM_MBUTTONDBLCLK = 0x0209; - public const int WM_XBUTTONDBLCLK = 0x020D; - 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; - - public const int RGN_AND = 1; - - #endregion Constants - - #region Lexer Constants - - // Map the constant language names - public static readonly Dictionary NameConstantMap = new() { + public static class NativeMethods + { + #region Constants + + private const string DLL_NAME_GDI32 = "gdi32.dll"; + private const string DLL_NAME_KERNEL32 = "kernel32.dll"; + private const string DLL_NAME_OLE32 = "ole32.dll"; + private const string DLL_NAME_USER32 = "user32.dll"; + + public const int INVALID_POSITION = -1; + + // Autocompletions + public const int SC_AC_FILLUP = 1; + public const int SC_AC_DOUBLECLICK = 2; + public const int SC_AC_TAB = 3; + public const int SC_AC_NEWLINE = 4; + public const int SC_AC_COMMAND = 5; + + // 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; + + // Clipboard formats + public const string CF_HTML = "HTML Format"; + + // Idle styling + public const int SC_IDLESTYLING_NONE = 0; + public const int SC_IDLESTYLING_TOVISIBLE = 1; + public const int SC_IDLESTYLING_AFTERVISIBLE = 2; + public const int SC_IDLESTYLING_ALL = 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 policy flags + public const int CARET_SLOP = 0x01; + public const int CARET_STRICT = 0x04; + public const int CARET_JUMPS = 0x10; + public const int CARET_EVEN = 0x08; + + // 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; + public const int EDGE_MULTILINE = 3; + + // Message-only window + public const int HWND_MESSAGE = -3; + + // Indicator styles + 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_POINT = 18; + public const int INDIC_POINTCHARACTER = 19; + public const int INDIC_GRADIENT = 20; + public const int INDIC_GRADIENTCENTRE = 21; + public const int INDIC_POINT_TOP = 22; + + [Obsolete("Use INDICATOR_CONTAINER instead.")] + public const int INDIC_CONTAINER = 8; + [Obsolete("Use INDICATOR_MAX instead.")] + public const int INDIC_MAX = 31; + + // Indicators + public const int INDICATOR_CONTAINER = 8; + public const int INDICATOR_IME = 32; + public const int INDICATOR_IME_MAX = 35; + public const int INDICATOR_HISTORY_REVERTED_TO_ORIGIN_INSERTION = 36; + public const int INDICATOR_HISTORY_REVERTED_TO_ORIGIN_DELETION = 37; + public const int INDICATOR_HISTORY_SAVED_INSERTION = 38; + public const int INDICATOR_HISTORY_SAVED_DELETION = 39; + public const int INDICATOR_HISTORY_MODIFIED_INSERTION = 40; + public const int INDICATOR_HISTORY_MODIFIED_DELETION = 41; + public const int INDICATOR_HISTORY_REVERTED_TO_MODIFIED_INSERTION = 42; + public const int INDICATOR_HISTORY_REVERTED_TO_MODIFIED_DELETION = 43; + public const int INDICATOR_MAX = 43; + + // Phases + public const int SC_PHASES_ONE = 0; + public const int SC_PHASES_TWO = 1; + public const int SC_PHASES_MULTIPLE = 2; + + // 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; + + // Font quality + public const int SC_EFF_QUALITY_DEFAULT = 0; + public const int SC_EFF_QUALITY_NON_ANTIALIASED = 1; + public const int SC_EFF_QUALITY_ANTIALIASED = 2; + public const int SC_EFF_QUALITY_LCD_OPTIMIZED = 3; + + // End-of-line + public const int SC_EOL_CRLF = 0; + public const int SC_EOL_CR = 1; + public const int SC_EOL_LF = 2; + + // Fold action + public const int SC_FOLDACTION_CONTRACT = 0; + public const int SC_FOLDACTION_EXPAND = 1; + public const int SC_FOLDACTION_TOGGLE = 2; + + // Fold level + public const int SC_FOLDLEVELBASE = 0x400; + public const int SC_FOLDLEVELWHITEFLAG = 0x1000; + public const int SC_FOLDLEVELHEADERFLAG = 0x2000; + public const int SC_FOLDLEVELNUMBERMASK = 0x0FFF; + + // Fold flags + public const int SC_FOLDFLAG_LINEBEFORE_EXPANDED = 0x0002; + public const int SC_FOLDFLAG_LINEBEFORE_CONTRACTED = 0x0004; + public const int SC_FOLDFLAG_LINEAFTER_EXPANDED = 0x0008; + public const int SC_FOLDFLAG_LINEAFTER_CONTRACTED = 0x0010; + public const int SC_FOLDFLAG_LEVELNUMBERS = 0x0040; + public const int SC_FOLDFLAG_LINESTATE = 0x0080; + + // Fold display text + public const int SC_FOLDDISPLAYTEXT_HIDDEN = 0; + public const int SC_FOLDDISPLAYTEXT_STANDARD = 1; + public const int SC_FOLDDISPLAYTEXT_BOXED = 2; + + // Line end type + public const int SC_LINE_END_TYPE_DEFAULT = 0; + public const int SC_LINE_END_TYPE_UNICODE = 1; + + //Line layers + public const int SC_LAYER_BASE = 0; + public const int SC_LAYER_UNDER_TEXT = 1; + public const int SC_LAYER_OVER_TEXT = 2; + + // 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_MARGIN_COLOUR = 6; + + 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_VERTICALBOOKMARK = 32; + public const int SC_MARK_BAR = 33; + public const int SC_MARK_CHARACTER = 10000; + public const int SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN = 21; + public const int SC_MARKNUM_HISTORY_SAVED = 22; + public const int SC_MARKNUM_HISTORY_MODIFIED = 23; + public const int SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED = 24; + 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; + public const int SC_STATUS_WARN_START = 1000; + public const int SC_STATUS_WARN_REGEX = 1001; + + // 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_NONE = 0x0; + 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; + + // 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; + + // Change history + public const int SC_CHANGE_HISTORY_DISABLED = 0; + public const int SC_CHANGE_HISTORY_ENABLED = 1; + public const int SC_CHANGE_HISTORY_MARKERS = 2; + public const int SC_CHANGE_HISTORY_INDICATORS = 4; + + // 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_MARKERSETFORETRANSLUCENT = 2294; + public const int SCI_MARKERSETBACKTRANSLUCENT = 2295; + 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_SETMARGINBACKN = 2250; + public const int SCI_GETMARGINBACKN = 2251; + public const int SCI_SETMARGINS = 2252; + public const int SCI_GETMARGINS = 2253; + 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_FINDTEXTFULL = 2196; + 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_ISRANGEWORD = 2691; + 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_TARGETWHOLEDOCUMENT = 2690; + 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_LINEREVERSE = 2354; + 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; // Bad, bad, bad. Don't use these... + // public const int SCI_POSITIONAFTER = 2418; // they treat \r\n as one character. + 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_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_GETTABDRAWMODE = 2698; + public const int SCI_SETTABDRAWMODE = 2699; + 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_MULTIPLESELECTADDNEXT = 2688; + public const int SCI_MULTIPLESELECTADDEACH = 2689; + 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_SETIDLESTYLING = 2692; + public const int SCI_GETIDLESTYLING = 2693; + public const int SCI_MULTIEDGEADDLINE = 2694; + public const int SCI_MULTIEDGECLEARALL = 2695; + public const int SCI_SETMOUSEWHEELCAPTURES = 2696; + public const int SCI_GETMOUSEWHEELCAPTURES = 2697; + public const int SCI_TOGGLEFOLDSHOWTEXT = 2700; + 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; + public const int SCI_SETCARETLINELAYER = 2765; + public const int SCI_SETCHANGEHISTORY = 2780; + public const int SCI_GETCHANGEHISTORY = 2781; + 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; + public const int SC_BIDIRECTIONAL_DISABLED = 0; + public const int SC_BIDIRECTIONAL_L2R = 1; + public const int SC_BIDIRECTIONAL_R2L = 2; + public const int SCI_GETBIDIRECTIONAL = 2708; + public const int SCI_SETBIDIRECTIONAL = 2709; + public const int SCI_SETILEXER = 4033; + + // Keys + public const int SCK_DOWN = 300; + public const int SCK_UP = 301; + public const int SCK_LEFT = 302; + public const int SCK_RIGHT = 303; + public const int SCK_HOME = 304; + public const int SCK_END = 305; + public const int SCK_PRIOR = 306; + public const int SCK_NEXT = 307; + public const int SCK_DELETE = 308; + public const int SCK_INSERT = 309; + public const int SCK_ESCAPE = 7; + public const int SCK_BACK = 8; + public const int SCK_TAB = 9; + public const int SCK_RETURN = 13; + public const int SCK_ADD = 310; + public const int SCK_SUBTRACT = 311; + public const int SCK_DIVIDE = 312; + public const int SCK_WIN = 313; + public const int SCK_RWIN = 314; + public const int SCK_MENU = 315; + + // 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; + public const int SCN_AUTOCCOMPLETED = 2030; + public const int SCN_MARGINRIGHTCLICK = 2031; + public const int SCN_AUTOCSELECTIONCHANGE = 2032; + + // Popup + public const int SC_POPUP_NEVER = 0; + public const int SC_POPUP_ALL = 1; + public const int SC_POPUP_TEXT = 2; + + // 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; + public const int SCVS_NOWRAPLINESTART = 4; + + // 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_FOLDDISPLAYTEXT = 39; + 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; + public const int SC_CASE_CAMEL = 3; + + // Technology + public const int SC_TECHNOLOGY_DEFAULT = 0; + public const int SC_TECHNOLOGY_DIRECTWRITE = 1; + public const int SC_TECHNOLOGY_DIRECTWRITERETAIN = 2; + public const int SC_TECHNOLOGY_DIRECTWRITEDC = 3; + + // Tab draw + public const int SCTD_LONGARROW = 0; + public const int SCTD_STRIKEOUT = 1; + + // 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; + public const int SCWS_VISIBLEONLYININDENT = 3; + + // Window messages + public const int WM_CREATE = 0x0001; + public const int WM_DESTROY = 0x0002; + public const int WM_SETCURSOR = 0x0020; + public const int WM_NOTIFY = 0x004E; + public const int WM_NCPAINT = 0x0085; + public const int WM_LBUTTONDBLCLK = 0x0203; + public const int WM_RBUTTONDBLCLK = 0x0206; + public const int WM_MBUTTONDBLCLK = 0x0209; + public const int WM_XBUTTONDBLCLK = 0x020D; + 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; + + public const int RGN_AND = 1; + + #endregion Constants + + #region Lexer Constants + + // Map the constant language names + public static readonly Dictionary NameConstantMap = new Dictionary() { { SCLEX_CONTAINER, "" }, { SCLEX_NULL, "null" }, { SCLEX_PYTHON, "python" }, @@ -1358,869 +1358,870 @@ public static class NativeMethods { SCLEX_JULIA, "julia" }, }; - // 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_JSON = 120; - public const int SCLEX_EDIFACT = 121; - public const int SCLEX_INDENT = 122; - public const int SCLEX_MAXIMA = 123; - public const int SCLEX_STATA = 124; - public const int SCLEX_SAS = 125; - public const int SCLEX_NIM = 126; - public const int SCLEX_CIL = 127; - public const int SCLEX_X12 = 128; - public const int SCLEX_DATAFLEX = 129; - public const int SCLEX_HOLLYWOOD = 130; - public const int SCLEX_RAKU = 131; - public const int SCLEX_FSHARP = 132; - public const int SCLEX_JULIA = 133; - public const int SCLEX_AUTOMATIC = 1000; - - // Ada - public const int SCE_ADA_DEFAULT = 0; - public const int SCE_ADA_WORD = 1; - public const int SCE_ADA_IDENTIFIER = 2; - public const int SCE_ADA_NUMBER = 3; - public const int SCE_ADA_DELIMITER = 4; - public const int SCE_ADA_CHARACTER = 5; - public const int SCE_ADA_CHARACTEREOL = 6; - public const int SCE_ADA_STRING = 7; - public const int SCE_ADA_STRINGEOL = 8; - public const int SCE_ADA_LABEL = 9; - public const int SCE_ADA_COMMENTLINE = 10; - public const int SCE_ADA_ILLEGAL = 11; - - // ASM - public const int SCE_ASM_DEFAULT = 0; - public const int SCE_ASM_COMMENT = 1; - public const int SCE_ASM_NUMBER = 2; - public const int SCE_ASM_STRING = 3; - public const int SCE_ASM_OPERATOR = 4; - public const int SCE_ASM_IDENTIFIER = 5; - public const int SCE_ASM_CPUINSTRUCTION = 6; - public const int SCE_ASM_MATHINSTRUCTION = 7; - public const int SCE_ASM_REGISTER = 8; - public const int SCE_ASM_DIRECTIVE = 9; - public const int SCE_ASM_DIRECTIVEOPERAND = 10; - public const int SCE_ASM_COMMENTBLOCK = 11; - public const int SCE_ASM_CHARACTER = 12; - public const int SCE_ASM_STRINGEOL = 13; - public const int SCE_ASM_EXTINSTRUCTION = 14; - public const int SCE_ASM_COMMENTDIRECTIVE = 15; - - // Batch - public const int SCE_BAT_DEFAULT = 0; - public const int SCE_BAT_COMMENT = 1; - public const int SCE_BAT_WORD = 2; - public const int SCE_BAT_LABEL = 3; - public const int SCE_BAT_HIDE = 4; - public const int SCE_BAT_COMMAND = 5; - public const int SCE_BAT_IDENTIFIER = 6; - public const int SCE_BAT_OPERATOR = 7; - - // 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; - - //CLW - public const int SCE_CLW_DEFAULT = 0; - public const int SCE_CLW_LABEL = 1; - public const int SCE_CLW_COMMENT = 2; - public const int SCE_CLW_STRING = 3; - public const int SCE_CLW_USER_IDENTIFIER = 4; - public const int SCE_CLW_INTEGER_CONSTANT = 5; - public const int SCE_CLW_REAL_CONSTANT = 6; - public const int SCE_CLW_PICTURE_STRING = 7; - public const int SCE_CLW_KEYWORD = 8; - public const int SCE_CLW_COMPILER_DIRECTIVE = 9; - public const int SCE_CLW_RUNTIME_EXPRESSIONS = 10; - public const int SCE_CLW_BUILTIN_PROCEDURES_FUNCTION = 11; - public const int SCE_CLW_STRUCTURE_DATA_TYPE = 12; - public const int SCE_CLW_ATTRIBUTE = 13; - public const int SCE_CLW_STANDARD_EQUATE = 14; - public const int SCE_CLW_ERROR = 15; - public const int SCE_CLW_DEPRECATED = 16; - - // 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; - - // Fortran - public const int SCE_F_DEFAULT = 0; - public const int SCE_F_COMMENT = 1; - public const int SCE_F_NUMBER = 2; - public const int SCE_F_STRING1 = 3; - public const int SCE_F_STRING2 = 4; - public const int SCE_F_STRINGEOL = 5; - public const int SCE_F_OPERATOR = 6; - public const int SCE_F_IDENTIFIER = 7; - public const int SCE_F_WORD = 8; - public const int SCE_F_WORD2 = 9; - public const int SCE_F_WORD3 = 10; - public const int SCE_F_PREPROCESSOR = 11; - public const int SCE_F_OPERATOR2 = 12; - public const int SCE_F_LABEL = 13; - public const int SCE_F_CONTINUATION = 14; - - // HTML - public const int SCE_H_DEFAULT = 0; - public const int SCE_H_TAG = 1; - public const int SCE_H_TAGUNKNOWN = 2; - public const int SCE_H_ATTRIBUTE = 3; - public const int SCE_H_ATTRIBUTEUNKNOWN = 4; - public const int SCE_H_NUMBER = 5; - public const int SCE_H_DOUBLESTRING = 6; - public const int SCE_H_SINGLESTRING = 7; - public const int SCE_H_OTHER = 8; - public const int SCE_H_COMMENT = 9; - public const int SCE_H_ENTITY = 10; - public const int SCE_H_TAGEND = 11; - public const int SCE_H_XMLSTART = 12; - public const int SCE_H_XMLEND = 13; - public const int SCE_H_SCRIPT = 14; - public const int SCE_H_ASP = 15; - public const int SCE_H_ASPAT = 16; - public const int SCE_H_CDATA = 17; - public const int SCE_H_QUESTION = 18; - public const int SCE_H_VALUE = 19; - public const int SCE_H_XCCOMMENT = 20; - - // JavaScript - public const int SCE_HJ_START = 40; - public const int SCE_HJ_DEFAULT = 41; - public const int SCE_HJ_COMMENT = 42; - public const int SCE_HJ_COMMENTLINE = 43; - public const int SCE_HJ_COMMENTDOC = 44; - public const int SCE_HJ_NUMBER = 45; - public const int SCE_HJ_WORD = 46; - public const int SCE_HJ_KEYWORD = 47; - public const int SCE_HJ_DOUBLESTRING = 48; - public const int SCE_HJ_SINGLESTRING = 49; - public const int SCE_HJ_SYMBOLS = 50; - public const int SCE_HJ_STRINGEOL = 51; - public const int SCE_HJ_REGEX = 52; - - // JSON - public const int SCE_JSON_DEFAULT = 0; - public const int SCE_JSON_NUMBER = 1; - public const int SCE_JSON_STRING = 2; - public const int SCE_JSON_STRINGEOL = 3; - public const int SCE_JSON_PROPERTYNAME = 4; - public const int SCE_JSON_ESCAPESEQUENCE = 5; - public const int SCE_JSON_LINECOMMENT = 6; - public const int SCE_JSON_BLOCKCOMMENT = 7; - public const int SCE_JSON_OPERATOR = 8; - public const int SCE_JSON_URI = 9; - public const int SCE_JSON_COMPACTIRI = 10; - public const int SCE_JSON_KEYWORD = 11; - public const int SCE_JSON_LDKEYWORD = 12; - public const int SCE_JSON_ERROR = 13; - - // Lisp - public const int SCE_LISP_DEFAULT = 0; - public const int SCE_LISP_COMMENT = 1; - public const int SCE_LISP_NUMBER = 2; - public const int SCE_LISP_KEYWORD = 3; - public const int SCE_LISP_KEYWORD_KW = 4; - public const int SCE_LISP_SYMBOL = 5; - public const int SCE_LISP_STRING = 6; - public const int SCE_LISP_STRINGEOL = 8; - public const int SCE_LISP_IDENTIFIER = 9; - public const int SCE_LISP_OPERATOR = 10; - public const int SCE_LISP_SPECIAL = 11; - public const int SCE_LISP_MULTI_COMMENT = 12; - - // Lua - public const int SCE_LUA_DEFAULT = 0; - public const int SCE_LUA_COMMENT = 1; - public const int SCE_LUA_COMMENTLINE = 2; - public const int SCE_LUA_COMMENTDOC = 3; - public const int SCE_LUA_NUMBER = 4; - public const int SCE_LUA_WORD = 5; - public const int SCE_LUA_STRING = 6; - public const int SCE_LUA_CHARACTER = 7; - public const int SCE_LUA_LITERALSTRING = 8; - public const int SCE_LUA_PREPROCESSOR = 9; - public const int SCE_LUA_OPERATOR = 10; - public const int SCE_LUA_IDENTIFIER = 11; - public const int SCE_LUA_STRINGEOL = 12; - public const int SCE_LUA_WORD2 = 13; - public const int SCE_LUA_WORD3 = 14; - public const int SCE_LUA_WORD4 = 15; - public const int SCE_LUA_WORD5 = 16; - public const int SCE_LUA_WORD6 = 17; - public const int SCE_LUA_WORD7 = 18; - public const int SCE_LUA_WORD8 = 19; - public const int SCE_LUA_LABEL = 20; - - public const int SCE_PAS_DEFAULT = 0; - public const int SCE_PAS_IDENTIFIER = 1; - public const int SCE_PAS_COMMENT = 2; - public const int SCE_PAS_COMMENT2 = 3; - public const int SCE_PAS_COMMENTLINE = 4; - public const int SCE_PAS_PREPROCESSOR = 5; - public const int SCE_PAS_PREPROCESSOR2 = 6; - public const int SCE_PAS_NUMBER = 7; - public const int SCE_PAS_HEXNUMBER = 8; - public const int SCE_PAS_WORD = 9; - public const int SCE_PAS_STRING = 10; - public const int SCE_PAS_STRINGEOL = 11; - public const int SCE_PAS_CHARACTER = 12; - public const int SCE_PAS_OPERATOR = 13; - public const int SCE_PAS_ASM = 14; - - // Matlab - public const int SCE_MATLAB_DEFAULT = 0; - public const int SCE_MATLAB_COMMENT = 1; - public const int SCE_MATLAB_COMMAND = 2; - public const int SCE_MATLAB_NUMBER = 3; - public const int SCE_MATLAB_KEYWORD = 4; - public const int SCE_MATLAB_STRING = 5; - public const int SCE_MATLAB_OPERATOR = 6; - public const int SCE_MATLAB_IDENTIFIER = 7; - public const int SCE_MATLAB_DOUBLEQUOTESTRING = 8; - - // Perl - public const int SCE_PL_DEFAULT = 0; - public const int SCE_PL_ERROR = 1; - public const int SCE_PL_COMMENTLINE = 2; - public const int SCE_PL_POD = 3; - public const int SCE_PL_NUMBER = 4; - public const int SCE_PL_WORD = 5; - public const int SCE_PL_STRING = 6; - public const int SCE_PL_CHARACTER = 7; - public const int SCE_PL_PUNCTUATION = 8; - public const int SCE_PL_PREPROCESSOR = 9; - public const int SCE_PL_OPERATOR = 10; - public const int SCE_PL_IDENTIFIER = 11; - public const int SCE_PL_SCALAR = 12; - public const int SCE_PL_ARRAY = 13; - public const int SCE_PL_HASH = 14; - public const int SCE_PL_SYMBOLTABLE = 15; - public const int SCE_PL_VARIABLE_INDEXER = 16; - public const int SCE_PL_REGEX = 17; - public const int SCE_PL_REGSUBST = 18; - public const int SCE_PL_LONGQUOTE = 19; - public const int SCE_PL_BACKTICKS = 20; - public const int SCE_PL_DATASECTION = 21; - public const int SCE_PL_HERE_DELIM = 22; - public const int SCE_PL_HERE_Q = 23; - public const int SCE_PL_HERE_QQ = 24; - public const int SCE_PL_HERE_QX = 25; - public const int SCE_PL_STRING_Q = 26; - public const int SCE_PL_STRING_QQ = 27; - public const int SCE_PL_STRING_QX = 28; - public const int SCE_PL_STRING_QR = 29; - public const int SCE_PL_STRING_QW = 30; - public const int SCE_PL_POD_VERB = 31; - public const int SCE_PL_SUB_PROTOTYPE = 40; - public const int SCE_PL_FORMAT_IDENT = 41; - public const int SCE_PL_FORMAT = 42; - public const int SCE_PL_STRING_VAR = 43; - public const int SCE_PL_XLAT = 44; - public const int SCE_PL_REGEX_VAR = 54; - public const int SCE_PL_REGSUBST_VAR = 55; - public const int SCE_PL_BACKTICKS_VAR = 57; - public const int SCE_PL_HERE_QQ_VAR = 61; - public const int SCE_PL_HERE_QX_VAR = 62; - public const int SCE_PL_STRING_QQ_VAR = 64; - public const int SCE_PL_STRING_QX_VAR = 65; - public const int SCE_PL_STRING_QR_VAR = 66; - - // PowerShell - public const int SCE_POWERSHELL_DEFAULT = 0; - public const int SCE_POWERSHELL_COMMENT = 1; - public const int SCE_POWERSHELL_STRING = 2; - public const int SCE_POWERSHELL_CHARACTER = 3; - public const int SCE_POWERSHELL_NUMBER = 4; - public const int SCE_POWERSHELL_VARIABLE = 5; - public const int SCE_POWERSHELL_OPERATOR = 6; - public const int SCE_POWERSHELL_IDENTIFIER = 7; - public const int SCE_POWERSHELL_KEYWORD = 8; - public const int SCE_POWERSHELL_CMDLET = 9; - public const int SCE_POWERSHELL_ALIAS = 10; - public const int SCE_POWERSHELL_FUNCTION = 11; - public const int SCE_POWERSHELL_USER1 = 12; - public const int SCE_POWERSHELL_COMMENTSTREAM = 13; - public const int SCE_POWERSHELL_HERE_STRING = 14; - public const int SCE_POWERSHELL_HERE_CHARACTER = 15; - public const int SCE_POWERSHELL_COMMENTDOCKEYWORD = 16; - - // Properties - public const int SCE_PROPS_DEFAULT = 0; - public const int SCE_PROPS_COMMENT = 1; - public const int SCE_PROPS_SECTION = 2; - public const int SCE_PROPS_ASSIGNMENT = 3; - public const int SCE_PROPS_DEFVAL = 4; - public const int SCE_PROPS_KEY = 5; - - // PHP script - public const int SCE_HPHP_COMPLEX_VARIABLE = 104; - public const int SCE_HPHP_DEFAULT = 118; - public const int SCE_HPHP_HSTRING = 119; - public const int SCE_HPHP_SIMPLESTRING = 120; - public const int SCE_HPHP_WORD = 121; - public const int SCE_HPHP_NUMBER = 122; - public const int SCE_HPHP_VARIABLE = 123; - public const int SCE_HPHP_COMMENT = 124; - public const int SCE_HPHP_COMMENTLINE = 125; - public const int SCE_HPHP_HSTRING_VARIABLE = 126; - public const int SCE_HPHP_OPERATOR = 127; - - // SQL - public const int SCE_SQL_DEFAULT = 0; - public const int SCE_SQL_COMMENT = 1; - public const int SCE_SQL_COMMENTLINE = 2; - public const int SCE_SQL_COMMENTDOC = 3; - public const int SCE_SQL_NUMBER = 4; - public const int SCE_SQL_WORD = 5; - public const int SCE_SQL_STRING = 6; - public const int SCE_SQL_CHARACTER = 7; - public const int SCE_SQL_SQLPLUS = 8; - public const int SCE_SQL_SQLPLUS_PROMPT = 9; - public const int SCE_SQL_OPERATOR = 10; - public const int SCE_SQL_IDENTIFIER = 11; - public const int SCE_SQL_SQLPLUS_COMMENT = 13; - public const int SCE_SQL_COMMENTLINEDOC = 15; - public const int SCE_SQL_WORD2 = 16; - public const int SCE_SQL_COMMENTDOCKEYWORD = 17; - public const int SCE_SQL_COMMENTDOCKEYWORDERROR = 18; - public const int SCE_SQL_USER1 = 19; - public const int SCE_SQL_USER2 = 20; - public const int SCE_SQL_USER3 = 21; - public const int SCE_SQL_USER4 = 22; - public const int SCE_SQL_QUOTEDIDENTIFIER = 23; - public const int SCE_SQL_QOPERATOR = 24; - - // 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; - - // Ruby - public const int SCE_RB_DEFAULT = 0; - public const int SCE_RB_ERROR = 1; - public const int SCE_RB_COMMENTLINE = 2; - public const int SCE_RB_POD = 3; - public const int SCE_RB_NUMBER = 4; - public const int SCE_RB_WORD = 5; - public const int SCE_RB_STRING = 6; - public const int SCE_RB_CHARACTER = 7; - public const int SCE_RB_CLASSNAME = 8; - public const int SCE_RB_DEFNAME = 9; - public const int SCE_RB_OPERATOR = 10; - public const int SCE_RB_IDENTIFIER = 11; - public const int SCE_RB_REGEX = 12; - public const int SCE_RB_GLOBAL = 13; - public const int SCE_RB_SYMBOL = 14; - public const int SCE_RB_MODULE_NAME = 15; - public const int SCE_RB_INSTANCE_VAR = 16; - public const int SCE_RB_CLASS_VAR = 17; - public const int SCE_RB_BACKTICKS = 18; - public const int SCE_RB_DATASECTION = 19; - public const int SCE_RB_HERE_DELIM = 20; - public const int SCE_RB_HERE_Q = 21; - public const int SCE_RB_HERE_QQ = 22; - public const int SCE_RB_HERE_QX = 23; - public const int SCE_RB_STRING_Q = 24; - public const int SCE_RB_STRING_QQ = 25; - public const int SCE_RB_STRING_QX = 26; - public const int SCE_RB_STRING_QR = 27; - public const int SCE_RB_STRING_QW = 28; - public const int SCE_RB_WORD_DEMOTED = 29; - public const int SCE_RB_STDIN = 30; - public const int SCE_RB_STDOUT = 31; - public const int SCE_RB_STDERR = 40; - public const int SCE_RB_UPPER_BOUND = 41; - - // Smalltalk - public const int SCE_ST_DEFAULT = 0; - public const int SCE_ST_STRING = 1; - public const int SCE_ST_NUMBER = 2; - public const int SCE_ST_COMMENT = 3; - public const int SCE_ST_SYMBOL = 4; - public const int SCE_ST_BINARY = 5; - public const int SCE_ST_BOOL = 6; - public const int SCE_ST_SELF = 7; - public const int SCE_ST_SUPER = 8; - public const int SCE_ST_NIL = 9; - public const int SCE_ST_GLOBAL = 10; - public const int SCE_ST_RETURN = 11; - public const int SCE_ST_SPECIAL = 12; - public const int SCE_ST_KWSEND = 13; - public const int SCE_ST_ASSIGN = 14; - public const int SCE_ST_CHARACTER = 15; - public const int SCE_ST_SPEC_SEL = 16; - - // Basic / VB - 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; - - // Markdown - public const int SCE_MARKDOWN_DEFAULT = 0; - public const int SCE_MARKDOWN_LINE_BEGIN = 1; - public const int SCE_MARKDOWN_STRONG1 = 2; - public const int SCE_MARKDOWN_STRONG2 = 3; - public const int SCE_MARKDOWN_EM1 = 4; - public const int SCE_MARKDOWN_EM2 = 5; - public const int SCE_MARKDOWN_HEADER1 = 6; - public const int SCE_MARKDOWN_HEADER2 = 7; - public const int SCE_MARKDOWN_HEADER3 = 8; - public const int SCE_MARKDOWN_HEADER4 = 9; - public const int SCE_MARKDOWN_HEADER5 = 10; - public const int SCE_MARKDOWN_HEADER6 = 11; - public const int SCE_MARKDOWN_PRECHAR = 12; - public const int SCE_MARKDOWN_ULIST_ITEM = 13; - public const int SCE_MARKDOWN_OLIST_ITEM = 14; - public const int SCE_MARKDOWN_BLOCKQUOTE = 15; - public const int SCE_MARKDOWN_STRIKEOUT = 16; - public const int SCE_MARKDOWN_HRULE = 17; - public const int SCE_MARKDOWN_LINK = 18; - public const int SCE_MARKDOWN_CODE = 19; - public const int SCE_MARKDOWN_CODE2 = 20; - public const int SCE_MARKDOWN_CODEBK = 21; - - // R - public const int SCE_R_DEFAULT = 0; - public const int SCE_R_COMMENT = 1; - public const int SCE_R_KWORD = 2; - public const int SCE_R_BASEKWORD = 3; - public const int SCE_R_OTHERKWORD = 4; - public const int SCE_R_NUMBER = 5; - public const int SCE_R_STRING = 6; - public const int SCE_R_STRING2 = 7; - public const int SCE_R_OPERATOR = 8; - public const int SCE_R_IDENTIFIER = 9; - public const int SCE_R_INFIX = 10; - public const int SCE_R_INFIXEOL = 11; - - // Verilog - public const int SCE_V_DEFAULT = 0; - public const int SCE_V_COMMENT = 1; - public const int SCE_V_COMMENTLINE = 2; - public const int SCE_V_COMMENTLINEBANG = 3; - public const int SCE_V_NUMBER = 4; - public const int SCE_V_WORD = 5; - public const int SCE_V_STRING = 6; - public const int SCE_V_WORD2 = 7; - public const int SCE_V_WORD3 = 8; - public const int SCE_V_PREPROCESSOR = 9; - public const int SCE_V_OPERATOR = 10; - public const int SCE_V_IDENTIFIER = 11; - public const int SCE_V_STRINGEOL = 12; - public const int SCE_V_USER = 19; - public const int SCE_V_COMMENT_WORD = 20; - public const int SCE_V_INPUT = 21; - public const int SCE_V_OUTPUT = 22; - public const int SCE_V_INOUT = 23; - public const int SCE_V_PORT_CONNECT = 24; - - #endregion Lexer Constants - - #region Callbacks - - public delegate IntPtr Scintilla_DirectFunction(IntPtr ptr, int iMessage, IntPtr wParam, IntPtr lParam); - - public delegate IntPtr CreateLexer(string lexerName); - - public delegate void GetLexerName(UIntPtr index, IntPtr name, IntPtr bufferLength); - - public delegate IntPtr GetLexerCount(); - - public delegate string LexerNameFromID(IntPtr identifier); - - #endregion Callbacks - - #region Functions - - [DllImport(DLL_NAME_USER32, SetLastError = true)] - public static extern IntPtr MB_GetString(uint hInst); - - public static string GetMessageBoxString(uint msgId) => - Marshal.PtrToStringUni(MB_GetString(msgId)); - - [DllImport(DLL_NAME_USER32, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool CloseClipboard(); - - [DllImport(DLL_NAME_GDI32, ExactSpelling = true)] - public static extern int CombineRgn(IntPtr hrgnDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2, int fnCombineMode); - - [DllImport(DLL_NAME_GDI32, ExactSpelling = true)] - public static extern IntPtr CreateRectRgn(int x1, int y1, int x2, int y2); - - [DllImport(DLL_NAME_KERNEL32, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] - public static extern IntPtr GetProcAddress(HandleRef hModule, string lpProcName); - - [DllImport(DLL_NAME_USER32, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool EmptyClipboard(); - - [DllImport(DLL_NAME_USER32, ExactSpelling = true)] - public static extern IntPtr GetWindowDC(IntPtr hWnd); - - [DllImport(DLL_NAME_USER32, ExactSpelling = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); - - [DllImport(DLL_NAME_KERNEL32, EntryPoint = "LoadLibraryW", CharSet = CharSet.Unicode, SetLastError = true)] - public static extern IntPtr LoadLibrary(string lpFileName); - - [DllImport(DLL_NAME_KERNEL32, EntryPoint = "RtlMoveMemory", SetLastError = true)] - public static extern void MoveMemory(IntPtr dest, IntPtr src, int length); - - [DllImport(DLL_NAME_USER32, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool OpenClipboard(IntPtr hWndNewOwner); - - [DllImport(DLL_NAME_USER32, SetLastError = true)] - public static extern uint RegisterClipboardFormat(string lpszFormat); - - [DllImport(DLL_NAME_USER32, ExactSpelling = true)] - public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); - - [DllImport(DLL_NAME_OLE32, ExactSpelling = true)] - public static extern int RevokeDragDrop(IntPtr hwnd); - - [DllImport(DLL_NAME_USER32, EntryPoint = "SendMessageW", CharSet = CharSet.Unicode, SetLastError = true)] - public static extern IntPtr SendMessage(HandleRef hWnd, int msg, IntPtr wParam, IntPtr lParam); - - [DllImport(DLL_NAME_USER32, SetLastError = true)] - public static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem); - - [DllImport(DLL_NAME_USER32, SetLastError = true)] - public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); - - #endregion Functions - - #region Structures - - // http://www.openrce.org/articles/full_view/23 - // It's worth noting that this structure (and the 64-bit version below) 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 ILoaderVTable32 - { - public ReleaseDelegate Release; - public AddDataDelegate AddData; - public ConvertToDocumentDelegate ConvertToDocument; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int ReleaseDelegate(IntPtr self); - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int AddDataDelegate(IntPtr self, byte* data, int length); - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate IntPtr ConvertToDocumentDelegate(IntPtr self); + // 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_JSON = 120; + public const int SCLEX_EDIFACT = 121; + public const int SCLEX_INDENT = 122; + public const int SCLEX_MAXIMA = 123; + public const int SCLEX_STATA = 124; + public const int SCLEX_SAS = 125; + public const int SCLEX_NIM = 126; + public const int SCLEX_CIL = 127; + public const int SCLEX_X12 = 128; + public const int SCLEX_DATAFLEX = 129; + public const int SCLEX_HOLLYWOOD = 130; + public const int SCLEX_RAKU = 131; + public const int SCLEX_FSHARP = 132; + public const int SCLEX_JULIA = 133; + public const int SCLEX_AUTOMATIC = 1000; + + // Ada + public const int SCE_ADA_DEFAULT = 0; + public const int SCE_ADA_WORD = 1; + public const int SCE_ADA_IDENTIFIER = 2; + public const int SCE_ADA_NUMBER = 3; + public const int SCE_ADA_DELIMITER = 4; + public const int SCE_ADA_CHARACTER = 5; + public const int SCE_ADA_CHARACTEREOL = 6; + public const int SCE_ADA_STRING = 7; + public const int SCE_ADA_STRINGEOL = 8; + public const int SCE_ADA_LABEL = 9; + public const int SCE_ADA_COMMENTLINE = 10; + public const int SCE_ADA_ILLEGAL = 11; + + // ASM + public const int SCE_ASM_DEFAULT = 0; + public const int SCE_ASM_COMMENT = 1; + public const int SCE_ASM_NUMBER = 2; + public const int SCE_ASM_STRING = 3; + public const int SCE_ASM_OPERATOR = 4; + public const int SCE_ASM_IDENTIFIER = 5; + public const int SCE_ASM_CPUINSTRUCTION = 6; + public const int SCE_ASM_MATHINSTRUCTION = 7; + public const int SCE_ASM_REGISTER = 8; + public const int SCE_ASM_DIRECTIVE = 9; + public const int SCE_ASM_DIRECTIVEOPERAND = 10; + public const int SCE_ASM_COMMENTBLOCK = 11; + public const int SCE_ASM_CHARACTER = 12; + public const int SCE_ASM_STRINGEOL = 13; + public const int SCE_ASM_EXTINSTRUCTION = 14; + public const int SCE_ASM_COMMENTDIRECTIVE = 15; + + // Batch + public const int SCE_BAT_DEFAULT = 0; + public const int SCE_BAT_COMMENT = 1; + public const int SCE_BAT_WORD = 2; + public const int SCE_BAT_LABEL = 3; + public const int SCE_BAT_HIDE = 4; + public const int SCE_BAT_COMMAND = 5; + public const int SCE_BAT_IDENTIFIER = 6; + public const int SCE_BAT_OPERATOR = 7; + + // 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; + + //CLW + public const int SCE_CLW_DEFAULT = 0; + public const int SCE_CLW_LABEL = 1; + public const int SCE_CLW_COMMENT = 2; + public const int SCE_CLW_STRING = 3; + public const int SCE_CLW_USER_IDENTIFIER = 4; + public const int SCE_CLW_INTEGER_CONSTANT = 5; + public const int SCE_CLW_REAL_CONSTANT = 6; + public const int SCE_CLW_PICTURE_STRING = 7; + public const int SCE_CLW_KEYWORD = 8; + public const int SCE_CLW_COMPILER_DIRECTIVE = 9; + public const int SCE_CLW_RUNTIME_EXPRESSIONS = 10; + public const int SCE_CLW_BUILTIN_PROCEDURES_FUNCTION = 11; + public const int SCE_CLW_STRUCTURE_DATA_TYPE = 12; + public const int SCE_CLW_ATTRIBUTE = 13; + public const int SCE_CLW_STANDARD_EQUATE = 14; + public const int SCE_CLW_ERROR = 15; + public const int SCE_CLW_DEPRECATED = 16; + + // 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; + + // Fortran + public const int SCE_F_DEFAULT = 0; + public const int SCE_F_COMMENT = 1; + public const int SCE_F_NUMBER = 2; + public const int SCE_F_STRING1 = 3; + public const int SCE_F_STRING2 = 4; + public const int SCE_F_STRINGEOL = 5; + public const int SCE_F_OPERATOR = 6; + public const int SCE_F_IDENTIFIER = 7; + public const int SCE_F_WORD = 8; + public const int SCE_F_WORD2 = 9; + public const int SCE_F_WORD3 = 10; + public const int SCE_F_PREPROCESSOR = 11; + public const int SCE_F_OPERATOR2 = 12; + public const int SCE_F_LABEL = 13; + public const int SCE_F_CONTINUATION = 14; + + // HTML + public const int SCE_H_DEFAULT = 0; + public const int SCE_H_TAG = 1; + public const int SCE_H_TAGUNKNOWN = 2; + public const int SCE_H_ATTRIBUTE = 3; + public const int SCE_H_ATTRIBUTEUNKNOWN = 4; + public const int SCE_H_NUMBER = 5; + public const int SCE_H_DOUBLESTRING = 6; + public const int SCE_H_SINGLESTRING = 7; + public const int SCE_H_OTHER = 8; + public const int SCE_H_COMMENT = 9; + public const int SCE_H_ENTITY = 10; + public const int SCE_H_TAGEND = 11; + public const int SCE_H_XMLSTART = 12; + public const int SCE_H_XMLEND = 13; + public const int SCE_H_SCRIPT = 14; + public const int SCE_H_ASP = 15; + public const int SCE_H_ASPAT = 16; + public const int SCE_H_CDATA = 17; + public const int SCE_H_QUESTION = 18; + public const int SCE_H_VALUE = 19; + public const int SCE_H_XCCOMMENT = 20; + + // JavaScript + public const int SCE_HJ_START = 40; + public const int SCE_HJ_DEFAULT = 41; + public const int SCE_HJ_COMMENT = 42; + public const int SCE_HJ_COMMENTLINE = 43; + public const int SCE_HJ_COMMENTDOC = 44; + public const int SCE_HJ_NUMBER = 45; + public const int SCE_HJ_WORD = 46; + public const int SCE_HJ_KEYWORD = 47; + public const int SCE_HJ_DOUBLESTRING = 48; + public const int SCE_HJ_SINGLESTRING = 49; + public const int SCE_HJ_SYMBOLS = 50; + public const int SCE_HJ_STRINGEOL = 51; + public const int SCE_HJ_REGEX = 52; + + // JSON + public const int SCE_JSON_DEFAULT = 0; + public const int SCE_JSON_NUMBER = 1; + public const int SCE_JSON_STRING = 2; + public const int SCE_JSON_STRINGEOL = 3; + public const int SCE_JSON_PROPERTYNAME = 4; + public const int SCE_JSON_ESCAPESEQUENCE = 5; + public const int SCE_JSON_LINECOMMENT = 6; + public const int SCE_JSON_BLOCKCOMMENT = 7; + public const int SCE_JSON_OPERATOR = 8; + public const int SCE_JSON_URI = 9; + public const int SCE_JSON_COMPACTIRI = 10; + public const int SCE_JSON_KEYWORD = 11; + public const int SCE_JSON_LDKEYWORD = 12; + public const int SCE_JSON_ERROR = 13; + + // Lisp + public const int SCE_LISP_DEFAULT = 0; + public const int SCE_LISP_COMMENT = 1; + public const int SCE_LISP_NUMBER = 2; + public const int SCE_LISP_KEYWORD = 3; + public const int SCE_LISP_KEYWORD_KW = 4; + public const int SCE_LISP_SYMBOL = 5; + public const int SCE_LISP_STRING = 6; + public const int SCE_LISP_STRINGEOL = 8; + public const int SCE_LISP_IDENTIFIER = 9; + public const int SCE_LISP_OPERATOR = 10; + public const int SCE_LISP_SPECIAL = 11; + public const int SCE_LISP_MULTI_COMMENT = 12; + + // Lua + public const int SCE_LUA_DEFAULT = 0; + public const int SCE_LUA_COMMENT = 1; + public const int SCE_LUA_COMMENTLINE = 2; + public const int SCE_LUA_COMMENTDOC = 3; + public const int SCE_LUA_NUMBER = 4; + public const int SCE_LUA_WORD = 5; + public const int SCE_LUA_STRING = 6; + public const int SCE_LUA_CHARACTER = 7; + public const int SCE_LUA_LITERALSTRING = 8; + public const int SCE_LUA_PREPROCESSOR = 9; + public const int SCE_LUA_OPERATOR = 10; + public const int SCE_LUA_IDENTIFIER = 11; + public const int SCE_LUA_STRINGEOL = 12; + public const int SCE_LUA_WORD2 = 13; + public const int SCE_LUA_WORD3 = 14; + public const int SCE_LUA_WORD4 = 15; + public const int SCE_LUA_WORD5 = 16; + public const int SCE_LUA_WORD6 = 17; + public const int SCE_LUA_WORD7 = 18; + public const int SCE_LUA_WORD8 = 19; + public const int SCE_LUA_LABEL = 20; + + public const int SCE_PAS_DEFAULT = 0; + public const int SCE_PAS_IDENTIFIER = 1; + public const int SCE_PAS_COMMENT = 2; + public const int SCE_PAS_COMMENT2 = 3; + public const int SCE_PAS_COMMENTLINE = 4; + public const int SCE_PAS_PREPROCESSOR = 5; + public const int SCE_PAS_PREPROCESSOR2 = 6; + public const int SCE_PAS_NUMBER = 7; + public const int SCE_PAS_HEXNUMBER = 8; + public const int SCE_PAS_WORD = 9; + public const int SCE_PAS_STRING = 10; + public const int SCE_PAS_STRINGEOL = 11; + public const int SCE_PAS_CHARACTER = 12; + public const int SCE_PAS_OPERATOR = 13; + public const int SCE_PAS_ASM = 14; + + // Matlab + public const int SCE_MATLAB_DEFAULT = 0; + public const int SCE_MATLAB_COMMENT = 1; + public const int SCE_MATLAB_COMMAND = 2; + public const int SCE_MATLAB_NUMBER = 3; + public const int SCE_MATLAB_KEYWORD = 4; + public const int SCE_MATLAB_STRING = 5; + public const int SCE_MATLAB_OPERATOR = 6; + public const int SCE_MATLAB_IDENTIFIER = 7; + public const int SCE_MATLAB_DOUBLEQUOTESTRING = 8; + + // Perl + public const int SCE_PL_DEFAULT = 0; + public const int SCE_PL_ERROR = 1; + public const int SCE_PL_COMMENTLINE = 2; + public const int SCE_PL_POD = 3; + public const int SCE_PL_NUMBER = 4; + public const int SCE_PL_WORD = 5; + public const int SCE_PL_STRING = 6; + public const int SCE_PL_CHARACTER = 7; + public const int SCE_PL_PUNCTUATION = 8; + public const int SCE_PL_PREPROCESSOR = 9; + public const int SCE_PL_OPERATOR = 10; + public const int SCE_PL_IDENTIFIER = 11; + public const int SCE_PL_SCALAR = 12; + public const int SCE_PL_ARRAY = 13; + public const int SCE_PL_HASH = 14; + public const int SCE_PL_SYMBOLTABLE = 15; + public const int SCE_PL_VARIABLE_INDEXER = 16; + public const int SCE_PL_REGEX = 17; + public const int SCE_PL_REGSUBST = 18; + public const int SCE_PL_LONGQUOTE = 19; + public const int SCE_PL_BACKTICKS = 20; + public const int SCE_PL_DATASECTION = 21; + public const int SCE_PL_HERE_DELIM = 22; + public const int SCE_PL_HERE_Q = 23; + public const int SCE_PL_HERE_QQ = 24; + public const int SCE_PL_HERE_QX = 25; + public const int SCE_PL_STRING_Q = 26; + public const int SCE_PL_STRING_QQ = 27; + public const int SCE_PL_STRING_QX = 28; + public const int SCE_PL_STRING_QR = 29; + public const int SCE_PL_STRING_QW = 30; + public const int SCE_PL_POD_VERB = 31; + public const int SCE_PL_SUB_PROTOTYPE = 40; + public const int SCE_PL_FORMAT_IDENT = 41; + public const int SCE_PL_FORMAT = 42; + public const int SCE_PL_STRING_VAR = 43; + public const int SCE_PL_XLAT = 44; + public const int SCE_PL_REGEX_VAR = 54; + public const int SCE_PL_REGSUBST_VAR = 55; + public const int SCE_PL_BACKTICKS_VAR = 57; + public const int SCE_PL_HERE_QQ_VAR = 61; + public const int SCE_PL_HERE_QX_VAR = 62; + public const int SCE_PL_STRING_QQ_VAR = 64; + public const int SCE_PL_STRING_QX_VAR = 65; + public const int SCE_PL_STRING_QR_VAR = 66; + + // PowerShell + public const int SCE_POWERSHELL_DEFAULT = 0; + public const int SCE_POWERSHELL_COMMENT = 1; + public const int SCE_POWERSHELL_STRING = 2; + public const int SCE_POWERSHELL_CHARACTER = 3; + public const int SCE_POWERSHELL_NUMBER = 4; + public const int SCE_POWERSHELL_VARIABLE = 5; + public const int SCE_POWERSHELL_OPERATOR = 6; + public const int SCE_POWERSHELL_IDENTIFIER = 7; + public const int SCE_POWERSHELL_KEYWORD = 8; + public const int SCE_POWERSHELL_CMDLET = 9; + public const int SCE_POWERSHELL_ALIAS = 10; + public const int SCE_POWERSHELL_FUNCTION = 11; + public const int SCE_POWERSHELL_USER1 = 12; + public const int SCE_POWERSHELL_COMMENTSTREAM = 13; + public const int SCE_POWERSHELL_HERE_STRING = 14; + public const int SCE_POWERSHELL_HERE_CHARACTER = 15; + public const int SCE_POWERSHELL_COMMENTDOCKEYWORD = 16; + + // Properties + public const int SCE_PROPS_DEFAULT = 0; + public const int SCE_PROPS_COMMENT = 1; + public const int SCE_PROPS_SECTION = 2; + public const int SCE_PROPS_ASSIGNMENT = 3; + public const int SCE_PROPS_DEFVAL = 4; + public const int SCE_PROPS_KEY = 5; + + // PHP script + public const int SCE_HPHP_COMPLEX_VARIABLE = 104; + public const int SCE_HPHP_DEFAULT = 118; + public const int SCE_HPHP_HSTRING = 119; + public const int SCE_HPHP_SIMPLESTRING = 120; + public const int SCE_HPHP_WORD = 121; + public const int SCE_HPHP_NUMBER = 122; + public const int SCE_HPHP_VARIABLE = 123; + public const int SCE_HPHP_COMMENT = 124; + public const int SCE_HPHP_COMMENTLINE = 125; + public const int SCE_HPHP_HSTRING_VARIABLE = 126; + public const int SCE_HPHP_OPERATOR = 127; + + // SQL + public const int SCE_SQL_DEFAULT = 0; + public const int SCE_SQL_COMMENT = 1; + public const int SCE_SQL_COMMENTLINE = 2; + public const int SCE_SQL_COMMENTDOC = 3; + public const int SCE_SQL_NUMBER = 4; + public const int SCE_SQL_WORD = 5; + public const int SCE_SQL_STRING = 6; + public const int SCE_SQL_CHARACTER = 7; + public const int SCE_SQL_SQLPLUS = 8; + public const int SCE_SQL_SQLPLUS_PROMPT = 9; + public const int SCE_SQL_OPERATOR = 10; + public const int SCE_SQL_IDENTIFIER = 11; + public const int SCE_SQL_SQLPLUS_COMMENT = 13; + public const int SCE_SQL_COMMENTLINEDOC = 15; + public const int SCE_SQL_WORD2 = 16; + public const int SCE_SQL_COMMENTDOCKEYWORD = 17; + public const int SCE_SQL_COMMENTDOCKEYWORDERROR = 18; + public const int SCE_SQL_USER1 = 19; + public const int SCE_SQL_USER2 = 20; + public const int SCE_SQL_USER3 = 21; + public const int SCE_SQL_USER4 = 22; + public const int SCE_SQL_QUOTEDIDENTIFIER = 23; + public const int SCE_SQL_QOPERATOR = 24; + + // 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; + + // Ruby + public const int SCE_RB_DEFAULT = 0; + public const int SCE_RB_ERROR = 1; + public const int SCE_RB_COMMENTLINE = 2; + public const int SCE_RB_POD = 3; + public const int SCE_RB_NUMBER = 4; + public const int SCE_RB_WORD = 5; + public const int SCE_RB_STRING = 6; + public const int SCE_RB_CHARACTER = 7; + public const int SCE_RB_CLASSNAME = 8; + public const int SCE_RB_DEFNAME = 9; + public const int SCE_RB_OPERATOR = 10; + public const int SCE_RB_IDENTIFIER = 11; + public const int SCE_RB_REGEX = 12; + public const int SCE_RB_GLOBAL = 13; + public const int SCE_RB_SYMBOL = 14; + public const int SCE_RB_MODULE_NAME = 15; + public const int SCE_RB_INSTANCE_VAR = 16; + public const int SCE_RB_CLASS_VAR = 17; + public const int SCE_RB_BACKTICKS = 18; + public const int SCE_RB_DATASECTION = 19; + public const int SCE_RB_HERE_DELIM = 20; + public const int SCE_RB_HERE_Q = 21; + public const int SCE_RB_HERE_QQ = 22; + public const int SCE_RB_HERE_QX = 23; + public const int SCE_RB_STRING_Q = 24; + public const int SCE_RB_STRING_QQ = 25; + public const int SCE_RB_STRING_QX = 26; + public const int SCE_RB_STRING_QR = 27; + public const int SCE_RB_STRING_QW = 28; + public const int SCE_RB_WORD_DEMOTED = 29; + public const int SCE_RB_STDIN = 30; + public const int SCE_RB_STDOUT = 31; + public const int SCE_RB_STDERR = 40; + public const int SCE_RB_UPPER_BOUND = 41; + + // Smalltalk + public const int SCE_ST_DEFAULT = 0; + public const int SCE_ST_STRING = 1; + public const int SCE_ST_NUMBER = 2; + public const int SCE_ST_COMMENT = 3; + public const int SCE_ST_SYMBOL = 4; + public const int SCE_ST_BINARY = 5; + public const int SCE_ST_BOOL = 6; + public const int SCE_ST_SELF = 7; + public const int SCE_ST_SUPER = 8; + public const int SCE_ST_NIL = 9; + public const int SCE_ST_GLOBAL = 10; + public const int SCE_ST_RETURN = 11; + public const int SCE_ST_SPECIAL = 12; + public const int SCE_ST_KWSEND = 13; + public const int SCE_ST_ASSIGN = 14; + public const int SCE_ST_CHARACTER = 15; + public const int SCE_ST_SPEC_SEL = 16; + + // Basic / VB + 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; + + // Markdown + public const int SCE_MARKDOWN_DEFAULT = 0; + public const int SCE_MARKDOWN_LINE_BEGIN = 1; + public const int SCE_MARKDOWN_STRONG1 = 2; + public const int SCE_MARKDOWN_STRONG2 = 3; + public const int SCE_MARKDOWN_EM1 = 4; + public const int SCE_MARKDOWN_EM2 = 5; + public const int SCE_MARKDOWN_HEADER1 = 6; + public const int SCE_MARKDOWN_HEADER2 = 7; + public const int SCE_MARKDOWN_HEADER3 = 8; + public const int SCE_MARKDOWN_HEADER4 = 9; + public const int SCE_MARKDOWN_HEADER5 = 10; + public const int SCE_MARKDOWN_HEADER6 = 11; + public const int SCE_MARKDOWN_PRECHAR = 12; + public const int SCE_MARKDOWN_ULIST_ITEM = 13; + public const int SCE_MARKDOWN_OLIST_ITEM = 14; + public const int SCE_MARKDOWN_BLOCKQUOTE = 15; + public const int SCE_MARKDOWN_STRIKEOUT = 16; + public const int SCE_MARKDOWN_HRULE = 17; + public const int SCE_MARKDOWN_LINK = 18; + public const int SCE_MARKDOWN_CODE = 19; + public const int SCE_MARKDOWN_CODE2 = 20; + public const int SCE_MARKDOWN_CODEBK = 21; + + // R + public const int SCE_R_DEFAULT = 0; + public const int SCE_R_COMMENT = 1; + public const int SCE_R_KWORD = 2; + public const int SCE_R_BASEKWORD = 3; + public const int SCE_R_OTHERKWORD = 4; + public const int SCE_R_NUMBER = 5; + public const int SCE_R_STRING = 6; + public const int SCE_R_STRING2 = 7; + public const int SCE_R_OPERATOR = 8; + public const int SCE_R_IDENTIFIER = 9; + public const int SCE_R_INFIX = 10; + public const int SCE_R_INFIXEOL = 11; + + // Verilog + public const int SCE_V_DEFAULT = 0; + public const int SCE_V_COMMENT = 1; + public const int SCE_V_COMMENTLINE = 2; + public const int SCE_V_COMMENTLINEBANG = 3; + public const int SCE_V_NUMBER = 4; + public const int SCE_V_WORD = 5; + public const int SCE_V_STRING = 6; + public const int SCE_V_WORD2 = 7; + public const int SCE_V_WORD3 = 8; + public const int SCE_V_PREPROCESSOR = 9; + public const int SCE_V_OPERATOR = 10; + public const int SCE_V_IDENTIFIER = 11; + public const int SCE_V_STRINGEOL = 12; + public const int SCE_V_USER = 19; + public const int SCE_V_COMMENT_WORD = 20; + public const int SCE_V_INPUT = 21; + public const int SCE_V_OUTPUT = 22; + public const int SCE_V_INOUT = 23; + public const int SCE_V_PORT_CONNECT = 24; + + #endregion Lexer Constants + + #region Callbacks + + public delegate IntPtr Scintilla_DirectFunction(IntPtr ptr, int iMessage, IntPtr wParam, IntPtr lParam); + + public delegate IntPtr CreateLexer(string lexerName); + + public delegate void GetLexerName(UIntPtr index, IntPtr name, IntPtr bufferLength); + + public delegate IntPtr GetLexerCount(); + + public delegate string LexerNameFromID(IntPtr identifier); + + #endregion Callbacks + + #region Functions + + [DllImport(DLL_NAME_USER32, SetLastError = true)] + public static extern IntPtr MB_GetString(uint hInst); + + public static string GetMessageBoxString(uint msgId) => + Marshal.PtrToStringUni(MB_GetString(msgId)); + + [DllImport(DLL_NAME_USER32, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool CloseClipboard(); + + [DllImport(DLL_NAME_GDI32, ExactSpelling = true)] + public static extern int CombineRgn(IntPtr hrgnDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2, int fnCombineMode); + + [DllImport(DLL_NAME_GDI32, ExactSpelling = true)] + public static extern IntPtr CreateRectRgn(int x1, int y1, int x2, int y2); + + [DllImport(DLL_NAME_KERNEL32, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] + public static extern IntPtr GetProcAddress(HandleRef hModule, string lpProcName); + + [DllImport(DLL_NAME_USER32, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool EmptyClipboard(); + + [DllImport(DLL_NAME_USER32, ExactSpelling = true)] + public static extern IntPtr GetWindowDC(IntPtr hWnd); + + [DllImport(DLL_NAME_USER32, ExactSpelling = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); + + [DllImport(DLL_NAME_KERNEL32, EntryPoint = "LoadLibraryW", CharSet = CharSet.Unicode, SetLastError = true)] + public static extern IntPtr LoadLibrary(string lpFileName); + + [DllImport(DLL_NAME_KERNEL32, EntryPoint = "RtlMoveMemory", SetLastError = true)] + public static extern void MoveMemory(IntPtr dest, IntPtr src, int length); + + [DllImport(DLL_NAME_USER32, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool OpenClipboard(IntPtr hWndNewOwner); + + [DllImport(DLL_NAME_USER32, SetLastError = true)] + public static extern uint RegisterClipboardFormat(string lpszFormat); + + [DllImport(DLL_NAME_USER32, ExactSpelling = true)] + public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); + + [DllImport(DLL_NAME_OLE32, ExactSpelling = true)] + public static extern int RevokeDragDrop(IntPtr hwnd); + + [DllImport(DLL_NAME_USER32, EntryPoint = "SendMessageW", CharSet = CharSet.Unicode, SetLastError = true)] + public static extern IntPtr SendMessage(HandleRef hWnd, int msg, IntPtr wParam, IntPtr lParam); + + [DllImport(DLL_NAME_USER32, SetLastError = true)] + public static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem); + + [DllImport(DLL_NAME_USER32, SetLastError = true)] + public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); + + #endregion Functions + + #region Structures + + // http://www.openrce.org/articles/full_view/23 + // It's worth noting that this structure (and the 64-bit version below) 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 ILoaderVTable32 + { + public ReleaseDelegate Release; + public AddDataDelegate AddData; + public ConvertToDocumentDelegate ConvertToDocument; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate int ReleaseDelegate(IntPtr self); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate int AddDataDelegate(IntPtr self, byte* data, int length); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate IntPtr ConvertToDocumentDelegate(IntPtr self); + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct ILoaderVTable64 + { + public ReleaseDelegate Release; + public AddDataDelegate AddData; + public ConvertToDocumentDelegate ConvertToDocument; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int ReleaseDelegate(IntPtr self); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int AddDataDelegate(IntPtr self, byte* data, int length); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr ConvertToDocumentDelegate(IntPtr self); + } + + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int left; + public int top; + public int right; + public int bottom; + } + + [StructLayout(LayoutKind.Sequential)] + public struct Sci_CharacterRange + { + public int cpMin; + public int cpMax; + } + + [StructLayout(LayoutKind.Sequential)] + public struct Sci_CharacterRangeFull + { + public IntPtr cpMin; + public IntPtr 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 Sci_TextRangeFull + { + public Sci_CharacterRangeFull chrg; + public IntPtr lpstrText; + } + + [StructLayout(LayoutKind.Sequential)] + public struct Sci_TextToFind + { + public Sci_CharacterRange chrg; + public IntPtr lpstrText; + public Sci_CharacterRange chrgText; + } + + [StructLayout(LayoutKind.Sequential)] + public struct Sci_TextToFindFull + { + public Sci_CharacterRangeFull chrg; + public IntPtr lpstrText; + public Sci_CharacterRangeFull chrgText; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SCNotification + { + public Sci_NotifyHeader nmhdr; + public IntPtr position; + public int ch; + public int modifiers; + public int modificationType; + public IntPtr text; + public IntPtr length; + public IntPtr linesAdded; + public int message; + public IntPtr wParam; + public IntPtr lParam; + public IntPtr line; + public int foldLevelNow; + public int foldLevelPrev; + public int margin; + public int listType; + public int x; + public int y; + public int token; + public IntPtr annotationLinesAdded; + public int updated; + public int listCompletionMethod; + } + + #endregion Structures } - [StructLayout(LayoutKind.Sequential)] - public unsafe struct ILoaderVTable64 - { - public ReleaseDelegate Release; - public AddDataDelegate AddData; - public ConvertToDocumentDelegate ConvertToDocument; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate int ReleaseDelegate(IntPtr self); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate int AddDataDelegate(IntPtr self, byte* data, int length); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr ConvertToDocumentDelegate(IntPtr self); - } - - [StructLayout(LayoutKind.Sequential)] - public struct RECT - { - public int left; - public int top; - public int right; - public int bottom; - } - - [StructLayout(LayoutKind.Sequential)] - public struct Sci_CharacterRange - { - public int cpMin; - public int cpMax; - } - - [StructLayout(LayoutKind.Sequential)] - public struct Sci_CharacterRangeFull - { - public nint cpMin; - public nint 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 Sci_TextRangeFull - { - public Sci_CharacterRangeFull chrg; - public IntPtr lpstrText; - } - - [StructLayout(LayoutKind.Sequential)] - public struct Sci_TextToFind - { - public Sci_CharacterRange chrg; - public IntPtr lpstrText; - public Sci_CharacterRange chrgText; - } - - [StructLayout(LayoutKind.Sequential)] - public struct Sci_TextToFindFull - { - public Sci_CharacterRangeFull chrg; - public IntPtr lpstrText; - public Sci_CharacterRangeFull chrgText; - } - - [StructLayout(LayoutKind.Sequential)] - public struct SCNotification - { - public Sci_NotifyHeader nmhdr; - public IntPtr position; - public int ch; - public int modifiers; - public int modificationType; - public IntPtr text; - public IntPtr length; - public IntPtr linesAdded; - public int message; - public IntPtr wParam; - public IntPtr lParam; - public IntPtr line; - public int foldLevelNow; - public int foldLevelPrev; - public int margin; - public int listType; - public int x; - public int y; - public int token; - public IntPtr annotationLinesAdded; - public int updated; - public int listCompletionMethod; - } - - #endregion Structures -} - #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member +} diff --git a/Scintilla.NET/NeedShownEventArgs.cs b/Scintilla.NET/NeedShownEventArgs.cs index 38ea9db..dcbd346 100644 --- a/Scintilla.NET/NeedShownEventArgs.cs +++ b/Scintilla.NET/NeedShownEventArgs.cs @@ -1,61 +1,62 @@ using System; -namespace ScintillaNET; - -/// -/// Provides data for the event. -/// -public class NeedShownEventArgs : EventArgs +namespace ScintillaNET { - private readonly Scintilla scintilla; - private readonly int bytePosition; - private readonly int byteLength; - private int? position; - private int? length; - /// - /// Gets the length of the text that needs to be shown. + /// Provides data for the event. /// - /// The length of text starting at that needs to be shown. - public int Length + public class NeedShownEventArgs : EventArgs { - get + private readonly Scintilla scintilla; + private readonly int bytePosition; + private readonly int byteLength; + private int? position; + private int? length; + + /// + /// Gets the length of the text that needs to be shown. + /// + /// The length of text starting at that needs to be shown. + public int Length { - if (this.length == null) + get { - int endBytePosition = this.bytePosition + this.byteLength; - int endPosition = this.scintilla.Lines.ByteToCharPosition(endBytePosition); - this.length = endPosition - Position; - } + if (this.length == null) + { + int endBytePosition = this.bytePosition + this.byteLength; + int endPosition = this.scintilla.Lines.ByteToCharPosition(endBytePosition); + this.length = endPosition - Position; + } - return (int)this.length; + return (int)this.length; + } } - } - /// - /// Gets the zero-based document position where text needs to be shown. - /// - /// The zero-based document position where the range of text to be shown starts. - public int Position - { - get + /// + /// Gets the zero-based document position where text needs to be shown. + /// + /// The zero-based document position where the range of text to be shown starts. + public int Position { - this.position ??= this.scintilla.Lines.ByteToCharPosition(this.bytePosition); + get + { + this.position = this.position ?? this.scintilla.Lines.ByteToCharPosition(this.bytePosition); - return (int)this.position; + return (int)this.position; + } } - } - /// - /// Initializes a new instance of the class. - /// - /// The control that generated this event. - /// The zero-based byte position within the document where text needs to be shown. - /// The length in bytes of the text that needs to be shown. - public NeedShownEventArgs(Scintilla scintilla, int bytePosition, int byteLength) - { - this.scintilla = scintilla; - this.bytePosition = bytePosition; - this.byteLength = byteLength; + /// + /// Initializes a new instance of the class. + /// + /// The control that generated this event. + /// The zero-based byte position within the document where text needs to be shown. + /// The length in bytes of the text that needs to be shown. + public NeedShownEventArgs(Scintilla scintilla, int bytePosition, int byteLength) + { + this.scintilla = scintilla; + this.bytePosition = bytePosition; + this.byteLength = byteLength; + } } } diff --git a/Scintilla.NET/Order.cs b/Scintilla.NET/Order.cs index 65b8520..474a7f0 100644 --- a/Scintilla.NET/Order.cs +++ b/Scintilla.NET/Order.cs @@ -1,22 +1,23 @@ -namespace ScintillaNET; - -/// -/// The sorting order for autocompletion lists. -/// -public enum Order +namespace ScintillaNET { /// - /// Requires that an autocompletion lists be sorted in alphabetical order. This is the default. + /// The sorting order for autocompletion lists. /// - Presorted = NativeMethods.SC_ORDER_PRESORTED, + public enum Order + { + /// + /// Requires that an autocompletion lists be sorted in alphabetical order. This is the default. + /// + Presorted = NativeMethods.SC_ORDER_PRESORTED, - /// - /// Instructs a control to perform an alphabetical sort of autocompletion lists. - /// - PerformSort = NativeMethods.SC_ORDER_PERFORMSORT, + /// + /// Instructs a control to perform an alphabetical sort of autocompletion lists. + /// + PerformSort = NativeMethods.SC_ORDER_PERFORMSORT, - /// - /// User-defined order. - /// - Custom = NativeMethods.SC_ORDER_CUSTOM + /// + /// User-defined order. + /// + Custom = NativeMethods.SC_ORDER_CUSTOM + } } diff --git a/Scintilla.NET/Phases.cs b/Scintilla.NET/Phases.cs index 48c4adb..7305b8e 100644 --- a/Scintilla.NET/Phases.cs +++ b/Scintilla.NET/Phases.cs @@ -1,23 +1,24 @@ -namespace ScintillaNET; - -/// -/// The number of phases used when drawing. -/// -public enum Phases +namespace ScintillaNET { /// - /// Drawing is done in a single phase. This is the fastest but provides no support for kerning. + /// The number of phases used when drawing. /// - One = NativeMethods.SC_PHASES_ONE, + public enum Phases + { + /// + /// Drawing is done in a single phase. This is the fastest but provides no support for kerning. + /// + One = NativeMethods.SC_PHASES_ONE, - /// - /// Drawing is done in two phases; the background first and then the text. This is the default. - /// - Two = NativeMethods.SC_PHASES_TWO, + /// + /// Drawing is done in two phases; the background first and then the text. This is the default. + /// + Two = NativeMethods.SC_PHASES_TWO, - /// - /// Drawing is done in multiple phases; once for each feature. This is the slowest but allows - /// extreme ascenders and descenders to overflow into adjacent lines. - /// - Multiple = NativeMethods.SC_PHASES_MULTIPLE + /// + /// Drawing is done in multiple phases; once for each feature. This is the slowest but allows + /// extreme ascenders and descenders to overflow into adjacent lines. + /// + Multiple = NativeMethods.SC_PHASES_MULTIPLE + } } diff --git a/Scintilla.NET/PopupMode.cs b/Scintilla.NET/PopupMode.cs index 7c8ca6a..dd82abb 100644 --- a/Scintilla.NET/PopupMode.cs +++ b/Scintilla.NET/PopupMode.cs @@ -1,25 +1,26 @@ -namespace ScintillaNET; - -/// -/// Behavior of the standard edit control context menu. -/// -/// -public enum PopupMode +namespace ScintillaNET { /// - /// Never show the default editing menu. + /// Behavior of the standard edit control context menu. /// - Never = NativeMethods.SC_POPUP_NEVER, + /// + public enum PopupMode + { + /// + /// Never show the default editing menu. + /// + Never = NativeMethods.SC_POPUP_NEVER, - /// - /// Show default editing menu if clicking on the control. - /// - All = NativeMethods.SC_POPUP_ALL, + /// + /// Show default editing menu if clicking on the control. + /// + All = NativeMethods.SC_POPUP_ALL, - /// - /// Show default editing menu only if clicking on text area. - /// - /// To receive the event, this value must be used. - /// - Text = NativeMethods.SC_POPUP_TEXT + /// + /// Show default editing menu only if clicking on text area. + /// + /// To receive the event, this value must be used. + /// + Text = NativeMethods.SC_POPUP_TEXT + } } diff --git a/Scintilla.NET/ProjectionEqualityComparer.cs b/Scintilla.NET/ProjectionEqualityComparer.cs index 68afe8d..fc4301f 100644 --- a/Scintilla.NET/ProjectionEqualityComparer.cs +++ b/Scintilla.NET/ProjectionEqualityComparer.cs @@ -3,133 +3,135 @@ using System; using System.Collections.Generic; -namespace ScintillaNET; -/// -/// Non-generic class to produce instances of the generic class, -/// optionally using type inference. -/// -internal static class ProjectionEqualityComparer +namespace ScintillaNET { /// - /// Creates an instance of ProjectionEqualityComparer using the specified projection. + /// Non-generic class to produce instances of the generic class, + /// optionally using type inference. /// - /// Type parameter for the elements to be compared - /// Type parameter for the keys to be compared, - /// after being projected from the elements - /// Projection to use when determining the key of an element - /// A comparer which will compare elements by projecting - /// each element to its key, and comparing keys - public static ProjectionEqualityComparer Create(Func projection) + internal static class ProjectionEqualityComparer { - return new ProjectionEqualityComparer(projection); - } - - /// - /// Creates an instance of ProjectionEqualityComparer using the specified projection. - /// The ignored parameter is solely present to aid type inference. - /// - /// Type parameter for the elements to be compared - /// Type parameter for the keys to be compared, - /// after being projected from the elements - /// Value is ignored - type may be used by type inference - /// Projection to use when determining the key of an element - /// A comparer which will compare elements by projecting - /// each element to its key, and comparing keys - public static ProjectionEqualityComparer Create - (TSource ignored, - Func projection) - { - return new ProjectionEqualityComparer(projection); - } -} + /// + /// Creates an instance of ProjectionEqualityComparer using the specified projection. + /// + /// Type parameter for the elements to be compared + /// Type parameter for the keys to be compared, + /// after being projected from the elements + /// Projection to use when determining the key of an element + /// A comparer which will compare elements by projecting + /// each element to its key, and comparing keys + public static ProjectionEqualityComparer Create(Func projection) + { + return new ProjectionEqualityComparer(projection); + } -/// -/// Class generic in the source only to produce instances of the -/// doubly generic class, optionally using type inference. -/// -internal static class ProjectionEqualityComparer -{ - /// - /// Creates an instance of ProjectionEqualityComparer using the specified projection. - /// - /// Type parameter for the keys to be compared, - /// after being projected from the elements - /// Projection to use when determining the key of an element - /// A comparer which will compare elements by projecting each element to its key, - /// and comparing keys - public static ProjectionEqualityComparer Create(Func projection) - { - return new ProjectionEqualityComparer(projection); + /// + /// Creates an instance of ProjectionEqualityComparer using the specified projection. + /// The ignored parameter is solely present to aid type inference. + /// + /// Type parameter for the elements to be compared + /// Type parameter for the keys to be compared, + /// after being projected from the elements + /// Value is ignored - type may be used by type inference + /// Projection to use when determining the key of an element + /// A comparer which will compare elements by projecting + /// each element to its key, and comparing keys + public static ProjectionEqualityComparer Create + (TSource ignored, + Func projection) + { + return new ProjectionEqualityComparer(projection); + } } -} - -/// -/// Comparer which projects each element of the comparison to a key, and then compares -/// those keys using the specified (or default) comparer for the key type. -/// -/// Type of elements which this comparer -/// will be asked to compare -/// Type of the key projected -/// from the element -internal class ProjectionEqualityComparer : IEqualityComparer -{ - private readonly Func projection; - private readonly IEqualityComparer comparer; /// - /// Creates a new instance using the specified projection, which must not be null. - /// The default comparer for the projected type is used. + /// Class generic in the source only to produce instances of the + /// doubly generic class, optionally using type inference. /// - /// Projection to use during comparisons - public ProjectionEqualityComparer(Func projection) - : this(projection, null) + internal static class ProjectionEqualityComparer { + /// + /// Creates an instance of ProjectionEqualityComparer using the specified projection. + /// + /// Type parameter for the keys to be compared, + /// after being projected from the elements + /// Projection to use when determining the key of an element + /// A comparer which will compare elements by projecting each element to its key, + /// and comparing keys + public static ProjectionEqualityComparer Create(Func projection) + { + return new ProjectionEqualityComparer(projection); + } } /// - /// Creates a new instance using the specified projection, which must not be null. + /// Comparer which projects each element of the comparison to a key, and then compares + /// those keys using the specified (or default) comparer for the key type. /// - /// Projection to use during comparisons - /// The comparer to use on the keys. May be null, in - /// which case the default comparer will be used. - public ProjectionEqualityComparer(Func projection, IEqualityComparer comparer) + /// Type of elements which this comparer + /// will be asked to compare + /// Type of the key projected + /// from the element + internal class ProjectionEqualityComparer : IEqualityComparer { - this.comparer = comparer ?? EqualityComparer.Default; - this.projection = projection ?? throw new ArgumentNullException("projection"); - } + private readonly Func projection; + private readonly IEqualityComparer comparer; - /// - /// Compares the two specified values for equality by applying the projection - /// to each value and then using the equality comparer on the resulting keys. Null - /// references are never passed to the projection. - /// - public bool Equals(TSource x, TSource y) - { - if (x == null && y == null) + /// + /// Creates a new instance using the specified projection, which must not be null. + /// The default comparer for the projected type is used. + /// + /// Projection to use during comparisons + public ProjectionEqualityComparer(Func projection) + : this(projection, null) { - return true; } - if (x == null || y == null) + /// + /// Creates a new instance using the specified projection, which must not be null. + /// + /// Projection to use during comparisons + /// The comparer to use on the keys. May be null, in + /// which case the default comparer will be used. + public ProjectionEqualityComparer(Func projection, IEqualityComparer comparer) { - return false; + this.comparer = comparer ?? EqualityComparer.Default; + this.projection = projection ?? throw new ArgumentNullException("projection"); } - return this.comparer.Equals(this.projection(x), this.projection(y)); - } - - /// - /// Produces a hash code for the given value by projecting it and - /// then asking the equality comparer to find the hash code of - /// the resulting key. - /// - public int GetHashCode(TSource obj) - { - if (obj == null) + /// + /// Compares the two specified values for equality by applying the projection + /// to each value and then using the equality comparer on the resulting keys. Null + /// references are never passed to the projection. + /// + public bool Equals(TSource x, TSource y) { - throw new ArgumentNullException("obj"); + if (x == null && y == null) + { + return true; + } + + if (x == null || y == null) + { + return false; + } + + return this.comparer.Equals(this.projection(x), this.projection(y)); } - return this.comparer.GetHashCode(this.projection(obj)); + /// + /// Produces a hash code for the given value by projecting it and + /// then asking the equality comparer to find the hash code of + /// the resulting key. + /// + public int GetHashCode(TSource obj) + { + if (obj == null) + { + throw new ArgumentNullException("obj"); + } + + return this.comparer.GetHashCode(this.projection(obj)); + } } } diff --git a/Scintilla.NET/PropertyType.cs b/Scintilla.NET/PropertyType.cs index a27a358..7f4db95 100644 --- a/Scintilla.NET/PropertyType.cs +++ b/Scintilla.NET/PropertyType.cs @@ -1,22 +1,23 @@ -namespace ScintillaNET; - -/// -/// Lexer property types. -/// -public enum PropertyType +namespace ScintillaNET { /// - /// A Boolean property. This is the default. + /// Lexer property types. /// - Boolean = NativeMethods.SC_TYPE_BOOLEAN, + public enum PropertyType + { + /// + /// A Boolean property. This is the default. + /// + Boolean = NativeMethods.SC_TYPE_BOOLEAN, - /// - /// An integer property. - /// - Integer = NativeMethods.SC_TYPE_INTEGER, + /// + /// An integer property. + /// + Integer = NativeMethods.SC_TYPE_INTEGER, - /// - /// A string property. - /// - String = NativeMethods.SC_TYPE_STRING + /// + /// A string property. + /// + String = NativeMethods.SC_TYPE_STRING + } } diff --git a/Scintilla.NET/SCNotificationEventArgs.cs b/Scintilla.NET/SCNotificationEventArgs.cs index cdaac44..c8b7599 100644 --- a/Scintilla.NET/SCNotificationEventArgs.cs +++ b/Scintilla.NET/SCNotificationEventArgs.cs @@ -1,14 +1,15 @@ using System; -namespace ScintillaNET; - -// For internal use only -internal sealed class SCNotificationEventArgs : EventArgs +namespace ScintillaNET { - public NativeMethods.SCNotification SCNotification { get; private set; } - - public SCNotificationEventArgs(NativeMethods.SCNotification scn) + // For internal use only + internal sealed class SCNotificationEventArgs : EventArgs { - SCNotification = scn; + public NativeMethods.SCNotification SCNotification { get; private set; } + + public SCNotificationEventArgs(NativeMethods.SCNotification scn) + { + SCNotification = scn; + } } } diff --git a/Scintilla.NET/Scintilla.NET.csproj b/Scintilla.NET/Scintilla.NET.csproj index 4d62a83..e35d0af 100644 --- a/Scintilla.NET/Scintilla.NET.csproj +++ b/Scintilla.NET/Scintilla.NET.csproj @@ -12,9 +12,6 @@ bin\$(Configuration)\ AnyCPU - - latest - SCINTILLA5 diff --git a/Scintilla.NET/Scintilla.cs b/Scintilla.NET/Scintilla.cs index 42982ce..4099953 100644 --- a/Scintilla.NET/Scintilla.cs +++ b/Scintilla.NET/Scintilla.cs @@ -23,7 +23,7 @@ public class Scintilla : Control { static Scintilla() { - List searchedPathList = []; + var searchedPathList = new List(); foreach (string path in EnumerateSatelliteLibrarySearchPaths()) { string scintillaDllPath = Path.Combine(path, "Scintilla.dll"); @@ -62,12 +62,15 @@ static Scintilla() private static bool InDesignProcess() { - using var proc = Process.GetCurrentProcess(); - string procName = proc.ProcessName; - return - procName is "devenv" or "DesignToolsServer" or // WinForms app in VS IDE - "xdesproc" or // WPF app in VS IDE/Blend - "blend"; + using (var proc = Process.GetCurrentProcess()) + { + string procName = proc.ProcessName; + return + procName == "devenv" || + procName == "DesignToolsServer" || // WinForms app in VS IDE + procName == "xdesproc" || // WPF app in VS IDE/Blend + procName == "blend"; + } } /// @@ -116,39 +119,39 @@ public static IEnumerable EnumerateSatelliteLibrarySearchPaths() private static Lexilla lexilla; // Events - private static readonly object scNotificationEventKey = new(); - private static readonly object insertCheckEventKey = new(); - private static readonly object beforeInsertEventKey = new(); - private static readonly object beforeDeleteEventKey = new(); - private static readonly object insertEventKey = new(); - private static readonly object deleteEventKey = new(); - private static readonly object updateUIEventKey = new(); - private static readonly object modifyAttemptEventKey = new(); - private static readonly object styleNeededEventKey = new(); - private static readonly object savePointReachedEventKey = new(); - private static readonly object savePointLeftEventKey = new(); - private static readonly object changeAnnotationEventKey = new(); - private static readonly object marginClickEventKey = new(); - private static readonly object marginRightClickEventKey = new(); - private static readonly object charAddedEventKey = new(); - private static readonly object autoCSelectionEventKey = new(); - private static readonly object autoCSelectionChangeEventKey = new(); - private static readonly object autoCCompletedEventKey = new(); - private static readonly object autoCCancelledEventKey = new(); - private static readonly object autoCCharDeletedEventKey = new(); - private static readonly object dwellStartEventKey = new(); - private static readonly object callTipClickEventKey = new(); - private static readonly object dwellEndEventKey = new(); - private static readonly object borderStyleChangedEventKey = new(); - private static readonly object doubleClickEventKey = new(); - private static readonly object paintedEventKey = new(); - private static readonly object needShownEventKey = new(); - private static readonly object hotspotClickEventKey = new(); - private static readonly object hotspotDoubleClickEventKey = new(); - private static readonly object hotspotReleaseClickEventKey = new(); - private static readonly object indicatorClickEventKey = new(); - private static readonly object indicatorReleaseEventKey = new(); - private static readonly object zoomChangedEventKey = new(); + 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 marginRightClickEventKey = new object(); + private static readonly object charAddedEventKey = new object(); + private static readonly object autoCSelectionEventKey = new object(); + private static readonly object autoCSelectionChangeEventKey = new object(); + private static readonly object autoCCompletedEventKey = 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 callTipClickEventKey = new object(); + private static readonly object dwellEndEventKey = new object(); + private static readonly object borderStyleChangedEventKey = new object(); + private static readonly object doubleClickEventKey = new object(); + private static readonly object paintedEventKey = new object(); + private static readonly object needShownEventKey = new object(); + private static readonly object hotspotClickEventKey = new object(); + private static readonly object hotspotDoubleClickEventKey = new object(); + private static readonly object hotspotReleaseClickEventKey = new object(); + private static readonly object indicatorClickEventKey = new object(); + private static readonly object indicatorReleaseEventKey = new object(); + private static readonly object zoomChangedEventKey = new object(); // The goods private IntPtr sciPtr; @@ -349,7 +352,7 @@ public unsafe void AutoCSetFillUps(string chars) // That means we need to keep a copy of the string around for the life of the control AND put it // in a place where it won't get moved by the GC. - chars ??= string.Empty; + chars = chars ?? string.Empty; if (this.fillUpChars != IntPtr.Zero) { @@ -1012,7 +1015,7 @@ public unsafe int FindText(SearchFlags searchFlags, string text, int start, int fixed (byte* bp = bytes) { - NativeMethods.Sci_TextToFind textToFind = new NativeMethods.Sci_TextToFind() { + var textToFind = new NativeMethods.Sci_TextToFind() { chrg = new NativeMethods.Sci_CharacterRange() { cpMin = Lines.CharToBytePosition(Helpers.Clamp(start, 0, TextLength)), cpMax = Lines.CharToBytePosition(Helpers.Clamp(end, 0, TextLength)), @@ -1310,146 +1313,284 @@ public unsafe string GetWideTextRange(int position, int length) /// public string GetLexerIDFromLexer(Lexer lexer) { - return lexer switch - { - Lexer.SCLEX_A68K => "a68k", - Lexer.SCLEX_ADPL => "apdl", - Lexer.SCLEX_ASYMPTOTE => "asy", - Lexer.SCLEX_AU3 => "au3", - Lexer.SCLEX_AVE => "ave", - Lexer.SCLEX_AVS => "avs", - Lexer.SCLEX_ABAQUS => "abaqus", - Lexer.SCLEX_ADA => "ada", - Lexer.SCLEX_ASCIIDOC => "asciidoc", - Lexer.SCLEX_ASM => "asm", - Lexer.SCLEX_AS => "as", - Lexer.SCLEX_ASN1 => "asn1", - Lexer.SCLEX_BAAN => "baan", - Lexer.SCLEX_BASH => "bash", - Lexer.SCLEX_BLITZBASIC => "blitzbasic", - Lexer.SCLEX_PUREBASIC => "purebasic", - Lexer.SCLEX_FREEBASIC => "freebasic", - Lexer.SCLEX_BATCH => "batch", - Lexer.SCLEX_BIBTEX => "bibtex", - Lexer.SCLEX_BULLANT => "bullant", - Lexer.SCLEX_CIL => "cil", - Lexer.SCLEX_CLW => "clarion", - Lexer.SCLEX_CLWNOCASE => "clarionnocase", - Lexer.SCLEX_COBOL => "COBOL", - Lexer.SCLEX_CPP => "cpp", - Lexer.SCLEX_CPPNOCASE => "cppnocase", - Lexer.SCLEX_CSHARP => "cpp", - Lexer.SCLEX_JAVA => "cpp", - Lexer.SCLEX_JAVASCRIPT => "cpp", - Lexer.SCLEX_CSS => "css", - Lexer.SCLEX_CAML => "caml", - Lexer.SCLEX_CMAKE => "cmake", - Lexer.SCLEX_COFFEESCRIPT => "coffeescript", - Lexer.SCLEX_CONF => "conf", - Lexer.SCLEX_NNCRONTAB => "nncrontab", - Lexer.SCLEX_CSOUND => "csound", - Lexer.SCLEX_D => "d", - Lexer.SCLEX_DMAP => "DMAP", - Lexer.SCLEX_DMIS => "DMIS", - Lexer.SCLEX_DATAFLEX => "dataflex", - Lexer.SCLEX_DIFF => "diff", - Lexer.SCLEX_ECL => "ecl", - Lexer.SCLEX_EDIFACT => "edifact", - Lexer.SCLEX_ESCRIPT => "escript", - Lexer.SCLEX_EIFFEL => "eiffel", - Lexer.SCLEX_EIFFELKW => "eiffelkw", - Lexer.SCLEX_ERLANG => "erlang", - Lexer.SCLEX_ERRORLIST => "errorlist", - Lexer.SCLEX_FSHARP => "fsharp", - Lexer.SCLEX_FLAGSHIP => "flagship", - Lexer.SCLEX_FORTH => "forth", - Lexer.SCLEX_FORTRAN => "fortran", - Lexer.SCLEX_F77 => "f77", - Lexer.SCLEX_GAP => "gap", - Lexer.SCLEX_GDSCRIPT => "gdscript", - Lexer.SCLEX_GUI4CLI => "gui4cli", - Lexer.SCLEX_HTML => "hypertext", - Lexer.SCLEX_XML => "xml", - Lexer.SCLEX_PHPSCRIPT => "phpscript", - Lexer.SCLEX_HASKELL => "haskell", - Lexer.SCLEX_LITERATEHASKELL => "literatehaskell", - Lexer.SCLEX_SREC => "srec", - Lexer.SCLEX_IHEX => "ihex", - Lexer.SCLEX_TEHEX => "tehex", - Lexer.SCLEX_HOLLYWOOD => "hollywood", - Lexer.SCLEX_INDENT => "indent", - Lexer.SCLEX_INNOSETUP => "inno", - Lexer.SCLEX_JSON => "json", - Lexer.SCLEX_JULIA => "julia", - Lexer.SCLEX_KIX => "kix", - Lexer.SCLEX_KVIRC => "kvirc", - Lexer.SCLEX_LATEX => "latex", - Lexer.SCLEX_LISP => "lisp", - Lexer.SCLEX_LOUT => "lout", - Lexer.SCLEX_LUA => "lua", - Lexer.SCLEX_MMIXAL => "mmixal", - Lexer.SCLEX_LOT => "lot", - Lexer.SCLEX_MSSQL => "mssql", - Lexer.SCLEX_MAGIK => "magiksf", - Lexer.SCLEX_MAKEFILE => "makefile", - Lexer.SCLEX_MARKDOWN => "markdown", - Lexer.SCLEX_MATLAB => "matlab", - Lexer.SCLEX_OCTAVE => "octave", - Lexer.SCLEX_MAXIMA => "maxima", - Lexer.SCLEX_METAPOST => "metapost", - Lexer.SCLEX_MODULA => "modula", - Lexer.SCLEX_MYSQL => "mysql", - Lexer.SCLEX_NIM => "nim", - Lexer.SCLEX_NIMROD => "nimrod", - Lexer.SCLEX_NSIS => "nsis", - Lexer.SCLEX_NULL => "null", - Lexer.SCLEX_OSCRIPT => "oscript", - Lexer.SCLEX_OPAL => "opal", - Lexer.SCLEX_POWERBASIC => "powerbasic", - Lexer.SCLEX_PLM => "PL/M", - Lexer.SCLEX_PO => "po", - Lexer.SCLEX_POV => "pov", - Lexer.SCLEX_POSTSCRIPT => "ps", - Lexer.SCLEX_PASCAL => "pascal", - Lexer.SCLEX_PERL => "perl", - Lexer.SCLEX_POWERPRO => "powerpro", - Lexer.SCLEX_POWERSHELL => "powershell", - Lexer.SCLEX_PROGRESS => "abl", - Lexer.SCLEX_PROPERTIES => "props", - Lexer.SCLEX_PYTHON => "python", - Lexer.SCLEX_R => "r", - Lexer.SCLEX_S => "r", - Lexer.SCLEX_SPLUS => "r", - Lexer.SCLEX_RAKU => "raku", - Lexer.SCLEX_REBOL => "rebol", - Lexer.SCLEX_REGISTRY => "registry", - Lexer.SCLEX_RUBY => "ruby", - Lexer.SCLEX_RUST => "rust", - Lexer.SCLEX_SAS => "sas", - Lexer.SCLEX_SML => "SML", - Lexer.SCLEX_SQL => "sql", - Lexer.SCLEX_STTXT => "fcST", - Lexer.SCLEX_SCRIPTOL => "scriptol", - Lexer.SCLEX_SMALLTALK => "smalltalk", - Lexer.SCLEX_SORCUS => "sorcins", - Lexer.SCLEX_SPECMAN => "specman", - Lexer.SCLEX_SPICE => "spice", - Lexer.SCLEX_STATA => "stata", - Lexer.SCLEX_TACL => "TACL", - Lexer.SCLEX_TADS3 => "tads3", - Lexer.SCLEX_TAL => "TAL", - Lexer.SCLEX_TCL => "tcl", - Lexer.SCLEX_TCMD => "tcmd", - Lexer.SCLEX_TEX => "tex", - Lexer.SCLEX_TXT2TAGS => "txt2tags", - Lexer.SCLEX_VB => "vb", - Lexer.SCLEX_VBSCRIPT => "vbscript", - Lexer.SCLEX_VHDL => "vhdl", - Lexer.SCLEX_VERILOG => "verilog", - Lexer.SCLEX_VISUALPROLOG => "visualprolog", - Lexer.SCLEX_X12 => "x12", - Lexer.SCLEX_YAML => "yaml", - _ => throw new ArgumentOutOfRangeException(nameof(lexer), lexer, null), + switch (lexer) + { + case Lexer.SCLEX_A68K: + return "a68k"; + case Lexer.SCLEX_ADPL: + return "apdl"; + case Lexer.SCLEX_ASYMPTOTE: + return "asy"; + case Lexer.SCLEX_AU3: + return "au3"; + case Lexer.SCLEX_AVE: + return "ave"; + case Lexer.SCLEX_AVS: + return "avs"; + case Lexer.SCLEX_ABAQUS: + return "abaqus"; + case Lexer.SCLEX_ADA: + return "ada"; + case Lexer.SCLEX_ASCIIDOC: + return "asciidoc"; + case Lexer.SCLEX_ASM: + return "asm"; + case Lexer.SCLEX_AS: + return "as"; + case Lexer.SCLEX_ASN1: + return "asn1"; + case Lexer.SCLEX_BAAN: + return "baan"; + case Lexer.SCLEX_BASH: + return "bash"; + case Lexer.SCLEX_BLITZBASIC: + return "blitzbasic"; + case Lexer.SCLEX_PUREBASIC: + return "purebasic"; + case Lexer.SCLEX_FREEBASIC: + return "freebasic"; + case Lexer.SCLEX_BATCH: + return "batch"; + case Lexer.SCLEX_BIBTEX: + return "bibtex"; + case Lexer.SCLEX_BULLANT: + return "bullant"; + case Lexer.SCLEX_CIL: + return "cil"; + case Lexer.SCLEX_CLW: + return "clarion"; + case Lexer.SCLEX_CLWNOCASE: + return "clarionnocase"; + case Lexer.SCLEX_COBOL: + return "COBOL"; + case Lexer.SCLEX_CPP: + return "cpp"; + case Lexer.SCLEX_CPPNOCASE: + return "cppnocase"; + case Lexer.SCLEX_CSHARP: + return "cpp"; + case Lexer.SCLEX_JAVA: + return "cpp"; + case Lexer.SCLEX_JAVASCRIPT: + return "cpp"; + case Lexer.SCLEX_CSS: + return "css"; + case Lexer.SCLEX_CAML: + return "caml"; + case Lexer.SCLEX_CMAKE: + return "cmake"; + case Lexer.SCLEX_COFFEESCRIPT: + return "coffeescript"; + case Lexer.SCLEX_CONF: + return "conf"; + case Lexer.SCLEX_NNCRONTAB: + return "nncrontab"; + case Lexer.SCLEX_CSOUND: + return "csound"; + case Lexer.SCLEX_D: + return "d"; + case Lexer.SCLEX_DMAP: + return "DMAP"; + case Lexer.SCLEX_DMIS: + return "DMIS"; + case Lexer.SCLEX_DATAFLEX: + return "dataflex"; + case Lexer.SCLEX_DIFF: + return "diff"; + case Lexer.SCLEX_ECL: + return "ecl"; + case Lexer.SCLEX_EDIFACT: + return "edifact"; + case Lexer.SCLEX_ESCRIPT: + return "escript"; + case Lexer.SCLEX_EIFFEL: + return "eiffel"; + case Lexer.SCLEX_EIFFELKW: + return "eiffelkw"; + case Lexer.SCLEX_ERLANG: + return "erlang"; + case Lexer.SCLEX_ERRORLIST: + return "errorlist"; + case Lexer.SCLEX_FSHARP: + return "fsharp"; + case Lexer.SCLEX_FLAGSHIP: + return "flagship"; + case Lexer.SCLEX_FORTH: + return "forth"; + case Lexer.SCLEX_FORTRAN: + return "fortran"; + case Lexer.SCLEX_F77: + return "f77"; + case Lexer.SCLEX_GAP: + return "gap"; + case Lexer.SCLEX_GDSCRIPT: + return "gdscript"; + case Lexer.SCLEX_GUI4CLI: + return "gui4cli"; + case Lexer.SCLEX_HTML: + return "hypertext"; + case Lexer.SCLEX_XML: + return "xml"; + case Lexer.SCLEX_PHPSCRIPT: + return "phpscript"; + case Lexer.SCLEX_HASKELL: + return "haskell"; + case Lexer.SCLEX_LITERATEHASKELL: + return "literatehaskell"; + case Lexer.SCLEX_SREC: + return "srec"; + case Lexer.SCLEX_IHEX: + return "ihex"; + case Lexer.SCLEX_TEHEX: + return "tehex"; + case Lexer.SCLEX_HOLLYWOOD: + return "hollywood"; + case Lexer.SCLEX_INDENT: + return "indent"; + case Lexer.SCLEX_INNOSETUP: + return "inno"; + case Lexer.SCLEX_JSON: + return "json"; + case Lexer.SCLEX_JULIA: + return "julia"; + case Lexer.SCLEX_KIX: + return "kix"; + case Lexer.SCLEX_KVIRC: + return "kvirc"; + case Lexer.SCLEX_LATEX: + return "latex"; + case Lexer.SCLEX_LISP: + return "lisp"; + case Lexer.SCLEX_LOUT: + return "lout"; + case Lexer.SCLEX_LUA: + return "lua"; + case Lexer.SCLEX_MMIXAL: + return "mmixal"; + case Lexer.SCLEX_LOT: + return "lot"; + case Lexer.SCLEX_MSSQL: + return "mssql"; + case Lexer.SCLEX_MAGIK: + return "magiksf"; + case Lexer.SCLEX_MAKEFILE: + return "makefile"; + case Lexer.SCLEX_MARKDOWN: + return "markdown"; + case Lexer.SCLEX_MATLAB: + return "matlab"; + case Lexer.SCLEX_OCTAVE: + return "octave"; + case Lexer.SCLEX_MAXIMA: + return "maxima"; + case Lexer.SCLEX_METAPOST: + return "metapost"; + case Lexer.SCLEX_MODULA: + return "modula"; + case Lexer.SCLEX_MYSQL: + return "mysql"; + case Lexer.SCLEX_NIM: + return "nim"; + case Lexer.SCLEX_NIMROD: + return "nimrod"; + case Lexer.SCLEX_NSIS: + return "nsis"; + case Lexer.SCLEX_NULL: + return "null"; + case Lexer.SCLEX_OSCRIPT: + return "oscript"; + case Lexer.SCLEX_OPAL: + return "opal"; + case Lexer.SCLEX_POWERBASIC: + return "powerbasic"; + case Lexer.SCLEX_PLM: + return "PL/M"; + case Lexer.SCLEX_PO: + return "po"; + case Lexer.SCLEX_POV: + return "pov"; + case Lexer.SCLEX_POSTSCRIPT: + return "ps"; + case Lexer.SCLEX_PASCAL: + return "pascal"; + case Lexer.SCLEX_PERL: + return "perl"; + case Lexer.SCLEX_POWERPRO: + return "powerpro"; + case Lexer.SCLEX_POWERSHELL: + return "powershell"; + case Lexer.SCLEX_PROGRESS: + return "abl"; + case Lexer.SCLEX_PROPERTIES: + return "props"; + case Lexer.SCLEX_PYTHON: + return "python"; + case Lexer.SCLEX_R: + return "r"; + case Lexer.SCLEX_S: + return "r"; + case Lexer.SCLEX_SPLUS: + return "r"; + case Lexer.SCLEX_RAKU: + return "raku"; + case Lexer.SCLEX_REBOL: + return "rebol"; + case Lexer.SCLEX_REGISTRY: + return "registry"; + case Lexer.SCLEX_RUBY: + return "ruby"; + case Lexer.SCLEX_RUST: + return "rust"; + case Lexer.SCLEX_SAS: + return "sas"; + case Lexer.SCLEX_SML: + return "SML"; + case Lexer.SCLEX_SQL: + return "sql"; + case Lexer.SCLEX_STTXT: + return "fcST"; + case Lexer.SCLEX_SCRIPTOL: + return "scriptol"; + case Lexer.SCLEX_SMALLTALK: + return "smalltalk"; + case Lexer.SCLEX_SORCUS: + return "sorcins"; + case Lexer.SCLEX_SPECMAN: + return "specman"; + case Lexer.SCLEX_SPICE: + return "spice"; + case Lexer.SCLEX_STATA: + return "stata"; + case Lexer.SCLEX_TACL: + return "TACL"; + case Lexer.SCLEX_TADS3: + return "tads3"; + case Lexer.SCLEX_TAL: + return "TAL"; + case Lexer.SCLEX_TCL: + return "tcl"; + case Lexer.SCLEX_TCMD: + return "tcmd"; + case Lexer.SCLEX_TEX: + return "tex"; + case Lexer.SCLEX_TXT2TAGS: + return "txt2tags"; + case Lexer.SCLEX_VB: + return "vb"; + case Lexer.SCLEX_VBSCRIPT: + return "vbscript"; + case Lexer.SCLEX_VHDL: + return "vhdl"; + case Lexer.SCLEX_VERILOG: + return "verilog"; + case Lexer.SCLEX_VISUALPROLOG: + return "visualprolog"; + case Lexer.SCLEX_X12: + return "x12"; + case Lexer.SCLEX_YAML: + return "yaml"; + default: + throw new ArgumentOutOfRangeException(nameof(lexer), lexer, null); }; } @@ -2320,7 +2461,7 @@ public unsafe void ReplaceSelection(string text) /// public unsafe int ReplaceTarget(string text) { - text ??= string.Empty; + text = text ?? string.Empty; byte[] bytes = Helpers.GetBytes(text, Encoding, false); // Scintilla asserts that lParam is not null, so make sure it isn't @@ -2682,7 +2823,7 @@ public unsafe void SetKeywords(int set, string keywords) public static void SetDestroyHandleBehavior(bool reparent) { // WM_DESTROY workaround - Scintilla.reparentAll ??= reparent; + Scintilla.reparentAll = Scintilla.reparentAll ?? reparent; } /// @@ -3131,15 +3272,17 @@ private void WmNcPaint(ref Message m) IntPtr hDC = NativeMethods.GetWindowDC(m.HWnd); try { - using var graphics = Graphics.FromHdc(hDC); - // Clip everything except the border - var bounds = new Rectangle(0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top); - graphics.ExcludeClip(Rectangle.Inflate(bounds, -borderSize.Width, -borderSize.Height)); - - // Paint the theme border - if (this.renderer.IsBackgroundPartiallyTransparent()) - this.renderer.DrawParentBackground(graphics, bounds, this); - this.renderer.DrawBackground(graphics, bounds); + using (var graphics = Graphics.FromHdc(hDC)) + { + // Clip everything except the border + var bounds = new Rectangle(0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top); + graphics.ExcludeClip(Rectangle.Inflate(bounds, -borderSize.Width, -borderSize.Height)); + + // Paint the theme border + if (this.renderer.IsBackgroundPartiallyTransparent()) + this.renderer.DrawParentBackground(graphics, bounds, this); + this.renderer.DrawBackground(graphics, bounds); + } } finally { @@ -3166,7 +3309,7 @@ private void WmReflectNotify(ref Message m) { // A standard Windows notification and a Scintilla notification header are compatible var scn = (NativeMethods.SCNotification)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.SCNotification)); - if (scn.nmhdr.code is >= NativeMethods.SCN_STYLENEEDED and <= NativeMethods.SCN_AUTOCSELECTIONCHANGE) + if (scn.nmhdr.code >= NativeMethods.SCN_STYLENEEDED && scn.nmhdr.code <= NativeMethods.SCN_AUTOCSELECTIONCHANGE) { if (Events[scNotificationEventKey] is EventHandler handler) handler(this, new SCNotificationEventArgs(scn)); @@ -4925,7 +5068,7 @@ public override Font Font set { Style defaultFontStyle = Styles[Style.Default]; - value ??= Parent?.Font ?? Control.DefaultFont; + value = value ?? Parent?.Font ?? Control.DefaultFont; defaultFontStyle.Font = value.Name; defaultFontStyle.SizeF = value.Size; defaultFontStyle.Bold = value.Bold; @@ -5167,7 +5310,7 @@ public string LexerName if (!SetLexerByName(value)) { - throw new InvalidOperationException(@$"Lexer with the name of '{value}' was not found."); + throw new InvalidOperationException($@"Lexer with the name of '{value}' was not found."); } this.lexerName = value; @@ -6371,7 +6514,7 @@ public override unsafe string Text // 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. - string text = new((sbyte*)ptr, 0, length, Encoding); + string text = new string((sbyte*)ptr, 0, length, Encoding); return text; } set diff --git a/Scintilla.NET/ScintillaDesigner.cs b/Scintilla.NET/ScintillaDesigner.cs index cc1d003..dff7051 100644 --- a/Scintilla.NET/ScintillaDesigner.cs +++ b/Scintilla.NET/ScintillaDesigner.cs @@ -1,42 +1,40 @@ using System; using System.Collections; -using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms.Design; -namespace ScintillaNET; - -internal class ScintillaDesigner : ControlDesigner +namespace ScintillaNET { - protected override void PreFilterProperties(IDictionary properties) + internal class ScintillaDesigner : ControlDesigner { - base.PreFilterProperties(properties); - - var scrollWidthTracking = (PropertyDescriptor)properties[nameof(Scintilla.ScrollWidthTracking)]; - scrollWidthTracking = TypeDescriptor.CreateProperty( - scrollWidthTracking.ComponentType, - scrollWidthTracking, - scrollWidthTracking.Attributes.Cast().Concat([new RefreshPropertiesAttribute(RefreshProperties.All)]).ToArray() - ); - properties[nameof(Scintilla.ScrollWidthTracking)] = scrollWidthTracking; - - var scrollWidth = (PropertyDescriptor)properties[nameof(Scintilla.ScrollWidth)]; - if ((bool)scrollWidthTracking.GetValue(Component)) + protected override void PreFilterProperties(IDictionary properties) { - scrollWidth = TypeDescriptor.CreateProperty( - scrollWidth.ComponentType, - scrollWidth, - scrollWidth.Attributes.Cast().Concat( - [ - new BrowsableAttribute(false), - new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden), - ] - ).ToArray() + base.PreFilterProperties(properties); + + var scrollWidthTracking = (PropertyDescriptor)properties[nameof(Scintilla.ScrollWidthTracking)]; + scrollWidthTracking = TypeDescriptor.CreateProperty( + scrollWidthTracking.ComponentType, + scrollWidthTracking, + scrollWidthTracking.Attributes.Cast().Concat(new Attribute[] { new RefreshPropertiesAttribute(RefreshProperties.All) }).ToArray() ); - properties[nameof(Scintilla.ScrollWidth)] = scrollWidth; + properties[nameof(Scintilla.ScrollWidthTracking)] = scrollWidthTracking; + + var scrollWidth = (PropertyDescriptor)properties[nameof(Scintilla.ScrollWidth)]; + if ((bool)scrollWidthTracking.GetValue(Component)) + { + scrollWidth = TypeDescriptor.CreateProperty( + scrollWidth.ComponentType, + scrollWidth, + scrollWidth.Attributes.Cast().Concat( + new Attribute[] { + new BrowsableAttribute(false), + new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden), + } + ).ToArray() + ); + properties[nameof(Scintilla.ScrollWidth)] = scrollWidth; + } } } } diff --git a/Scintilla.NET/ScintillaReader.cs b/Scintilla.NET/ScintillaReader.cs index a8da89b..79b808e 100644 --- a/Scintilla.NET/ScintillaReader.cs +++ b/Scintilla.NET/ScintillaReader.cs @@ -1,190 +1,191 @@ using System; using System.IO; -namespace ScintillaNET; - -/// -/// Implements a TextReader that reads from a Scintilla control. -/// -public class ScintillaReader : TextReader +namespace ScintillaNET { /// - /// Arbitrarily chosen default buffer size + /// Implements a TextReader that reads from a Scintilla control. /// - private const int DefaultBufferSize = 256; + public class ScintillaReader : TextReader + { + /// + /// Arbitrarily chosen default buffer size + /// + private const int DefaultBufferSize = 256; - /// - /// Returns the number of buffered characters left to be read. - /// - private int BufferRemaining => this._data != null ? this._data.Length - this._dataIndex : 0; - /// - /// Returns the number of unbuffered characters left to be read. - /// - private int UnbufferedRemaining => this._lastData - this._nextData; - /// - /// Returns the total number of characters left to be read. - /// - private int TotalRemaining => BufferRemaining + UnbufferedRemaining; + /// + /// Returns the number of buffered characters left to be read. + /// + private int BufferRemaining => this._data != null ? this._data.Length - this._dataIndex : 0; + /// + /// Returns the number of unbuffered characters left to be read. + /// + private int UnbufferedRemaining => this._lastData - this._nextData; + /// + /// Returns the total number of characters left to be read. + /// + private int TotalRemaining => BufferRemaining + UnbufferedRemaining; - private readonly Scintilla _scintilla; - private readonly int _bufferSize; - private string _data; - private int _dataIndex; - private int _nextData; - private readonly int _lastData; + private readonly Scintilla _scintilla; + private readonly int _bufferSize; + private string _data; + private int _dataIndex; + private int _nextData; + private readonly int _lastData; - /// - /// Initializes a new instance of the ScintillaReader class that reads all text from the specified Scintilla control. - /// - /// The Scintilla control from which to read. - public ScintillaReader(Scintilla scintilla) - : this(scintilla, 0, scintilla.TextLength) - { - } - /// - /// Initializes a new instance of the ScintillaReader class that reads all text from the specified Scintilla control. - /// - /// The Scintilla control from which to read. - /// The number of characters to buffer at a time. - public ScintillaReader(Scintilla scintilla, int bufferSize) - : this(scintilla, 0, scintilla.TextLength, bufferSize) - { - } - /// - /// Initializes a new instance of the ScintillaReader class that reads a subsection from the specified Scintilla control. - /// - /// The Scintilla control from which to read. - /// The index of the first character to read. - /// The index just past the last character to read. - public ScintillaReader(Scintilla scintilla, int start, int end) - : this(scintilla, start, end, DefaultBufferSize) - { - } - /// - /// Initializes a new instance of the ScintillaReader class that reads a subsection from the specified Scintilla control. - /// - /// The Scintilla control from which to read. - /// The index of the first character to read. - /// The index just past the last character to read. - /// The number of characters to buffer at a time. - public ScintillaReader(Scintilla scintilla, int start, int end, int bufferSize) - { - this._scintilla = scintilla; - this._bufferSize = bufferSize > 0 ? bufferSize : DefaultBufferSize; - this._nextData = start; - this._lastData = end; - // ensure start state is valid - BufferNextRegion(); - } - - /// - /// Returns the next character to be read from the reader without actually removing it from the stream. Returns -1 if no characters are available. - /// - /// The next character from the input stream, or -1 if no more characters are available. - public override int Peek() - { - // _data is set to null upon EOF - return this._data != null ? this._data[this._dataIndex] : -1; - } - /// - /// Removes a character from the stream and returns it. Returns -1 if no characters are available. - /// - /// The next character from the input stream, or -1 if no more characters are available. - public override int Read() - { - if (this._data != null) + /// + /// Initializes a new instance of the ScintillaReader class that reads all text from the specified Scintilla control. + /// + /// The Scintilla control from which to read. + public ScintillaReader(Scintilla scintilla) + : this(scintilla, 0, scintilla.TextLength) { - // EOF not reached - char n = this._data[this._dataIndex++]; - if (this._dataIndex >= this._data.Length) - { - // end of buffer reached; load next section - BufferNextRegion(); - } - - return n; } - else + /// + /// Initializes a new instance of the ScintillaReader class that reads all text from the specified Scintilla control. + /// + /// The Scintilla control from which to read. + /// The number of characters to buffer at a time. + public ScintillaReader(Scintilla scintilla, int bufferSize) + : this(scintilla, 0, scintilla.TextLength, bufferSize) { - return -1; } - } - /// - /// Reads a maximum of count characters from the current stream and writes the data to buffer, beginning at index. - /// - /// The buffer to receive the characters. - /// The position in buffer at which to begin writing. - /// The maximum number of characters to read. - /// The actual number of characters that have been read. The number will be less than or equal to count. - /// buffer is null. - /// The buffer length minus index is less than count. - /// index or count is negative. - public override int Read(char[] buffer, int index, int count) - { - return ReadBlock(buffer, index, count); - } + /// + /// Initializes a new instance of the ScintillaReader class that reads a subsection from the specified Scintilla control. + /// + /// The Scintilla control from which to read. + /// The index of the first character to read. + /// The index just past the last character to read. + public ScintillaReader(Scintilla scintilla, int start, int end) + : this(scintilla, start, end, DefaultBufferSize) + { + } + /// + /// Initializes a new instance of the ScintillaReader class that reads a subsection from the specified Scintilla control. + /// + /// The Scintilla control from which to read. + /// The index of the first character to read. + /// The index just past the last character to read. + /// The number of characters to buffer at a time. + public ScintillaReader(Scintilla scintilla, int start, int end, int bufferSize) + { + this._scintilla = scintilla; + this._bufferSize = bufferSize > 0 ? bufferSize : DefaultBufferSize; + this._nextData = start; + this._lastData = end; + // ensure start state is valid + BufferNextRegion(); + } - /// - /// Reads a maximum of count characters from the current stream and writes the data to buffer, beginning at index. - /// - /// The buffer to receive the characters. - /// The position in buffer at which to begin writing. - /// The maximum number of characters to read. - /// The actual number of characters that have been read. The number will be less than or equal to count. - /// buffer is null. - /// The buffer length minus index is less than count. - /// index or count is negative. - public override int ReadBlock(char[] buffer, int index, int count) - { - if (this._data != null) + /// + /// Returns the next character to be read from the reader without actually removing it from the stream. Returns -1 if no characters are available. + /// + /// The next character from the input stream, or -1 if no more characters are available. + public override int Peek() + { + // _data is set to null upon EOF + return this._data != null ? this._data[this._dataIndex] : -1; + } + /// + /// Removes a character from the stream and returns it. Returns -1 if no characters are available. + /// + /// The next character from the input stream, or -1 if no more characters are available. + public override int Read() { - int bufferRemaining = BufferRemaining; - if (count < bufferRemaining) + if (this._data != null) { - // buffer larger than read size - this._data.CopyTo(this._dataIndex, buffer, index, count); - return count; + // EOF not reached + char n = this._data[this._dataIndex++]; + if (this._dataIndex >= this._data.Length) + { + // end of buffer reached; load next section + BufferNextRegion(); + } + + return n; } else { - // buffer smaller or equal to read size - this._data.CopyTo(this._dataIndex, buffer, index, bufferRemaining); - if (count > bufferRemaining) - { - // buffer is smaller; read rest - string rest = this._scintilla.GetTextRange( - this._nextData, - Math.Min(count - bufferRemaining, UnbufferedRemaining)); - rest.CopyTo(0, buffer, index + bufferRemaining, rest.Length); - count = bufferRemaining + rest.Length; - this._nextData += rest.Length; - } - // read at least up to buffer's end; refill buffer - BufferNextRegion(); - return count; + return -1; } } - else + /// + /// Reads a maximum of count characters from the current stream and writes the data to buffer, beginning at index. + /// + /// The buffer to receive the characters. + /// The position in buffer at which to begin writing. + /// The maximum number of characters to read. + /// The actual number of characters that have been read. The number will be less than or equal to count. + /// buffer is null. + /// The buffer length minus index is less than count. + /// index or count is negative. + public override int Read(char[] buffer, int index, int count) { - return 0; + return ReadBlock(buffer, index, count); } - } - /// - /// Fills the buffer with the next section of text. - /// - private void BufferNextRegion() - { - if (this._nextData < this._lastData) + /// + /// Reads a maximum of count characters from the current stream and writes the data to buffer, beginning at index. + /// + /// The buffer to receive the characters. + /// The position in buffer at which to begin writing. + /// The maximum number of characters to read. + /// The actual number of characters that have been read. The number will be less than or equal to count. + /// buffer is null. + /// The buffer length minus index is less than count. + /// index or count is negative. + public override int ReadBlock(char[] buffer, int index, int count) { - int size = Math.Min(this._lastData - this._nextData, this._bufferSize); - this._data = this._scintilla.GetTextRange(this._nextData, size); - this._nextData += this._data.Length; - this._dataIndex = 0; + if (this._data != null) + { + int bufferRemaining = BufferRemaining; + if (count < bufferRemaining) + { + // buffer larger than read size + this._data.CopyTo(this._dataIndex, buffer, index, count); + return count; + } + else + { + // buffer smaller or equal to read size + this._data.CopyTo(this._dataIndex, buffer, index, bufferRemaining); + if (count > bufferRemaining) + { + // buffer is smaller; read rest + string rest = this._scintilla.GetTextRange( + this._nextData, + Math.Min(count - bufferRemaining, UnbufferedRemaining)); + rest.CopyTo(0, buffer, index + bufferRemaining, rest.Length); + count = bufferRemaining + rest.Length; + this._nextData += rest.Length; + } + // read at least up to buffer's end; refill buffer + BufferNextRegion(); + return count; + } + } + else + { + return 0; + } } - else + + /// + /// Fills the buffer with the next section of text. + /// + private void BufferNextRegion() { - this._data = null; + if (this._nextData < this._lastData) + { + int size = Math.Min(this._lastData - this._nextData, this._bufferSize); + this._data = this._scintilla.GetTextRange(this._nextData, size); + this._nextData += this._data.Length; + this._dataIndex = 0; + } + else + { + this._data = null; + } } } } diff --git a/Scintilla.NET/SearchFlags.cs b/Scintilla.NET/SearchFlags.cs index 739939d..573ac38 100644 --- a/Scintilla.NET/SearchFlags.cs +++ b/Scintilla.NET/SearchFlags.cs @@ -1,53 +1,54 @@ using System; -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 +namespace ScintillaNET { /// - /// Case-insensitive literal match. - /// - None = NativeMethods.SCFIND_NONE, - - /// - /// 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 as defined by . - /// - WholeWord = NativeMethods.SCFIND_WHOLEWORD, - - /// - /// A match only occurs if the character before is not a word character as defined by . - /// - WordStart = NativeMethods.SCFIND_WORDSTART, - - /// - /// The search string should be interpreted as a regular expression. - /// Uses Scintilla's base implementation unless combined with . - /// Regular expressions will only match ranges within a single line, never matching over multiple lines. - /// - Regex = NativeMethods.SCFIND_REGEXP, - - /// - /// Treat regular expression in a more POSIX compatible manner by interpreting bare '(' and ')' for tagged sections rather than "\(" and "\)". - /// Has no effect when is set. - /// - Posix = NativeMethods.SCFIND_POSIX, - - /// - /// The search string should be interpreted as a regular expression and use the C++11 <regex> standard library engine. - /// The property can queried to determine if the regular expression is invalid. - /// The ECMAScript flag is set on the regex object and documents will exhibit Unicode-compliant behaviour. - /// Regular expressions will only match ranges within a single line, never matching over multiple lines. - /// Must also have set. + /// Specifies the how patterns are matched when performing a search in a control. /// - Cxx11Regex = NativeMethods.SCFIND_CXX11REGEX + /// This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values. + [Flags] + public enum SearchFlags + { + /// + /// Case-insensitive literal match. + /// + None = NativeMethods.SCFIND_NONE, + + /// + /// 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 as defined by . + /// + WholeWord = NativeMethods.SCFIND_WHOLEWORD, + + /// + /// A match only occurs if the character before is not a word character as defined by . + /// + WordStart = NativeMethods.SCFIND_WORDSTART, + + /// + /// The search string should be interpreted as a regular expression. + /// Uses Scintilla's base implementation unless combined with . + /// Regular expressions will only match ranges within a single line, never matching over multiple lines. + /// + Regex = NativeMethods.SCFIND_REGEXP, + + /// + /// Treat regular expression in a more POSIX compatible manner by interpreting bare '(' and ')' for tagged sections rather than "\(" and "\)". + /// Has no effect when is set. + /// + Posix = NativeMethods.SCFIND_POSIX, + + /// + /// The search string should be interpreted as a regular expression and use the C++11 <regex> standard library engine. + /// The property can queried to determine if the regular expression is invalid. + /// The ECMAScript flag is set on the regex object and documents will exhibit Unicode-compliant behaviour. + /// Regular expressions will only match ranges within a single line, never matching over multiple lines. + /// Must also have set. + /// + Cxx11Regex = NativeMethods.SCFIND_CXX11REGEX + } } diff --git a/Scintilla.NET/Selection.cs b/Scintilla.NET/Selection.cs index 8754e75..a6266ce 100644 --- a/Scintilla.NET/Selection.cs +++ b/Scintilla.NET/Selection.cs @@ -1,150 +1,151 @@ using System; -namespace ScintillaNET; - -/// -/// Represents a selection when there are multiple active selections in a control. -/// -public class Selection +namespace ScintillaNET { - private readonly Scintilla scintilla; - /// - /// Gets or sets the anchor position of the selection. + /// Represents a selection when there are multiple active selections in a control. /// - /// The zero-based document position of the selection anchor. - public int Anchor + public class Selection { - get - { - int pos = this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNANCHOR, new IntPtr(Index)).ToInt32(); - if (pos <= 0) - return pos; + private readonly Scintilla scintilla; - return this.scintilla.Lines.ByteToCharPosition(pos); - } - set + /// + /// Gets or sets the anchor position of the selection. + /// + /// The zero-based document position of the selection anchor. + public int Anchor { - value = Helpers.Clamp(value, 0, this.scintilla.TextLength); - value = this.scintilla.Lines.CharToBytePosition(value); - this.scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNANCHOR, new IntPtr(Index), new IntPtr(value)); - } - } + get + { + int pos = this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNANCHOR, new IntPtr(Index)).ToInt32(); + if (pos <= 0) + return pos; - /// - /// 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 this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNANCHORVIRTUALSPACE, new IntPtr(Index)).ToInt32(); + return this.scintilla.Lines.ByteToCharPosition(pos); + } + set + { + value = Helpers.Clamp(value, 0, this.scintilla.TextLength); + value = this.scintilla.Lines.CharToBytePosition(value); + this.scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNANCHOR, new IntPtr(Index), new IntPtr(value)); + } } - set + + /// + /// 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 { - value = Helpers.ClampMin(value, 0); - this.scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNANCHORVIRTUALSPACE, new IntPtr(Index), new IntPtr(value)); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNANCHORVIRTUALSPACE, new IntPtr(Index)).ToInt32(); + } + set + { + value = Helpers.ClampMin(value, 0); + this.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 + /// + /// Gets or sets the caret position of the selection. + /// + /// The zero-based document position of the selection caret. + public int Caret { - int pos = this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNCARET, new IntPtr(Index)).ToInt32(); - if (pos <= 0) - return pos; + get + { + int pos = this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNCARET, new IntPtr(Index)).ToInt32(); + if (pos <= 0) + return pos; - return this.scintilla.Lines.ByteToCharPosition(pos); - } - set - { - value = Helpers.Clamp(value, 0, this.scintilla.TextLength); - value = this.scintilla.Lines.CharToBytePosition(value); - this.scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNCARET, new IntPtr(Index), new IntPtr(value)); + return this.scintilla.Lines.ByteToCharPosition(pos); + } + set + { + value = Helpers.Clamp(value, 0, this.scintilla.TextLength); + value = this.scintilla.Lines.CharToBytePosition(value); + this.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 + /// + /// 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 { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNCARETVIRTUALSPACE, new IntPtr(Index)).ToInt32(); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNCARETVIRTUALSPACE, new IntPtr(Index)).ToInt32(); + } + set + { + value = Helpers.ClampMin(value, 0); + this.scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNCARETVIRTUALSPACE, new IntPtr(Index), new IntPtr(value)); + } } - set - { - value = Helpers.ClampMin(value, 0); - this.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 + /// + /// Gets or sets the end position of the selection. + /// + /// The zero-based document position where the selection ends. + public int End { - int pos = this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNEND, new IntPtr(Index)).ToInt32(); - if (pos <= 0) - return pos; + get + { + int pos = this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNEND, new IntPtr(Index)).ToInt32(); + if (pos <= 0) + return pos; - return this.scintilla.Lines.ByteToCharPosition(pos); - } - set - { - value = Helpers.Clamp(value, 0, this.scintilla.TextLength); - value = this.scintilla.Lines.CharToBytePosition(value); - this.scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNEND, new IntPtr(Index), new IntPtr(value)); + return this.scintilla.Lines.ByteToCharPosition(pos); + } + set + { + value = Helpers.Clamp(value, 0, this.scintilla.TextLength); + value = this.scintilla.Lines.CharToBytePosition(value); + this.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 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 + /// + /// Gets or sets the start position of the selection. + /// + /// The zero-based document position where the selection starts. + public int Start { - int pos = this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNSTART, new IntPtr(Index)).ToInt32(); - if (pos <= 0) - return pos; + get + { + int pos = this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONNSTART, new IntPtr(Index)).ToInt32(); + if (pos <= 0) + return pos; - return this.scintilla.Lines.ByteToCharPosition(pos); + return this.scintilla.Lines.ByteToCharPosition(pos); + } + set + { + value = Helpers.Clamp(value, 0, this.scintilla.TextLength); + value = this.scintilla.Lines.CharToBytePosition(value); + this.scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNSTART, new IntPtr(Index), new IntPtr(value)); + } } - set + + /// + /// 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) { - value = Helpers.Clamp(value, 0, this.scintilla.TextLength); - value = this.scintilla.Lines.CharToBytePosition(value); - this.scintilla.DirectMessage(NativeMethods.SCI_SETSELECTIONNSTART, new IntPtr(Index), new IntPtr(value)); + this.scintilla = scintilla; + Index = index; } } - - /// - /// 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/Scintilla.NET/SelectionCollection.cs b/Scintilla.NET/SelectionCollection.cs index 016f4ef..e358e23 100644 --- a/Scintilla.NET/SelectionCollection.cs +++ b/Scintilla.NET/SelectionCollection.cs @@ -2,77 +2,78 @@ using System.Collections; using System.Collections.Generic; -namespace ScintillaNET; - -/// -/// A multiple selection collection. -/// -public class SelectionCollection : IEnumerable +namespace ScintillaNET { - private readonly Scintilla scintilla; - /// - /// Provides an enumerator that iterates through the collection. + /// A multiple selection collection. /// - /// An object that contains all objects within the . - public IEnumerator GetEnumerator() + public class SelectionCollection : IEnumerable { - int count = Count; - for (int i = 0; i < count; i++) - yield return this[i]; + private readonly Scintilla scintilla; - yield break; - } + /// + /// 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]; - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + yield break; + } - /// - /// Gets the number of active selections. - /// - /// The number of selections in the . - public int Count - { - get + IEnumerator IEnumerable.GetEnumerator() { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONS).ToInt32(); + return GetEnumerator(); } - } - /// - /// Gets a value indicating whether all selection ranges are empty. - /// - /// true if all selection ranges are empty; otherwise, false. - public bool IsEmpty - { - get + /// + /// Gets the number of active selections. + /// + /// The number of selections in the . + public int Count { - return this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONEMPTY) != IntPtr.Zero; + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONS).ToInt32(); + } } - } - /// - /// Gets the at the specified zero-based index. - /// - /// The zero-based index of the to get. - /// The at the specified index. - public Selection this[int index] - { - get + /// + /// Gets a value indicating whether all selection ranges are empty. + /// + /// true if all selection ranges are empty; otherwise, false. + public bool IsEmpty { - index = Helpers.Clamp(index, 0, Count - 1); - return new Selection(this.scintilla, index); + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_GETSELECTIONEMPTY) != IntPtr.Zero; + } } - } - /// - /// Initializes a new instance of the class. - /// - /// - public SelectionCollection(Scintilla scintilla) - { - this.scintilla = scintilla; + /// + /// Gets the at the specified zero-based index. + /// + /// The zero-based index of the to get. + /// The at the specified index. + public Selection this[int index] + { + get + { + index = Helpers.Clamp(index, 0, Count - 1); + return new Selection(this.scintilla, index); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// + public SelectionCollection(Scintilla scintilla) + { + this.scintilla = scintilla; + } } } diff --git a/Scintilla.NET/Status.cs b/Scintilla.NET/Status.cs index d69ef76..2451e5f 100644 --- a/Scintilla.NET/Status.cs +++ b/Scintilla.NET/Status.cs @@ -1,27 +1,28 @@ -namespace ScintillaNET; - -/// -/// Possible status codes returned by the property. -/// -public enum Status +namespace ScintillaNET { /// - /// No failures. + /// Possible status codes returned by the property. /// - Ok = NativeMethods.SC_STATUS_OK, + public enum Status + { + /// + /// No failures. + /// + Ok = NativeMethods.SC_STATUS_OK, - /// - /// Generic failure. - /// - Failure = NativeMethods.SC_STATUS_FAILURE, + /// + /// Generic failure. + /// + Failure = NativeMethods.SC_STATUS_FAILURE, - /// - /// Memory is exhausted. - /// - BadAlloc = NativeMethods.SC_STATUS_BADALLOC, + /// + /// Memory is exhausted. + /// + BadAlloc = NativeMethods.SC_STATUS_BADALLOC, - /// - /// Regular expression is invalid. - /// - WarnRegex = NativeMethods.SC_STATUS_WARN_REGEX + /// + /// Regular expression is invalid. + /// + WarnRegex = NativeMethods.SC_STATUS_WARN_REGEX + } } diff --git a/Scintilla.NET/Style.cs b/Scintilla.NET/Style.cs index 6f27f8c..398d7a5 100644 --- a/Scintilla.NET/Style.cs +++ b/Scintilla.NET/Style.cs @@ -2,3605 +2,3606 @@ using System.Drawing; using System.Text; -namespace ScintillaNET; - -/// -/// A style definition in a control. -/// -public class Style +namespace ScintillaNET { - #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; - - /// - /// Fold text tag style index. This is the style used for drawing text tags attached to folded text when - /// and are used. - /// - public const int FoldDisplayText = NativeMethods.STYLE_FOLDDISPLAYTEXT; - - #endregion Constants - - #region Fields - - private readonly Scintilla scintilla; - - #endregion Fields - - #region Methods - - /// - /// Copies the current style to another style. - /// - /// The to which the current style should be copied. - public void CopyTo(Style destination) - { - if (destination == null) - return; - - destination.BackColor = BackColor; - // destination.Bold = Bold; - destination.Case = Case; - destination.FillLine = FillLine; - destination.Font = Font; - destination.ForeColor = ForeColor; - destination.Hotspot = Hotspot; - destination.Italic = Italic; - destination.Size = Size; - destination.SizeF = SizeF; - destination.Underline = Underline; - destination.Visible = Visible; - destination.Weight = Weight; - } - - #endregion Methods - - #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 - { - int color = this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETBACK, new IntPtr(Index), IntPtr.Zero).ToInt32(); - return HelperMethods.FromWin32ColorOpaque(color); - } - set - { - if (value.IsEmpty) - value = Color.White; - - int color = HelperMethods.ToWin32ColorOpaque(value); - this.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 this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETBOLD, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - IntPtr bold = value ? new IntPtr(1) : IntPtr.Zero; - this.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 - { - int @case = this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETCASE, new IntPtr(Index), IntPtr.Zero).ToInt32(); - return (StyleCase)@case; - } - set - { - // Just an excuse to use @... syntax - int @case = (int)value; - this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETCASE, new IntPtr(Index), new IntPtr(@case)); - } - } - - /// - /// This is an experimental and incompletely implemented style attribute. The default setting is changeable set true - /// but when set false it makes text read-only. The user can not move the caret within not-changeable text and - /// not-changeable text may not be deleted by the user. The application may delete not-changeable text by calling - /// . - /// - /// false to make the text read-only, true otherwise. The default is true. - public bool Changeable - { - get - { - return this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETCHANGEABLE, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - IntPtr changeable = value ? new IntPtr(1) : IntPtr.Zero; - this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETCHANGEABLE, new IntPtr(Index), changeable); - } - } - - /// - /// 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 this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETEOLFILLED, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - IntPtr fillLine = value ? new IntPtr(1) : IntPtr.Zero; - this.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 - { - int length = this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFONT, new IntPtr(Index), IntPtr.Zero).ToInt32(); - byte[] font = new byte[length]; - unsafe - { - fixed (byte* bp = font) - this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFONT, new IntPtr(Index), new IntPtr(bp)); - } - - string name = Encoding.UTF8.GetString(font, 0, length); - return name; - } - set - { - if (string.IsNullOrEmpty(value)) - value = "Verdana"; - - // Scintilla expects UTF-8 - byte[] font = Helpers.GetBytes(value, Encoding.UTF8, true); - unsafe - { - fixed (byte* bp = font) - this.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 - { - int color = this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFORE, new IntPtr(Index), IntPtr.Zero).ToInt32(); - return HelperMethods.FromWin32ColorOpaque(color); - } - set - { - if (value.IsEmpty) - value = Color.Black; - - int color = HelperMethods.ToWin32ColorOpaque(value); - this.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 this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETHOTSPOT, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - IntPtr hotspot = value ? new IntPtr(1) : IntPtr.Zero; - this.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 this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETITALIC, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - IntPtr italic = value ? new IntPtr(1) : IntPtr.Zero; - this.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 this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETSIZE, new IntPtr(Index), IntPtr.Zero).ToInt32(); - } - set - { - this.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 - { - int fraction = this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETSIZEFRACTIONAL, new IntPtr(Index), IntPtr.Zero).ToInt32(); - return (float)fraction / NativeMethods.SC_FONT_SIZE_MULTIPLIER; - } - set - { - int fraction = (int)(value * NativeMethods.SC_FONT_SIZE_MULTIPLIER); - this.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 this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETUNDERLINE, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - IntPtr underline = value ? new IntPtr(1) : IntPtr.Zero; - this.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 this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETVISIBLE, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; - } - set - { - IntPtr visible = value ? new IntPtr(1) : IntPtr.Zero; - this.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 this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETWEIGHT, new IntPtr(Index), IntPtr.Zero).ToInt32(); - } - set - { - this.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 Ada - - /// - /// Style constants for use with the Ada lexer. - /// - public static class Ada - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_ADA_DEFAULT; - - /// - /// Line comment style index. - /// - public const int CommentLine = NativeMethods.SCE_ADA_COMMENTLINE; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_ADA_NUMBER; - - /// - /// Keyword style index. - /// - public const int Word = NativeMethods.SCE_ADA_WORD; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_ADA_STRING; - - /// - /// Single-quoted string style index. - /// - public const int Character = NativeMethods.SCE_ADA_CHARACTER; - - /// - /// Delimiter style index. - /// - public const int Delimiter = NativeMethods.SCE_ADA_DELIMITER; - - /// - /// Label style index. - /// - public const int Label = NativeMethods.SCE_ADA_LABEL; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_ADA_IDENTIFIER; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_ADA_STRINGEOL; - - /// - /// Unclosed character EOL style index. - /// - public const int CharacterEol = NativeMethods.SCE_ADA_CHARACTEREOL; - - /// - /// Illegal identifier or keyword style index. - /// - public const int Illegal = NativeMethods.SCE_ADA_ILLEGAL; - } - - #endregion Ada - - #region Asm - /// - /// Style constants for use with the Asm lexer. + /// A style definition in a control. /// - public static class Asm + public class Style { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_ASM_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_ASM_COMMENT; - - /// - /// Comment block style index. - /// - public const int CommentBlock = NativeMethods.SCE_ASM_COMMENTBLOCK; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_ASM_NUMBER; - - /// - /// Math instruction (keword list 1) style index. - /// - public const int MathInstruction = NativeMethods.SCE_ASM_MATHINSTRUCTION; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_ASM_STRING; - - /// - /// Single-quoted string style index. - /// - public const int Character = NativeMethods.SCE_ASM_CHARACTER; - - /// - /// CPU instruction (keyword list 0) style index. - /// - public const int CpuInstruction = NativeMethods.SCE_ASM_CPUINSTRUCTION; - - /// - /// Register (keyword list 2) style index. - /// - public const int Register = NativeMethods.SCE_ASM_REGISTER; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_ASM_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_ASM_IDENTIFIER; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_ASM_STRINGEOL; - - /// - /// Directive (keyword list 3) string style index. - /// - public const int Directive = NativeMethods.SCE_ASM_DIRECTIVE; - - /// - /// Directive operand (keyword list 4) style index. - /// - public const int DirectiveOperand = NativeMethods.SCE_ASM_DIRECTIVEOPERAND; - - /// - /// Extended instruction (keyword list 5) style index. - /// - public const int ExtInstruction = NativeMethods.SCE_ASM_EXTINSTRUCTION; - - /// - /// Comment directive style index. - /// - public const int CommentDirective = NativeMethods.SCE_ASM_COMMENTDIRECTIVE; - } - - #endregion Asm - - #region BlitzBasic - - /// - /// Style constants for use with the BlitzBasic lexer. - /// - public static class BlitzBasic - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_B_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 (index 1) style index. - /// - public const int Keyword2 = NativeMethods.SCE_B_KEYWORD2; - - /// - /// Keyword list 3 (index 2) style index. - /// - public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; - - /// - /// Keyword list 4 (index 3) 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 BlitzBasic - - #region Batch - - /// - /// Style constants for use with the Batch lexer. - /// - public static class Batch - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_BAT_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_BAT_COMMENT; - - /// - /// Keyword (list 0) style index. - /// - public const int Word = NativeMethods.SCE_BAT_WORD; - - /// - /// Label style index. - /// - public const int Label = NativeMethods.SCE_BAT_LABEL; - - /// - /// Hide (@ECHO OFF/ON) style index. - /// - public const int Hide = NativeMethods.SCE_BAT_HIDE; - - /// - /// External command (keyword list 1) style index. - /// - public const int Command = NativeMethods.SCE_BAT_COMMAND; - - /// - /// Identifier string style index. - /// - public const int Identifier = NativeMethods.SCE_BAT_IDENTIFIER; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_BAT_OPERATOR; - } - - #endregion Batch - - #region Clw - - /// - /// Style constants for use with the Clw lexer. - /// - public static class CLW - { - /// - /// Attributes style index - /// - public const int Attributes = NativeMethods.SCE_CLW_ATTRIBUTE; - - /// - /// Built in procedures function style index. - /// - public const int BuiltInProceduresFunction = NativeMethods.SCE_CLW_BUILTIN_PROCEDURES_FUNCTION; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_CLW_COMMENT; - - /// - /// Compiler directive style index - /// - public const int CompilerDirective = NativeMethods.SCE_CLW_COMPILER_DIRECTIVE; - - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_CLW_DEFAULT; - - /// - /// Depreciated style index - /// - public const int Depreciated = NativeMethods.SCE_CLW_DEPRECATED; - - /// - /// Error style index - /// - public const int Error = NativeMethods.SCE_CLW_ERROR; - - /// - /// Integer Constant style index. - /// - public const int IntegerConstant = NativeMethods.SCE_CLW_INTEGER_CONSTANT; - - /// - /// Keyword style index - /// - public const int Keyword = NativeMethods.SCE_CLW_KEYWORD; - - /// - /// Label string style index. - /// - public const int Label = NativeMethods.SCE_CLW_LABEL; - - /// - /// Real Constant style index. - /// - public const int PictureString = NativeMethods.SCE_CLW_PICTURE_STRING; - - /// - /// Real Constant style index. - /// - public const int RealConstant = NativeMethods.SCE_CLW_REAL_CONSTANT; - - /// - /// Runtime expressions style index - /// - public const int RuntimeExpressions = NativeMethods.SCE_CLW_RUNTIME_EXPRESSIONS; - - /// - /// Standard equates style index - /// - public const int StandardEquates = NativeMethods.SCE_CLW_STANDARD_EQUATE; - - /// - /// Single-quoted string style index. - /// - public const int String = NativeMethods.SCE_CLW_STRING; - - /// - /// Structure data type style index. - /// - public const int StructureDataTypes = NativeMethods.SCE_CLW_STRUCTURE_DATA_TYPE; - - /// - /// User Identifier style index. - /// - public const int UserIdentifier = NativeMethods.SCE_CLW_USER_IDENTIFIER; - } - - #endregion Clw - - #region Cpp - - /// - /// Style constants for use with the Cpp 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 Css 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 Fortran - - /// - /// Style constants for use with the Fortran lexer. - /// - public static class Fortran - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_F_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_F_COMMENT; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_F_NUMBER; - - /// - /// Single-quoted string style index. - /// - public const int String1 = NativeMethods.SCE_F_STRING1; - - /// - /// Double-quoted string style index. - /// - public const int String2 = NativeMethods.SCE_F_STRING2; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_F_STRINGEOL; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_F_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_F_IDENTIFIER; - - /// - /// Keyword (list 0) style index. - /// - public const int Word = NativeMethods.SCE_F_WORD; - - /// - /// Keyword 2 (list 1) style index. - /// - public const int Word2 = NativeMethods.SCE_F_WORD2; - - /// - /// Keyword 3 (list 2) style index. - /// - public const int Word3 = NativeMethods.SCE_F_WORD3; - - /// - /// Preprocessor style index. - /// - public const int Preprocessor = NativeMethods.SCE_F_PREPROCESSOR; - - /// - /// Operator 2 style index. - /// - public const int Operator2 = NativeMethods.SCE_F_OPERATOR2; - - /// - /// Label string style index. - /// - public const int Label = NativeMethods.SCE_F_LABEL; - - /// - /// Continuation style index. - /// - public const int Continuation = NativeMethods.SCE_F_CONTINUATION; - } - - #endregion Fortran - - #region FreeBasic - - /// - /// Style constants for use with the FreeBasic lexer. - /// - public static class FreeBasic - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_B_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 (index 1) style index. - /// - public const int Keyword2 = NativeMethods.SCE_B_KEYWORD2; - - /// - /// Keyword list 3 (index 2) style index. - /// - public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; - - /// - /// Keyword list 4 (index 3) 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 FreeBasic - - #region Html - - /// - /// Style constants for use with the Html lexer. - /// - public static class Html - { - /// - /// Content style index. - /// - public const int Default = NativeMethods.SCE_H_DEFAULT; - - /// - /// Tag style index. - /// - public const int Tag = NativeMethods.SCE_H_TAG; - - /// - /// Unknown tag style index. - /// - public const int TagUnknown = NativeMethods.SCE_H_TAGUNKNOWN; - - /// - /// Attribute style index. - /// - public const int Attribute = NativeMethods.SCE_H_ATTRIBUTE; - - /// - /// Unknown attribute style index. - /// - public const int AttributeUnknown = NativeMethods.SCE_H_ATTRIBUTEUNKNOWN; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_H_NUMBER; - - /// - /// Double-quoted string style index. - /// - public const int DoubleString = NativeMethods.SCE_H_DOUBLESTRING; - - /// - /// Single-quoted string style index. - /// - public const int SingleString = NativeMethods.SCE_H_SINGLESTRING; - - /// - /// Other tag content (not elements or attributes) style index. - /// - public const int Other = NativeMethods.SCE_H_OTHER; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_H_COMMENT; - - /// - /// Entity ($nnn;) name style index. - /// - public const int Entity = NativeMethods.SCE_H_ENTITY; - - /// - /// End-tag style index. - /// - public const int TagEnd = NativeMethods.SCE_H_TAGEND; - - /// - /// Start of XML declaration (<?xml>) style index. - /// - public const int XmlStart = NativeMethods.SCE_H_XMLSTART; - - /// - /// End of XML declaration (?>) style index. - /// - public const int XmlEnd = NativeMethods.SCE_H_XMLEND; - - /// - /// Script tag (<script>) style index. - /// - public const int Script = NativeMethods.SCE_H_SCRIPT; - - /// - /// ASP-like script engine block (<%) style index. - /// - public const int Asp = NativeMethods.SCE_H_ASP; - - /// - /// ASP-like language declaration (<%@) style index. - /// - public const int AspAt = NativeMethods.SCE_H_ASPAT; - - /// - /// CDATA section style index. - /// - public const int CData = NativeMethods.SCE_H_CDATA; - - /// - /// Question mark style index. - /// - public const int Question = NativeMethods.SCE_H_QUESTION; - - /// - /// Value style index. - /// - public const int Value = NativeMethods.SCE_H_VALUE; - - /// - /// Script engine comment (<%--) style index. - /// - public const int XcComment = NativeMethods.SCE_H_XCCOMMENT; - } - - #endregion Html - - #region JavaScript - - /// - /// Embedded JavaScript style constants for use with the JavaScript lexer. - /// - public static class JavaScript - { - /// - /// Start style index (allows EOL filled background to not start on same line as SCRIPT tag). - /// - public const int Start = NativeMethods.SCE_HJ_START; - - /// - /// Default style index. - /// - public const int Default = NativeMethods.SCE_HJ_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_HJ_COMMENT; - - /// - /// Line comment style index. - /// - public const int CommentLine = NativeMethods.SCE_HJ_COMMENTLINE; - - /// - /// Doc comment style index. - /// - public const int CommentDoc = NativeMethods.SCE_HJ_COMMENTDOC; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_HJ_NUMBER; - - /// - /// Word style index. - /// - public const int Word = NativeMethods.SCE_HJ_WORD; - - /// - /// Keyword style index. - /// - public const int Keyword = NativeMethods.SCE_HJ_KEYWORD; - - /// - /// Double-quoted string style index. - /// - public const int DoubleString = NativeMethods.SCE_HJ_DOUBLESTRING; - - /// - /// Single-quoted string style index. - /// - public const int SingleString = NativeMethods.SCE_HJ_SINGLESTRING; - - /// - /// Symbols style index. - /// - public const int Symbols = NativeMethods.SCE_HJ_SYMBOLS; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_HJ_STRINGEOL; - - /// - /// Regular expression style index. - /// - public const int Regex = NativeMethods.SCE_HJ_REGEX; - } - - #endregion JavaScript - - #region Json - - /// - /// Style constants for use with the Json lexer. - /// - public static class Json - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_JSON_DEFAULT; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_JSON_NUMBER; - - /// - /// String style index. - /// - public const int String = NativeMethods.SCE_JSON_STRING; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_JSON_STRINGEOL; - - /// - /// Property name style index. - /// - public const int PropertyName = NativeMethods.SCE_JSON_PROPERTYNAME; - - /// - /// Escape sequence style index. - /// - public const int EscapeSequence = NativeMethods.SCE_JSON_ESCAPESEQUENCE; - - /// - /// Line comment style index. - /// - public const int LineComment = NativeMethods.SCE_JSON_LINECOMMENT; - - /// - /// Block comment style index. - /// - public const int BlockComment = NativeMethods.SCE_JSON_BLOCKCOMMENT; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_JSON_OPERATOR; - - /// - /// URI style index. - /// - public const int Uri = NativeMethods.SCE_JSON_URI; - - /// - /// Compact Internationalized Resource Identifier (IRI) style index. - /// - public const int CompactIRI = NativeMethods.SCE_JSON_COMPACTIRI; - - /// - /// Keyword style index. - /// - public const int Keyword = NativeMethods.SCE_JSON_KEYWORD; - - /// - /// Linked data (LD) keyword style index. - /// - public const int LdKeyword = NativeMethods.SCE_JSON_LDKEYWORD; - - /// - /// Error style index. - /// - public const int Error = NativeMethods.SCE_JSON_ERROR; - } - - #endregion Json - - #region Lisp - - /// - /// Style constants for use with the Lisp lexer. - /// - public static class Lisp - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_LISP_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_LISP_COMMENT; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_LISP_NUMBER; - - /// - /// Functions and special operators (list 0) style index. - /// - public const int Keyword = NativeMethods.SCE_LISP_KEYWORD; - - /// - /// Keywords (list 1) style index. - /// - public const int KeywordKw = NativeMethods.SCE_LISP_KEYWORD_KW; - - /// - /// Symbol style index. - /// - public const int Symbol = NativeMethods.SCE_LISP_SYMBOL; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_LISP_STRING; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_LISP_STRINGEOL; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_LISP_IDENTIFIER; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_LISP_OPERATOR; - - /// - /// Special character style index. - /// - public const int Special = NativeMethods.SCE_LISP_SPECIAL; - - /// - /// Multi-line comment style index. - /// - public const int MultiComment = NativeMethods.SCE_LISP_MULTI_COMMENT; - } - - #endregion Lisp - - #region Lua - - /// - /// Style constants for use with the Lua lexer. - /// - public static class Lua - { - /// - /// Default style index. - /// - public const int Default = NativeMethods.SCE_LUA_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_LUA_COMMENT; - - /// - /// Line comment style index. - /// - public const int CommentLine = NativeMethods.SCE_LUA_COMMENTLINE; - - /// - /// Documentation comment style index. - /// - public const int CommentDoc = NativeMethods.SCE_LUA_COMMENTDOC; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_LUA_NUMBER; - - /// - /// Keyword list 1 (index 0) style index. - /// - public const int Word = NativeMethods.SCE_LUA_WORD; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_LUA_STRING; - - /// - /// Single-quoted string style index. - /// - public const int Character = NativeMethods.SCE_LUA_CHARACTER; - - /// - /// Literal string style index. - /// - public const int LiteralString = NativeMethods.SCE_LUA_LITERALSTRING; - - /// - /// Preprocessor style index. - /// - public const int Preprocessor = NativeMethods.SCE_LUA_PREPROCESSOR; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_LUA_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_LUA_IDENTIFIER; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_LUA_STRINGEOL; - - /// - /// Keywords list 2 (index 1) style index. - /// - public const int Word2 = NativeMethods.SCE_LUA_WORD2; - - /// - /// Keywords list 3 (index 2) style index. - /// - public const int Word3 = NativeMethods.SCE_LUA_WORD3; - - /// - /// Keywords list 4 (index 3) style index. - /// - public const int Word4 = NativeMethods.SCE_LUA_WORD4; - - /// - /// Keywords list 5 (index 4) style index. - /// - public const int Word5 = NativeMethods.SCE_LUA_WORD5; - - /// - /// Keywords list 6 (index 5) style index. - /// - public const int Word6 = NativeMethods.SCE_LUA_WORD6; - - /// - /// Keywords list 7 (index 6) style index. - /// - public const int Word7 = NativeMethods.SCE_LUA_WORD7; - - /// - /// Keywords list 8 (index 7) style index. - /// - public const int Word8 = NativeMethods.SCE_LUA_WORD8; - - /// - /// Label style index. - /// - public const int Label = NativeMethods.SCE_LUA_LABEL; - } - - #endregion Lua - - #region Matlab - - /// - /// Style constants for use with the Matlab lexer. - /// - public static class Matlab - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_MATLAB_DEFAULT; - - /// - /// Line comment style index. - /// - public const int Comment = NativeMethods.SCE_MATLAB_COMMENT; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_MATLAB_NUMBER; - - /// - /// String style index. - /// - public const int String = NativeMethods.SCE_MATLAB_STRING; - - /// - /// Command style index. - /// - public const int Command = NativeMethods.SCE_MATLAB_COMMAND; - - /// - /// Keyword style index. - /// - public const int Keyword = NativeMethods.SCE_MATLAB_KEYWORD; - - /// - /// Double quote string style index. - /// - public const int DoubleQuoteString = NativeMethods.SCE_MATLAB_DOUBLEQUOTESTRING; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_MATLAB_IDENTIFIER; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_MATLAB_OPERATOR; - } - - #endregion Matlab - - #region Pascal - - /// - /// Style constants for use with the Pascal lexer. - /// - public static class Pascal - { - /// - /// Default style index. - /// - public const int Default = NativeMethods.SCE_PAS_DEFAULT; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_PAS_IDENTIFIER; - - /// - /// Comment style '{' index. - /// - public const int Comment = NativeMethods.SCE_PAS_COMMENT; - - /// - /// Comment style 2 "(*" index. - /// - public const int Comment2 = NativeMethods.SCE_PAS_COMMENT2; - - /// - /// Comment line style "//" index. - /// - public const int CommentLine = NativeMethods.SCE_PAS_COMMENTLINE; - - /// - /// Preprocessor style "{$" index. - /// - public const int Preprocessor = NativeMethods.SCE_PAS_PREPROCESSOR; - - /// - /// Preprocessor style 2 "(*$" index. - /// - public const int Preprocessor2 = NativeMethods.SCE_PAS_PREPROCESSOR2; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_PAS_NUMBER; - - /// - /// Hexadecimal number style index. - /// - public const int HexNumber = NativeMethods.SCE_PAS_HEXNUMBER; - - /// - /// Word (keyword set 0) style index. - /// - public const int Word = NativeMethods.SCE_PAS_WORD; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_PAS_STRING; - - /// - /// Unclosed string EOL style index. - /// - public const int StringEol = NativeMethods.SCE_PAS_STRINGEOL; - - /// - /// Single-quoted string style index. - /// - public const int Character = NativeMethods.SCE_PAS_CHARACTER; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_PAS_OPERATOR; - - /// - /// Assembly style index. - /// - public const int Asm = NativeMethods.SCE_PAS_ASM; - } - - #endregion Pascal - - #region Perl - - /// - /// Style constants for use with the Perl lexer. - /// - public static class Perl - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_PL_DEFAULT; - - /// - /// Error style index. - /// - public const int Error = NativeMethods.SCE_PL_ERROR; - - /// - /// Line comment style index. - /// - public const int CommentLine = NativeMethods.SCE_PL_COMMENTLINE; - - /// - /// POD style index. - /// - public const int Pod = NativeMethods.SCE_PL_POD; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_PL_NUMBER; - - /// - /// Keyword style index. - /// - public const int Word = NativeMethods.SCE_PL_WORD; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_PL_STRING; - - /// - /// Single-quoted string style index. - /// - public const int Character = NativeMethods.SCE_PL_CHARACTER; - - /// - /// Punctuation style index. - /// - public const int Punctuation = NativeMethods.SCE_PL_PUNCTUATION; - - /// - /// Preprocessor style index. - /// - public const int Preprocessor = NativeMethods.SCE_PL_PREPROCESSOR; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_PL_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_PL_IDENTIFIER; - - /// - /// Scalar style index. - /// - public const int Scalar = NativeMethods.SCE_PL_SCALAR; - - /// - /// Array style index. - /// - public const int Array = NativeMethods.SCE_PL_ARRAY; - - /// - /// Hash style index. - /// - public const int Hash = NativeMethods.SCE_PL_HASH; - - /// - /// Symbol table style index. - /// - public const int SymbolTable = NativeMethods.SCE_PL_SYMBOLTABLE; - - /// - /// Variable indexer index. - /// - public const int VariableIndexer = NativeMethods.SCE_PL_VARIABLE_INDEXER; - - /// - /// Regular expression style index. - /// - public const int Regex = NativeMethods.SCE_PL_REGEX; - - /// - /// RegSubst style index. - /// - public const int RegSubst = NativeMethods.SCE_PL_REGSUBST; - - // public const int LongQuote = NativeMethods.SCE_PL_LONGQUOTE; - - /// - /// Backtick (grave accent, backquote) style index. - /// - public const int BackTicks = NativeMethods.SCE_PL_BACKTICKS; - - /// - /// Data section style index. - /// - public const int DataSection = NativeMethods.SCE_PL_DATASECTION; - - /// - /// HereDoc delimiter style index. - /// - public const int HereDelim = NativeMethods.SCE_PL_HERE_DELIM; - - /// - /// HereDoc single-quote style index. - /// - public const int HereQ = NativeMethods.SCE_PL_HERE_Q; - - /// - /// HereDoc double-quote style index. - /// - public const int HereQq = NativeMethods.SCE_PL_HERE_QQ; - - /// - /// HereDoc backtick style index. - /// - public const int HereQx = NativeMethods.SCE_PL_HERE_QX; - - /// - /// Q quote style index. - /// - public const int StringQ = NativeMethods.SCE_PL_STRING_Q; - - /// - /// QQ quote style index. - /// - public const int StringQq = NativeMethods.SCE_PL_STRING_QQ; - - /// - /// QZ quote style index. - /// - public const int StringQx = NativeMethods.SCE_PL_STRING_QX; - - /// - /// QR quote style index. - /// - public const int StringQr = NativeMethods.SCE_PL_STRING_QR; - - /// - /// QW quote style index. - /// - public const int StringQw = NativeMethods.SCE_PL_STRING_QW; - - /// - /// POD verbatim style index. - /// - public const int PodVerb = NativeMethods.SCE_PL_POD_VERB; - - /// - /// Subroutine prototype style index. - /// - public const int SubPrototype = NativeMethods.SCE_PL_SUB_PROTOTYPE; - - /// - /// Format identifier style index. - /// - public const int FormatIdent = NativeMethods.SCE_PL_FORMAT_IDENT; - - /// - /// Format style index. - /// - public const int Format = NativeMethods.SCE_PL_FORMAT; - - /// - /// String variable style index. - /// - public const int StringVar = NativeMethods.SCE_PL_STRING_VAR; - - /// - /// XLAT style index. - /// - public const int XLat = NativeMethods.SCE_PL_XLAT; - - /// - /// Regular expression variable style index. - /// - public const int RegexVar = NativeMethods.SCE_PL_REGEX_VAR; - - /// - /// RegSubst variable style index. - /// - public const int RegSubstVar = NativeMethods.SCE_PL_REGSUBST_VAR; - - /// - /// Backticks variable style index. - /// - public const int BackticksVar = NativeMethods.SCE_PL_BACKTICKS_VAR; - - /// - /// HereDoc QQ quote variable style index. - /// - public const int HereQqVar = NativeMethods.SCE_PL_HERE_QQ_VAR; - - /// - /// HereDoc QX quote variable style index. - /// - public const int HereQxVar = NativeMethods.SCE_PL_HERE_QX_VAR; - - /// - /// QQ quote variable style index. - /// - public const int StringQqVar = NativeMethods.SCE_PL_STRING_QQ_VAR; - - /// - /// QX quote variable style index. - /// - public const int StringQxVar = NativeMethods.SCE_PL_STRING_QX_VAR; - - /// - /// QR quote variable style index. - /// - public const int StringQrVar = NativeMethods.SCE_PL_STRING_QR_VAR; - } - - #endregion Perl - - #region PhpScript - - /// - /// Style constants for use with the PhpScript lexer. - /// - public static class PhpScript - { - /// - /// Complex Variable style index. - /// - public const int ComplexVariable = NativeMethods.SCE_HPHP_COMPLEX_VARIABLE; - - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_HPHP_DEFAULT; - - /// - /// Double-quoted string style index. - /// - public const int HString = NativeMethods.SCE_HPHP_HSTRING; - - /// - /// Single-quoted string style index. - /// - public const int SimpleString = NativeMethods.SCE_HPHP_SIMPLESTRING; - - /// - /// Keyword style index. - /// - public const int Word = NativeMethods.SCE_HPHP_WORD; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_HPHP_NUMBER; - - /// - /// Variable style index. - /// - public const int Variable = NativeMethods.SCE_HPHP_VARIABLE; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_HPHP_COMMENT; - - /// - /// Line comment style index. - /// - public const int CommentLine = NativeMethods.SCE_HPHP_COMMENTLINE; - - /// - /// Double-quoted string variable style index. - /// - public const int HStringVariable = NativeMethods.SCE_HPHP_HSTRING_VARIABLE; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_HPHP_OPERATOR; - } - - #endregion PhpScript - - #region PowerShell - - /// - /// Style constants for use with the PowerShell lexer. - /// - public static class PowerShell - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_POWERSHELL_DEFAULT; - - /// - /// Line comment style index - /// - public const int Comment = NativeMethods.SCE_POWERSHELL_COMMENT; - - /// - /// String style index. - /// - public const int String = NativeMethods.SCE_POWERSHELL_STRING; - - /// - /// Character style index. - /// - public const int Character = NativeMethods.SCE_POWERSHELL_CHARACTER; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_POWERSHELL_NUMBER; - - /// - /// Variable style index. - /// - public const int Variable = NativeMethods.SCE_POWERSHELL_VARIABLE; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_POWERSHELL_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_POWERSHELL_IDENTIFIER; - - /// - /// Keyword (set 0) style index. - /// - public const int Keyword = NativeMethods.SCE_POWERSHELL_KEYWORD; - - /// - /// Cmdlet (set 1) style index. - /// - public const int Cmdlet = NativeMethods.SCE_POWERSHELL_CMDLET; - - /// - /// Alias (set 2) style index. - /// - public const int Alias = NativeMethods.SCE_POWERSHELL_ALIAS; - - /// - /// Function (set 3) style index. - /// - public const int Function = NativeMethods.SCE_POWERSHELL_FUNCTION; - - /// - /// User word (set 4) style index. - /// - public const int User1 = NativeMethods.SCE_POWERSHELL_USER1; - - /// - /// Multi-line comment style index. - /// - public const int CommentStream = NativeMethods.SCE_POWERSHELL_COMMENTSTREAM; - - /// - /// Here string style index. - /// - public const int HereString = NativeMethods.SCE_POWERSHELL_HERE_STRING; - - /// - /// Here character style index. - /// - public const int HereCharacter = NativeMethods.SCE_POWERSHELL_HERE_CHARACTER; - - /// - /// Comment based help keyword style index. - /// - public const int CommentDocKeyword = NativeMethods.SCE_POWERSHELL_COMMENTDOCKEYWORD; - } - - #endregion PowerShell - - #region Properties - - /// - /// Style constants for use with the Properties lexer. - /// - public static class Properties - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_PROPS_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_PROPS_COMMENT; - - /// - /// Section style index. - /// - public const int Section = NativeMethods.SCE_PROPS_SECTION; - - /// - /// Assignment operator index. - /// - public const int Assignment = NativeMethods.SCE_PROPS_ASSIGNMENT; - - /// - /// Default (registry-only) value index. - /// - public const int DefVal = NativeMethods.SCE_PROPS_DEFVAL; - - /// - /// Key style index. - /// - public const int Key = NativeMethods.SCE_PROPS_KEY; - } - - #endregion Properties - - #region PureBasic - - /// - /// Style constants for use with the PureBasic lexer. - /// - public static class PureBasic - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_B_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 (index 1) style index. - /// - public const int Keyword2 = NativeMethods.SCE_B_KEYWORD2; - - /// - /// Keyword list 3 (index 2) style index. - /// - public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; - - /// - /// Keyword list 4 (index 3) 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 PureBasic - - #region Python - - /// - /// Style constants for use with the Python 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 Ruby - - /// - /// Style constants for use with the Ruby lexer. - /// - public static class Ruby - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_RB_DEFAULT; - - /// - /// Error style index. - /// - public const int Error = NativeMethods.SCE_RB_ERROR; - - /// - /// Line comment style index. - /// - public const int CommentLine = NativeMethods.SCE_RB_COMMENTLINE; - - /// - /// POD style index. - /// - public const int Pod = NativeMethods.SCE_RB_POD; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_RB_NUMBER; - - /// - /// Keyword style index. - /// - public const int Word = NativeMethods.SCE_RB_WORD; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_RB_STRING; - - /// - /// Single-quoted string style index. - /// - public const int Character = NativeMethods.SCE_RB_CHARACTER; - - /// - /// Class name style index. - /// - public const int ClassName = NativeMethods.SCE_RB_CLASSNAME; - - /// - /// Definition style index. - /// - public const int DefName = NativeMethods.SCE_RB_DEFNAME; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_RB_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_RB_IDENTIFIER; - - /// - /// Regular expression style index. - /// - public const int Regex = NativeMethods.SCE_RB_REGEX; - - /// - /// Global style index. - /// - public const int Global = NativeMethods.SCE_RB_GLOBAL; - - /// - /// Symbol style index. - /// - public const int Symbol = NativeMethods.SCE_RB_SYMBOL; - - /// - /// Module name style index. - /// - public const int ModuleName = NativeMethods.SCE_RB_MODULE_NAME; - - /// - /// Instance variable style index. - /// - public const int InstanceVar = NativeMethods.SCE_RB_INSTANCE_VAR; - - /// - /// Class variable style index. - /// - public const int ClassVar = NativeMethods.SCE_RB_CLASS_VAR; - - /// - /// Backticks style index. - /// - public const int BackTicks = NativeMethods.SCE_RB_BACKTICKS; - - /// - /// Data section style index. - /// - public const int DataSection = NativeMethods.SCE_RB_DATASECTION; - - /// - /// HereDoc delimiter style index. - /// - public const int HereDelim = NativeMethods.SCE_RB_HERE_DELIM; - - /// - /// HereDoc Q quote style index. - /// - public const int HereQ = NativeMethods.SCE_RB_HERE_Q; - - /// - /// HereDoc QQ quote style index. - /// - public const int HereQq = NativeMethods.SCE_RB_HERE_QQ; - - /// - /// HereDoc QX quote style index. - /// - public const int HereQx = NativeMethods.SCE_RB_HERE_QX; - - /// - /// Q quote string style index. - /// - public const int StringQ = NativeMethods.SCE_RB_STRING_Q; - - /// - /// QQ quote string style index. - /// - public const int StringQq = NativeMethods.SCE_RB_STRING_QQ; - - /// - /// QX quote string style index. - /// - public const int StringQx = NativeMethods.SCE_RB_STRING_QX; - - /// - /// QR quote string style index. - /// - public const int StringQr = NativeMethods.SCE_RB_STRING_QR; - - /// - /// QW quote style index. - /// - public const int StringQw = NativeMethods.SCE_RB_STRING_QW; - - /// - /// Demoted keyword style index. - /// - public const int WordDemoted = NativeMethods.SCE_RB_WORD_DEMOTED; - - /// - /// Standard-in style index. - /// - public const int StdIn = NativeMethods.SCE_RB_STDIN; - - /// - /// Standard-out style index. - /// - public const int StdOut = NativeMethods.SCE_RB_STDOUT; - - /// - /// Standard-error style index. - /// - public const int StdErr = NativeMethods.SCE_RB_STDERR; - - // public const int UpperBound = NativeMethods.SCE_RB_UPPER_BOUND; - } - - #endregion Ruby - - #region Smalltalk - - /// - /// Style constants for use with the Smalltalk lexer. - /// - public static class Smalltalk - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_ST_DEFAULT; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_ST_STRING; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_ST_NUMBER; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_ST_COMMENT; - - /// - /// Symbol style index. - /// - public const int Symbol = NativeMethods.SCE_ST_SYMBOL; - - /// - /// Binary style index. - /// - public const int Binary = NativeMethods.SCE_ST_BINARY; - - /// - /// Bool style index. - /// - public const int Bool = NativeMethods.SCE_ST_BOOL; - - /// - /// Self style index. - /// - public const int Self = NativeMethods.SCE_ST_SELF; - - /// - /// Super style index. - /// - public const int Super = NativeMethods.SCE_ST_SUPER; - - /// - /// NIL style index. - /// - public const int Nil = NativeMethods.SCE_ST_NIL; - - /// - /// Global style index. - /// - public const int Global = NativeMethods.SCE_ST_GLOBAL; - - /// - /// Return style index. - /// - public const int Return = NativeMethods.SCE_ST_RETURN; - - /// - /// Special style index. - /// - public const int Special = NativeMethods.SCE_ST_SPECIAL; - - /// - /// KWS End style index. - /// - public const int KwsEnd = NativeMethods.SCE_ST_KWSEND; - - /// - /// Assign style index. - /// - public const int Assign = NativeMethods.SCE_ST_ASSIGN; - - /// - /// Single-quoted string style index. - /// - public const int Character = NativeMethods.SCE_ST_CHARACTER; - - /// - /// Special selector style index. - /// - public const int SpecSel = NativeMethods.SCE_ST_SPEC_SEL; - } - - #endregion Smalltalk - - #region Sql - - /// - /// Style constants for use with the Sql lexer. - /// - public static class Sql - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_SQL_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_SQL_COMMENT; - - /// - /// Line comment style index. - /// - public const int CommentLine = NativeMethods.SCE_SQL_COMMENTLINE; - - /// - /// Documentation comment style index. - /// - public const int CommentDoc = NativeMethods.SCE_SQL_COMMENTDOC; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_SQL_NUMBER; - - /// - /// Keyword list 1 (index 0) style index. - /// - public const int Word = NativeMethods.SCE_SQL_WORD; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_SQL_STRING; - - /// - /// Single-quoted string style index. - /// - public const int Character = NativeMethods.SCE_SQL_CHARACTER; - - /// - /// Keyword from the SQL*Plus list (index 3) style index. - /// - public const int SqlPlus = NativeMethods.SCE_SQL_SQLPLUS; - - /// - /// SQL*Plus prompt style index. - /// - public const int SqlPlusPrompt = NativeMethods.SCE_SQL_SQLPLUS_PROMPT; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_SQL_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_SQL_IDENTIFIER; - - /// - /// SQL*Plus comment style index. - /// - public const int SqlPlusComment = NativeMethods.SCE_SQL_SQLPLUS_COMMENT; - - /// - /// Documentation line comment style index. - /// - public const int CommentLineDoc = NativeMethods.SCE_SQL_COMMENTLINEDOC; - - /// - /// Keyword list 2 (index 1) style index. - /// - public const int Word2 = NativeMethods.SCE_SQL_WORD2; - - /// - /// Documentation (Doxygen) keyword style index. - /// - public const int CommentDocKeyword = NativeMethods.SCE_SQL_COMMENTDOCKEYWORD; - - /// - /// Documentation (Doxygen) keyword error style index. - /// - public const int CommentDocKeywordError = NativeMethods.SCE_SQL_COMMENTDOCKEYWORDERROR; - - /// - /// Keyword user-list 1 (index 4) style index. - /// - public const int User1 = NativeMethods.SCE_SQL_USER1; - - /// - /// Keyword user-list 2 (index 5) style index. - /// - public const int User2 = NativeMethods.SCE_SQL_USER2; - - /// - /// Keyword user-list 3 (index 6) style index. - /// - public const int User3 = NativeMethods.SCE_SQL_USER3; - - /// - /// Keyword user-list 4 (index 7) style index. - /// - public const int User4 = NativeMethods.SCE_SQL_USER4; - - /// - /// Quoted identifier style index. - /// - public const int QuotedIdentifier = NativeMethods.SCE_SQL_QUOTEDIDENTIFIER; - - /// - /// Q operator style index. - /// - public const int QOperator = NativeMethods.SCE_SQL_QOPERATOR; - } - - #endregion Sql - - #region Markdown - - /// - /// Style constants for use with the Markdown lexer. - /// - public static class Markdown - { - /// - /// Default text style index. - /// - public const int Default = NativeMethods.SCE_MARKDOWN_DEFAULT; - - /// - /// Line begin style index. - /// - public const int LineBegin = NativeMethods.SCE_MARKDOWN_LINE_BEGIN; - - /// - /// Strong type 1 style index. - /// - public const int Strong1 = NativeMethods.SCE_MARKDOWN_STRONG1; - - /// - /// Strong type 2 style index. - /// - public const int Strong2 = NativeMethods.SCE_MARKDOWN_STRONG2; - - /// - /// Empasis type 1 style index. - /// - public const int Em1 = NativeMethods.SCE_MARKDOWN_EM1; - - /// - /// Empasis type 2 style index. - /// - public const int Em2 = NativeMethods.SCE_MARKDOWN_EM2; - - /// - /// Header type 1 style index. - /// - public const int Header1 = NativeMethods.SCE_MARKDOWN_HEADER1; - - /// - /// Header type 2 style index. - /// - public const int Header2 = NativeMethods.SCE_MARKDOWN_HEADER2; - - /// - /// Header type 3 style index. - /// - public const int Header3 = NativeMethods.SCE_MARKDOWN_HEADER3; - - /// - /// Header type 4 style index. - /// - public const int Header4 = NativeMethods.SCE_MARKDOWN_HEADER4; - - /// - /// Header type 5 style index. - /// - public const int Header5 = NativeMethods.SCE_MARKDOWN_HEADER5; - - /// - /// Header type 6 style index. - /// - public const int Header6 = NativeMethods.SCE_MARKDOWN_HEADER6; - - /// - /// Pre char style index. - /// - public const int PreChar = NativeMethods.SCE_MARKDOWN_PRECHAR; - - /// - /// Unordered list style index. - /// - public const int UListItem = NativeMethods.SCE_MARKDOWN_ULIST_ITEM; - - /// - /// Ordered list style index. - /// - public const int OListItem = NativeMethods.SCE_MARKDOWN_OLIST_ITEM; - - /// - /// Blockquote style index. - /// - public const int BlockQuote = NativeMethods.SCE_MARKDOWN_BLOCKQUOTE; - - /// - /// Strikeout style index. - /// - public const int Strikeout = NativeMethods.SCE_MARKDOWN_STRIKEOUT; - - /// - /// Horizontal rule style index. - /// - public const int HRule = NativeMethods.SCE_MARKDOWN_HRULE; - - /// - /// Link style index. - /// - public const int Link = NativeMethods.SCE_MARKDOWN_LINK; - - /// - /// Code type 1 style index. - /// - public const int Code = NativeMethods.SCE_MARKDOWN_CODE; - - /// - /// Code type 2 style index. - /// - public const int Code2 = NativeMethods.SCE_MARKDOWN_CODE2; - - /// - /// Code block style index. - /// - public const int CodeBk = NativeMethods.SCE_MARKDOWN_CODEBK; - } - - #endregion Markdown - - #region R - - /// - /// Style constants for use with the R lexer. - /// - public static class R - { - /// - /// Default style index. - /// - public const int Default = NativeMethods.SCE_R_DEFAULT; - - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_R_COMMENT; - - /// - /// Keyword (set 0) style index. - /// - public const int KWord = NativeMethods.SCE_R_KWORD; - - /// - /// Base keyword (set 1) style index. - /// - public const int BaseKWord = NativeMethods.SCE_R_BASEKWORD; - - /// - /// Other keyword (set 2) style index. - /// - public const int OtherKWord = NativeMethods.SCE_R_OTHERKWORD; - - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_R_NUMBER; - - /// - /// Double-quoted string style index. - /// - public const int String = NativeMethods.SCE_R_STRING; - - /// - /// Single-quoted string style index. - /// - public const int String2 = NativeMethods.SCE_R_STRING2; - - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_R_OPERATOR; - - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_R_IDENTIFIER; - - /// - /// Infix style index. - /// - public const int Infix = NativeMethods.SCE_R_INFIX; - - /// - /// Unclosed infix EOL style index. - /// - public const int InfixEol = NativeMethods.SCE_R_INFIXEOL; - } - - #endregion R - - #region Vb - - /// - /// Style constants for use with the Vb lexer. - /// - public static class Vb - { - /// - /// Default (whitespace) style index. - /// - public const int Default = NativeMethods.SCE_B_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; + #region Constants /// - /// Date style index. + /// Default style index. This style is used to define properties that all styles receive when calling . /// - public const int Date = NativeMethods.SCE_B_DATE; + public const int Default = NativeMethods.STYLE_DEFAULT; /// - /// Unclosed string EOL style index. + /// 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 StringEol = NativeMethods.SCE_B_STRINGEOL; + public const int LineNumber = NativeMethods.STYLE_LINENUMBER; /// - /// Keyword list 2 (index 1) style index. + /// 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 Keyword2 = NativeMethods.SCE_B_KEYWORD2; + public const int CallTip = NativeMethods.STYLE_CALLTIP; /// - /// Keyword list 3 (index 2) style index. + /// Indent guide style index. This style is used to specify the foreground and background colors of . /// - public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; + public const int IndentGuide = NativeMethods.STYLE_INDENTGUIDE; /// - /// Keyword list 4 (index 3) style index. + /// 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 Keyword4 = NativeMethods.SCE_B_KEYWORD4; + public const int BraceLight = NativeMethods.STYLE_BRACELIGHT; /// - /// Constant style index. + /// Bad brace style index. This style is used on an unmatched brace character when set with the method. /// - public const int Constant = NativeMethods.SCE_B_CONSTANT; + public const int BraceBad = NativeMethods.STYLE_BRACEBAD; /// - /// Inline assembler style index. + /// Fold text tag style index. This is the style used for drawing text tags attached to folded text when + /// and are used. /// - public const int Asm = NativeMethods.SCE_B_ASM; + public const int FoldDisplayText = NativeMethods.STYLE_FOLDDISPLAYTEXT; - /// - /// Label style index. - /// - public const int Label = NativeMethods.SCE_B_LABEL; + #endregion Constants - /// - /// Error style index. - /// - public const int Error = NativeMethods.SCE_B_ERROR; + #region Fields - /// - /// Hexadecimal number style index. - /// - public const int HexNumber = NativeMethods.SCE_B_HEXNUMBER; + private readonly Scintilla scintilla; - /// - /// Binary number style index. - /// - public const int BinNumber = NativeMethods.SCE_B_BINNUMBER; + #endregion Fields - /// - /// Block comment style index. - /// - public const int CommentBlock = NativeMethods.SCE_B_COMMENTBLOCK; + #region Methods /// - /// Documentation line style index. + /// Copies the current style to another style. /// - public const int DocLine = NativeMethods.SCE_B_DOCLINE; + /// The to which the current style should be copied. + public void CopyTo(Style destination) + { + if (destination == null) + return; + + destination.BackColor = BackColor; + // destination.Bold = Bold; + destination.Case = Case; + destination.FillLine = FillLine; + destination.Font = Font; + destination.ForeColor = ForeColor; + destination.Hotspot = Hotspot; + destination.Italic = Italic; + destination.Size = Size; + destination.SizeF = SizeF; + destination.Underline = Underline; + destination.Visible = Visible; + destination.Weight = Weight; + } - /// - /// Documentation block style index. - /// - public const int DocBlock = NativeMethods.SCE_B_DOCBLOCK; + #endregion Methods + + #region Properties /// - /// Documentation keyword style index. + /// Gets or sets the background color of the style. /// - public const int DocKeyword = NativeMethods.SCE_B_DOCKEYWORD; - } - - #endregion Vb + /// A Color object representing the style background color. The default is White. + /// Alpha color values are ignored. + public Color BackColor + { + get + { + int color = this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETBACK, new IntPtr(Index), IntPtr.Zero).ToInt32(); + return HelperMethods.FromWin32ColorOpaque(color); + } + set + { + if (value.IsEmpty) + value = Color.White; - #region VbScript + int color = HelperMethods.ToWin32ColorOpaque(value); + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETBACK, new IntPtr(Index), new IntPtr(color)); + } + } - /// - /// Style constants for use with the VbScript lexer. - /// - public static class VbScript - { /// - /// Default (whitespace) style index. + /// Gets or sets whether the style font is bold. /// - public const int Default = NativeMethods.SCE_B_DEFAULT; + /// true if bold; otherwise, false. The default is false. + /// Setting this property affects the property. + public bool Bold + { + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETBOLD, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; + } + set + { + IntPtr bold = value ? new IntPtr(1) : IntPtr.Zero; + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETBOLD, new IntPtr(Index), bold); + } + } /// - /// Comment style index. + /// Gets or sets the casing used to display the styled text. /// - public const int Comment = NativeMethods.SCE_B_COMMENT; + /// One of the enum values. The default is . + /// This does not affect how text is stored, only displayed. + public StyleCase Case + { + get + { + int @case = this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETCASE, new IntPtr(Index), IntPtr.Zero).ToInt32(); + return (StyleCase)@case; + } + set + { + // Just an excuse to use @... syntax + int @case = (int)value; + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETCASE, new IntPtr(Index), new IntPtr(@case)); + } + } /// - /// Number style index. + /// This is an experimental and incompletely implemented style attribute. The default setting is changeable set true + /// but when set false it makes text read-only. The user can not move the caret within not-changeable text and + /// not-changeable text may not be deleted by the user. The application may delete not-changeable text by calling + /// . /// - public const int Number = NativeMethods.SCE_B_NUMBER; + /// false to make the text read-only, true otherwise. The default is true. + public bool Changeable + { + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETCHANGEABLE, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; + } + set + { + IntPtr changeable = value ? new IntPtr(1) : IntPtr.Zero; + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETCHANGEABLE, new IntPtr(Index), changeable); + } + } /// - /// Keyword style index. + /// 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. /// - public const int Keyword = NativeMethods.SCE_B_KEYWORD; + /// true to fill the line; otherwise, false. The default is false. + public bool FillLine + { + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETEOLFILLED, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; + } + set + { + IntPtr fillLine = value ? new IntPtr(1) : IntPtr.Zero; + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETEOLFILLED, new IntPtr(Index), fillLine); + } + } /// - /// String style index. + /// Gets or sets the style font name. /// - public const int String = NativeMethods.SCE_B_STRING; + /// 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 + { + int length = this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFONT, new IntPtr(Index), IntPtr.Zero).ToInt32(); + byte[] font = new byte[length]; + unsafe + { + fixed (byte* bp = font) + this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFONT, new IntPtr(Index), new IntPtr(bp)); + } + + string name = Encoding.UTF8.GetString(font, 0, length); + return name; + } + set + { + if (string.IsNullOrEmpty(value)) + value = "Verdana"; + + // Scintilla expects UTF-8 + byte[] font = Helpers.GetBytes(value, Encoding.UTF8, true); + unsafe + { + fixed (byte* bp = font) + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETFONT, new IntPtr(Index), new IntPtr(bp)); + } + } + } /// - /// Preprocessor style index. + /// Gets or sets the foreground color of the style. /// - public const int Preprocessor = NativeMethods.SCE_B_PREPROCESSOR; + /// A Color object representing the style foreground color. The default is Black. + /// Alpha color values are ignored. + public Color ForeColor + { + get + { + int color = this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETFORE, new IntPtr(Index), IntPtr.Zero).ToInt32(); + return HelperMethods.FromWin32ColorOpaque(color); + } + set + { + if (value.IsEmpty) + value = Color.Black; - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_B_OPERATOR; + int color = HelperMethods.ToWin32ColorOpaque(value); + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETFORE, new IntPtr(Index), new IntPtr(color)); + } + } /// - /// Identifier style index. + /// Gets or sets whether hovering the mouse over the style text exhibits hyperlink behavior. /// - public const int Identifier = NativeMethods.SCE_B_IDENTIFIER; + /// true to use hyperlink behavior; otherwise, false. The default is false. + public bool Hotspot + { + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETHOTSPOT, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; + } + set + { + IntPtr hotspot = value ? new IntPtr(1) : IntPtr.Zero; + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETHOTSPOT, new IntPtr(Index), hotspot); + } + } /// - /// Date style index. + /// Gets the zero-based style definition index. /// - public const int Date = NativeMethods.SCE_B_DATE; + /// The style definition index within the . + public int Index { get; private set; } /// - /// Unclosed string EOL style index. + /// Gets or sets whether the style font is italic. /// - public const int StringEol = NativeMethods.SCE_B_STRINGEOL; + /// true if italic; otherwise, false. The default is false. + public bool Italic + { + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETITALIC, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; + } + set + { + IntPtr italic = value ? new IntPtr(1) : IntPtr.Zero; + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETITALIC, new IntPtr(Index), italic); + } + } /// - /// Keyword list 2 (index 1) style index. + /// Gets or sets the size of the style font in points. /// - public const int Keyword2 = NativeMethods.SCE_B_KEYWORD2; + /// The size of the style font as a whole number of points. The default is 8. + public int Size + { + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETSIZE, new IntPtr(Index), IntPtr.Zero).ToInt32(); + } + set + { + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETSIZE, new IntPtr(Index), new IntPtr(value)); + } + } /// - /// Keyword list 3 (index 2) style index. + /// Gets or sets the size of the style font in fractoinal points. /// - public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; + /// The size of the style font in fractional number of points. The default is 8. + public float SizeF + { + get + { + int fraction = this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETSIZEFRACTIONAL, new IntPtr(Index), IntPtr.Zero).ToInt32(); + return (float)fraction / NativeMethods.SC_FONT_SIZE_MULTIPLIER; + } + set + { + int fraction = (int)(value * NativeMethods.SC_FONT_SIZE_MULTIPLIER); + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETSIZEFRACTIONAL, new IntPtr(Index), new IntPtr(fraction)); + } + } /// - /// Keyword list 4 (index 3) style index. + /// Gets or sets whether the style is underlined. /// - public const int Keyword4 = NativeMethods.SCE_B_KEYWORD4; + /// true if underlined; otherwise, false. The default is false. + public bool Underline + { + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETUNDERLINE, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; + } + set + { + IntPtr underline = value ? new IntPtr(1) : IntPtr.Zero; + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETUNDERLINE, new IntPtr(Index), underline); + } + } /// - /// Constant style index. + /// Gets or sets whether the style text is visible. /// - public const int Constant = NativeMethods.SCE_B_CONSTANT; + /// true to display the style text; otherwise, false. The default is true. + public bool Visible + { + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETVISIBLE, new IntPtr(Index), IntPtr.Zero) != IntPtr.Zero; + } + set + { + IntPtr visible = value ? new IntPtr(1) : IntPtr.Zero; + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETVISIBLE, new IntPtr(Index), visible); + } + } /// - /// Inline assembler style index. + /// Gets or sets the style font weight. /// - public const int Asm = NativeMethods.SCE_B_ASM; + /// The font weight. The default is 400. + /// Setting this property affects the property. + public int Weight + { + get + { + return this.scintilla.DirectMessage(NativeMethods.SCI_STYLEGETWEIGHT, new IntPtr(Index), IntPtr.Zero).ToInt32(); + } + set + { + this.scintilla.DirectMessage(NativeMethods.SCI_STYLESETWEIGHT, new IntPtr(Index), new IntPtr(value)); + } + } - /// - /// Label style index. - /// - public const int Label = NativeMethods.SCE_B_LABEL; + #endregion Properties - /// - /// Error style index. - /// - public const int Error = NativeMethods.SCE_B_ERROR; + #region Constructors /// - /// Hexadecimal number style index. + /// Initializes a new instances of the class. /// - public const int HexNumber = NativeMethods.SCE_B_HEXNUMBER; + /// 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; + } - /// - /// Binary number style index. - /// - public const int BinNumber = NativeMethods.SCE_B_BINNUMBER; + #endregion Constructors - /// - /// Block comment style index. - /// - public const int CommentBlock = NativeMethods.SCE_B_COMMENTBLOCK; + #region Ada /// - /// Documentation line style index. + /// Style constants for use with the Ada lexer. /// - public const int DocLine = NativeMethods.SCE_B_DOCLINE; + public static class Ada + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_ADA_DEFAULT; + + /// + /// Line comment style index. + /// + public const int CommentLine = NativeMethods.SCE_ADA_COMMENTLINE; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_ADA_NUMBER; + + /// + /// Keyword style index. + /// + public const int Word = NativeMethods.SCE_ADA_WORD; + + /// + /// Double-quoted string style index. + /// + public const int String = NativeMethods.SCE_ADA_STRING; + + /// + /// Single-quoted string style index. + /// + public const int Character = NativeMethods.SCE_ADA_CHARACTER; + + /// + /// Delimiter style index. + /// + public const int Delimiter = NativeMethods.SCE_ADA_DELIMITER; + + /// + /// Label style index. + /// + public const int Label = NativeMethods.SCE_ADA_LABEL; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_ADA_IDENTIFIER; + + /// + /// Unclosed string EOL style index. + /// + public const int StringEol = NativeMethods.SCE_ADA_STRINGEOL; + + /// + /// Unclosed character EOL style index. + /// + public const int CharacterEol = NativeMethods.SCE_ADA_CHARACTEREOL; + + /// + /// Illegal identifier or keyword style index. + /// + public const int Illegal = NativeMethods.SCE_ADA_ILLEGAL; + } - /// - /// Documentation block style index. - /// - public const int DocBlock = NativeMethods.SCE_B_DOCBLOCK; + #endregion Ada + + #region Asm /// - /// Documentation keyword style index. + /// Style constants for use with the Asm lexer. /// - public const int DocKeyword = NativeMethods.SCE_B_DOCKEYWORD; - } + public static class Asm + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_ASM_DEFAULT; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_ASM_COMMENT; + + /// + /// Comment block style index. + /// + public const int CommentBlock = NativeMethods.SCE_ASM_COMMENTBLOCK; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_ASM_NUMBER; + + /// + /// Math instruction (keword list 1) style index. + /// + public const int MathInstruction = NativeMethods.SCE_ASM_MATHINSTRUCTION; + + /// + /// Double-quoted string style index. + /// + public const int String = NativeMethods.SCE_ASM_STRING; + + /// + /// Single-quoted string style index. + /// + public const int Character = NativeMethods.SCE_ASM_CHARACTER; + + /// + /// CPU instruction (keyword list 0) style index. + /// + public const int CpuInstruction = NativeMethods.SCE_ASM_CPUINSTRUCTION; + + /// + /// Register (keyword list 2) style index. + /// + public const int Register = NativeMethods.SCE_ASM_REGISTER; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_ASM_OPERATOR; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_ASM_IDENTIFIER; + + /// + /// Unclosed string EOL style index. + /// + public const int StringEol = NativeMethods.SCE_ASM_STRINGEOL; + + /// + /// Directive (keyword list 3) string style index. + /// + public const int Directive = NativeMethods.SCE_ASM_DIRECTIVE; + + /// + /// Directive operand (keyword list 4) style index. + /// + public const int DirectiveOperand = NativeMethods.SCE_ASM_DIRECTIVEOPERAND; + + /// + /// Extended instruction (keyword list 5) style index. + /// + public const int ExtInstruction = NativeMethods.SCE_ASM_EXTINSTRUCTION; + + /// + /// Comment directive style index. + /// + public const int CommentDirective = NativeMethods.SCE_ASM_COMMENTDIRECTIVE; + } - #endregion VbScript + #endregion Asm - #region Verilog + #region BlitzBasic - /// - /// Style constants for use with the Verilog lexer. - /// - public static class Verilog - { /// - /// Default (whitespace) style index. + /// Style constants for use with the BlitzBasic lexer. /// - public const int Default = NativeMethods.SCE_V_DEFAULT; + public static class BlitzBasic + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_B_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 (index 1) style index. + /// + public const int Keyword2 = NativeMethods.SCE_B_KEYWORD2; + + /// + /// Keyword list 3 (index 2) style index. + /// + public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; + + /// + /// Keyword list 4 (index 3) 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; + } - /// - /// Comment style index. - /// - public const int Comment = NativeMethods.SCE_V_COMMENT; + #endregion BlitzBasic - /// - /// Comment line style index. - /// - public const int CommentLine = NativeMethods.SCE_V_COMMENTLINE; + #region Batch /// - /// Comment line bang (exclamation) style index. + /// Style constants for use with the Batch lexer. /// - public const int CommentLineBang = NativeMethods.SCE_V_COMMENTLINEBANG; + public static class Batch + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_BAT_DEFAULT; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_BAT_COMMENT; + + /// + /// Keyword (list 0) style index. + /// + public const int Word = NativeMethods.SCE_BAT_WORD; + + /// + /// Label style index. + /// + public const int Label = NativeMethods.SCE_BAT_LABEL; + + /// + /// Hide (@ECHO OFF/ON) style index. + /// + public const int Hide = NativeMethods.SCE_BAT_HIDE; + + /// + /// External command (keyword list 1) style index. + /// + public const int Command = NativeMethods.SCE_BAT_COMMAND; + + /// + /// Identifier string style index. + /// + public const int Identifier = NativeMethods.SCE_BAT_IDENTIFIER; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_BAT_OPERATOR; + } - /// - /// Number style index. - /// - public const int Number = NativeMethods.SCE_V_NUMBER; + #endregion Batch - /// - /// Keyword (set 0) style index. - /// - public const int Word = NativeMethods.SCE_V_WORD; + #region Clw /// - /// String style index. + /// Style constants for use with the Clw lexer. /// - public const int String = NativeMethods.SCE_V_STRING; + public static class CLW + { + /// + /// Attributes style index + /// + public const int Attributes = NativeMethods.SCE_CLW_ATTRIBUTE; + + /// + /// Built in procedures function style index. + /// + public const int BuiltInProceduresFunction = NativeMethods.SCE_CLW_BUILTIN_PROCEDURES_FUNCTION; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_CLW_COMMENT; + + /// + /// Compiler directive style index + /// + public const int CompilerDirective = NativeMethods.SCE_CLW_COMPILER_DIRECTIVE; + + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_CLW_DEFAULT; + + /// + /// Depreciated style index + /// + public const int Depreciated = NativeMethods.SCE_CLW_DEPRECATED; + + /// + /// Error style index + /// + public const int Error = NativeMethods.SCE_CLW_ERROR; + + /// + /// Integer Constant style index. + /// + public const int IntegerConstant = NativeMethods.SCE_CLW_INTEGER_CONSTANT; + + /// + /// Keyword style index + /// + public const int Keyword = NativeMethods.SCE_CLW_KEYWORD; + + /// + /// Label string style index. + /// + public const int Label = NativeMethods.SCE_CLW_LABEL; + + /// + /// Real Constant style index. + /// + public const int PictureString = NativeMethods.SCE_CLW_PICTURE_STRING; + + /// + /// Real Constant style index. + /// + public const int RealConstant = NativeMethods.SCE_CLW_REAL_CONSTANT; + + /// + /// Runtime expressions style index + /// + public const int RuntimeExpressions = NativeMethods.SCE_CLW_RUNTIME_EXPRESSIONS; + + /// + /// Standard equates style index + /// + public const int StandardEquates = NativeMethods.SCE_CLW_STANDARD_EQUATE; + + /// + /// Single-quoted string style index. + /// + public const int String = NativeMethods.SCE_CLW_STRING; + + /// + /// Structure data type style index. + /// + public const int StructureDataTypes = NativeMethods.SCE_CLW_STRUCTURE_DATA_TYPE; + + /// + /// User Identifier style index. + /// + public const int UserIdentifier = NativeMethods.SCE_CLW_USER_IDENTIFIER; + } - /// - /// Keyword (set 1) style index. - /// - public const int Word2 = NativeMethods.SCE_V_WORD2; + #endregion Clw - /// - /// Keyword (set 2) style index. - /// - public const int Word3 = NativeMethods.SCE_V_WORD3; + #region Cpp /// - /// Preprocessor style index. + /// Style constants for use with the Cpp lexer. /// - public const int Preprocessor = NativeMethods.SCE_V_PREPROCESSOR; + 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; + } - /// - /// Operator style index. - /// - public const int Operator = NativeMethods.SCE_V_OPERATOR; + #endregion Cpp - /// - /// Identifier style index. - /// - public const int Identifier = NativeMethods.SCE_V_IDENTIFIER; + #region Css /// - /// Unclosed string EOL style index. + /// Style constants for use with the Css lexer. /// - public const int StringEol = NativeMethods.SCE_V_STRINGEOL; + 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; + } - /// - /// User word (set 3) style index. - /// - public const int User = NativeMethods.SCE_V_USER; + #endregion Css - /// - /// Comment word (set 4) style index. - /// - public const int CommentWord = NativeMethods.SCE_V_COMMENT_WORD; + #region Fortran /// - /// Input style index. + /// Style constants for use with the Fortran lexer. /// - public const int Input = NativeMethods.SCE_V_INPUT; + public static class Fortran + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_F_DEFAULT; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_F_COMMENT; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_F_NUMBER; + + /// + /// Single-quoted string style index. + /// + public const int String1 = NativeMethods.SCE_F_STRING1; + + /// + /// Double-quoted string style index. + /// + public const int String2 = NativeMethods.SCE_F_STRING2; + + /// + /// Unclosed string EOL style index. + /// + public const int StringEol = NativeMethods.SCE_F_STRINGEOL; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_F_OPERATOR; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_F_IDENTIFIER; + + /// + /// Keyword (list 0) style index. + /// + public const int Word = NativeMethods.SCE_F_WORD; + + /// + /// Keyword 2 (list 1) style index. + /// + public const int Word2 = NativeMethods.SCE_F_WORD2; + + /// + /// Keyword 3 (list 2) style index. + /// + public const int Word3 = NativeMethods.SCE_F_WORD3; + + /// + /// Preprocessor style index. + /// + public const int Preprocessor = NativeMethods.SCE_F_PREPROCESSOR; + + /// + /// Operator 2 style index. + /// + public const int Operator2 = NativeMethods.SCE_F_OPERATOR2; + + /// + /// Label string style index. + /// + public const int Label = NativeMethods.SCE_F_LABEL; + + /// + /// Continuation style index. + /// + public const int Continuation = NativeMethods.SCE_F_CONTINUATION; + } - /// - /// Output style index. - /// - public const int Output = NativeMethods.SCE_V_OUTPUT; + #endregion Fortran + + #region FreeBasic /// - /// In-out style index. + /// Style constants for use with the FreeBasic lexer. /// - public const int InOut = NativeMethods.SCE_V_INOUT; + public static class FreeBasic + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_B_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 (index 1) style index. + /// + public const int Keyword2 = NativeMethods.SCE_B_KEYWORD2; + + /// + /// Keyword list 3 (index 2) style index. + /// + public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; + + /// + /// Keyword list 4 (index 3) 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 FreeBasic + + #region Html /// - /// Port connect style index. + /// Style constants for use with the Html lexer. /// - public const int PortConnect = NativeMethods.SCE_V_PORT_CONNECT; - } + public static class Html + { + /// + /// Content style index. + /// + public const int Default = NativeMethods.SCE_H_DEFAULT; + + /// + /// Tag style index. + /// + public const int Tag = NativeMethods.SCE_H_TAG; + + /// + /// Unknown tag style index. + /// + public const int TagUnknown = NativeMethods.SCE_H_TAGUNKNOWN; + + /// + /// Attribute style index. + /// + public const int Attribute = NativeMethods.SCE_H_ATTRIBUTE; + + /// + /// Unknown attribute style index. + /// + public const int AttributeUnknown = NativeMethods.SCE_H_ATTRIBUTEUNKNOWN; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_H_NUMBER; + + /// + /// Double-quoted string style index. + /// + public const int DoubleString = NativeMethods.SCE_H_DOUBLESTRING; + + /// + /// Single-quoted string style index. + /// + public const int SingleString = NativeMethods.SCE_H_SINGLESTRING; + + /// + /// Other tag content (not elements or attributes) style index. + /// + public const int Other = NativeMethods.SCE_H_OTHER; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_H_COMMENT; + + /// + /// Entity ($nnn;) name style index. + /// + public const int Entity = NativeMethods.SCE_H_ENTITY; + + /// + /// End-tag style index. + /// + public const int TagEnd = NativeMethods.SCE_H_TAGEND; + + /// + /// Start of XML declaration (<?xml>) style index. + /// + public const int XmlStart = NativeMethods.SCE_H_XMLSTART; + + /// + /// End of XML declaration (?>) style index. + /// + public const int XmlEnd = NativeMethods.SCE_H_XMLEND; + + /// + /// Script tag (<script>) style index. + /// + public const int Script = NativeMethods.SCE_H_SCRIPT; + + /// + /// ASP-like script engine block (<%) style index. + /// + public const int Asp = NativeMethods.SCE_H_ASP; + + /// + /// ASP-like language declaration (<%@) style index. + /// + public const int AspAt = NativeMethods.SCE_H_ASPAT; + + /// + /// CDATA section style index. + /// + public const int CData = NativeMethods.SCE_H_CDATA; + + /// + /// Question mark style index. + /// + public const int Question = NativeMethods.SCE_H_QUESTION; + + /// + /// Value style index. + /// + public const int Value = NativeMethods.SCE_H_VALUE; + + /// + /// Script engine comment (<%--) style index. + /// + public const int XcComment = NativeMethods.SCE_H_XCCOMMENT; + } - #endregion Verilog + #endregion Html - #region Xml + #region JavaScript - /// - /// Style constants for use with the Xml lexer. - /// - public static class Xml - { /// - /// Content style index. + /// Embedded JavaScript style constants for use with the JavaScript lexer. /// - public const int Default = NativeMethods.SCE_H_DEFAULT; + public static class JavaScript + { + /// + /// Start style index (allows EOL filled background to not start on same line as SCRIPT tag). + /// + public const int Start = NativeMethods.SCE_HJ_START; + + /// + /// Default style index. + /// + public const int Default = NativeMethods.SCE_HJ_DEFAULT; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_HJ_COMMENT; + + /// + /// Line comment style index. + /// + public const int CommentLine = NativeMethods.SCE_HJ_COMMENTLINE; + + /// + /// Doc comment style index. + /// + public const int CommentDoc = NativeMethods.SCE_HJ_COMMENTDOC; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_HJ_NUMBER; + + /// + /// Word style index. + /// + public const int Word = NativeMethods.SCE_HJ_WORD; + + /// + /// Keyword style index. + /// + public const int Keyword = NativeMethods.SCE_HJ_KEYWORD; + + /// + /// Double-quoted string style index. + /// + public const int DoubleString = NativeMethods.SCE_HJ_DOUBLESTRING; + + /// + /// Single-quoted string style index. + /// + public const int SingleString = NativeMethods.SCE_HJ_SINGLESTRING; + + /// + /// Symbols style index. + /// + public const int Symbols = NativeMethods.SCE_HJ_SYMBOLS; + + /// + /// Unclosed string EOL style index. + /// + public const int StringEol = NativeMethods.SCE_HJ_STRINGEOL; + + /// + /// Regular expression style index. + /// + public const int Regex = NativeMethods.SCE_HJ_REGEX; + } + + #endregion JavaScript + + #region Json /// - /// Tag style index. + /// Style constants for use with the Json lexer. /// - public const int Tag = NativeMethods.SCE_H_TAG; + public static class Json + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_JSON_DEFAULT; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_JSON_NUMBER; + + /// + /// String style index. + /// + public const int String = NativeMethods.SCE_JSON_STRING; + + /// + /// Unclosed string EOL style index. + /// + public const int StringEol = NativeMethods.SCE_JSON_STRINGEOL; + + /// + /// Property name style index. + /// + public const int PropertyName = NativeMethods.SCE_JSON_PROPERTYNAME; + + /// + /// Escape sequence style index. + /// + public const int EscapeSequence = NativeMethods.SCE_JSON_ESCAPESEQUENCE; + + /// + /// Line comment style index. + /// + public const int LineComment = NativeMethods.SCE_JSON_LINECOMMENT; + + /// + /// Block comment style index. + /// + public const int BlockComment = NativeMethods.SCE_JSON_BLOCKCOMMENT; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_JSON_OPERATOR; + + /// + /// URI style index. + /// + public const int Uri = NativeMethods.SCE_JSON_URI; + + /// + /// Compact Internationalized Resource Identifier (IRI) style index. + /// + public const int CompactIRI = NativeMethods.SCE_JSON_COMPACTIRI; + + /// + /// Keyword style index. + /// + public const int Keyword = NativeMethods.SCE_JSON_KEYWORD; + + /// + /// Linked data (LD) keyword style index. + /// + public const int LdKeyword = NativeMethods.SCE_JSON_LDKEYWORD; + + /// + /// Error style index. + /// + public const int Error = NativeMethods.SCE_JSON_ERROR; + } + + #endregion Json + + #region Lisp /// - /// Unknown tag style index. + /// Style constants for use with the Lisp lexer. /// - public const int TagUnknown = NativeMethods.SCE_H_TAGUNKNOWN; + public static class Lisp + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_LISP_DEFAULT; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_LISP_COMMENT; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_LISP_NUMBER; + + /// + /// Functions and special operators (list 0) style index. + /// + public const int Keyword = NativeMethods.SCE_LISP_KEYWORD; + + /// + /// Keywords (list 1) style index. + /// + public const int KeywordKw = NativeMethods.SCE_LISP_KEYWORD_KW; + + /// + /// Symbol style index. + /// + public const int Symbol = NativeMethods.SCE_LISP_SYMBOL; + + /// + /// Double-quoted string style index. + /// + public const int String = NativeMethods.SCE_LISP_STRING; + + /// + /// Unclosed string EOL style index. + /// + public const int StringEol = NativeMethods.SCE_LISP_STRINGEOL; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_LISP_IDENTIFIER; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_LISP_OPERATOR; + + /// + /// Special character style index. + /// + public const int Special = NativeMethods.SCE_LISP_SPECIAL; + + /// + /// Multi-line comment style index. + /// + public const int MultiComment = NativeMethods.SCE_LISP_MULTI_COMMENT; + } + + #endregion Lisp + + #region Lua /// - /// Attribute style index. + /// Style constants for use with the Lua lexer. /// - public const int Attribute = NativeMethods.SCE_H_ATTRIBUTE; + public static class Lua + { + /// + /// Default style index. + /// + public const int Default = NativeMethods.SCE_LUA_DEFAULT; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_LUA_COMMENT; + + /// + /// Line comment style index. + /// + public const int CommentLine = NativeMethods.SCE_LUA_COMMENTLINE; + + /// + /// Documentation comment style index. + /// + public const int CommentDoc = NativeMethods.SCE_LUA_COMMENTDOC; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_LUA_NUMBER; + + /// + /// Keyword list 1 (index 0) style index. + /// + public const int Word = NativeMethods.SCE_LUA_WORD; + + /// + /// Double-quoted string style index. + /// + public const int String = NativeMethods.SCE_LUA_STRING; + + /// + /// Single-quoted string style index. + /// + public const int Character = NativeMethods.SCE_LUA_CHARACTER; + + /// + /// Literal string style index. + /// + public const int LiteralString = NativeMethods.SCE_LUA_LITERALSTRING; + + /// + /// Preprocessor style index. + /// + public const int Preprocessor = NativeMethods.SCE_LUA_PREPROCESSOR; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_LUA_OPERATOR; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_LUA_IDENTIFIER; + + /// + /// Unclosed string EOL style index. + /// + public const int StringEol = NativeMethods.SCE_LUA_STRINGEOL; + + /// + /// Keywords list 2 (index 1) style index. + /// + public const int Word2 = NativeMethods.SCE_LUA_WORD2; + + /// + /// Keywords list 3 (index 2) style index. + /// + public const int Word3 = NativeMethods.SCE_LUA_WORD3; + + /// + /// Keywords list 4 (index 3) style index. + /// + public const int Word4 = NativeMethods.SCE_LUA_WORD4; + + /// + /// Keywords list 5 (index 4) style index. + /// + public const int Word5 = NativeMethods.SCE_LUA_WORD5; + + /// + /// Keywords list 6 (index 5) style index. + /// + public const int Word6 = NativeMethods.SCE_LUA_WORD6; + + /// + /// Keywords list 7 (index 6) style index. + /// + public const int Word7 = NativeMethods.SCE_LUA_WORD7; + + /// + /// Keywords list 8 (index 7) style index. + /// + public const int Word8 = NativeMethods.SCE_LUA_WORD8; + + /// + /// Label style index. + /// + public const int Label = NativeMethods.SCE_LUA_LABEL; + } + + #endregion Lua + + #region Matlab /// - /// Unknown attribute style index. + /// Style constants for use with the Matlab lexer. /// - public const int AttributeUnknown = NativeMethods.SCE_H_ATTRIBUTEUNKNOWN; + public static class Matlab + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_MATLAB_DEFAULT; + + /// + /// Line comment style index. + /// + public const int Comment = NativeMethods.SCE_MATLAB_COMMENT; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_MATLAB_NUMBER; + + /// + /// String style index. + /// + public const int String = NativeMethods.SCE_MATLAB_STRING; + + /// + /// Command style index. + /// + public const int Command = NativeMethods.SCE_MATLAB_COMMAND; + + /// + /// Keyword style index. + /// + public const int Keyword = NativeMethods.SCE_MATLAB_KEYWORD; + + /// + /// Double quote string style index. + /// + public const int DoubleQuoteString = NativeMethods.SCE_MATLAB_DOUBLEQUOTESTRING; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_MATLAB_IDENTIFIER; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_MATLAB_OPERATOR; + } + + #endregion Matlab + + #region Pascal /// - /// Number style index. + /// Style constants for use with the Pascal lexer. /// - public const int Number = NativeMethods.SCE_H_NUMBER; + public static class Pascal + { + /// + /// Default style index. + /// + public const int Default = NativeMethods.SCE_PAS_DEFAULT; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_PAS_IDENTIFIER; + + /// + /// Comment style '{' index. + /// + public const int Comment = NativeMethods.SCE_PAS_COMMENT; + + /// + /// Comment style 2 "(*" index. + /// + public const int Comment2 = NativeMethods.SCE_PAS_COMMENT2; + + /// + /// Comment line style "//" index. + /// + public const int CommentLine = NativeMethods.SCE_PAS_COMMENTLINE; + + /// + /// Preprocessor style "{$" index. + /// + public const int Preprocessor = NativeMethods.SCE_PAS_PREPROCESSOR; + + /// + /// Preprocessor style 2 "(*$" index. + /// + public const int Preprocessor2 = NativeMethods.SCE_PAS_PREPROCESSOR2; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_PAS_NUMBER; + + /// + /// Hexadecimal number style index. + /// + public const int HexNumber = NativeMethods.SCE_PAS_HEXNUMBER; + + /// + /// Word (keyword set 0) style index. + /// + public const int Word = NativeMethods.SCE_PAS_WORD; + + /// + /// Double-quoted string style index. + /// + public const int String = NativeMethods.SCE_PAS_STRING; + + /// + /// Unclosed string EOL style index. + /// + public const int StringEol = NativeMethods.SCE_PAS_STRINGEOL; + + /// + /// Single-quoted string style index. + /// + public const int Character = NativeMethods.SCE_PAS_CHARACTER; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_PAS_OPERATOR; + + /// + /// Assembly style index. + /// + public const int Asm = NativeMethods.SCE_PAS_ASM; + } + + #endregion Pascal + + #region Perl /// - /// Double-quoted string style index. + /// Style constants for use with the Perl lexer. /// - public const int DoubleString = NativeMethods.SCE_H_DOUBLESTRING; + public static class Perl + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_PL_DEFAULT; + + /// + /// Error style index. + /// + public const int Error = NativeMethods.SCE_PL_ERROR; + + /// + /// Line comment style index. + /// + public const int CommentLine = NativeMethods.SCE_PL_COMMENTLINE; + + /// + /// POD style index. + /// + public const int Pod = NativeMethods.SCE_PL_POD; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_PL_NUMBER; + + /// + /// Keyword style index. + /// + public const int Word = NativeMethods.SCE_PL_WORD; + + /// + /// Double-quoted string style index. + /// + public const int String = NativeMethods.SCE_PL_STRING; + + /// + /// Single-quoted string style index. + /// + public const int Character = NativeMethods.SCE_PL_CHARACTER; + + /// + /// Punctuation style index. + /// + public const int Punctuation = NativeMethods.SCE_PL_PUNCTUATION; + + /// + /// Preprocessor style index. + /// + public const int Preprocessor = NativeMethods.SCE_PL_PREPROCESSOR; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_PL_OPERATOR; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_PL_IDENTIFIER; + + /// + /// Scalar style index. + /// + public const int Scalar = NativeMethods.SCE_PL_SCALAR; + + /// + /// Array style index. + /// + public const int Array = NativeMethods.SCE_PL_ARRAY; + + /// + /// Hash style index. + /// + public const int Hash = NativeMethods.SCE_PL_HASH; + + /// + /// Symbol table style index. + /// + public const int SymbolTable = NativeMethods.SCE_PL_SYMBOLTABLE; + + /// + /// Variable indexer index. + /// + public const int VariableIndexer = NativeMethods.SCE_PL_VARIABLE_INDEXER; + + /// + /// Regular expression style index. + /// + public const int Regex = NativeMethods.SCE_PL_REGEX; + + /// + /// RegSubst style index. + /// + public const int RegSubst = NativeMethods.SCE_PL_REGSUBST; + + // public const int LongQuote = NativeMethods.SCE_PL_LONGQUOTE; + + /// + /// Backtick (grave accent, backquote) style index. + /// + public const int BackTicks = NativeMethods.SCE_PL_BACKTICKS; + + /// + /// Data section style index. + /// + public const int DataSection = NativeMethods.SCE_PL_DATASECTION; + + /// + /// HereDoc delimiter style index. + /// + public const int HereDelim = NativeMethods.SCE_PL_HERE_DELIM; + + /// + /// HereDoc single-quote style index. + /// + public const int HereQ = NativeMethods.SCE_PL_HERE_Q; + + /// + /// HereDoc double-quote style index. + /// + public const int HereQq = NativeMethods.SCE_PL_HERE_QQ; + + /// + /// HereDoc backtick style index. + /// + public const int HereQx = NativeMethods.SCE_PL_HERE_QX; + + /// + /// Q quote style index. + /// + public const int StringQ = NativeMethods.SCE_PL_STRING_Q; + + /// + /// QQ quote style index. + /// + public const int StringQq = NativeMethods.SCE_PL_STRING_QQ; + + /// + /// QZ quote style index. + /// + public const int StringQx = NativeMethods.SCE_PL_STRING_QX; + + /// + /// QR quote style index. + /// + public const int StringQr = NativeMethods.SCE_PL_STRING_QR; + + /// + /// QW quote style index. + /// + public const int StringQw = NativeMethods.SCE_PL_STRING_QW; + + /// + /// POD verbatim style index. + /// + public const int PodVerb = NativeMethods.SCE_PL_POD_VERB; + + /// + /// Subroutine prototype style index. + /// + public const int SubPrototype = NativeMethods.SCE_PL_SUB_PROTOTYPE; + + /// + /// Format identifier style index. + /// + public const int FormatIdent = NativeMethods.SCE_PL_FORMAT_IDENT; + + /// + /// Format style index. + /// + public const int Format = NativeMethods.SCE_PL_FORMAT; + + /// + /// String variable style index. + /// + public const int StringVar = NativeMethods.SCE_PL_STRING_VAR; + + /// + /// XLAT style index. + /// + public const int XLat = NativeMethods.SCE_PL_XLAT; + + /// + /// Regular expression variable style index. + /// + public const int RegexVar = NativeMethods.SCE_PL_REGEX_VAR; + + /// + /// RegSubst variable style index. + /// + public const int RegSubstVar = NativeMethods.SCE_PL_REGSUBST_VAR; + + /// + /// Backticks variable style index. + /// + public const int BackticksVar = NativeMethods.SCE_PL_BACKTICKS_VAR; + + /// + /// HereDoc QQ quote variable style index. + /// + public const int HereQqVar = NativeMethods.SCE_PL_HERE_QQ_VAR; + + /// + /// HereDoc QX quote variable style index. + /// + public const int HereQxVar = NativeMethods.SCE_PL_HERE_QX_VAR; + + /// + /// QQ quote variable style index. + /// + public const int StringQqVar = NativeMethods.SCE_PL_STRING_QQ_VAR; + + /// + /// QX quote variable style index. + /// + public const int StringQxVar = NativeMethods.SCE_PL_STRING_QX_VAR; + + /// + /// QR quote variable style index. + /// + public const int StringQrVar = NativeMethods.SCE_PL_STRING_QR_VAR; + } + + #endregion Perl + + #region PhpScript /// - /// Single-quoted string style index. + /// Style constants for use with the PhpScript lexer. /// - public const int SingleString = NativeMethods.SCE_H_SINGLESTRING; + public static class PhpScript + { + /// + /// Complex Variable style index. + /// + public const int ComplexVariable = NativeMethods.SCE_HPHP_COMPLEX_VARIABLE; + + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_HPHP_DEFAULT; + + /// + /// Double-quoted string style index. + /// + public const int HString = NativeMethods.SCE_HPHP_HSTRING; + + /// + /// Single-quoted string style index. + /// + public const int SimpleString = NativeMethods.SCE_HPHP_SIMPLESTRING; + + /// + /// Keyword style index. + /// + public const int Word = NativeMethods.SCE_HPHP_WORD; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_HPHP_NUMBER; + + /// + /// Variable style index. + /// + public const int Variable = NativeMethods.SCE_HPHP_VARIABLE; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_HPHP_COMMENT; + + /// + /// Line comment style index. + /// + public const int CommentLine = NativeMethods.SCE_HPHP_COMMENTLINE; + + /// + /// Double-quoted string variable style index. + /// + public const int HStringVariable = NativeMethods.SCE_HPHP_HSTRING_VARIABLE; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_HPHP_OPERATOR; + } + + #endregion PhpScript + + #region PowerShell /// - /// Other tag content (not elements or attributes) style index. + /// Style constants for use with the PowerShell lexer. /// - public const int Other = NativeMethods.SCE_H_OTHER; + public static class PowerShell + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_POWERSHELL_DEFAULT; + + /// + /// Line comment style index + /// + public const int Comment = NativeMethods.SCE_POWERSHELL_COMMENT; + + /// + /// String style index. + /// + public const int String = NativeMethods.SCE_POWERSHELL_STRING; + + /// + /// Character style index. + /// + public const int Character = NativeMethods.SCE_POWERSHELL_CHARACTER; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_POWERSHELL_NUMBER; + + /// + /// Variable style index. + /// + public const int Variable = NativeMethods.SCE_POWERSHELL_VARIABLE; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_POWERSHELL_OPERATOR; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_POWERSHELL_IDENTIFIER; + + /// + /// Keyword (set 0) style index. + /// + public const int Keyword = NativeMethods.SCE_POWERSHELL_KEYWORD; + + /// + /// Cmdlet (set 1) style index. + /// + public const int Cmdlet = NativeMethods.SCE_POWERSHELL_CMDLET; + + /// + /// Alias (set 2) style index. + /// + public const int Alias = NativeMethods.SCE_POWERSHELL_ALIAS; + + /// + /// Function (set 3) style index. + /// + public const int Function = NativeMethods.SCE_POWERSHELL_FUNCTION; + + /// + /// User word (set 4) style index. + /// + public const int User1 = NativeMethods.SCE_POWERSHELL_USER1; + + /// + /// Multi-line comment style index. + /// + public const int CommentStream = NativeMethods.SCE_POWERSHELL_COMMENTSTREAM; + + /// + /// Here string style index. + /// + public const int HereString = NativeMethods.SCE_POWERSHELL_HERE_STRING; + + /// + /// Here character style index. + /// + public const int HereCharacter = NativeMethods.SCE_POWERSHELL_HERE_CHARACTER; + + /// + /// Comment based help keyword style index. + /// + public const int CommentDocKeyword = NativeMethods.SCE_POWERSHELL_COMMENTDOCKEYWORD; + } + + #endregion PowerShell + + #region Properties /// - /// Comment style index. + /// Style constants for use with the Properties lexer. /// - public const int Comment = NativeMethods.SCE_H_COMMENT; + public static class Properties + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_PROPS_DEFAULT; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_PROPS_COMMENT; + + /// + /// Section style index. + /// + public const int Section = NativeMethods.SCE_PROPS_SECTION; + + /// + /// Assignment operator index. + /// + public const int Assignment = NativeMethods.SCE_PROPS_ASSIGNMENT; + + /// + /// Default (registry-only) value index. + /// + public const int DefVal = NativeMethods.SCE_PROPS_DEFVAL; + + /// + /// Key style index. + /// + public const int Key = NativeMethods.SCE_PROPS_KEY; + } + + #endregion Properties + + #region PureBasic /// - /// Entity ($nnn;) name style index. + /// Style constants for use with the PureBasic lexer. /// - public const int Entity = NativeMethods.SCE_H_ENTITY; + public static class PureBasic + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_B_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 (index 1) style index. + /// + public const int Keyword2 = NativeMethods.SCE_B_KEYWORD2; + + /// + /// Keyword list 3 (index 2) style index. + /// + public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; + + /// + /// Keyword list 4 (index 3) 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 PureBasic + + #region Python /// - /// End-tag style index. + /// Style constants for use with the Python lexer. /// - public const int TagEnd = NativeMethods.SCE_H_TAGEND; + 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 Ruby /// - /// Start of XML declaration (<?xml>) style index. + /// Style constants for use with the Ruby lexer. /// - public const int XmlStart = NativeMethods.SCE_H_XMLSTART; + public static class Ruby + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_RB_DEFAULT; + + /// + /// Error style index. + /// + public const int Error = NativeMethods.SCE_RB_ERROR; + + /// + /// Line comment style index. + /// + public const int CommentLine = NativeMethods.SCE_RB_COMMENTLINE; + + /// + /// POD style index. + /// + public const int Pod = NativeMethods.SCE_RB_POD; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_RB_NUMBER; + + /// + /// Keyword style index. + /// + public const int Word = NativeMethods.SCE_RB_WORD; + + /// + /// Double-quoted string style index. + /// + public const int String = NativeMethods.SCE_RB_STRING; + + /// + /// Single-quoted string style index. + /// + public const int Character = NativeMethods.SCE_RB_CHARACTER; + + /// + /// Class name style index. + /// + public const int ClassName = NativeMethods.SCE_RB_CLASSNAME; + + /// + /// Definition style index. + /// + public const int DefName = NativeMethods.SCE_RB_DEFNAME; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_RB_OPERATOR; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_RB_IDENTIFIER; + + /// + /// Regular expression style index. + /// + public const int Regex = NativeMethods.SCE_RB_REGEX; + + /// + /// Global style index. + /// + public const int Global = NativeMethods.SCE_RB_GLOBAL; + + /// + /// Symbol style index. + /// + public const int Symbol = NativeMethods.SCE_RB_SYMBOL; + + /// + /// Module name style index. + /// + public const int ModuleName = NativeMethods.SCE_RB_MODULE_NAME; + + /// + /// Instance variable style index. + /// + public const int InstanceVar = NativeMethods.SCE_RB_INSTANCE_VAR; + + /// + /// Class variable style index. + /// + public const int ClassVar = NativeMethods.SCE_RB_CLASS_VAR; + + /// + /// Backticks style index. + /// + public const int BackTicks = NativeMethods.SCE_RB_BACKTICKS; + + /// + /// Data section style index. + /// + public const int DataSection = NativeMethods.SCE_RB_DATASECTION; + + /// + /// HereDoc delimiter style index. + /// + public const int HereDelim = NativeMethods.SCE_RB_HERE_DELIM; + + /// + /// HereDoc Q quote style index. + /// + public const int HereQ = NativeMethods.SCE_RB_HERE_Q; + + /// + /// HereDoc QQ quote style index. + /// + public const int HereQq = NativeMethods.SCE_RB_HERE_QQ; + + /// + /// HereDoc QX quote style index. + /// + public const int HereQx = NativeMethods.SCE_RB_HERE_QX; + + /// + /// Q quote string style index. + /// + public const int StringQ = NativeMethods.SCE_RB_STRING_Q; + + /// + /// QQ quote string style index. + /// + public const int StringQq = NativeMethods.SCE_RB_STRING_QQ; + + /// + /// QX quote string style index. + /// + public const int StringQx = NativeMethods.SCE_RB_STRING_QX; + + /// + /// QR quote string style index. + /// + public const int StringQr = NativeMethods.SCE_RB_STRING_QR; + + /// + /// QW quote style index. + /// + public const int StringQw = NativeMethods.SCE_RB_STRING_QW; + + /// + /// Demoted keyword style index. + /// + public const int WordDemoted = NativeMethods.SCE_RB_WORD_DEMOTED; + + /// + /// Standard-in style index. + /// + public const int StdIn = NativeMethods.SCE_RB_STDIN; + + /// + /// Standard-out style index. + /// + public const int StdOut = NativeMethods.SCE_RB_STDOUT; + + /// + /// Standard-error style index. + /// + public const int StdErr = NativeMethods.SCE_RB_STDERR; + + // public const int UpperBound = NativeMethods.SCE_RB_UPPER_BOUND; + } + + #endregion Ruby + + #region Smalltalk /// - /// End of XML declaration (?>) style index. + /// Style constants for use with the Smalltalk lexer. /// - public const int XmlEnd = NativeMethods.SCE_H_XMLEND; + public static class Smalltalk + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_ST_DEFAULT; + + /// + /// Double-quoted string style index. + /// + public const int String = NativeMethods.SCE_ST_STRING; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_ST_NUMBER; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_ST_COMMENT; + + /// + /// Symbol style index. + /// + public const int Symbol = NativeMethods.SCE_ST_SYMBOL; + + /// + /// Binary style index. + /// + public const int Binary = NativeMethods.SCE_ST_BINARY; + + /// + /// Bool style index. + /// + public const int Bool = NativeMethods.SCE_ST_BOOL; + + /// + /// Self style index. + /// + public const int Self = NativeMethods.SCE_ST_SELF; + + /// + /// Super style index. + /// + public const int Super = NativeMethods.SCE_ST_SUPER; + + /// + /// NIL style index. + /// + public const int Nil = NativeMethods.SCE_ST_NIL; + + /// + /// Global style index. + /// + public const int Global = NativeMethods.SCE_ST_GLOBAL; + + /// + /// Return style index. + /// + public const int Return = NativeMethods.SCE_ST_RETURN; + + /// + /// Special style index. + /// + public const int Special = NativeMethods.SCE_ST_SPECIAL; + + /// + /// KWS End style index. + /// + public const int KwsEnd = NativeMethods.SCE_ST_KWSEND; + + /// + /// Assign style index. + /// + public const int Assign = NativeMethods.SCE_ST_ASSIGN; + + /// + /// Single-quoted string style index. + /// + public const int Character = NativeMethods.SCE_ST_CHARACTER; + + /// + /// Special selector style index. + /// + public const int SpecSel = NativeMethods.SCE_ST_SPEC_SEL; + } + + #endregion Smalltalk + + #region Sql /// - /// Script tag (<script>) style index. + /// Style constants for use with the Sql lexer. /// - public const int Script = NativeMethods.SCE_H_SCRIPT; + public static class Sql + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_SQL_DEFAULT; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_SQL_COMMENT; + + /// + /// Line comment style index. + /// + public const int CommentLine = NativeMethods.SCE_SQL_COMMENTLINE; + + /// + /// Documentation comment style index. + /// + public const int CommentDoc = NativeMethods.SCE_SQL_COMMENTDOC; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_SQL_NUMBER; + + /// + /// Keyword list 1 (index 0) style index. + /// + public const int Word = NativeMethods.SCE_SQL_WORD; + + /// + /// Double-quoted string style index. + /// + public const int String = NativeMethods.SCE_SQL_STRING; + + /// + /// Single-quoted string style index. + /// + public const int Character = NativeMethods.SCE_SQL_CHARACTER; + + /// + /// Keyword from the SQL*Plus list (index 3) style index. + /// + public const int SqlPlus = NativeMethods.SCE_SQL_SQLPLUS; + + /// + /// SQL*Plus prompt style index. + /// + public const int SqlPlusPrompt = NativeMethods.SCE_SQL_SQLPLUS_PROMPT; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_SQL_OPERATOR; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_SQL_IDENTIFIER; + + /// + /// SQL*Plus comment style index. + /// + public const int SqlPlusComment = NativeMethods.SCE_SQL_SQLPLUS_COMMENT; + + /// + /// Documentation line comment style index. + /// + public const int CommentLineDoc = NativeMethods.SCE_SQL_COMMENTLINEDOC; + + /// + /// Keyword list 2 (index 1) style index. + /// + public const int Word2 = NativeMethods.SCE_SQL_WORD2; + + /// + /// Documentation (Doxygen) keyword style index. + /// + public const int CommentDocKeyword = NativeMethods.SCE_SQL_COMMENTDOCKEYWORD; + + /// + /// Documentation (Doxygen) keyword error style index. + /// + public const int CommentDocKeywordError = NativeMethods.SCE_SQL_COMMENTDOCKEYWORDERROR; + + /// + /// Keyword user-list 1 (index 4) style index. + /// + public const int User1 = NativeMethods.SCE_SQL_USER1; + + /// + /// Keyword user-list 2 (index 5) style index. + /// + public const int User2 = NativeMethods.SCE_SQL_USER2; + + /// + /// Keyword user-list 3 (index 6) style index. + /// + public const int User3 = NativeMethods.SCE_SQL_USER3; + + /// + /// Keyword user-list 4 (index 7) style index. + /// + public const int User4 = NativeMethods.SCE_SQL_USER4; + + /// + /// Quoted identifier style index. + /// + public const int QuotedIdentifier = NativeMethods.SCE_SQL_QUOTEDIDENTIFIER; + + /// + /// Q operator style index. + /// + public const int QOperator = NativeMethods.SCE_SQL_QOPERATOR; + } + + #endregion Sql + + #region Markdown /// - /// ASP-like script engine block (<%) style index. + /// Style constants for use with the Markdown lexer. /// - public const int Asp = NativeMethods.SCE_H_ASP; + public static class Markdown + { + /// + /// Default text style index. + /// + public const int Default = NativeMethods.SCE_MARKDOWN_DEFAULT; + + /// + /// Line begin style index. + /// + public const int LineBegin = NativeMethods.SCE_MARKDOWN_LINE_BEGIN; + + /// + /// Strong type 1 style index. + /// + public const int Strong1 = NativeMethods.SCE_MARKDOWN_STRONG1; + + /// + /// Strong type 2 style index. + /// + public const int Strong2 = NativeMethods.SCE_MARKDOWN_STRONG2; + + /// + /// Empasis type 1 style index. + /// + public const int Em1 = NativeMethods.SCE_MARKDOWN_EM1; + + /// + /// Empasis type 2 style index. + /// + public const int Em2 = NativeMethods.SCE_MARKDOWN_EM2; + + /// + /// Header type 1 style index. + /// + public const int Header1 = NativeMethods.SCE_MARKDOWN_HEADER1; + + /// + /// Header type 2 style index. + /// + public const int Header2 = NativeMethods.SCE_MARKDOWN_HEADER2; + + /// + /// Header type 3 style index. + /// + public const int Header3 = NativeMethods.SCE_MARKDOWN_HEADER3; + + /// + /// Header type 4 style index. + /// + public const int Header4 = NativeMethods.SCE_MARKDOWN_HEADER4; + + /// + /// Header type 5 style index. + /// + public const int Header5 = NativeMethods.SCE_MARKDOWN_HEADER5; + + /// + /// Header type 6 style index. + /// + public const int Header6 = NativeMethods.SCE_MARKDOWN_HEADER6; + + /// + /// Pre char style index. + /// + public const int PreChar = NativeMethods.SCE_MARKDOWN_PRECHAR; + + /// + /// Unordered list style index. + /// + public const int UListItem = NativeMethods.SCE_MARKDOWN_ULIST_ITEM; + + /// + /// Ordered list style index. + /// + public const int OListItem = NativeMethods.SCE_MARKDOWN_OLIST_ITEM; + + /// + /// Blockquote style index. + /// + public const int BlockQuote = NativeMethods.SCE_MARKDOWN_BLOCKQUOTE; + + /// + /// Strikeout style index. + /// + public const int Strikeout = NativeMethods.SCE_MARKDOWN_STRIKEOUT; + + /// + /// Horizontal rule style index. + /// + public const int HRule = NativeMethods.SCE_MARKDOWN_HRULE; + + /// + /// Link style index. + /// + public const int Link = NativeMethods.SCE_MARKDOWN_LINK; + + /// + /// Code type 1 style index. + /// + public const int Code = NativeMethods.SCE_MARKDOWN_CODE; + + /// + /// Code type 2 style index. + /// + public const int Code2 = NativeMethods.SCE_MARKDOWN_CODE2; + + /// + /// Code block style index. + /// + public const int CodeBk = NativeMethods.SCE_MARKDOWN_CODEBK; + } + + #endregion Markdown + + #region R /// - /// ASP-like language declaration (<%@) style index. + /// Style constants for use with the R lexer. /// - public const int AspAt = NativeMethods.SCE_H_ASPAT; + public static class R + { + /// + /// Default style index. + /// + public const int Default = NativeMethods.SCE_R_DEFAULT; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_R_COMMENT; + + /// + /// Keyword (set 0) style index. + /// + public const int KWord = NativeMethods.SCE_R_KWORD; + + /// + /// Base keyword (set 1) style index. + /// + public const int BaseKWord = NativeMethods.SCE_R_BASEKWORD; + + /// + /// Other keyword (set 2) style index. + /// + public const int OtherKWord = NativeMethods.SCE_R_OTHERKWORD; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_R_NUMBER; + + /// + /// Double-quoted string style index. + /// + public const int String = NativeMethods.SCE_R_STRING; + + /// + /// Single-quoted string style index. + /// + public const int String2 = NativeMethods.SCE_R_STRING2; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_R_OPERATOR; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_R_IDENTIFIER; + + /// + /// Infix style index. + /// + public const int Infix = NativeMethods.SCE_R_INFIX; + + /// + /// Unclosed infix EOL style index. + /// + public const int InfixEol = NativeMethods.SCE_R_INFIXEOL; + } + + #endregion R + + #region Vb /// - /// CDATA section style index. + /// Style constants for use with the Vb lexer. /// - public const int CData = NativeMethods.SCE_H_CDATA; + public static class Vb + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_B_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 (index 1) style index. + /// + public const int Keyword2 = NativeMethods.SCE_B_KEYWORD2; + + /// + /// Keyword list 3 (index 2) style index. + /// + public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; + + /// + /// Keyword list 4 (index 3) 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 Vb + + #region VbScript /// - /// Question mark style index. + /// Style constants for use with the VbScript lexer. /// - public const int Question = NativeMethods.SCE_H_QUESTION; + public static class VbScript + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_B_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 (index 1) style index. + /// + public const int Keyword2 = NativeMethods.SCE_B_KEYWORD2; + + /// + /// Keyword list 3 (index 2) style index. + /// + public const int Keyword3 = NativeMethods.SCE_B_KEYWORD3; + + /// + /// Keyword list 4 (index 3) 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 VbScript + + #region Verilog /// - /// Value style index. + /// Style constants for use with the Verilog lexer. /// - public const int Value = NativeMethods.SCE_H_VALUE; + public static class Verilog + { + /// + /// Default (whitespace) style index. + /// + public const int Default = NativeMethods.SCE_V_DEFAULT; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_V_COMMENT; + + /// + /// Comment line style index. + /// + public const int CommentLine = NativeMethods.SCE_V_COMMENTLINE; + + /// + /// Comment line bang (exclamation) style index. + /// + public const int CommentLineBang = NativeMethods.SCE_V_COMMENTLINEBANG; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_V_NUMBER; + + /// + /// Keyword (set 0) style index. + /// + public const int Word = NativeMethods.SCE_V_WORD; + + /// + /// String style index. + /// + public const int String = NativeMethods.SCE_V_STRING; + + /// + /// Keyword (set 1) style index. + /// + public const int Word2 = NativeMethods.SCE_V_WORD2; + + /// + /// Keyword (set 2) style index. + /// + public const int Word3 = NativeMethods.SCE_V_WORD3; + + /// + /// Preprocessor style index. + /// + public const int Preprocessor = NativeMethods.SCE_V_PREPROCESSOR; + + /// + /// Operator style index. + /// + public const int Operator = NativeMethods.SCE_V_OPERATOR; + + /// + /// Identifier style index. + /// + public const int Identifier = NativeMethods.SCE_V_IDENTIFIER; + + /// + /// Unclosed string EOL style index. + /// + public const int StringEol = NativeMethods.SCE_V_STRINGEOL; + + /// + /// User word (set 3) style index. + /// + public const int User = NativeMethods.SCE_V_USER; + + /// + /// Comment word (set 4) style index. + /// + public const int CommentWord = NativeMethods.SCE_V_COMMENT_WORD; + + /// + /// Input style index. + /// + public const int Input = NativeMethods.SCE_V_INPUT; + + /// + /// Output style index. + /// + public const int Output = NativeMethods.SCE_V_OUTPUT; + + /// + /// In-out style index. + /// + public const int InOut = NativeMethods.SCE_V_INOUT; + + /// + /// Port connect style index. + /// + public const int PortConnect = NativeMethods.SCE_V_PORT_CONNECT; + } + + #endregion Verilog + + #region Xml /// - /// Script engine comment (<%--) style index. + /// Style constants for use with the Xml lexer. /// - public const int XcComment = NativeMethods.SCE_H_XCCOMMENT; - } + public static class Xml + { + /// + /// Content style index. + /// + public const int Default = NativeMethods.SCE_H_DEFAULT; + + /// + /// Tag style index. + /// + public const int Tag = NativeMethods.SCE_H_TAG; + + /// + /// Unknown tag style index. + /// + public const int TagUnknown = NativeMethods.SCE_H_TAGUNKNOWN; + + /// + /// Attribute style index. + /// + public const int Attribute = NativeMethods.SCE_H_ATTRIBUTE; + + /// + /// Unknown attribute style index. + /// + public const int AttributeUnknown = NativeMethods.SCE_H_ATTRIBUTEUNKNOWN; + + /// + /// Number style index. + /// + public const int Number = NativeMethods.SCE_H_NUMBER; + + /// + /// Double-quoted string style index. + /// + public const int DoubleString = NativeMethods.SCE_H_DOUBLESTRING; + + /// + /// Single-quoted string style index. + /// + public const int SingleString = NativeMethods.SCE_H_SINGLESTRING; + + /// + /// Other tag content (not elements or attributes) style index. + /// + public const int Other = NativeMethods.SCE_H_OTHER; + + /// + /// Comment style index. + /// + public const int Comment = NativeMethods.SCE_H_COMMENT; + + /// + /// Entity ($nnn;) name style index. + /// + public const int Entity = NativeMethods.SCE_H_ENTITY; + + /// + /// End-tag style index. + /// + public const int TagEnd = NativeMethods.SCE_H_TAGEND; + + /// + /// Start of XML declaration (<?xml>) style index. + /// + public const int XmlStart = NativeMethods.SCE_H_XMLSTART; + + /// + /// End of XML declaration (?>) style index. + /// + public const int XmlEnd = NativeMethods.SCE_H_XMLEND; + + /// + /// Script tag (<script>) style index. + /// + public const int Script = NativeMethods.SCE_H_SCRIPT; + + /// + /// ASP-like script engine block (<%) style index. + /// + public const int Asp = NativeMethods.SCE_H_ASP; + + /// + /// ASP-like language declaration (<%@) style index. + /// + public const int AspAt = NativeMethods.SCE_H_ASPAT; + + /// + /// CDATA section style index. + /// + public const int CData = NativeMethods.SCE_H_CDATA; + + /// + /// Question mark style index. + /// + public const int Question = NativeMethods.SCE_H_QUESTION; + + /// + /// Value style index. + /// + public const int Value = NativeMethods.SCE_H_VALUE; + + /// + /// Script engine comment (<%--) style index. + /// + public const int XcComment = NativeMethods.SCE_H_XCCOMMENT; + } - #endregion Xml + #endregion Xml + } } diff --git a/Scintilla.NET/StyleCase.cs b/Scintilla.NET/StyleCase.cs index 7339970..946d128 100644 --- a/Scintilla.NET/StyleCase.cs +++ b/Scintilla.NET/StyleCase.cs @@ -1,27 +1,28 @@ -namespace ScintillaNET; - -/// -/// The possible casing styles of a style. -/// -public enum StyleCase +namespace ScintillaNET { /// - /// Display the text normally. + /// The possible casing styles of a style. /// - Mixed = NativeMethods.SC_CASE_MIXED, + 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 upper case. + /// + Upper = NativeMethods.SC_CASE_UPPER, - /// - /// Display the text in lower case. - /// - Lower = NativeMethods.SC_CASE_LOWER, + /// + /// Display the text in lower case. + /// + Lower = NativeMethods.SC_CASE_LOWER, - /// - /// Display the text in camel case. - /// - Camel = NativeMethods.SC_CASE_CAMEL + /// + /// Display the text in camel case. + /// + Camel = NativeMethods.SC_CASE_CAMEL + } } diff --git a/Scintilla.NET/StyleCollection.cs b/Scintilla.NET/StyleCollection.cs index d626202..1912fed 100644 --- a/Scintilla.NET/StyleCollection.cs +++ b/Scintilla.NET/StyleCollection.cs @@ -1,66 +1,67 @@ using System.Collections; using System.Collections.Generic; -namespace ScintillaNET; - -/// -/// An immutable collection of style definitions in a control. -/// -public class StyleCollection : IEnumerable