| ofs | hex dump | ascii |
|---|
| 0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 03 83 00 00 02 70 08 06 00 00 00 33 e6 b4 | .PNG........IHDR.......p.....3.. |
| 0020 | f9 00 00 00 01 73 52 47 42 00 ae ce 1c e9 00 00 00 04 67 41 4d 41 00 00 b1 8f 0b fc 61 05 00 00 | .....sRGB.........gAMA......a... |
| 0040 | 00 09 70 48 59 73 00 00 0e c3 00 00 0e c3 01 c7 6f a8 64 00 00 00 19 74 45 58 74 53 6f 66 74 77 | ..pHYs..........o.d....tEXtSoftw |
| 0060 | 61 72 65 00 70 61 69 6e 74 2e 6e 65 74 20 34 2e 30 2e 31 37 33 6e 9f 63 00 00 ff 80 49 44 41 54 | are.paint.net.4.0.173n.c....IDAT |
| 0080 | 78 5e ec bd 79 d7 2c 4b 59 a6 ff fb 0a dd 4b 7b b5 ed 84 b3 b6 33 e2 84 8a ca a0 a2 88 42 3b 0b | x^..y.,KY.....K{.....3.......B;. |
| 00a0 | 82 0c 02 82 0c 8a d8 ab bf fc fe e5 15 91 57 e6 9d cf fb 64 55 bd fb ec 03 e7 ec 9d 7f dc 2b e2 | ..............W....dU.........+. |
| 00c0 | 19 23 72 88 e1 ae cc aa fa ff 5e bc 78 71 e1 c2 85 0b 17 2e 5c b8 70 e1 c2 85 0b 17 de 30 b4 ca | .#r.......^.xq......\.p......0.. |
| 00e0 | 0b 17 2e 5c b8 70 e1 c2 85 0b 17 2e 5c b8 f0 7a a3 55 5e b8 70 e1 c2 85 0b 17 2e 5c b8 70 e1 c2 | ...\.p......\..z.U^.p......\.p.. |
| 0100 | 85 d7 1b ad f2 c2 85 0b 17 2e 5c b8 70 e1 c2 85 0b 17 2e bc de 68 95 17 2e 5c b8 70 e1 c2 85 0b | ..........\.p........h...\.p.... |
| 0120 | 17 2e 5c b8 70 e1 f5 46 ab bc 70 e1 c2 85 0b 17 2e 5c b8 70 e1 c2 85 0b af 37 5a e5 85 0b 17 2e | ..\.p..F..p......\.p.....7Z..... |
| 0140 | 5c b8 70 e1 c2 85 0b 17 2e 5c 78 bd d1 2a 2f 5c b8 70 e1 c2 85 0b 17 2e 5c b8 70 e1 c2 eb 8d 56 | \.p......\x..*/\.p......\.p....V |
| 0160 | 79 e1 c2 85 0b 17 2e 5c b8 70 e1 c2 85 0b 17 5e 6f b4 ca 0b 17 2e 5c b8 70 e1 c2 85 0b 17 2e 5c | y......\.p.....^o.....\.p......\ |
| 0180 | b8 f0 7a a3 55 5e b8 70 e1 c2 85 0b 17 2e 5c b8 70 e1 c2 85 d7 1b ad f2 c2 85 0b 17 2e 5c b8 70 | ..z.U^.p......\.p............\.p |
| 01a0 | e1 c2 85 0b 17 2e bc de 68 95 17 2e 5c b8 70 e1 c2 85 0b 17 2e 5c b8 70 e1 f5 46 ab bc 70 e1 c2 | ........h...\.p......\.p..F..p.. |
| 01c0 | 85 0b 17 2e 5c b8 70 e1 c2 85 0b af 37 5a e5 85 0b 17 2e 5c b8 70 e1 c2 85 0b 17 2e 5c 78 bd d1 | ....\.p.....7Z.....\.p......\x.. |
| 01e0 | 2a 2f 5c b8 70 e1 c2 85 0b 17 2e 5c b8 70 e1 c2 eb 8d 56 79 e1 c2 85 0b 17 2e 5c b8 70 e1 c2 85 | */\.p......\.p....Vy......\.p... |
| 0200 | 0b 17 5e 6f b4 ca 0b 17 2e 5c b8 70 e1 1e fe fd df ff fd 85 f8 d6 b7 be f5 e2 9b df fc e6 8b af | ..^o.....\.p.................... |
| 0220 | 7f fd eb a3 b4 fe d5 af 7e f5 c5 57 be f2 95 17 5f fc e2 17 07 fe e5 5f fe 65 94 5f f8 c2 17 5e | ........~..W...._......_.e._...^ |
| 0240 | 7c ee 73 9f 7b f1 99 cf 7c e6 c5 3f fd d3 3f 8d fa 3f ff f3 3f 8f fa a7 3e f5 a9 17 ff f8 8f ff | |.s.{...|..?..?..?..?...>....... |
| 0260 | 78 40 d5 fd fd df ff fd 8b bf fd db bf 1d f8 bb bf fb bb 17 7f fd d7 7f 7d c0 5f fd d5 5f bd f8 | x@......................}._.._.. |
| 0280 | 3f ff e7 ff 0c 58 a7 ec f4 29 57 1f d1 e5 ac b2 75 fb 90 b6 1a 8f 4c df ff e6 6f fe 66 ab 83 7f | ?....X...)W.....u.....L...o.f... |
| 02a0 | f8 87 7f 18 e7 c0 f3 80 9c e7 40 7c fa d3 9f 1e 3e 9c 33 ce 1d e7 f3 f3 9f ff fc 00 e7 f7 4b 5f | ..........@|....>.3...........K_ |
| 02c0 | fa d2 38 d7 80 fa d7 be f6 b5 17 ff f6 6f ff 36 e0 35 e2 9a e5 f5 53 ae d7 f9 c2 85 0b 17 2e bc | ..8..........o.6.5....S......... |
| 02e0 | be 68 95 17 2e 5c b8 70 e1 9d 8b dc bc 4b bc be fc e5 2f 6f 9b 7f 09 97 64 0b c2 20 89 80 5c 48 | .h...\.p.....K..../o....d.....\H |
| 0300 | 9e 24 34 42 a2 02 3e f9 c9 4f 0e 9d 7e c8 d4 5f 06 99 fb 96 8d ba 6d 76 3e da f5 81 48 01 64 eb | .$4B..>..O..~.._......mv>...H.d. |
| 0320 | 92 ab 2c 2b cc 99 3a fb 90 c0 0f 58 4f ff 8a ea 9f 31 19 6b ff 95 3b 9d 79 00 7a 72 a5 7f fa 69 | ..,+..:....XO....1.k..;.y.zr...i |
| 0340 | ef da 17 f8 a0 37 4e e2 99 c8 f6 3b 98 07 df 94 6d 5f 3d 25 f7 58 25 ad 94 dc 8b 90 56 ee 4f ee | .....7N....;....m_=%.X%.....V.O. |
| 0360 | 57 3e 24 e0 c3 02 88 ea 7f fc c7 7f 0c d4 7b fd c2 85 0b 17 2e bc bd 68 95 17 2e 5c b8 70 e1 e5 | W>$...........{........h...\.p.. |
| 0380 | c0 86 16 b2 66 f9 8d 6f 7c 63 6c 76 7d 1a c6 93 1b cb cf 7e f6 b3 63 a3 4c 09 41 73 43 9d 9b 7c | ....f..o|clv}......~..c.L.AsC..| |
| 03a0 | 48 18 a5 9b ef ba d9 77 43 2e 11 30 b6 ea ce 7c 3b bb b9 b5 a9 33 56 3f 91 b1 a2 c6 2a ab 4b b9 | H......wC..0...|;....3V?....*.K. |
| 03c0 | da 45 e6 cb 98 94 89 05 92 96 84 fe d4 f5 53 d6 9e 7a 65 eb 35 c7 a3 38 8b 21 37 fd ce 7e 50 76 | .E............S..ze.5..8.!7..~Pv |
| 03e0 | 7a e1 b1 2a 77 79 d1 a9 f7 1e aa 30 cf 19 68 db 7e a4 2e 65 72 27 c8 6b bd f6 21 81 ce 63 53 16 | z..*wy.....0..h.~..er'.k..!..cS. |
| 0400 | b5 1d 73 18 a3 9e ba 72 6d 8b b1 c3 78 f2 e9 72 3e 2d 85 74 fe eb bf fe eb f6 d4 f3 22 9c 17 2e | ..s....rm...x..r>-.t........"... |
| 0420 | 5c b8 70 44 ab bc 70 e1 c2 85 37 05 92 36 36 8b bc 3e c7 c6 91 0d 24 1b 49 36 95 3c d1 10 be 9e | \.pD..p...7..66..>....$.I6.<.... |
| 0440 | 28 71 63 43 ca 06 b5 12 36 a1 fd 13 9f f8 c4 13 bd 50 4e 7b 87 8c 11 b7 ec 69 a3 0f d5 fe 1c 9c | (qcC....6........PN{.....i...... |
| 0460 | b5 a1 ed 5e 7e e3 6b 8e d4 7b fe 2a 32 46 92 90 75 7d d2 86 4e 1f 65 eb 42 d9 b8 ce 5e 75 89 da | ...^~.k..{.*2F..u}..N.e.B...^u.. |
| 0480 | af 5b 36 90 7d d2 5f 3f ed 1e 8b 30 87 b8 a7 37 37 a8 b2 90 a0 3d 82 2e ae cb 81 ce fe e7 71 18 | .[6.}._?...0...77....=........q. |
| 04a0 | 8b ac 9f f1 94 f4 3d 75 99 cf 63 32 4f d6 ab ff 73 61 3e fb 99 e7 d2 dc 8c 73 5f cd 65 ec 57 82 | ......=u..c2O...sa>......s_.e.W. |
| 04c0 | c9 07 3c cc 19 cc 1f 17 c1 bc 70 e1 c2 bb 19 ad f2 c2 85 0b 17 de 2d 90 cc f1 ea 59 7d e2 c6 46 | ..<.......p...........-....Y}..F |
| 04e0 | 8e 0d 1d af ad e5 a6 b9 6e 5a 73 63 98 40 07 d1 f3 95 c9 ce de e9 04 72 6e 34 95 f5 cb 98 f4 a9 | ........nZsc.@.........rn4...... |
| 0500 | 48 fb 2d 74 71 a2 ca a9 17 99 27 6d fa de 6a 27 e3 8c d5 5f 9b 75 37 f4 40 9d 71 09 63 d2 bf 03 | H.-tq.....'m..j'..._.u7.@.q.c... |
| 0520 | be 29 d7 98 b4 a7 cd fa bd 36 aa 1d 59 a4 3e 6d 55 5f fb 08 32 0f e0 78 45 97 c3 98 4e 0f 2a e1 | .).......6..Y.>mU_..2..// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Diagnostics;
using System.Globalization;
namespace Tango.Scripting.Editors.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
#if DEBUG
// Required for thread safety check which is done only in debug builds.
// To save space, we don't store the document reference in release builds as we don't need it there.
readonly TextDocument document;
#endif
internal bool isDeleted;
internal DocumentLine(TextDocument document)
{
#if DEBUG
Debug.Assert(document != null);
this.document = document;
#endif
}
[Conditional("DEBUG")]
void DebugVerifyAccess()
{
#if DEBUG
document.DebugVerifyAccess();
#endif
}
#endregion
#region Events
// /// <summary>
// /// Is raised when the line is deleted.
// /// </summary>
// public event EventHandler Deleted;
//
// /// <summary>
// /// Is raised when the line's text changes.
// /// </summary>
// public event EventHandler TextChanged;
//
// /// <summary>
// /// Raises the Deleted or TextChanged event.
// /// </summary>
// internal void RaiseChanged()
// {
// if (IsDeleted) {
// if (Deleted != null)
// Deleted(this, EventArgs.Empty);
// } else {
// if (TextChanged != null)
// TextChanged(this, EventArgs.Empty);
// }
// }
#endregion
#region Properties stored in tree
/// <summary>
/// Gets if this line was deleted from the document.
/// </summary>
public bool IsDeleted {
get {
DebugVerifyAccess();
return isDeleted;
}
}
/// <summary>
/// Gets the number of this line.
/// Runtime: O(log n)
/// </summary>
/// <exception cref="InvalidOperationException">The line was deleted.</exception>
public int LineNumber {
get {
if (IsDeleted)
throw new InvalidOperationException();
return DocumentLineTree.GetIndexFromNode(this) + 1;
}
}
/// <summary>
/// Gets the starting offset of the line in the document's text.
/// Runtime: O(log n)
/// </summary>
/// <exception cref="InvalidOperationException">The line was deleted.</exception>
public int Offset {
get {
if (IsDeleted)
throw new InvalidOperationException();
return DocumentLineTree.GetOffsetFromNode(this);
}
}
/// <summary>
/// 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>
/// <remarks>EndOffset = <see cref="Offset"/> + <see cref="Length"/>.</remarks>
public int EndOffset {
get { return this.Offset + this.Length; }
}
#endregion
#region Length
int totalLength;
byte delimiterLength;
/// <summary>
/// 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>
public int Length {
get {
DebugVerifyAccess();
return totalLength - delimiterLength;
}
}
/// <summary>
/// Gets the length of this line, including 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>
public int TotalLength {
get {
DebugVerifyAccess();
return totalLength;
}
internal set {
// this is set by DocumentLineTree
totalLength = value;
}
}
/// <summary>
/// <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 delimiter's length before the deletion.</remarks>
public int DelimiterLength {
get {
DebugVerifyAccess();
return delimiterLength;
}
internal set {
Debug.Assert(value >= 0 && value <= 2);
delimiterLength = (byte)value;
}
}
#endregion
#region Previous / Next Line
/// <summary>
/// Gets the next line in the document.
/// </summary>
/// <returns>The line following this line, or null if this is the last line.</returns>
public DocumentLine NextLine {
get {
DebugVerifyAccess();
if (right != null) {
return right.LeftMost;
} else {
DocumentLine node = this;
DocumentLine oldNode;
do {
oldNode = node;
node = node.parent;
// we are on the way up from the right part, don't output node again
} while (node != null && node.right == oldNode);
return node;
}
}
}
/// <summary>
/// Gets the previous line in the document.
/// </summary>
/// <returns>The line before this line, or null if this is the first line.</returns>
public DocumentLine PreviousLine {
get {
DebugVerifyAccess();
if (left != null) {
return left.RightMost;
} else {
DocumentLine node = this;
DocumentLine oldNode;
do {
oldNode = node;
node = node.parent;
// we are on the way up from the left part, don't output node again
} while (node != null && node.left == oldNode);
return node;
}
}
}
#endregion
#region ToString
/// <summary>
/// Gets a string with debug output showing the line number and offset.
/// Does not include the line's text.
/// </summary>
public override string ToString()
{
if (IsDeleted)
return "[DocumentLine deleted]";
else
return string.Format(
CultureInfo.InvariantCulture,
"[DocumentLine Number={0} Offset={1} Length={2}]", LineNumber, Offset, Length);
}
#endregion
}
}
|