PageRenderTime 1044ms CodeModel.GetById 1040ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 1ms

/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineElementGenerator.cs

http://github.com/icsharpcode/ILSpy
C# | 78 lines | 25 code | 8 blank | 45 comment | 2 complexity | 5527a9cde2dd2adcb54213c89a7decb0 MD5 | raw file
 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;
20
21namespace ICSharpCode.AvalonEdit.Rendering
22{
23	/// <summary>
24	/// Abstract base class for generators that produce new visual line elements.
25	/// </summary>
26	public abstract class VisualLineElementGenerator
27	{
28		/// <summary>
29		/// Gets the text run construction context.
30		/// </summary>
31		protected ITextRunConstructionContext CurrentContext { get; private set; }
32		
33		/// <summary>
34		/// Initializes the generator for the <see cref="ITextRunConstructionContext"/>
35		/// </summary>
36		public virtual void StartGeneration(ITextRunConstructionContext context)
37		{
38			if (context == null)
39				throw new ArgumentNullException("context");
40			this.CurrentContext = context;
41		}
42		
43		/// <summary>
44		/// De-initializes the generator.
45		/// </summary>
46		public virtual void FinishGeneration()
47		{
48			this.CurrentContext = null;
49		}
50		
51		/// <summary>
52		/// Should only be used by VisualLine.ConstructVisualElements.
53		/// </summary>
54		internal int cachedInterest;
55		
56		/// <summary>
57		/// Gets the first offset >= startOffset where the generator wants to construct an element.
58		/// Return -1 to signal no interest.
59		/// </summary>
60		public abstract int GetFirstInterestedOffset(int startOffset);
61		
62		/// <summary>
63		/// Constructs an element at the specified offset.
64		/// May return null if no element should be constructed.
65		/// </summary>
66		/// <remarks>
67		/// Avoid signalling interest and then building no element by returning null - doing so
68		/// causes the generated <see cref="VisualLineText"/> elements to be unnecessarily split
69		/// at the position where you signalled interest.
70		/// </remarks>
71		public abstract VisualLineElement ConstructElement(int offset);
72	}
73	
74	internal interface IBuiltinElementGenerator
75	{
76		void FetchOptions(TextEditorOptions options);
77	}
78}