Browse Source

Copied information from the Code Project article into the AvalonEdit help file.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5053 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
c9fc64257d
  1. 24
      samples/AvalonEdit.Sample/article.html
  2. 33
      src/Libraries/AvalonEdit/Documentation/Architecture.aml
  3. 133
      src/Libraries/AvalonEdit/Documentation/Code Completion.aml
  4. 175
      src/Libraries/AvalonEdit/Documentation/Coordinate Systems.aml
  5. 58
      src/Libraries/AvalonEdit/Documentation/Folding.aml
  6. 12
      src/Libraries/AvalonEdit/Documentation/ICSharpCode.AvalonEdit.content
  7. 165
      src/Libraries/AvalonEdit/Documentation/ICSharpCode.AvalonEdit.shfbproj
  8. 566
      src/Libraries/AvalonEdit/Documentation/License.html
  9. BIN
      src/Libraries/AvalonEdit/Documentation/Media/NamespaceDependencies.png
  10. BIN
      src/Libraries/AvalonEdit/Documentation/Media/RenderingPipeline.png
  11. BIN
      src/Libraries/AvalonEdit/Documentation/Media/VisualTree.png
  12. BIN
      src/Libraries/AvalonEdit/Documentation/Media/WelcomeScreenshot.png
  13. 78
      src/Libraries/AvalonEdit/Documentation/Sample Application.aml
  14. 187
      src/Libraries/AvalonEdit/Documentation/Syntax Highlighting.aml
  15. 162
      src/Libraries/AvalonEdit/Documentation/Text Rendering.aml
  16. 50
      src/Libraries/AvalonEdit/Documentation/Welcome.aml
  17. 10
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ChangeTrackingCheckpoint.cs
  18. 25
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentLine.cs
  19. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ILineTracker.cs
  20. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ISegment.cs
  21. 48
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextAnchor.cs
  22. 99
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs
  23. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextLocation.cs
  24. 28
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegment.cs
  25. 16
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegmentCollection.cs
  26. 9
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  27. 77
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.shfb
  28. 167
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/documentation/Coordinate Systems.xml
  29. 32
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/documentation/Folding.xml
  30. 72
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/documentation/Introduction.xml
  31. 55
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/documentation/SyntaxHighlighting.xml

24
samples/AvalonEdit.Sample/article.html

@ -45,7 +45,7 @@ CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; } @@ -45,7 +45,7 @@ CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; }
<ul class=download>
<li><a href="AvalonEdit/AvalonEdit_Binaries.zip">Download binaries - 206.5 KB</a></li>
<li><a href="AvalonEdit/AvalonEdit_Source.zip">Download source code - 350.29 KB</a></li>
<li><a href="AvalonEdit/AvalonEdit_Source.zip">Download source code - 391.3 KB</a></li>
<li><a href="AvalonEdit/AvalonEdit_CHM_Documentation.zip">Download .chm documentation file - 1.88 MB</a></li>
</ul>
<p>The latest version of AvalonEdit can be found as part of the <a href="http://www.icsharpcode.net/OpenSource/SD/">SharpDevelop</a> project.
@ -72,7 +72,7 @@ for <a href="http://www.codeproject.com/KB/edit/TextEditorControl.aspx">ICSharpC @@ -72,7 +72,7 @@ for <a href="http://www.codeproject.com/KB/edit/TextEditorControl.aspx">ICSharpC
For example, an AddIn should be able to allow inserting images into comments &ndash; this way you could put
stuff like class diagrams right into the source code!
<p>
With, <b>Easy to use</b>, I'm referring to the programming API. It should just work&trade;.
With, <b>Easy to use</b>, I'm referring to the programming API. It should just work.
For example, this means if you change the document text,
the editor should automatically redraw without having to call <code>Invalidate()</code>.
@ -101,7 +101,7 @@ ASP.NET, Boo, Coco/R grammars, C++, C#, HTML, Java, JavaScript, Patch files, PHP @@ -101,7 +101,7 @@ ASP.NET, Boo, Coco/R grammars, C++, C#, HTML, Java, JavaScript, Patch files, PHP
<p>If you need more of AvalonEdit than a simple text box with syntax highlighting, you will first have to learn more about the architecture of AvalonEdit.
<!------------------------------------------------------------>
<h2>Architecture</h2>
<h2>Architecture of AvalonEdit</h2>
<img src="AvalonEdit/dependencies.png" width="583" height="439" alt="Namespace Dependency Graph"/>
<p>
As you can see in this dependency graph, AvalonEdit consists of a few sub-namespaces that have cleanly separated jobs.
@ -127,7 +127,7 @@ While the main control provides some convenience methods for common tasks, for m @@ -127,7 +127,7 @@ While the main control provides some convenience methods for common tasks, for m
or <code>textEditor.TextArea.TextView</code>.
<!------------------------------------------------------------>
<h2>Document (The Text Model)</h2>
<h2>The Text Model: Document</h2>
<p>The main class of the model is <code>ICSharpCode.AvalonEdit.Document.TextDocument</code>.
Basically, the document is a <code>StringBuilder</code> with events.
@ -179,7 +179,7 @@ Those are convenience methods built on top of the <code>DocumentLine</code> clas @@ -179,7 +179,7 @@ Those are convenience methods built on top of the <code>DocumentLine</code> clas
This collection is read-only to user code and is automatically updated to reflect the current document content.
<!------------------------------------------------------------>
<h2>Rendering</h2>
<h2>Rendering: TextView</h2>
In the whole 'Document' section, there was no mention of extensibility.
The text rendering infrastructure now has to compensate for that by being completely extensible.
@ -200,7 +200,7 @@ them to the <code>TextView</code> to implement additional features in the editor @@ -200,7 +200,7 @@ them to the <code>TextView</code> to implement additional features in the editor
The extensibility features of the rendering namespace are discussed in detail in the article "AvalonEdit Rendering". (to be published soon)
-->
<h2>Editing</h2>
<h2>Editing: TextArea</h2>
The <code>TextArea</code> class is handling user input and executing the appropriate actions.
Both the caret and the selection are controlled by the <code>TextArea</code>.
@ -236,7 +236,7 @@ Currently, only the <code>XmlFoldingStrategy</code> is built into AvalonEdit. @@ -236,7 +236,7 @@ Currently, only the <code>XmlFoldingStrategy</code> is built into AvalonEdit.
The sample application to this article also contains the <code>BraceFoldingStrategy</code> that folds using { and }.
However, it is a very simple implementation and does not handle { and } inside strings or comments correctly.
<h2>Syntax highlighting</h2>
<h2>Syntax Highlighting</h2>
The highlighting engine in AvalonEdit is implemented in the class <code>DocumentHighlighter</code>.
Highlighting is the process of taking a <code>DocumentLine</code> and constructing a <code>HighlightedLine</code> instance for it
by assigning colors to different sections of the line.
@ -289,17 +289,17 @@ Here is a complete highlighting definition for a sub-set of C#: @@ -289,17 +289,17 @@ Here is a complete highlighting definition for a sub-set of C#:
The highlighting engine works with "spans" and "rules" that each have a color assigned to them. In the XSHD format, colors can be both
referenced (<code>color="Comment"</code>) or directly specified (<code>fontWeight="bold" foreground="Blue"</code>).
<p>
Spans consist of two regular expressions (begin+end); while rules are simply a single regex with a color. The <code>&lt;Keywords></code> element is just a nice
syntax to define a highlighting rule that matches a set of words; internally a single regex will be used for the whole keyword list.
Spans consist of two regular expressions (begin+end), while rules are simply a single RegEx with a color. The <code>&lt;Keywords></code> element is just a nice
syntax to define a highlighting rule that matches a set of words; internally a single RegEx will be used for the whole keyword list.
<p>
The highlighting engine works by first analyzing the spans: whenever a begin regex matches some text, that span is pushed onto a stack.
Whenever the end regex of the current span matches some text, the span is popped from the stack.
The highlighting engine works by first analyzing the spans: whenever a begin RegEx matches some text, that span is pushed onto a stack.
Whenever the end RegEx of the current span matches some text, the span is popped from the stack.
<p>
Each span has a nested rule set associated with it, which is empty by default.
This is why keywords won't be highlighted inside comments: the span's empty ruleset is active there, so the keyword rule is not applied.
<p>
This feature is also used in the string span: the nested span will match when a backslash is encountered, and the character following the backslash
will be consumed by the end regex of the nested span (<code>.</code> matches any character).
will be consumed by the end RegEx of the nested span (<code>.</code> matches any character).
This ensures that <code>\"</code> does not denote the end of the string span; but <code>\\"</code> still does.
<p>
What's great about the highlighting engine is that it highlights only on-demand, works incrementally,

33
src/Libraries/AvalonEdit/Documentation/Architecture.aml

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="5d1af8a2-fc1b-4a1b-b6c1-f33fb14bec1f" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--
<summary>
<para>Optional summary abstract</para>
</summary>
-->
<introduction>
<!-- Uncomment this to generate an outline of the section and sub-section
titles. Specify a numeric value as the inner text to limit it to
a specific number of sub-topics when creating the outline. Specify
zero (0) to limit it to top-level sections only. -->
<!-- <autoOutline /> -->
<mediaLink><image xlink:href="NamespaceDependencies" placement="center"/></mediaLink>
<para>As you can see in this dependency graph, AvalonEdit consists of a few
sub-namespaces that have cleanly separated jobs.
Most of the namespaces have a kind of 'main' class.</para>
<para>Here is the visual tree of the TextEditor control:</para>
<mediaLink><image xlink:href="VisualTree" placement="center"/></mediaLink>
<para>It's important to understand that AvalonEdit is a composite control
with the three layers:
<codeEntityReference>T:ICSharpCode.AvalonEdit.TextEditor</codeEntityReference> (main control),
<codeEntityReference>T:ICSharpCode.AvalonEdit.Editing.TextArea</codeEntityReference> (editing),
<codeEntityReference>T:ICSharpCode.AvalonEdit.Rendering.TextView</codeEntityReference> (rendering).
</para><para>
While the main control provides some convenience methods for common tasks,
for most advanced features you have to work directly with the inner controls.
You can access them using <codeInline>textEditor.TextArea</codeInline> or
<codeInline>textEditor.TextArea.TextView</codeInline>.</para>
</introduction>
</developerConceptualDocument>
</topic>

133
src/Libraries/AvalonEdit/Documentation/Code Completion.aml

@ -0,0 +1,133 @@ @@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="47c58b63-f30c-4290-a2f2-881d21227446" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>
AvalonEdit comes with a code completion drop down window.
You only have to handle the text entering events to determine
when you want to show the window; all the UI is already done for you.
</para>
</introduction>
<section>
<title>Usage of the Code Completion Window</title>
<content>
<code language="cs">
// in the constructor:
textEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering;
textEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered;
}
CompletionWindow completionWindow;
void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
{
if (e.Text == ".") {
// Open code completion after the user has pressed dot:
completionWindow = new CompletionWindow(textEditor.TextArea);
IList&lt;ICompletionData&gt; data = completionWindow.CompletionList.CompletionData;
data.Add(new MyCompletionData("Item1"));
data.Add(new MyCompletionData("Item2"));
data.Add(new MyCompletionData("Item3"));
completionWindow.Show();
completionWindow.Closed += delegate {
completionWindow = null;
};
}
}
void textEditor_TextArea_TextEntering(object sender, TextCompositionEventArgs e)
{
if (e.Text.Length > 0 &amp;&amp; completionWindow != null) {
if (!char.IsLetterOrDigit(e.Text[0])) {
// Whenever a non-letter is typed while the completion window is open,
// insert the currently selected element.
completionWindow.CompletionList.RequestInsertion(e);
}
}
// Do not set e.Handled=true.
// We still want to insert the character that was typed.
}
</code>
<para>
This code will open the code completion window whenever '.' is pressed.
By default, the
<codeEntityReference>T:ICSharpCode.AvalonEdit.CodeCompletion.CompletionWindow</codeEntityReference>
only handles key presses like Tab and Enter to insert the currently
selected item. To also make it complete when keys like '.' or ';' are pressed,
we attach another handler to the <codeInline>TextEntering</codeInline> event
and tell the completion window to insert the selected item.
</para>
<para>
The <codeInline>CompletionWindow</codeInline> will actually never have
focus - instead, it hijacks
the WPF keyboard input events on the text area and passes them through its
<codeInline>ListBox</codeInline>.
This allows selecting entries in the completion list using the
keyboard and normal typing in the editor at the same time.
</para>
<para>
Here is the implementation of the MyCompletionData class used in the code above:
<code language="cs">
/// Implements AvalonEdit ICompletionData interface to provide the entries in the
/// completion drop down.
public class MyCompletionData : ICompletionData
{
public MyCompletionData(string text)
{
this.Text = text;
}
public System.Windows.Media.ImageSource Image {
get { return null; }
}
public string Text { get; private set; }
// Use this property if you want to show a fancy UIElement in the list.
public object Content {
get { return this.Text; }
}
public object Description {
get { return "Description for " + this.Text; }
}
public void Complete(TextArea textArea, ISegment completionSegment,
EventArgs insertionRequestEventArgs)
{
textArea.Document.Replace(completionSegment, this.Text);
}
}
</code>
Both the content and the description shown may be any content acceptable in WPF,
including custom UIElements.
You may also implement custom logic in the <codeInline>Complete</codeInline>
method if you want to do more than simply inserting the text.
The <codeInline>insertionRequestEventArgs</codeInline> can help decide which
kind of insertion the user wants - depending on how the insertion was triggered,
it is an instance of <codeInline>TextCompositionEventArgs</codeInline>,
<codeInline>KeyEventArgs</codeInline> or <codeInline>MouseEventArgs</codeInline>.
</para>
</content>
</section>
<section>
<title>Code Completion for C#</title>
<content>
<para>
Full C# code completion is not in the scope of AvalonEdit.
You will need a C# parser, a C# type system, and the ability
to resolve C# expressions in your type system.
</para>
<para>
If you want to learn how this is handled in SharpDevelop, please
see:
<externalLink>
<linkText>Code Completion in SharpDevelop</linkText>
<linkUri>http://wiki.sharpdevelop.net/CodeCompletion.ashx</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>
</para>
</content>
</section>
</developerConceptualDocument>
</topic>

