Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Highlighting/IHighlighter.cs

Last change on this file was 11700, checked in by jkarder, 10 years ago

#2077: created branch and added first version

File size: 5.7 KB
Line 
1// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4// software and associated documentation files (the "Software"), to deal in the Software
5// without restriction, including without limitation the rights to use, copy, modify, merge,
6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7// to whom the Software is furnished to do so, subject to the following conditions:
8//
9// The above copyright notice and this permission notice shall be included in all copies or
10// substantial portions of the Software.
11//
12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17// DEALINGS IN THE SOFTWARE.
18
19using System;
20using System.Collections.Generic;
21#if NREFACTORY
22using ICSharpCode.NRefactory.Editor;
23#else
24using ICSharpCode.AvalonEdit.Document;
25#endif
26
27namespace ICSharpCode.AvalonEdit.Highlighting
28{
29  /// <summary>
30  /// Represents a highlighted document.
31  /// </summary>
32  /// <remarks>This interface is used by the <see cref="HighlightingColorizer"/> to register the highlighter as a TextView service.</remarks>
33  public interface IHighlighter : IDisposable
34  {
35    /// <summary>
36    /// Gets the underlying text document.
37    /// </summary>
38    IDocument Document { get; }
39   
40    /// <summary>
41    /// Gets the stack of active colors (the colors associated with the active spans) at the end of the specified line.
42    /// -> GetColorStack(1) returns the colors at the start of the second line.
43    /// </summary>
44    /// <remarks>
45    /// GetColorStack(0) is valid and will return the empty stack.
46    /// The elements are returned in inside-out order (first element of result enumerable is the color of the innermost span).
47    /// </remarks>
48    IEnumerable<HighlightingColor> GetColorStack(int lineNumber);
49   
50    // Starting with SD 5.0, this interface exports GetColorStack() instead of GetSpanStack().
51    // This was done because custom highlighter implementations might not use the HighlightingSpan class (AST-based highlighting).
52   
53    /// <summary>
54    /// Highlights the specified document line.
55    /// </summary>
56    /// <param name="lineNumber">The line to highlight.</param>
57    /// <returns>A <see cref="HighlightedLine"/> line object that represents the highlighted sections.</returns>
58    HighlightedLine HighlightLine(int lineNumber);
59   
60    /// <summary>
61    /// Enforces a highlighting state update (triggering the HighlightingStateChanged event if necessary)
62    /// for all lines up to (and inclusive) the specified line number.
63    /// </summary>
64    void UpdateHighlightingState(int lineNumber);
65   
66    /// <summary>
67    /// Notification when the highlighter detects that the highlighting state at the
68    /// <b>beginning</b> of the specified lines has changed.
69    /// <c>fromLineNumber</c> and <c>toLineNumber</c> are both inclusive;
70    /// the common case of a single-line change is represented by <c>fromLineNumber == toLineNumber</c>.
71    ///
72    /// During highlighting, the highlighting of line X will cause this event to be raised
73    /// for line X+1 if the highlighting state at the end of line X has changed from its previous state.
74    /// This event may also be raised outside of the highlighting process to signalize that
75    /// changes to external data (not the document text; but e.g. semantic information)
76    /// require a re-highlighting of the specified lines.
77    /// </summary>
78    /// <remarks>
79    /// For implementers: there is the requirement that, during highlighting,
80    /// if there was no state changed reported for the beginning of line X,
81    /// and there were no document changes between the start of line X and the start of line Y (with Y > X),
82    /// then this event must not be raised for any line between X and Y (inclusive).
83    ///
84    /// Equal input state + unchanged line = Equal output state.
85    ///
86    /// See the comment in the HighlightingColorizer.OnHighlightStateChanged implementation
87    /// for details about the requirements for a correct custom IHighlighter.
88    ///
89    /// Outside of the highlighting process, this event can be raised without such restrictions.
90    /// </remarks>
91    event HighlightingStateChangedEventHandler HighlightingStateChanged;
92   
93    /// <summary>
94    /// Opens a group of <see cref="HighlightLine"/> calls.
95    /// It is not necessary to call this method before calling <see cref="HighlightLine"/>,
96    /// however, doing so can make the highlighting much more performant in some cases
97    /// (e.g. the C# semantic highlighter in SharpDevelop will re-use the resolver within a highlighting group).
98    /// </summary>
99    /// <remarks>
100    /// The group is closed by either a <see cref="EndHighlighting"/> or a <see cref="IDisposable.Dispose"/> call.
101    /// Nested groups are not allowed.
102    /// </remarks>
103    void BeginHighlighting();
104   
105    /// <summary>
106    /// Closes the currently opened group of <see cref="HighlightLine"/> calls.
107    /// </summary>
108    /// <seealso cref="BeginHighlighting"/>.
109    void EndHighlighting();
110   
111    /// <summary>
112    /// Retrieves the HighlightingColor with the specified name. Returns null if no color matching the name is found.
113    /// </summary>
114    HighlightingColor GetNamedColor(string name);
115   
116    /// <summary>
117    /// Gets the default text color.
118    /// </summary>
119    HighlightingColor DefaultTextColor { get; }
120  }
121 
122  /// <summary>
123  /// Event handler for <see cref="IHighlighter.HighlightingStateChanged"/>
124  /// </summary>
125  public delegate void HighlightingStateChangedEventHandler(int fromLineNumber, int toLineNumber);
126}
Note: See TracBrowser for help on using the repository browser.