175
src/Libraries/AvalonEdit/Documentation/Coordinate Systems.aml

@ -0,0 +1,175 @@ @@ -0,0 +1,175 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="5b1854b4-884c-4713-b921-b28e96a1b43e" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--
<summary>
<para>Optional summary abstract</para>
</summary>
-->
<introduction>
<!-- Uncomment this to generate an outline of the section and sub-section
titles. Specify a numeric value as the inner text to limit it to
a specific number of sub-topics when creating the outline. Specify
zero (0) to limit it to top-level sections only. -->
<!-- <autoOutline /> -->
<para>The text editor makes use of several different coordinate systems.
Here's an explanation of them.</para>
</introduction>
<!-- Add one or more top-level section elements. These are collapsible.
If using <autoOutline /> tag, add an address attribute to identify
it so that it can be jumped to with a hyperlink. -->
<section>
<title>Offset</title>
<content>
<para>In AvalonEdit, an index into the document is called an <newTerm>offset</newTerm>.</para>
<para>
Offsets usually represent the position between two characters.
The first offset at the start of the document is 0;
the offset after the first char in the document is 1.
The last valid offset is <codeInline>document.TextLength</codeInline>,
representing the end of the document.
This is exactly the same as the <codeInline>index</codeInline> parameter
used by methods in the .NET String or StringBuilder classes.
</para>
</content>
</section>
<section>
<title>TextLocation</title>
<content>
<para>The
<codeEntityReference qualifyHint="true">T:ICSharpCode.AvalonEdit.Document.TextLocation</codeEntityReference>
struct represents a Line/Column pair. Line and column are counted from 1.</para>
<para>The document provides the methods
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Document.TextDocument.GetLocation(System.Int32)</codeEntityReference>
and
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Document.TextDocument.GetOffset(ICSharpCode.AvalonEdit.Document.TextLocation)</codeEntityReference>
to convert between offsets and <codeInline>TextLocation</codeInline>s.</para>
</content>
</section>
<section>
<title>TextAnchor</title>
<content>
<para>If you are working with the text editor, you will likely run into the problem
that you need to store an offset, but want it to adjust automatically whenever
text is inserted prior to that offset. </para>
<para>Sure, you could listen to the TextDocument.Changed event and call
GetNewOffset on the DocumentChangeEventArgs to translate the offset,
but that gets tedious; especially when your object is short-lived and you
have to deal with deregistering the event handler at the correct point of time.</para>
<para>A text anchor object stores an Offset, but automatically
updates the offset when text is inserted/removed before the offset.
</para>
<para>
A much simpler solution is to use the
<codeEntityReference qualifyHint="true">T:ICSharpCode.AvalonEdit.Document.TextAnchor</codeEntityReference>
class.
Please take a look at the documentation for that class for more details.
</para>
</content>
</section>
<section>
<title>RelativeTextOffset</title>
<content>
<para>An offset in the document, but relative to the start offset of a <codeEntityReference>T:ICSharpCode.AvalonEdit.Rendering.VisualLine</codeEntityReference>.</para>
<para>Relative text offsets are used to store document offsets in visual lines.</para>
<para>You can convert between relative text offsets and document offsets
by adding/subtracting
<codeEntityReference qualifyHint="true">P:ICSharpCode.AvalonEdit.Rendering.VisualLine.FirstDocumentLine</codeEntityReference>.<codeEntityReference>P:ICSharpCode.AvalonEdit.Document.DocumentLine.Offset</codeEntityReference>.
</para>
</content>
</section>
<section>
<title>VisualColumn</title>
<content>
<para>An integer value that specifies a position inside a VisualLine.</para>
<para>
Not only text has a length in the visual line, but also other VisualLineElements.
VisualColumn is counting from 0 for each visual line.
</para>
<para>For example, tab markers take 2 visual columns (the marker and the tab space),
newline markers take 1 visual column; folding markers take just 1 visual column
even though they are longer in the document text.</para>
<para>Use the
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Rendering.VisualLine.GetVisualColumn(System.Int32)</codeEntityReference>
and
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Rendering.VisualLine.GetRelativeOffset(System.Int32)</codeEntityReference>
methods to convert between
visual columns and relative text offsets.</para>
<alert class="note">
<para>Do not confuse VisualColumn with text columns.
VisualColumn starts at 0, text column at 1. Text may have different length
in the two coordinate systems (e.g. tab markers, foldings).</para>
</alert>
</content>
</section>
<section>
<title>TextViewPosition</title>
<content>
<para>A Line,Column,VisualColumn triple.</para>
<para>The <codeEntityReference qualifyHint="true">T:ICSharpCode.AvalonEdit.TextViewPosition</codeEntityReference>
struct can be implicitly converted
to <codeEntityReference qualifyHint="false">T:ICSharpCode.AvalonEdit.Document.TextLocation</codeEntityReference>,
but has the additional VisualColumn information
that is necessary to accurately hold the caret position when
VisualLineElements with DocumentLength 0 are in use.</para>
</content>
</section>
<section>
<title>VisualTop</title>
<content>
<para>A double value that specifies the distance from the top of
the document to the top of a line measured in device-independent pixels.</para>
<para>VisualTop is equivalent to the Y component of a VisualPosition.</para>
</content>
</section>
<section>
<title>VisualPosition</title>
<content>
<para>A Point value (double X,Y) that specifies the position of an
element from the top left document corner measured in device-independent pixels.</para>
<para>To convert a VisualPosition to or from a (mouse) position inside
the TextView, simply subtract or add
<codeEntityReference qualifyHint="true">P:ICSharpCode.AvalonEdit.Rendering.TextView.ScrollOffset</codeEntityReference>
to it.
</para>
</content>
</section>
<relatedTopics>
<!-- One or more of the following:
- A local link
- An external link
- A code entity reference
<link xlink:href="Other Topic's ID"/>
<link xlink:href="Other Topic's ID">Link inner text</link>
<externalLink>
<linkText>Link text</linkText>
<linkAlternateText>Optional alternate link text</linkAlternateText>
<linkUri>URI</linkUri>
</externalLink>
<codeEntityReference>API member ID</codeEntityReference>
Examples:
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8270" />
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8278">Some other topic</link>
<externalLink>
<linkText>SHFB on CodePlex</linkText>
<linkAlternateText>Go to CodePlex</linkAlternateText>
<linkUri>http://www.codeplex.com/SHFB</linkUri>
</externalLink>
<codeEntityReference>T:TestDoc.TestClass</codeEntityReference>
<codeEntityReference>P:TestDoc.TestClass.SomeProperty</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.#ctor</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.#ctor(System.String,System.Int32)</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.ToString</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.FirstMethod</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.SecondMethod(System.Int32,System.String)</codeEntityReference>
-->
</relatedTopics>
</developerConceptualDocument>
</topic>

58
src/Libraries/AvalonEdit/Documentation/Folding.aml

@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="440df648-413e-4f42-a28b-6b2b0e9b1084" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>
Introduction for 'Folding'.
</para>
</introduction>
<section>
<title>How to use Folding in your application</title>
<content>
<para>
Folding (code collapsing) is implemented as an extension to the editor.
It could have been implemented in a separate assembly without having to
modify the AvalonEdit code.
A <codeEntityReference>T:ICSharpCode.AvalonEdit.Rendering.VisualLineElementGenerator</codeEntityReference>
takes care of the collapsed sections in the text document; and a custom
margin draws the plus and minus buttons.
</para>
<para>You could use the relevant classes separately;
but, to make it a bit easier to use, the static
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Folding.FoldingManager.Install</codeEntityReference>
method will create and register the necessary parts automatically.</para>
<para>All that's left for you is to regularly call
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Folding.FoldingManager.UpdateFoldings</codeEntityReference>
with the list of foldings you want to provide.
You could calculate that list yourself, or you could use a built-in
folding strategy to do it for you.</para>
<para>Here is the full code required to enable folding:
<code language="cs">foldingManager = FoldingManager.Install(textEditor.TextArea);
foldingStrategy = new XmlFoldingStrategy();
foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);</code>
If you want the folding markers to update when the text is changed,
you have to repeat the <codeInline>foldingStrategy.UpdateFoldings</codeInline> call regularly.
</para>
</content>
</section>
<section>
<title>How the FoldingManager works</title>
<content>
<para>
The FoldingManager maintains a list of foldings. The FoldMargin displays those foldings and provides
the UI for collapsing/expanding.
Folded foldings cause the FoldingElementGenerator to produce a line element that spans the whole folded
text section, causing the text generation for the visual line that contains the folding start to
continue after the folding end in another line.
To ensure scrolling works correctly in the presence of foldings, lines inside folded regions must not
be used as start lines for the visual line generation. This is done by setting the line height of all
such lines to 0. To efficiently set the height on a large number of lines and support reverting to the
old height when the folding is uncollapsed, a CollapsedLineSection is used.
</para>
</content>
</section>
<relatedTopics>
<codeEntityReference>T:ICSharpCode.AvalonEdit.Folding.FoldingManager</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>

12
src/Libraries/AvalonEdit/Documentation/ICSharpCode.AvalonEdit.content

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Topics defaultTopic="c52241ea-3eba-4ddf-b463-6349cbff38fd">
<Topic id="c52241ea-3eba-4ddf-b463-6349cbff38fd" visible="True" />
<Topic id="e41769b2-38f7-4605-b1d8-9cd22a50a685" visible="True" />
<Topic id="70c4df51-5ecb-4e24-a574-8c5a84306bd1" visible="True" />
<Topic id="5d1af8a2-fc1b-4a1b-b6c1-f33fb14bec1f" visible="True" />
<Topic id="5b1854b4-884c-4713-b921-b28e96a1b43e" visible="True" />
<Topic id="c06e9832-9ef0-4d65-ac2e-11f7ce9c7774" visible="True" />
<Topic id="4d4ceb51-154d-43f0-b876-ad9640c5d2d8" visible="True" />
<Topic id="440df648-413e-4f42-a28b-6b2b0e9b1084" visible="True" />
<Topic id="47c58b63-f30c-4290-a2f2-881d21227446" visible="True" />
</Topics>

165
src/Libraries/AvalonEdit/Documentation/ICSharpCode.AvalonEdit.shfbproj

@ -0,0 +1,165 @@ @@ -0,0 +1,165 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<!-- The configuration and platform will be used to determine which
assemblies to include from solution and project documentation
sources -->
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{850b6602-0a7f-413a-864a-e816b98d7407}</ProjectGuid>
<SHFBSchemaVersion>1.8.0.0</SHFBSchemaVersion>
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
Studio adds them anyway -->
<AssemblyName>Documentation</AssemblyName>
<RootNamespace>Documentation</RootNamespace>
<Name>Documentation</Name>
<!-- SHFB properties -->
<OutputPath>.\Help\</OutputPath>
<HtmlHelpName>AvalonEdit Documentation</HtmlHelpName>
<ProjectSummary>
</ProjectSummary>
<MissingTags>Summary, AutoDocumentCtors, Namespace</MissingTags>
<VisibleItems>InheritedMembers, InheritedFrameworkMembers, Protected, ProtectedInternalAsProtected</VisibleItems>
<HtmlHelp1xCompilerPath>
</HtmlHelp1xCompilerPath>
<HtmlHelp2xCompilerPath>
</HtmlHelp2xCompilerPath>
<SandcastlePath>
</SandcastlePath>
<WorkingPath>
</WorkingPath>
<BuildLogFile>
</BuildLogFile>
<FrameworkVersion>3.5</FrameworkVersion>
<HelpTitle>AvalonEdit</HelpTitle>
<CopyrightText>Copyright 2008-2009, Daniel Grunwald</CopyrightText>
<PresentationStyle>Prototype</PresentationStyle>
<HelpFileVersion>4.0.0.0</HelpFileVersion>
<ComponentConfigurations>
<ComponentConfig id="Cached Reflection Index Data" enabled="True">
<component id="Cached Reflection Index Data" type="SandcastleBuilder.Components.CachedCopyFromIndexComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<index name="reflection" value="/reflection/apis/api" key="@id" cache="10">
<cache base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" cacheFile="{@AppDataFolder}Cache\Reflection.cache" />
<data files="reflection.xml" />
</index>
<copy name="reflection" source="*" target="/document/reference" />
</component>
</ComponentConfig>
<ComponentConfig id="Cached MSDN URL References" enabled="True"><component id="Cached MSDN URL References" type="SandcastleBuilder.Components.CachedResolveReferenceLinksComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll"><cache filename="{@AppDataFolder}Cache\MsdnUrl.cache" /><targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@SDKLinks}" /><targets files="reflection.xml" type="{@ProjectLinks}" /></component></ComponentConfig>
<ComponentConfig id="IntelliSense Component" enabled="True"><component id="IntelliSense Component" type="SandcastleBuilder.Components.IntelliSenseComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll"><!-- Output options (optional)
Attributes:
Include Namespaces (false by default)
Namespaces filename ("Namespaces" if not specified or empty)
Directory (current folder if not specified or empty) --><output includeNamespaces="false" namespacesFile="Namespaces" folder="{@OutputFolder}" /></component></ComponentConfig>
<ComponentConfig id="Cached Framework Comments Index Data" enabled="True"><component id="Cached Framework Comments Index Data" type="SandcastleBuilder.Components.CachedCopyFromIndexComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll"><index name="comments" value="/doc/members/member" key="@name" cache="100">
{@CachedFrameworkCommentList}
{@CommentFileList}
</index><copy name="comments" source="*" target="/document/comments" /></component></ComponentConfig>
<ComponentConfig id="Code Block Component" enabled="True"><component id="Code Block Component" type="SandcastleBuilder.Components.CodeBlockComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<!-- Base path for relative filenames in source attributes
(optional) -->
<basePath value="{@HtmlEncProjectFolder}" />
<!-- Connect to language filter (optional). If omitted,
language filtering is enabled by default. -->
<languageFilter value="true" />
<!-- Allow missing source files (Optional). If omitted,
it will generate errors if referenced source files
are missing. -->
<allowMissingSource value="false" />
<!-- Remove region markers from imported code blocks. If omitted,
region markers in imported code blocks are left alone. -->
<removeRegionMarkers value="false" />
<!-- Code colorizer options (required).
Attributes:
Language syntax configuration file (required)
XSLT style file (required)
"Copy" image file URL (required)
Default language (optional)
Enable line numbering (optional)
Enable outlining (optional)
Keep XML comment "see" tags within the code (optional)
Tab size override (optional, 0 = Use syntax file setting)
Use language name as default title (optional) -->
<colorizer syntaxFile="{@SHFBFolder}Colorizer\highlight.xml" styleFile="{@SHFBFolder}Colorizer\highlight.xsl" copyImageUrl="../icons/CopyCode.gif" language="cs" numberLines="false" outlining="false" keepSeeTags="false" tabSize="0" defaultTitle="true" />
</component></ComponentConfig>
<ComponentConfig id="Post-transform Component" enabled="True"><component id="Post-transform Component" type="SandcastleBuilder.Components.PostTransformComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<!-- Code colorizer files (required).
Attributes:
Stylesheet file (required)
Script file (required)
"Copy" image file (required) -->
<colorizer stylesheet="{@SHFBFolder}Colorizer\highlight.css" scriptFile="{@SHFBFolder}Colorizer\highlight.js" copyImage="{@SHFBFolder}Colorizer\CopyCode.gif" />
<!-- Base output path for the files (required). This should match
the parent folder of the output path of the HTML files (see
SaveComponent). -->
<outputPath value="Output\" />
<!-- Logo image file (optional). Filename is required. The height,
width, altText, placement, and alignment attributes are
optional. -->
<logoFile filename="" height="0" width="0" altText="" placement="left" alignment="left" />
</component></ComponentConfig></ComponentConfigurations>
<DocumentationSources>
<DocumentationSource sourceFile="..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj" />
</DocumentationSources>
<NamespaceSummaries>
<NamespaceSummaryItem name="(global)" isDocumented="False" />
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit" isDocumented="True">This is the main AvalonEdit namespace.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.CodeCompletion" isDocumented="True">This namespace contains classes to show the code completion window.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Document" isDocumented="True">This namespace contains the document model.
The most important class here is TextDocument, which represents document that can be displayed and edited in the text editor.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Editing" isDocumented="True">This namespace is the home of the TextArea class. It manages user input and handles the caret and the selection.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Folding" isDocumented="True">This namespace contains the folding (code collapsing) implementation.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Highlighting" isDocumented="True">This namespace contains the engine for highlighting text documents (DocumentHighlighter).
Additionally, the class HighlightingColorizer provides integration of the highlighting engine into the text editor GUI.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Highlighting.Xshd" isDocumented="True">This namespace contains a document model for syntax highlighting definitions (.xshd files).</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Indentation" isDocumented="True">This namespace contains the logic for automatic indentation.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Rendering" isDocumented="True">This namespace contains the text rendering infrastructure.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Utils" isDocumented="True">This namespace contains various utility classes.</NamespaceSummaryItem>
<NamespaceSummaryItem name="XamlGeneratedNamespace" isDocumented="False" />
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Xml" isDocumented="True">This namespace contains an error-tolerant XML parser with support for incremental parsing, only reparsing the changed regions of a TextDocument.</NamespaceSummaryItem>
</NamespaceSummaries>
<CleanIntermediates>True</CleanIntermediates>
<SyntaxFilters>Standard</SyntaxFilters>
</PropertyGroup>
<!-- There are no properties for these two groups but they need to appear in
order for Visual Studio to perform the build. -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<None Include="Coordinate Systems.aml" />
<None Include="Architecture.aml" />
<None Include="Code Completion.aml" />
<None Include="Sample Application.aml" />
<None Include="Folding.aml" />
<None Include="Syntax Highlighting.aml" />
<None Include="Text Rendering.aml" />
<None Include="Welcome.aml" />
</ItemGroup>
<ItemGroup>
<ContentLayout Include="ICSharpCode.AvalonEdit.content" />
</ItemGroup>
<ItemGroup>
<Image Include="Media\WelcomeScreenshot.png">
<ImageId>WelcomeScreenshot</ImageId>
</Image>
<Image Include="Media\VisualTree.png">
<ImageId>VisualTree</ImageId>
<AlternateText>Visual Tree</AlternateText>
</Image>
<Image Include="Media\RenderingPipeline.png">
<ImageId>RenderingPipeline</ImageId>
</Image>
<Image Include="Media\NamespaceDependencies.png">
<ImageId>NamespaceDependencies</ImageId>
<AlternateText>Namespace Dependency Graph</AlternateText>
</Image>
<Content Include="License.html" />
</ItemGroup>
<ItemGroup>
<Folder Include="Media\" />
</ItemGroup>
<!-- Import the SHFB build targets -->
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
</Project>

566
src/Libraries/AvalonEdit/Documentation/License.html

@ -0,0 +1,566 @@ @@ -0,0 +1,566 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>License</title>
<meta name="id" content="e41769b2-38f7-4605-b1d8-9cd22a50a685">
<meta name="revisionNumber" content="1"></meta>
<link rel="stylesheet" type="text/css" href="../styles/presentation.css" />
</head>
<body>
<h3>GNU LESSER GENERAL PUBLIC LICENSE</h3>
<p>
Version 2.1, February 1999
</p>
<pre>Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
</pre>
<h3>Preamble</h3>
<p>
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
</p>
<p>
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
</p>
<p>
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
</p>
<p>
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
</p>
<p>
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
</p>
<p>
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
</p>
<p>
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
</p>
<p>
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
</p>
<p>
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
</p>
<p>
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
</p>
<p>
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
</p>
<p>
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
</p>
<p>
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
</p>
<p>
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
</p>
<p>
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
</p>
<h3>TERMS AND CONDITIONS FOR COPYING,
DISTRIBUTION AND MODIFICATION</h3>
<p>
<strong>0.</strong>
This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
</p>
<p>
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
</p>
<p>
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
</p>
<p>
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
</p>
<p>
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
</p>
<p>
<strong>1.</strong>
You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
</p>
<p>
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
</p>
<p>
<strong>2.</strong>
You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
</p>
<ul>
<li><strong>a)</strong>
The modified work must itself be a software library.</li>
<li><strong>b)</strong>
You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.</li>
<li><strong>c)</strong>
You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.</li>
<li><strong>d)</strong>
If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
<p>
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)</p></li>
</ul>
<p>
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be
reasonably considered independent and separate works in themselves, then
this License, and its terms, do not apply to those sections when you
distribute them as separate works. But when you distribute the same
sections as part of a whole which is a work based on the Library, the
distribution of the whole must be on the terms of this License, whose
permissions for other licensees extend to the entire whole, and thus to
each and every part regardless of who wrote it.
</p>
<p>
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works
based on the Library.
</p>
<p>
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of
this License.
</p>
<p>
<strong>3.</strong>
You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
</p>
<p>
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
</p>
<p>
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
</p>
<p>
<strong>4.</strong>
You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
</p>
<p>
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
</p>
<p>
<strong>5.</strong>
A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
</p>
<p>
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
</p>
<p>
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
</p>
<p>
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
</p>
<p>
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
</p>
<p>
<strong>6.</strong>
As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
</p>
<p>
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
</p>
<ul>
<li><strong>a)</strong> Accompany the work with the complete
corresponding machine-readable source code for the Library
including whatever changes were used in the work (which must be
distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete
machine-readable "work that uses the Library", as object code
and/or source code, so that the user can modify the Library and
then relink to produce a modified executable containing the
modified Library. (It is understood that the user who changes the
contents of definitions files in the Library will not necessarily
be able to recompile the application to use the modified
definitions.)</li>
<li><strong>b)</strong> Use a suitable shared library mechanism
for linking with the Library. A suitable mechanism is one that
(1) uses at run time a copy of the library already present on the
user's computer system, rather than copying library functions into
the executable, and (2) will operate properly with a modified
version of the library, if the user installs one, as long as the
modified version is interface-compatible with the version that the
work was made with.</li>
<li><strong>c)</strong> Accompany the work with a written offer,
valid for at least three years, to give the same user the
materials specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.</li>
<li><strong>d)</strong> If distribution of the work is made by
offering access to copy from a designated place, offer equivalent
access to copy the above specified materials from the same
place.</li>
<li><strong>e)</strong> Verify that the user has already received
a copy of these materials or that you have already sent this user
a copy.</li>
</ul>
<p>
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
</p>
<p>
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
</p>
<p>
<strong>7.</strong> You may place library facilities that are a work
based on the Library side-by-side in a single library together with
other library facilities not covered by this License, and distribute
such a combined library, provided that the separate distribution of
the work based on the Library and of the other library facilities is
otherwise permitted, and provided that you do these two things:
</p>
<ul>
<li><strong>a)</strong> Accompany the combined library with a copy
of the same work based on the Library, uncombined with any other
library facilities. This must be distributed under the terms of
the Sections above.</li>
<li><strong>b)</strong> Give prominent notice with the combined
library of the fact that part of it is a work based on the
Library, and explaining where to find the accompanying uncombined
form of the same work.</li>
</ul>
<p>
<strong>8.</strong> You may not copy, modify, sublicense, link with,
or distribute the Library except as expressly provided under this
License. Any attempt otherwise to copy, modify, sublicense, link
with, or distribute the Library is void, and will automatically
terminate your rights under this License. However, parties who have
received copies, or rights, from you under this License will not have
their licenses terminated so long as such parties remain in full
compliance.
</p>
<p>
<strong>9.</strong>
You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
</p>
<p>
<strong>10.</strong>
Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
</p>
<p>
<strong>11.</strong>
If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
</p>
<p>
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
</p>
<p>
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
</p>
<p>
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
</p>
<p>
<strong>12.</strong>
If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
</p>
<p>
<strong>13.</strong>
The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
</p>
<p>
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
</p>
<p>
<strong>14.</strong>
If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
</p>
<p>
<strong>NO WARRANTY</strong>
</p>
<p>
<strong>15.</strong>
BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
</p>
<p>
<strong>16.</strong>
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
</p>
<h3>END OF TERMS AND CONDITIONS</h3>
</body>
</html>

BIN
src/Libraries/AvalonEdit/Documentation/Media/NamespaceDependencies.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
src/Libraries/AvalonEdit/Documentation/Media/RenderingPipeline.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
src/Libraries/AvalonEdit/Documentation/Media/VisualTree.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

BIN
src/Libraries/AvalonEdit/Documentation/Media/WelcomeScreenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

78
src/Libraries/AvalonEdit/Documentation/Sample Application.aml

@ -0,0 +1,78 @@ @@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="70c4df51-5ecb-4e24-a574-8c5a84306bd1" revisionNumber="1">
<developerSampleDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--
<summary>
<para>Optional summary abstract</para>
</summary>
-->
<introduction>
<!-- Uncomment this to generate an outline of the section and sub-section
titles. Specify a numeric value as the inner text to limit it to
a specific number of sub-topics when creating the outline. Specify
zero (0) to limit it to top-level sections only. -->
<!-- <autoOutline /> -->
<para>In the SharpDevelop source code download, you will find a small sample
application in SharpDevelop\samples\AvalonEdit.Sample.</para>
</introduction>
<mediaLink><image xlink:href="WelcomeScreenshot" placement="center"/></mediaLink>
<!-- <procedure>Optional procedures. See How To document for procedure layout example.</procedure> -->
<!-- <requirements>Optional requirements section</requirements> -->
<!-- <demonstrates>Optional info about what is demonstrated</demonstrates> -->
<!-- <codeExample>Optional code example</codeExample> -->
<!-- Add one or more top-level section elements. These are collapsible.
If using <autoOutline />, add an address attribute to identify it
and specify a title so that it can be jumped to with a hyperlink. -->
<section>
<title>The Code Project article</title>
<content>
<para>
There is a Code Project article based on the sample application:
<externalLink>
<linkText>http://www.codeproject.com/KB/edit/AvalonEdit.aspx</linkText>
<linkUri>http://www.codeproject.com/KB/edit/AvalonEdit.aspx</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>
</para>
<para>
However, most of the material from that article has been included in this help file.
</para>
</content>
</section>
<relatedTopics>
<!-- One or more of the following:
- A local link
- An external link
- A code entity reference
<link xlink:href="Other Topic's ID">Link text</link>
<externalLink>
<linkText>Link text</linkText>
<linkAlternateText>Optional alternate link text</linkAlternateText>
<linkUri>URI</linkUri>
</externalLink>
<codeEntityReference>API member ID</codeEntityReference>
Examples:
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8278">Some other topic</link>
<externalLink>
<linkText>SHFB on CodePlex</linkText>
<linkAlternateText>Go to CodePlex</linkAlternateText>
<linkUri>http://shfb.codeplex.com</linkUri>
</externalLink>
<codeEntityReference>T:TestDoc.TestClass</codeEntityReference>
<codeEntityReference>P:TestDoc.TestClass.SomeProperty</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.#ctor</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.#ctor(System.String,System.Int32)</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.ToString</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.FirstMethod</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.SecondMethod(System.Int32,System.String)</codeEntityReference>
-->
</relatedTopics>
</developerSampleDocument>
</topic>

187
src/Libraries/AvalonEdit/Documentation/Syntax Highlighting.aml

@ -0,0 +1,187 @@ @@ -0,0 +1,187 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="4d4ceb51-154d-43f0-b876-ad9640c5d2d8" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>Probably the most important feature for any text editor is syntax highlighting.</para>
<para>AvalonEdit has a flexible text rendering model, see
<link xlink:href="c06e9832-9ef0-4d65-ac2e-11f7ce9c7774" />. Among the
text rendering extension points is the support for "visual line transformers" that
can change the display of a visual line after it has been constructed by the "visual element generators".
A useful base class implementing IVisualLineTransformer for the purpose of syntax highlighting
is <codeEntityReference>T:ICSharpCode.AvalonEdit.Rendering.DocumentColorizingTransformer</codeEntityReference>.
Take a look at that class' documentation to see
how to write fully custom syntax highlighters. This article only discusses the XML-driven built-in
highlighting engine.
</para>
</introduction>
<section>
<title>The highlighting engine</title>
<content>
<para>
The highlighting engine in AvalonEdit is implemented in the class
<codeEntityReference>T:ICSharpCode.AvalonEdit.Highlighting.DocumentHighlighter</codeEntityReference>.
Highlighting is the process of taking a DocumentLine and constructing
a <codeEntityReference>T:ICSharpCode.AvalonEdit.Highlighting.HighlightedLine</codeEntityReference>
instance for it by assigning colors to different sections of the line.
A <codeInline>HighlightedLine</codeInline> is simply a list of
(possibly nested) highlighted text sections.
</para><para>
The <codeInline>HighlightingColorizer</codeInline> class is the only
link between highlighting and rendering.
It uses a <codeInline>DocumentHighlighter</codeInline> to implement
a line transformer that applies the
highlighting to the visual lines in the rendering process.
</para><para>
Except for this single call, syntax highlighting is independent from the
rendering namespace. To help with other potential uses of the highlighting
engine, the <codeInline>HighlightedLine</codeInline> class has the
method <codeInline>ToHtml()</codeInline>
to produce syntax highlighted HTML source code.
</para>
<para>The highlighting rules used by the highlighting engine to highlight
the document are described by the following classes:
</para>
<definitionTable>
<definedTerm>HighlightingRuleSet</definedTerm>
<definition>Describes a set of highlighting spans and rules.</definition>
<definedTerm>HighlightingSpan</definedTerm>
<definition>A span consists of two regular expressions (Start and End), a color,
and a child ruleset.
The region between Start and End expressions will be assigned the
given color, and inside that span, the rules of the child
ruleset apply.
If the child ruleset also has <codeInline>HighlightingSpan</codeInline>s,
they can be nested, allowing highlighting constructs like nested comments or one language
embedded in another.</definition>
<definedTerm>HighlightingRule</definedTerm>
<definition>A highlighting rule is regular expression with a color.
It will matches of the regular expression using that color.</definition>
<definedTerm>HighlightingColor</definedTerm>
<definition>A highlighting color isn't just a color: it consists of a foreground
color, font weight and font style.</definition>
</definitionTable>
<para>
The highlighting engine works by first analyzing the spans: whenever a
begin RegEx matches some text, that span is pushed onto a stack.
Whenever the end RegEx of the current span matches some text,
the span is popped from the stack.
</para><para>
Each span has a nested rule set associated with it, which is empty
by default. This is why keywords won't be highlighted inside comments:
the span's empty ruleset is active there, so the keyword rule is not applied.
</para><para>
This feature is also used in the string span: the nested span will match
when a backslash is encountered, and the character following the backslash
will be consumed by the end RegEx of the nested span
(<codeInline>.</codeInline> matches any character).
This ensures that <codeInline>\"</codeInline> does not denote the end of the string span;
but <codeInline>\\"</codeInline> still does.
</para><para>
What's great about the highlighting engine is that it highlights only
on-demand, works incrementally, and yet usually requires only a
few KB of memory even for large code files.
</para><para>
On-demand means that when a document is opened, only the lines initially
visible will be highlighted. When the user scrolls down, highlighting will continue
from the point where it stopped the last time. If the user scrolls quickly,
so that the first visible line is far below the last highlighted line,
then the highlighting engine still has to process all the lines in between
– there might be comment starts in them. However, it will only scan that region
for changes in the span stack; highlighting rules will not be tested.
</para><para>
The stack of active spans is stored at the beginning of every line.
If the user scrolls back up, the lines getting into view can be highlighted
immediately because the necessary context (the span stack) is still available.
</para><para>
Incrementally means that even if the document is changed, the stored span stacks
will be reused as far as possible. If the user types <codeInline>/*</codeInline>,
that would theoretically cause the whole remainder of the file to become
highlighted in the comment color.
However, because the engine works on-demand, it will only update the span
stacks within the currently visible region and keep a notice
'the highlighting state is not consistent between line X and line X+1',
where X is the last line in the visible region.
Now, if the user would scroll down,
the highlighting state would be updated and the 'not consistent' notice
would be moved down. But usually, the user will continue typing
and type <codeInline>*/</codeInline> only a few lines later.
Now the highlighting state in the visible region will revert to the normal
'only the main ruleset is on the stack of active spans'.
When the user now scrolls down below the line with the 'not consistent' marker;
the engine will notice that the old stack and the new stack are identical;
and will remove the 'not consistent' marker.
This allows reusing the stored span stacks cached from before the user typed
<codeInline>/*</codeInline>.
</para><para>
While the stack of active spans might change frequently inside the lines,
it rarely changes from the beginning of one line to the beginning of the next line.
With most languages, such changes happen only at the start and end of multiline comments.
The highlighting engine exploits this property by storing the list of
span stacks in a special data structure
(<codeEntityReference>T:ICSharpCode.AvalonEdit.Utils.CompressingTreeList{T}</codeEntityReference>).
The memory usage of the highlighting engine is linear to the number of span stack changes;
not to the total number of lines.
This allows the highlighting engine to store the span stacks for big code
files using only a tiny amount of memory, especially in languages like
C# where sequences of <codeInline>//</codeInline> or <codeInline>///</codeInline>
are more popular than <codeInline>/* */</codeInline> comments.
</para>
</content>
</section>
<section>
<title>XML highlighting definitions</title>
<content>
<para>AvalonEdit supports XML syntax highlighting definitions (.xshd files).</para>
<para>In the AvalonEdit source code, you can find the file
<codeInline>ICSharpCode.AvalonEdit\Highlighting\Resources\ModeV2.xsd</codeInline>.
This is an XML schema for the .xshd file format; you can use it to
code completion for .xshd files in XML editors.
</para>
<para>Here is an example highlighting definition for a sub-set of C#:
<code language="xml"><![CDATA[
<SyntaxDefinition name="C#"
xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Comment" foreground="Green" />
<Color name="String" foreground="Blue" />
<!-- This is the main ruleset. -->
<RuleSet>
<Span color="Comment" begin="//" />
<Span color="Comment" multiline="true" begin="/\*" end="\*/" />
<Span color="String">
<Begin>"</Begin>
<End>"</End>
<RuleSet>
<!-- nested span for escape sequences -->
<Span begin="\\" end="." />
</RuleSet>
</Span>
<Keywords fontWeight="bold" foreground="Blue">
<Word>if</Word>
<Word>else</Word>
<!-- ... -->
</Keywords>
<!-- Digits -->
<Rule foreground="DarkBlue">
\b0[xX][0-9a-fA-F]+ # hex number
| \b
( \d+(\.[0-9]+)? #number with optional floating point
| \.[0-9]+ #or just starting with floating point
)
([eE][+-]?[0-9]+)? # optional exponent
</Rule>
</RuleSet>
</SyntaxDefinition>
]]></code>
</para>
</content>
</section>
<relatedTopics>
<codeEntityReference>N:ICSharpCode.AvalonEdit.Highlighting</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>

162
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/documentation/TextRendering.xml → src/Libraries/AvalonEdit/Documentation/Text Rendering.aml

@ -1,26 +1,33 @@ @@ -1,26 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<developerConceptualDocument
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"
xmlns:xlink="http://www.w3.org/1999/xlink">
<summary>
<para>This document describes how the TextView class renders the text, and
<?xml version="1.0" encoding="utf-8"?>
<topic id="c06e9832-9ef0-4d65-ac2e-11f7ce9c7774" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<summary>
<para>This document describes how the TextView class renders the text, and
how you can extend the text rendering process to add new features to the text editor.
</para>
</summary>
<introduction>
<para>The text rendering in AvalonEdit involves creating VisualLines for the visible document
part.</para>
</introduction>
<!-- Add one or more top-level section elements. These are collapsible.
</summary>
<introduction>
<para>The <codeEntityReference qualifyHint="true">T:ICSharpCode.AvalonEdit.Rendering.TextView</codeEntityReference>
class is the heart of AvalonEdit.
It takes care of getting the document onto the screen.</para>
<para>To do this in an extensible way, the TextView uses its own kind of model:
the <codeEntityReference>VisualLine</codeEntityReference>.
Visual lines are created only for the visible part of the document.</para>
<para>
The rendering process looks like this:
<mediaLink><image xlink:href="RenderingPipeline" placement="center"/></mediaLink>
The "element generators", "line transformers" and "background renderers" are
the extension points; it is possible to add custom implementations of them to
the TextView to implement additional features in the editor.
</para>
</introduction>
<!-- Add one or more top-level section elements. These are collapsible.
If using <autoOutline /> tag, add an address attribute to identify
it so that it can be jumped to with a hyperlink. -->
<section>
<title>Lifetime of VisualLines</title>
<content>
<para>
<section>
<title>Lifetime of VisualLines</title>
<content>
<para>
VisualLines are only created for the visible part of the document.
Lots of actions can trigger their creation, but most commonly the creation will be
caused by the MeasureOverride method of TextView.
@ -29,31 +36,24 @@ @@ -29,31 +36,24 @@
for that first line, and repeats that with the following lines
until the visible region is filled.
</para>
<para>
<para>
The TextView caches VisualLines - when the user scrolls down, only the VisualLines
coming into view are created, the rest is reused.
The VisualLine cache can be manually invalidated using the Redraw method family;
moreover, lots of actions cause automatic invalidation:
<list class="bullet">
<listItem>any change in the document will invalidate the affected VisualLines</listItem>
<listItem>changing the width of the TextView invalidates all VisualLines if word-wrap is enabled</listItem>
<listItem>changing any text editor settings (word-wrap, font size, etc.) will invalidate all VisualLines</listItem>
<listItem>VisualLines leaving the visible area after scrolling will be disposed</listItem>
</list>
<list class="bullet"><listItem>any change in the document will invalidate the affected VisualLines</listItem><listItem>changing the width of the TextView invalidates all VisualLines if word-wrap is enabled</listItem><listItem>changing any text editor settings (word-wrap, font size, etc.) will invalidate all VisualLines</listItem><listItem>VisualLines leaving the visible area after scrolling will be disposed</listItem></list>
In general, manual invalidation is required only if you have written a text editor extension
(BackgroundRenderer, VisualLineElementGenerator or VisualLineTransformer) that also consumes
external data - in that case, you'll have to notify the text editor that VisualLines need
to be recreated when your external data changes.
</para>
<alert class="note">
<para>If external data used by your text editor extension changes, call
TextView.<codeEntityReference>M:ICSharpCode.AvalonEdit.Rendering.TextView.Redraw</codeEntityReference>
<alert class="note">
<para>If external data used by your text editor extension changes, call
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Rendering.TextView.Redraw</codeEntityReference>
to invalidate the VisualLine.
</para>
</alert>
<para>
</alert>
<para>
Invalidating VisualLines does not cause immediate recreation of the lines!
Rather, the VisualLines are recreated when the text view is next re-measured.
While measurement in WPF normally happens with DispatcherPriority.Render,
@ -62,66 +62,66 @@ @@ -62,66 +62,66 @@
in case the user types faster than the text view can redraw, there will be only
one redraw for multiple input actions.
</para>
<alert class="note">
<para>
<alert class="note">
<para>
The TextView will never return invalid lines to you, but you
may run into the case that the valid visual lines are not available.
</para>
<para>
<para>
What happens in this case depends on the method you are calling -
the new visual line might get created automatically,
null could be returned, or you may get a
<codeEntityReference>T:ICSharpCode.AvalonEdit.Rendering.VisualLinesInvalidException</codeEntityReference>.
</para>
<para>
<para>
You can call
<codeEntityReference>M:ICSharpCode.AvalonEdit.Rendering.TextView.EnsureVisualLines</codeEntityReference>
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Rendering.TextView.EnsureVisualLines</codeEntityReference>
to make the text view create all VisualLines in the visible region.
</para>
</alert>
</content>
</section>
<section>
<title>Building visual line elements</title>
<content>
<para>
</alert>
</content>
</section>
<section>
<title>Building visual line elements</title>
<content>
<para>
As a first step, the VisualLineElementGenerators are used to produce elements. The
room in between the elements returned from the generators is filled with text elements.
Then, the VisualLine assigns the VisualColumn and RelativeTextOffset properties of the line elements.
</para>
<para>
<para>
For example, a line contains the text "Hello, World".
The user has enabled "ShowSpaces", so the text editor should show a little dot instead of the space.
In this case, the SingleCharacterElementGenerator, which is responsible for ShowSpaces, will produce
a "SpaceTextElement" for the space character. Because no other generators are interested in the line,
the remaining strings "Hello," and "World" will be represented by VisualLineText elements.
</para>
</content>
</section>
<section>
<title>Transforming visual line elements</title>
<content>
<para>
</content>
</section>
<section>
<title>Transforming visual line elements</title>
<content>
<para>
After that, the IVisualLineTransformers are used to modify the produced line elements. Transformers
must not add elements, but they may split existing elements, e.g. to colorize only parts of an
element. When splitting elements (or somehow modifying the elements collection), care must be taken
that the VisualColumn,VisualLine,RelativeTextOffset and DocumentLength properties stay correct.
</para>
<para>
<para>
The ColorizingTransformer base class provides helper methods for splitting, so the derived class
can simply say "color this section in that color".
</para>
<para>
<para>
The DocumentColorizingTransformer extends the ColorizingTransformer and additionally
allows highlighting on per DocumentLine, coloring text segments (instead of directly
working with visual line elements).
</para>
</content>
</section>
<section>
<title>Constructing TextLines</title>
<content>
<para>
</content>
</section>
<section>
<title>Constructing TextLines</title>
<content>
<para>
After building the visual line elements, the TextLines for the visual line are constructed.
A visual line may result in multiple text lines when word wrapping is active or when special visual
line elements force a line break.
@ -132,44 +132,40 @@ @@ -132,44 +132,40 @@
VisualLineElements are requested to produce TextRuns for their full or a partial length.
The TextView will take care to measure any inline UI elements in the visual lines.
</para>
</content>
</section>
<section>
<title>Rest of the Rendering</title>
<content>
<para>
</content>
</section>
<section>
<title>Rest of the Rendering</title>
<content>
<para>
After the visible region is filled, the TextView updates the heights stored in the document lines to
the measured heights. This way, scrolling takes account for word-wrapping.
The constructed text lines are stored for the arrange and render steps.
Now, finally, the measure step is complete.
</para>
<para>
<para>
The WPF arrange step doesn't have much work to do:
It just arranges inline UI elements at their position inside the text.
</para>
<para>
<para>
The actual rendering does not happen directly in the TextView, but in its
various layers.
</para>
<para>
<para>
These are the predefined layers:
<list class="bullet">
<listItem>Background layer: renders the background colors associated with the visual elements</listItem>
<listItem>Selection layer: renders the background of the selection</listItem>
<listItem>Text layer: renders the TextLines that were constructed during the Measure step.
<list class="bullet"><listItem>Background layer: renders the background colors associated with the visual elements</listItem><listItem>Selection layer: renders the background of the selection</listItem><listItem>Text layer: renders the TextLines that were constructed during the Measure step.
The text layer also serves as container for any inline UI elements.
</listItem>
<listItem>Caret layer: renders a blinking caret</listItem>
</list>
</listItem><listItem>Caret layer: renders a blinking caret</listItem></list>
It's also possible to insert new layers into the TextView using the
<codeEntityReference>M:ICSharpCode.AvalonEdit.Rendering.TextView.InsertLayer</codeEntityReference>
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Rendering.TextView.InsertLayer</codeEntityReference>
method.
This allows adding custom interactive components to the editor
while being in full control of the Z-Order.
</para>
</content>
</section>
<relatedTopics>
<codeEntityReference>T:ICSharpCode.AvalonEdit.Rendering.TextView</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</content>
</section>
<relatedTopics>
<codeEntityReference>T:ICSharpCode.AvalonEdit.Rendering.TextView</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>

50
src/Libraries/AvalonEdit/Documentation/Welcome.aml

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="c52241ea-3eba-4ddf-b463-6349cbff38fd" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<summary>
<para>AvalonEdit is a WPF-based extensible text editor.</para>
</summary>
<introduction>
<para>While the WPF RichTextBox is quite powerful, you quickly run into its limits
when trying to use it as a code editor: it's hard to write efficient syntax highlighting for it,
and you cannot really implement features like code folding with the standard RichTextBox.</para>
<para>The problem is: the RichTextBox edits a rich document.
In contrast, AvalonEdit simply edits text.</para>
<para>However, AvalonEdit offers lots of possibilities on how the text document is
displayed - so it is much more suitable for a code editor where things like the text color
are not controlled by the user, but instead depend on the text (syntax highlighting).
</para>
</introduction>
<mediaLink><image xlink:href="WelcomeScreenshot" placement="center"/></mediaLink>
<section>
<title>System requirements</title>
<content>
<para>AvalonEdit requires the
<externalLink>
<linkText>.NET Framework 3.5 SP1</linkText>
<linkUri>http://www.microsoft.com/downloads/details.aspx?FamilyID=ab99342f-5d1a-413d-8319-81da479ab0d7&amp;DisplayLang=en</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>.
For compiling AvalonEdit inside Visual Studio 2008, VS08 SP1 is required.
</para>
<para>AvalonEdit requires FullTrust and will not run as XBAP.</para>
</content>
</section>
<relatedTopics>
<codeEntityReference qualifyHint="true">T:ICSharpCode.AvalonEdit.TextEditor</codeEntityReference>
<externalLink>
<linkText>www.avalonedit.net</linkText>
<linkUri>http://www.avalonedit.net</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>
<externalLink>
<linkText>www.icsharpcode.net</linkText>
<linkUri>http://www.icsharpcode.net</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>
</relatedTopics>
</developerConceptualDocument>
</topic>

10
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ChangeTrackingCheckpoint.cs

@ -14,10 +14,16 @@ using System.Linq; @@ -14,10 +14,16 @@ using System.Linq;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
/// A checkpoint that allows tracking changes to a TextDocument.
///
/// <para>A checkpoint that allows tracking changes to a TextDocument.</para>
/// <para>
/// Use <see cref="TextDocument.CreateSnapshot(out ChangeTrackingCheckpoint)"/> to create a checkpoint.
/// </para>
/// </summary>
/// <remarks>
/// <para>The <see cref="ChangeTrackingCheckpoint"/> class allows tracking document changes, even from background threads.</para>
/// <para>Once you have two checkpoints, you can call <see cref="ChangeTrackingCheckpoint.GetChangesTo"/> to retrieve the complete list
/// of document changes that happened between those versions of the document.</para>
/// </remarks>
public sealed class ChangeTrackingCheckpoint
{
// Object that is unique per document.

25
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentLine.cs

@ -14,6 +14,18 @@ namespace ICSharpCode.AvalonEdit.Document @@ -14,6 +14,18 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Represents a line inside a <see cref="TextDocument"/>.
/// </summary>
/// <remarks>
/// <para>
/// The <see cref="TextDocument.Lines"/> collection contains one DocumentLine instance
/// for every line in the document. This collection is read-only to user code and is automatically
/// updated to reflect the current document content.
/// </para>
/// <para>
/// Internally, the DocumentLine instances are arranged in a binary tree that allows for both efficient updates and lookup.
/// Converting between offset and line number is possible in O(lg N) time,
/// and the data structure also updates all offsets in O(lg N) whenever a line is inserted or removed.
/// </para>
/// </remarks>
public sealed partial class DocumentLine : ISegment
{
#region Constructor
@ -120,7 +132,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -120,7 +132,7 @@ namespace ICSharpCode.AvalonEdit.Document
}
/// <summary>
/// Gets the end offset of the line in the document's text (the offset before the newline character).
/// Gets the end offset of the line in the document's text (the offset before the line delimiter).
/// Runtime: O(log n)
/// </summary>
/// <exception cref="InvalidOperationException">The line was deleted.</exception>
@ -135,7 +147,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -135,7 +147,7 @@ namespace ICSharpCode.AvalonEdit.Document
byte delimiterLength;
/// <summary>
/// Gets the length of this line. O(1)
/// Gets the length of this line. The length does not include the line delimiter. O(1)
/// </summary>
/// <remarks>This property is still available even if the line was deleted;
/// in that case, it contains the line's length before the deletion.</remarks>
@ -163,10 +175,12 @@ namespace ICSharpCode.AvalonEdit.Document @@ -163,10 +175,12 @@ namespace ICSharpCode.AvalonEdit.Document
}
/// <summary>
/// Gets the length of the newline.
/// <para>Gets the length of the line delimiter.</para>
/// <para>The value is 1 for single <c>"\r"</c> or <c>"\n"</c>, 2 for the <c>"\r\n"</c> sequence;
/// and 0 for the last line in the document.</para>
/// </summary>
/// <remarks>This property is still available even if the line was deleted;
/// in that case, it contains the line's length before the deletion.</remarks>
/// in that case, it contains the line delimiter's length before the deletion.</remarks>
public int DelimiterLength {
get {
document.DebugVerifyAccess();
@ -229,7 +243,8 @@ namespace ICSharpCode.AvalonEdit.Document @@ -229,7 +243,8 @@ namespace ICSharpCode.AvalonEdit.Document
#region ToString
/// <summary>
/// Gets a string representation of the line.
/// Gets a string with debug output showing the line number and offset.
/// Does not include the line's text.
/// </summary>
public override string ToString()
{

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ILineTracker.cs

@ -11,13 +11,15 @@ namespace ICSharpCode.AvalonEdit.Document @@ -11,13 +11,15 @@ namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
/// Allows for low-level line tracking.
/// </summary>
/// <remarks>
/// The methods on this interface are called by the TextDocument's LineManager immediately after the document
/// has changed, *while* the DocumentLineTree is updating.
/// Thus, the DocumentLineTree may be in an invalid state when these methods are called.
/// This interface should only be used to update per-line data structures like the HeightTree.
/// Line trackers must not cause any events to be raised during an update to prevent other code from seeing
/// the invalid state.
/// </summary>
/// </remarks>
public interface ILineTracker
{
/// <summary>

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ISegment.cs

@ -15,6 +15,8 @@ namespace ICSharpCode.AvalonEdit.Document @@ -15,6 +15,8 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// An (Offset,Length)-pair.
/// </summary>
/// <seealso cref="TextSegment"/>
/// <seealso cref="AnchorSegment"/>
public interface ISegment
{
/// <summary>
@ -137,12 +139,16 @@ namespace ICSharpCode.AvalonEdit.Document @@ -137,12 +139,16 @@ namespace ICSharpCode.AvalonEdit.Document
}
/// <summary>
/// A segment using text anchors as start and end positions.
/// A segment using <see cref="TextAnchor"/>s as start and end positions.
/// </summary>
/// <remarks>
/// <para>
/// For the constructors creating new anchors, the start position will be AfterInsertion and the end position will be BeforeInsertion.
/// Should the end position move before the start position, the segment will have length 0.
/// </para>
/// </remarks>
/// <seealso cref="ISegment"/>
/// <seealso cref="TextSegment"/>
public sealed class AnchorSegment : ISegment
{
readonly TextAnchor start, end;

48
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextAnchor.cs

@ -11,9 +11,32 @@ using ICSharpCode.AvalonEdit.Utils; @@ -11,9 +11,32 @@ using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
/// The TextAnchor class references a text location - a position between two characters.
/// It automatically updates its offset when text is inserted/removed in front of the anchor.
/// The TextAnchor class references an offset (a position between two characters).
/// It automatically updates the offset when text is inserted/removed in front of the anchor.
/// </summary>
/// <remarks>
/// <para>Use the <see cref="Offset"/> property to get the offset from a text anchor.
/// Use the <see cref="TextDocument.CreateAnchor"/> to create an anchor from an offset.
/// </para>
/// <para>
/// The document will automatically update all text anchors; and because it uses weak references to do so,
/// the garbage collector can simply collect the anchor object when you don't need it anymore.
/// </para>
/// <para>Moreover, the document is able to efficiently update a large number of anchors without having to look
/// at each anchor object individually. Updating the offsets of all anchors usually only takes time logarithmic
/// to the number of anchors. Retrieving the <see cref="Offset"/> property also runs in O(lg N).</para>
/// <inheritdoc cref="IsDeleted" />
/// <inheritdoc cref="MovementType" />
/// <para>If you want to track a segment, you can use the <see cref="AnchorSegment"/> class which
/// implements <see cref="ISegment"/> using two text anchors.</para>
/// </remarks>
/// <example>
/// Usage:
/// <code>TextAnchor anchor = document.CreateAnchor(offset);
/// ChangeMyDocument();
/// int newOffset = anchor.Offset;
/// </code>
/// </example>
public sealed class TextAnchor
{
readonly TextDocument document;
@ -34,18 +57,34 @@ namespace ICSharpCode.AvalonEdit.Document @@ -34,18 +57,34 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Controls how the anchor moves.
/// </summary>
/// <remarks>Anchor movement is ambiguous if text is inserted exactly at the anchor's location.
/// Does the anchor stay before the inserted text, or does it move after it?
/// The property <see cref="MovementType"/> will be used to determine which of these two options the anchor will choose.
/// The default value is <see cref="AnchorMovementType.BeforeInsertion"/>.</remarks>
public AnchorMovementType MovementType { get; set; }
/// <summary>
/// <para>
/// Specifies whether the anchor survives deletion of the text containing it.
/// </para><para>
/// <c>false</c>: The anchor is deleted when the a selection that includes the anchor is deleted.
/// <c>true</c>: The anchor is not deleted.
/// </para>
/// </summary>
/// <remarks><inheritdoc cref="IsDeleted" /></remarks>
public bool SurviveDeletion { get; set; }
/// <summary>
/// Gets whether the anchor was deleted.
/// </summary>
/// <remarks>
/// <para>When a piece of text containing an anchor is removed, then that anchor will be deleted.
/// First, the <see cref="IsDeleted"/> property is set to true on all deleted anchors,
/// then the <see cref="Deleted"/> events are raised.
/// You cannot retrieve the offset from an anchor that has been deleted.</para>
/// <para>This deletion behavior might be useful when using anchors for building a bookmark feature,
/// but in other cases you want to still be able to use the anchor. For those cases, set <c><see cref="SurviveDeletion"/> = true</c>.</para>
/// </remarks>
public bool IsDeleted {
get {
document.DebugVerifyAccess();
@ -56,6 +95,11 @@ namespace ICSharpCode.AvalonEdit.Document @@ -56,6 +95,11 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Occurs after the anchor was deleted.
/// </summary>
/// <remarks>
/// <inheritdoc cref="IsDeleted" />
/// <para>Due to the 'weak reference' nature of TextAnchor, you will receive the Deleted event only
/// while your code holds a reference to the TextAnchor object.</para>
/// </remarks>
public event EventHandler Deleted;
internal void OnDeleted(DelayedEvents delayedEvents)

99
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs

@ -18,9 +18,13 @@ using ICSharpCode.AvalonEdit.Utils; @@ -18,9 +18,13 @@ using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
/// Runtimes:
/// n = number of lines in the document
/// This class is the main class of the text model. Basically, it is a <see cref="System.Text.StringBuilder"/> with events.
/// </summary>
/// <remarks>
/// <b>Thread safety:</b>
/// <inheritdoc cref="VerifyAccess"/>
/// <para>However, there is a single method that is thread-safe: <see cref="CreateSnapshot()"/> (and its overloads).</para>
/// </remarks>
public sealed class TextDocument : ITextSource
{
#region Thread ownership
@ -31,6 +35,11 @@ namespace ICSharpCode.AvalonEdit.Document @@ -31,6 +35,11 @@ namespace ICSharpCode.AvalonEdit.Document
/// Verifies that the current thread is the documents owner thread.
/// Throws an <see cref="InvalidOperationException"/> if the wrong thread accesses the TextDocument.
/// </summary>
/// <remarks>
/// <para>The TextDocument class is not thread-safe. A document instance expects to have a single owner thread
/// and will throw an <see cref="InvalidOperationException"/> when accessed from another thread.
/// It is possible to change the owner thread using the <see cref="SetOwnerThread"/> method.</para>
/// </remarks>
public void VerifyAccess()
{
if (Thread.CurrentThread != owner)
@ -43,8 +52,11 @@ namespace ICSharpCode.AvalonEdit.Document @@ -43,8 +52,11 @@ namespace ICSharpCode.AvalonEdit.Document
/// for displaying the document.
/// </summary>
/// <remarks>
/// <inheritdoc cref="VerifyAccess"/>
/// <para>
/// The owner can be set to null, which means that no thread can access the document. But, if the document
/// has no owner thread, any thread may take ownership by calling SetOwnerThread.
/// has no owner thread, any thread may take ownership by calling <see cref="SetOwnerThread"/>.
/// </para>
/// </remarks>
public void SetOwnerThread(Thread newOwner)
{
@ -162,6 +174,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -162,6 +174,7 @@ namespace ICSharpCode.AvalonEdit.Document
}
/// <inheritdoc/>
/// <remarks><inheritdoc cref="Changing"/></remarks>
public event EventHandler TextChanged;
/// <inheritdoc/>
@ -175,26 +188,64 @@ namespace ICSharpCode.AvalonEdit.Document @@ -175,26 +188,64 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Is raised when the TextLength property changes.
/// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks>
public event EventHandler TextLengthChanged;
/// <summary>
/// Is raised before the document changes.
/// </summary>
/// <remarks>
/// <para>Here is the order in which events are raised during a document update:</para>
/// <list type="bullet">
/// <item><description><b><see cref="BeginUpdate">BeginUpdate()</see></b></description>
/// <list type="bullet">
/// <item><description><see cref="UpdateStarted"/> event is raised</description></item>
/// </list></item>
/// <item><description><b><see cref="Insert(int,string)">Insert()</see> / <see cref="Remove(int,int)">Remove()</see> / <see cref="Replace(int,int,string)">Replace()</see></b></description>
/// <list type="bullet">
/// <item><description><see cref="Changing"/> event is raised</description></item>
/// <item><description>The document is changed</description></item>
/// <item><description><see cref="TextAnchor.Deleted">TextAnchor.Deleted</see> event is raised if anchors were
/// in the deleted text portion</description></item>
/// <item><description><see cref="Changed"/> event is raised</description></item>
/// </list></item>
/// <item><description><b><see cref="EndUpdate">EndUpdate()</see></b></description>
/// <list type="bullet">
/// <item><description><see cref="TextChanged"/> event is raised</description></item>
/// <item><description><see cref="TextLengthChanged"/> event is raised</description></item>
/// <item><description><see cref="LineCountChanged"/> event is raised</description></item>
/// <item><description><see cref="UpdateFinished"/> event is raised</description></item>
/// </list></item>
/// </list>
/// <para>
/// If the insert/remove/replace methods are called without a call to <c>BeginUpdate()</c>,
/// they will call <c>BeginUpdate()</c> and <c>EndUpdate()</c> to ensure no change happens outside of <c>UpdateStarted</c>/<c>UpdateFinished</c>.
/// </para><para>
/// There can be multiple document changes between the <c>BeginUpdate()</c> and <c>EndUpdate()</c> calls.
/// In this case, the events associated with EndUpdate will be raised only once after the whole document update is done.
/// </para><para>
/// The <see cref="UndoStack"/> listens to the <c>UpdateStarted</c> and <c>UpdateFinished</c> events to group all changes into a single undo step.
/// </para>
/// </remarks>
public event EventHandler<DocumentChangeEventArgs> Changing;
/// <summary>
/// Is raised after the document has changed.
/// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks>
public event EventHandler<DocumentChangeEventArgs> Changed;
/// <summary>
/// Creates a snapshot of the current text.
/// </summary>
/// <remarks>
/// Unlike all other TextDocument methods, this method may be called from any thread; even when the owning thread
/// is concurrently writing to the document.
/// <para>This method returns an immutable snapshot of the document, and may be safely called even when
/// the document's owner thread is concurrently modifying the document.
/// </para><para>
/// This special thread-safety guarantee is valid only for TextDocument.CreateSnapshot(), not necessarily for other
/// classes implementing ITextSource.CreateSnapshot().
/// </para><para>
/// </para>
/// </remarks>
public ITextSource CreateSnapshot()
{
@ -207,12 +258,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -207,12 +258,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// Creates a snapshot of the current text.
/// Additionally, creates a checkpoint that allows tracking document changes.
/// </summary>
/// <remarks>
/// Unlike all other TextDocument methods, this method may be called from any thread; even when the owning thread
/// is concurrently writing to the document.
/// This special thread-safety guarantee is valid only for TextDocument.CreateSnapshot(), not necessarily for other
/// classes implementing ITextSource.CreateSnapshot().
/// </remarks>
/// <remarks><inheritdoc cref="CreateSnapshot()"/><inheritdoc cref="ChangeTrackingCheckpoint"/></remarks>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", Justification = "Need to return snapshot and checkpoint together to ensure thread-safety")]
public ITextSource CreateSnapshot(out ChangeTrackingCheckpoint checkpoint)
{
@ -236,12 +282,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -236,12 +282,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Creates a snapshot of a part of the current text.
/// </summary>
/// <remarks>
/// Unlike all other TextDocument methods, this method may be called from any thread; even when the owning thread
/// is concurrently writing to the document.
/// This special thread-safety guarantee is valid only for TextDocument.CreateSnapshot(), not necessarily for other
/// classes implementing ITextSource.CreateSnapshot().
/// </remarks>
/// <remarks><inheritdoc cref="CreateSnapshot()"/></remarks>
public ITextSource CreateSnapshot(int offset, int length)
{
lock (lockObject) {
@ -264,6 +305,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -264,6 +305,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Gets if an update is running.
/// </summary>
/// <remarks><inheritdoc cref="BeginUpdate"/></remarks>
public bool IsInUpdate {
get {
VerifyAccess();
@ -275,6 +317,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -275,6 +317,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// Immediately calls <see cref="BeginUpdate()"/>,
/// and returns an IDisposable that calls <see cref="EndUpdate()"/>.
/// </summary>
/// <remarks><inheritdoc cref="BeginUpdate"/></remarks>
public IDisposable RunUpdate()
{
BeginUpdate();
@ -282,12 +325,13 @@ namespace ICSharpCode.AvalonEdit.Document @@ -282,12 +325,13 @@ namespace ICSharpCode.AvalonEdit.Document
}
/// <summary>
/// Begins a group of document changes.
/// Some events are suspended until EndUpdate is called, and the <see cref="UndoStack"/> will
/// group all changes into a single action.
/// Calling BeginUpdate several times increments a counter, only after the appropriate number
/// of EndUpdate calls the events resume their work.
/// <para>Begins a group of document changes.</para>
/// <para>Some events are suspended until EndUpdate is called, and the <see cref="UndoStack"/> will
/// group all changes into a single action.</para>
/// <para>Calling BeginUpdate several times increments a counter, only after the appropriate number
/// of EndUpdate calls the events resume their work.</para>
/// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks>
public void BeginUpdate()
{
VerifyAccess();
@ -303,6 +347,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -303,6 +347,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Ends a group of document changes.
/// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks>
public void EndUpdate()
{
VerifyAccess();
@ -321,11 +366,13 @@ namespace ICSharpCode.AvalonEdit.Document @@ -321,11 +366,13 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Occurs when a document change starts.
/// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks>
public event EventHandler UpdateStarted;
/// <summary>
/// Occurs when a document change is finished.
/// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks>
public event EventHandler UpdateFinished;
#endregion
@ -573,6 +620,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -573,6 +620,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Gets a read-only list of lines.
/// </summary>
/// <remarks><inheritdoc cref="DocumentLine"/></remarks>
public IList<DocumentLine> Lines {
get { return lineTree; }
}
@ -606,6 +654,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -606,6 +654,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Gets the offset from a text location.
/// </summary>
/// <seealso cref="GetLocation"/>
public int GetOffset(TextLocation location)
{
return GetOffset(location.Line, location.Column);
@ -614,6 +663,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -614,6 +663,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Gets the offset from a text location.
/// </summary>
/// <seealso cref="GetLocation"/>
public int GetOffset(int line, int column)
{
DocumentLine docLine = GetLineByNumber(line);
@ -627,6 +677,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -627,6 +677,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Gets the location from an offset.
/// </summary>
/// <seealso cref="GetOffset(TextLocation)"/>
public TextLocation GetLocation(int offset)
{
DocumentLine line = GetLineByOffset(offset);
@ -637,6 +688,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -637,6 +688,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Gets the list of <see cref="ILineTracker"/>s attached to this document.
/// You can add custom line trackers to this list.
/// </summary>
public IList<ILineTracker> LineTrackers {
get {
@ -655,8 +707,9 @@ namespace ICSharpCode.AvalonEdit.Document @@ -655,8 +707,9 @@ namespace ICSharpCode.AvalonEdit.Document
}
/// <summary>
/// Creates a new text anchor at the specified offset.
/// Creates a new <see cref="TextAnchor"/> at the specified offset.
/// </summary>
/// <inheritdoc cref="TextAnchor" select="remarks|example"/>
public TextAnchor CreateAnchor(int offset)
{
VerifyAccess();

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextLocation.cs

@ -12,8 +12,12 @@ namespace ICSharpCode.AvalonEdit.Document @@ -12,8 +12,12 @@ namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
/// A line/column position.
/// Text editor lines/columns are counting from one.
/// Text editor lines/columns are counted started from one.
/// </summary>
/// <remarks>
/// The document provides the methods <see cref="TextDocument.GetLocation"/> and
/// <see cref="TextDocument.GetOffset(TextLocation)"/> to convert between offsets and TextLocations.
/// </remarks>
public struct TextLocation : IComparable<TextLocation>, IEquatable<TextLocation>
{
/// <summary>
@ -23,8 +27,10 @@ namespace ICSharpCode.AvalonEdit.Document @@ -23,8 +27,10 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Creates a TextLocation instance.
/// <para>
/// Warning: the parameters are (line, column).
/// Not (column, line) as in ICSharpCode.TextEditor!
/// </para>
/// </summary>
public TextLocation(int line, int column)
{

28
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegment.cs

@ -11,13 +11,33 @@ using System.Diagnostics; @@ -11,13 +11,33 @@ using System.Diagnostics;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
/// A segment that can be put into a TextSegmentCollection.
/// A segment that can be put into a <see cref="TextSegmentCollection{T}"/>.
/// </summary>
/// <remarks>
/// On insertions at the start or end offset of the text segment, a TextSegmentCollection handling the document
/// changes will keep the TextSegment small;
/// i.e. use AfterInsertion for the start position and BeforeInsertion for the end position.
/// <para>
/// A <see cref="TextSegment"/> can be stand-alone or part of a <see cref="TextSegmentCollection{T}"/>.
/// If the segment is stored inside a TextSegmentCollection, its Offset and Length will be updated by that collection.
/// </para>
/// <para>
/// When the document changes, the offsets of all text segments in the TextSegmentCollection will be adjusted accordingly.
/// Start offsets move like <see cref="AnchorMovementType">AnchorMovementType.AfterInsertion</see>,
/// end offsets move like <see cref="AnchorMovementType">AnchorMovementType.BeforeInsertion</see>
/// (i.e. the segment will always stay as small as possible).</para>
/// <para>
/// If a document change causes a segment to be deleted completely, it will be reduced to length 0, but segments are
/// never automatically removed from the collection.
/// Segments with length 0 will never expand due to document changes, and they move as <c>AfterInsertion</c>.
/// </para>
/// <para>
/// Thread-safety: a TextSegmentCollection that is connected to a <see cref="TextDocument"/> may only be used on that document's owner thread.
/// A disconnected TextSegmentCollection is safe for concurrent reads, but concurrent access is not safe when there are writes.
/// Keep in mind that reading the Offset properties of a text segment inside the collection is a read access on the
/// collection; and setting an Offset property of a text segment is a write access on the collection.
/// </para>
/// </remarks>
/// <seealso cref="ISegment"/>
/// <seealso cref="AnchorSegment"/>
/// <seealso cref="TextSegmentCollection{T}"/>
public class TextSegment : ISegment
{
internal ISegmentTree ownerTree;

16
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegmentCollection.cs

@ -28,21 +28,13 @@ namespace ICSharpCode.AvalonEdit.Document @@ -28,21 +28,13 @@ namespace ICSharpCode.AvalonEdit.Document
}
/// <summary>
/// <para>
/// A collection of text segments that supports efficient lookup of segments
/// intersecting with another segment.
///
/// When the document changes, the offsets of all text segments in the collection will be adjusted accordingly.
/// Start offsets move like AnchorMovementType.AfterInsertion, end offsets move like AnchorMovementType.BeforeInsertion
/// (i.e. the segment will always stay as small as possible).
/// If a document change causes a segment to be deleted completely, it will be reduced to length 0, but segments are
/// never automatically removed. Segments with length 0 will never expand due to document changes and move as AfterInsertion.
/// </para>
/// </summary>
/// <remarks>
/// Thread-safety: a TextSegmentCollection that is connected to a TextDocument may only be used on that document's owner thread.
/// A disconnected TextSegmentCollection is safe for concurrent reads, but concurrent access is not safe when there are writes.
/// Keep in mind that reading the Offset properties of a <see cref="TextSegment"/> inside the collection is a read access on the
/// collection; and setting an Offset property of a <see cref="TextSegment"/> is a write access on the collection.
/// </remarks>
/// <remarks><inheritdoc cref="TextSegment"/></remarks>
/// <see cref="TextSegment"/>
public sealed class TextSegmentCollection<T> : ICollection<T>, ISegmentTree, IWeakEventListener where T : TextSegment
{
// Implementation: this is basically a mixture of an augmented interval tree

9
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -370,18 +370,9 @@ @@ -370,18 +370,9 @@
<EmbeddedResource Include="Highlighting\Resources\ModeV2.xsd" />
<EmbeddedResource Include="Highlighting\Resources\CSharp-Mode.xshd" />
<EmbeddedResource Include="Highlighting\Resources\XmlDoc.xshd" />
<None Include="documentation\Coordinate Systems.xml" />
<None Include="documentation\Folding.xml" />
<None Include="documentation\Introduction.xml" />
<None Include="documentation\SyntaxHighlighting.xml" />
<None Include="documentation\TextRendering.xml" />
<None Include="ICSharpCode.AvalonEdit.shfb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Document" />
<Folder Include="documentation" />
<Folder Include="Folding" />
<Folder Include="Highlighting" />
<Folder Include="Highlighting\Xshd" />

77
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.shfb

@ -1,77 +0,0 @@ @@ -1,77 +0,0 @@
<project schemaVersion="1.6.0.7">
<assemblies>
<assembly assemblyPath=".\ICSharpCode.AvalonEdit.dll" xmlCommentsPath=".\ICSharpCode.AvalonEdit.xml" commentsOnly="False" />
</assemblies>
<namespaceSummaries>
<namespaceSummaryItem name="" isDocumented="False" />
<namespaceSummaryItem name="ICSharpCode.AvalonEdit" isDocumented="True">This is the main AvalonEdit namespace.</namespaceSummaryItem>
<namespaceSummaryItem name="ICSharpCode.AvalonEdit.CodeCompletion" isDocumented="True">This namespace contains classes to show the code completion window.</namespaceSummaryItem>
<namespaceSummaryItem name="ICSharpCode.AvalonEdit.Document" isDocumented="True">This namespace contains the document model.
The most important class here is TextDocument, which represents document that can be displayed and edited in the text editor.</namespaceSummaryItem>
<namespaceSummaryItem name="ICSharpCode.AvalonEdit.Editing" isDocumented="True">This namespace is the home of the TextArea class. It manages user input and handles the caret and the selection.</namespaceSummaryItem>
<namespaceSummaryItem name="ICSharpCode.AvalonEdit.Folding" isDocumented="True">This namespace contains the folding implementation.</namespaceSummaryItem>
<namespaceSummaryItem name="ICSharpCode.AvalonEdit.Highlighting" isDocumented="True">This namespace contains the engine for highlighting text documents (DocumentHighlighter).
Additionally, the class HighlightingColorizer provides integration of the highlighting engine into the text editor GUI.</namespaceSummaryItem>
<namespaceSummaryItem name="ICSharpCode.AvalonEdit.Highlighting.Xshd" isDocumented="True">This namespace contains a document model for syntax highlighting definitions (.xshd files).</namespaceSummaryItem>
<namespaceSummaryItem name="ICSharpCode.AvalonEdit.Indentation" isDocumented="True">This namespace contains the logic for automatic indentation.</namespaceSummaryItem>
<namespaceSummaryItem name="ICSharpCode.AvalonEdit.Rendering" isDocumented="True">This namespace contains the text rendering infrastructure.</namespaceSummaryItem>
<namespaceSummaryItem name="ICSharpCode.AvalonEdit.Utils" isDocumented="True">This namespace contains various utility classes</namespaceSummaryItem>
<namespaceSummaryItem name="XamlGeneratedNamespace" isDocumented="False" />
</namespaceSummaries>
<conceptualContent snippetFile="">
<topics defaultTopic="c52241ea-3eba-4ddf-b463-6349cbff38fd">
<topic id="c52241ea-3eba-4ddf-b463-6349cbff38fd" file="..\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\documentation\Introduction.xml" revision="1" visible="True" />
<topic id="5b1854b4-884c-4713-b921-b28e96a1b43e" file="..\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\documentation\Coordinate Systems.xml" revision="1" visible="True" />
<topic id="c06e9832-9ef0-4d65-ac2e-11f7ce9c7774" file="..\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\documentation\TextRendering.xml" revision="1" visible="True" />
<topic id="4d4ceb51-154d-43f0-b876-ad9640c5d2d8" file="..\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\documentation\SyntaxHighlighting.xml" revision="1" visible="True" />
<topic id="440df648-413e-4f42-a28b-6b2b0e9b1084" file="..\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\documentation\Folding.xml" revision="1" visible="True" />
</topics>
</conceptualContent>
<componentConfigurations>
<component id="Cached Reflection Index Data" enabled="True" configuration="&lt;component id=&quot;Cached Reflection Index Data&quot; type=&quot;SandcastleBuilder.Components.CachedCopyFromIndexComponent&quot; assembly=&quot;{@SHFBFolder}SandcastleBuilder.Components.dll&quot;&gt;&#xD;&#xA;&lt;index name=&quot;reflection&quot; value=&quot;/reflection/apis/api&quot; key=&quot;@id&quot; cache=&quot;10&quot;&gt;&#xD;&#xA; &lt;cache base=&quot;{@SandcastlePath}Data\Reflection&quot; recurse=&quot;true&quot; files=&quot;*.xml&quot; cacheFile=&quot;{@AppDataFolder}Cache\Reflection.cache&quot; /&gt;&#xD;&#xA; &lt;data files=&quot;reflection.xml&quot; /&gt;&#xD;&#xA;&lt;/index&gt;&#xD;&#xA;&lt;copy name=&quot;reflection&quot; source=&quot;*&quot; target=&quot;/document/reference&quot; /&gt;&#xD;&#xA;&lt;/component&gt;" />
<component id="Cached MSDN URL References" enabled="True" configuration="&lt;component id=&quot;Cached MSDN URL References&quot; type=&quot;SandcastleBuilder.Components.CachedResolveReferenceLinksComponent&quot; assembly=&quot;{@SHFBFolder}SandcastleBuilder.Components.dll&quot;&gt;&#xD;&#xA;&lt;cache filename=&quot;{@AppDataFolder}Cache\MsdnUrl.cache&quot; /&gt;&#xD;&#xA;&lt;targets base=&quot;{@SandcastlePath}Data\Reflection&quot; recurse=&quot;true&quot; files=&quot;*.xml&quot; type=&quot;{@SDKLinks}&quot; /&gt;&#xD;&#xA;&lt;targets files=&quot;reflection.xml&quot; type=&quot;{@ProjectLinks}&quot; /&gt;&#xD;&#xA;&lt;/component&gt;" />
<component id="IntelliSense Component" enabled="True" configuration="&lt;component id=&quot;IntelliSense Component&quot; type=&quot;SandcastleBuilder.Components.IntelliSenseComponent&quot; assembly=&quot;{@SHFBFolder}SandcastleBuilder.Components.dll&quot;&gt;&#xD;&#xA;&lt;!-- Output options (optional)&#xD;&#xA; Attributes:&#xD;&#xA; Include Namespaces (false by default)&#xD;&#xA; Namespaces filename (&quot;Namespaces&quot; if not specified or empty)&#xD;&#xA; Directory (current folder if not specified or empty) --&gt;&#xD;&#xA;&lt;output includeNamespaces=&quot;false&quot; namespacesFile=&quot;Namespaces&quot; folder=&quot;{@OutputFolder}&quot; /&gt;&#xD;&#xA;&lt;/component&gt;" />
<component id="Cached Framework Comments Index Data" enabled="True" configuration="&lt;component id=&quot;Cached Framework Comments Index Data&quot; type=&quot;SandcastleBuilder.Components.CachedCopyFromIndexComponent&quot; assembly=&quot;{@SHFBFolder}SandcastleBuilder.Components.dll&quot;&gt;&#xD;&#xA;&lt;index name=&quot;comments&quot; value=&quot;/doc/members/member&quot; key=&quot;@name&quot; cache=&quot;100&quot;&gt;&#xD;&#xA;{@CachedFrameworkCommentList}&#xD;&#xA;{@CommentFileList}&#xD;&#xA; &lt;/index&gt;&#xD;&#xA;&lt;copy name=&quot;comments&quot; source=&quot;*&quot; target=&quot;/document/comments&quot; /&gt;&#xD;&#xA;&lt;/component&gt;" />
</componentConfigurations>
<ProjectSummary />
<MissingTags>Summary, AutoDocumentCtors, Namespace</MissingTags>
<VisibleItems>InheritedMembers, InheritedFrameworkMembers, Protected, ProtectedInternalAsProtected</VisibleItems>
<HtmlHelp1xCompilerPath path="" />
<HtmlHelp2xCompilerPath path="" />
<OutputPath>.\Help\</OutputPath>
<SandcastlePath path="" />
<WorkingPath path="" />
<CleanIntermediates>True</CleanIntermediates>
<KeepLogFile>True</KeepLogFile>
<BuildLogFile path="" />
<HelpFileFormat>HtmlHelp1x</HelpFileFormat>
<CppCommentsFixup>False</CppCommentsFixup>
<FrameworkVersion>3.5</FrameworkVersion>
<IndentHtml>False</IndentHtml>
<Preliminary>False</Preliminary>
<RootNamespaceContainer>False</RootNamespaceContainer>
<RootNamespaceTitle />
<HelpTitle>AvalonEdit</HelpTitle>
<HtmlHelpName>AvalonEdit Documentation</HtmlHelpName>
<Language>en-US</Language>
<CopyrightHref />
<CopyrightText>Copyright 2008-2009, Daniel Grunwald</CopyrightText>
<FeedbackEMailAddress />
<FeedbackEMailLinkText />
<HeaderText />
<FooterText />
<ProjectLinkType>Local</ProjectLinkType>
<SdkLinkType>Msdn</SdkLinkType>
<SdkLinkTarget>Blank</SdkLinkTarget>
<PresentationStyle>Prototype</PresentationStyle>
<NamingMethod>Guid</NamingMethod>
<SyntaxFilters>Standard</SyntaxFilters>
<ShowFeedbackControl>False</ShowFeedbackControl>
<BinaryTOC>True</BinaryTOC>
<IncludeFavorites>False</IncludeFavorites>
<CollectionTocStyle>Hierarchical</CollectionTocStyle>
<IncludeStopWordList>True</IncludeStopWordList>
<PlugInNamespaces>ms.vsipcc+, ms.vsexpresscc+</PlugInNamespaces>
<HelpFileVersion>4.0.0.5048</HelpFileVersion>
<ContentPlacement>AboveNamespaces</ContentPlacement>
</project>

167
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/documentation/Coordinate Systems.xml

@ -1,167 +0,0 @@ @@ -1,167 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<developerConceptualDocument
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!--
<summary>
<para>Optional summary abstract</para>
</summary>
-->
<introduction>
<!-- Uncomment this to generate an outline of the section and sub-section
titles. Specify a numeric value as the inner text to limit it to
a specific number of sub-topics when creating the outline. Specify
zero (0) to limit it to top-level sections only. -->
<!-- <autoOutline /> -->
<para>The text editor makes use of several different coordinate systems.
Here's an explanation of them.</para>
</introduction>
<!-- Add one or more top-level section elements. These are collapsible.
If using <autoOutline /> tag, add an address attribute to identify
it so that it can be jumped to with a hyperlink. -->
<section>
<title>Offset</title>
<content>
<para>The number of characters from the start of the text, counting from 0.</para>
<para>Same as used by String.IndexOf() etc.</para>
</content>
</section>
<section>
<title>TextLocation</title>
<content>
<para>A Line,Column pair. Line and column count from 1.</para>
<para>Use the
TextDocument.<codeEntityReference>M:ICSharpCode.AvalonEdit.Document.TextDocument.GetLocation(System.Int32)</codeEntityReference>
and
TextDocument.<codeEntityReference>M:ICSharpCode.AvalonEdit.Document.TextDocument.GetOffset(ICSharpCode.AvalonEdit.Document.TextLocation)</codeEntityReference>
methods to convert between TextLocation and Offset.</para>
</content>
</section>
<section>
<title>TextAnchor</title>
<content>
<para>A text anchor object stores an Offset, but automatically
updates the offset when text is inserted/removed before the offset.
</para>
<para>
The document keeps weak references to anchors for updating them,
so you don't have to worry about memory leaks using text anchors.
</para>
<para>Use the
<codeEntityReference>P:ICSharpCode.AvalonEdit.Document.TextAnchor.Offset</codeEntityReference>
property to get the offset from a text anchor.
Use the
<codeEntityReference>M:ICSharpCode.AvalonEdit.Document.TextDocument.CreateAnchor(System.Int32)</codeEntityReference>
method to create an anchor from an offset.
</para>
</content>
</section>
<section>
<title>RelativeTextOffset</title>
<content>
<para>An offset in the document, but relative to the start offset of a VisualLine.</para>
<para>Relative text offsets are used to store document offsets in visual lines.</para>
<para>You can convert between relative text offsets and document offsets
by adding/subtracting
<codeEntityReference>T:ICSharpCode.AvalonEdit.Rendering.VisualLine</codeEntityReference>.<codeEntityReference>P:ICSharpCode.AvalonEdit.Rendering.VisualLine.FirstDocumentLine</codeEntityReference>.<codeEntityReference>P:ICSharpCode.AvalonEdit.Document.DocumentLine.Offset</codeEntityReference>.
</para>
</content>
</section>
<section>
<title>VisualColumn</title>
<content>
<para>An integer value that specifies a position inside a VisualLine.</para>
<para>
Not only text has a length in the visual line, but also other VisualLineElements.
VisualColumn is counting from 0 for each visual line.
</para>
<para>For example, tab markers take 2 visual columns (the marker and the tab space),
newline markers take 1 visual column; folding markers take just 1 visual column
even though they are longer in the document text.</para>
<para>Use the
<codeEntityReference>M:ICSharpCode.AvalonEdit.Rendering.VisualLine.GetVisualColumn(System.Int32)</codeEntityReference>
and
<codeEntityReference>M:ICSharpCode.AvalonEdit.Rendering.VisualLine.GetRelativeOffset(System.Int32)</codeEntityReference>
methods to convert between
visual columns and relative text offsets.</para>
<alert class="note">
<para>Do not confuse VisualColumn with text columns.
VisualColumn starts at 0, text column at 1. Text may have different length
in the two coordinate systems (e.g. tab markers, foldings).</para>
</alert>
</content>
</section>
<section>
<title>TextViewPosition</title>
<content>
<para>A Line,Column,VisualColumn triple.</para>
<para>Can be implicitly converted
to TextLocation, but has the additional VisualColumn information
that is necessary to accurately hold the caret position when
VisualLineElements with DocumentLength 0 are in use.</para>
</content>
</section>
<section>
<title>VisualTop</title>
<content>
<para>A double value that specifies the distance from the top of
the document to the top of a line measured in device-independent pixels.</para>
<para>VisualTop is equivalent to the Y component of a VisualPosition.</para>
</content>
</section>
<section>
<title>VisualPosition</title>
<content>
<para>A Point value (double X,Y) that specifies the position of an
element from the top left document corner measured in device-independent pixels.</para>
<para>To convert a VisualPosition to or from a (mouse) position inside
the TextView, simply subtract or add
TextView.<codeEntityReference>P:ICSharpCode.AvalonEdit.Rendering.TextView.ScrollOffset</codeEntityReference>
to it.
</para>
</content>
</section>
<relatedTopics>
<!-- One or more of the following:
- A local link
- An external link
- A code entity reference
<link xlink:href="Other Topic's ID"/>
<link xlink:href="Other Topic's ID">Link inner text</link>
<externalLink>
<linkText>Link text</linkText>
<linkAlternateText>Optional alternate link text</linkAlternateText>
<linkUri>URI</linkUri>
</externalLink>
<codeEntityReference>API member ID</codeEntityReference>
Examples:
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8270" />
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8278">Some other topic</link>
<externalLink>
<linkText>SHFB on CodePlex</linkText>
<linkAlternateText>Go to CodePlex</linkAlternateText>
<linkUri>http://www.codeplex.com/SHFB</linkUri>
</externalLink>
<codeEntityReference>T:TestDoc.TestClass</codeEntityReference>
<codeEntityReference>P:TestDoc.TestClass.SomeProperty</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.#ctor</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.#ctor(System.String,System.Int32)</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.ToString</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.FirstMethod</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.SecondMethod(System.Int32,System.String)</codeEntityReference>
-->
</relatedTopics>
</developerConceptualDocument>

32
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/documentation/Folding.xml

@ -1,32 +0,0 @@ @@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<developerConceptualDocument
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"
xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>
Introduction for 'Folding'.
</para>
</introduction>
<section>
<title>How the FoldingManager works</title>
<content>
<para>
The FoldingManager maintains a list of foldings. The FoldMargin displays those foldings and provides
the UI for collapsing/expanding.
Folded foldings cause the FoldingElementGenerator to produce a line element that spans the whole folded
text section, causing the text generation for the visual line that contains the folding start to
continue after the folding end in another line.
To ensure scrolling works correctly in the presence of foldings, lines inside folded regions must not
be used as start lines for the visual line generation. This is done by setting the line height of all
such lines to 0. To efficiently set the height on a large number of lines and support reverting to the
old height when the folding is uncollapsed, a CollapsedLineSection is used.
</para>
</content>
</section>
<relatedTopics>
<codeEntityReference>T:ICSharpCode.AvalonEdit.Folding.FoldingManager</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>

72
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/documentation/Introduction.xml

@ -1,72 +0,0 @@ @@ -1,72 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<developerConceptualDocument
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"
xmlns:xlink="http://www.w3.org/1999/xlink">
<summary>
<para>AvalonEdit is a WPF-based extensible text editor.</para>
</summary>
<introduction>
<para>While the WPF RichTextBox is quite powerful, you quickly run into its limits
when trying to use it as a code editor: it's hard to write efficient syntax highlighting for it,
and you cannot really implement features like code folding with the standard RichTextBox.</para>
<para>The problem is: the RichTextBox edits a rich document.
In contrast, AvalonEdit simply edits text.</para>
<para>However, AvalonEdit offers lots of possibilities on how the text document is
displayed - so it is much more suitable for a code editor where things like the text color
are not controlled by the user, but instead depend on the text (syntax highlighting).</para>
</introduction>
<!-- TODO: screenshot-->
<relatedTopics>
<codeEntityReference>T:ICSharpCode.AvalonEdit.TextEditor</codeEntityReference>
<externalLink>
<linkText>www.avalonedit.net</linkText>
<linkUri>http://www.avalonedit.net</linkUri>
</externalLink>
<externalLink>
<linkText>www.icsharpcode.net</linkText>
<linkUri>http://www.icsharpcode.net</linkUri>
</externalLink>
<!-- One or more of the following:
- A local link
- An external link
- A code entity reference
<link xlink:href="Other Topic's ID"/>
<link xlink:href="Other Topic's ID">Link inner text</link>
<externalLink>
<linkText>Link text</linkText>
<linkAlternateText>Optional alternate link text</linkAlternateText>
<linkUri>URI</linkUri>
</externalLink>
<codeEntityReference>API member ID</codeEntityReference>
Examples:
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8270" />
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8278">Some other topic</link>
<externalLink>
<linkText>SHFB on CodePlex</linkText>
<linkAlternateText>Go to CodePlex</linkAlternateText>
<linkUri>http://www.codeplex.com/SHFB</linkUri>
</externalLink>
<codeEntityReference>T:TestDoc.TestClass</codeEntityReference>
<codeEntityReference>P:TestDoc.TestClass.SomeProperty</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.#ctor</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.#ctor(System.String,System.Int32)</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.ToString</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.FirstMethod</codeEntityReference>
<codeEntityReference>M:TestDoc.TestClass.SecondMethod(System.Int32,System.String)</codeEntityReference>
-->
</relatedTopics>
</developerConceptualDocument>

55
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/documentation/SyntaxHighlighting.xml

@ -1,55 +0,0 @@ @@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<developerConceptualDocument
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"
xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>Probably the most important feature for any text editor is syntax highlighting.</para>
<para>AvalonEdit has a flexible text rendering model, see "Text Rendering". Among the
Text Rendering extension points is the support for "visual line transformers" that
can change the display of a visual line after it has been constructed by the "visual element generators".
A useful base class implementing IVisualLineTransformer for the purpose of syntax highlighting
is DocumentColorizingTransformer. Take a look at that class' documentation to see
how to write fully custom syntax highlighters. This article only discusses the XML-driven built-in
highlighting engine.
</para>
</introduction>
<section>
<title>The highlighting engine</title>
<content>
<para>
The core engine of the higlighting is the class DocumentHighlighter. It tracks changes
to a TextDocument and can produce HighlightedLines from DocumentLines.
A HighlightedLine is simply a list of (possibly nested) highlighted text sections.
</para>
<para>The highlighting rules used by the highlighting engine to highlight
the document are described by the following classes:
- HighlightingRuleSet: describes a set of highlighting spans and rules
- HighlightingSpan: consists of Start and End regular expressions, a color, and a
child ruleset. The region between Start and End expressions will be
assigned the given color, and inside that span, the rules of the child
ruleset apply (instead of the default rules).
If the child ruleset also has HighlightingSpans, they can be nested,
allowing highlighting constructs like nested comments or one language
embedded in another.
- HighlightingRule: A regular expression with a color. Highlights matches of the
regular expression using that color.
- HighlightingColor:
A highlighting color isn't just a color: it consists of a foreground
color, font weight and font style.
</para>
</content>
</section>
<section>
<title>XML highlighting definitions</title>
<content>
<para>AvalonEdit supports XML syntax highlighting definitions (.xshd files).</para>
</content>
</section>
<relatedTopics>
<codeEntityReference>N:ICSharpCode.AvalonEdit.Highlighting</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
Loading…
Cancel
Save