aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Graphics/bug-resolved.png
blob: e49f62923e5d45048e7f2f2cab76d1b124777846 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 80 00 00 00 80 08 06 00 00 00 c3 3e 61 .PNG........IHDR..............>a
0020 cb 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 03 75 00 00 03 75 01 d0 6c a3 a1 00 00 00 19 74 45 58 74 53 6f 66 74 77 ..pHYs...u...u..l......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 18 d0 49 44 41 54 are.paint.net.4.0.173n.c....IDAT
0080 78 5e e5 9d 09 90 5c 55 b9 c7 c5 e7 f3 e9 d3 52 79 2e 55 2e cf aa f7 44 5f 95 c0 4c a6 7b 66 32 x^....\U.......Ry.U....D_..L.{f2
00a0 5b 2f b7 f7 db dd b3 f4 cc f4 ac c9 64 d6 ec 21 84 0c 90 04 23 24 04 c2 16 10 48 02 84 04 10 45 [/..........d..!....#$....H....E
00c0 90 0a 20 6a d0 00 09 81 24 84 40 34 2c 22 f8 44 44 59 9e a0 68 82 c6 10 02 73 de f7 f5 4c 87 db ...j....$.@4,".DDY..h....s...L..
00e0 b7 ff dd 7d b7 de 34 55 bf a2 f8 e6 dc 73 ce fd ff ef 3d 77 e9 73 be fb 01 21 c4 3f 24 83 b7 b6 ...}..4U.....s....=w.s...!.?$...
0100 fe 57 7c 8d 77 41 db b8 74 5b 74 b6 eb e7 1d 63 be 57 db 66 78 0f 37 77 78 8e 46 c2 d2 71 d9 ed .W|.wA..t[t....c.W.fx.7wx.F..q..
0120 9e 08 d5 79 84 c3 56 27 9c 75 75 13 6e 77 fd bb 9e 40 c3 31 7f 4b e3 df 82 f1 a6 37 bc bd f5 bf ...y..V'.uu.nw...@.1.K.....7....
0140 0c cd 6e ba 27 3a ee 3e 27 7e 79 f0 7f 50 1b ff 08 c0 60 39 b2 42 f4 9e 44 4c 27 d6 ae 38 de f3 ..n.':.>'~y..P....`9.B..DL'..8..
0160 dc 8c 4d b2 70 35 d6 09 47 45 7d 02 67 45 83 08 d8 24 11 b2 7b 52 48 fe 3d 49 e3 e9 75 a2 f6 eb ..M.p5..GE}.gE...$..{RH.=I..u...
0180 76 51 f3 75 5b 82 5a 5b 95 08 8f 3b c4 e0 0e f9 f7 23 7b c3 9b c6 f6 47 7d b3 0f 44 4f 42 7d 28 vQ.u[.Z[...;.....#{....G}..DOB}(
01a0 47 60 b0 5c 20 b3 3f 4c 04 89 eb 88 57 09 a1 e4 9c b7 ba 45 f7 5a bf 70 d8 27 0f 04 27 11 b0 b9 G`.\..?L....W......E.Z.p.'..'...
01c0 33 1e 00 8d a7 4f 27 f3 27 8d af a9 a8 12 c1 79 0d 62 e6 8f 82 62 d6 83 a1 14 06 77 ca 7f 1a de 3....O'.'......y.b...b.....w....
01e0 13 be 73 f4 b1 48 d7 d8 13 d1 8f a0 be 95 0b 30 58 ca 90 b1 1f 27 ba 88 ef 11 87 d8 e8 5c 2c 78 ..s..H.........0X....'.......\,x
0200 3c 26 5c ce f7 47 03 e5 41 a0 34 3f 79 d6 4f af b3 89 f8 f5 9e 34 e3 11 34 32 fc 6d 78 77 f8 27 <&\..G..A.4?y.O......4..42.mxw.'
0220 a3 fb 22 73 e8 60 f8 24 ea 73 29 03 83 a5 08 19 c9 67 fb 62 e2 8f 49 63 f5 b0 f4 0f 71 11 ec 72 .."s.`.$.s)......g.b..Ic....q..r
0240 24 cc 76 56 36 a4 1d 00 b5 a7 4e 0e fb 4e b9 56 cc b8 27 fd ac d7 02 8d 0c 87 47 1f 8d ac 2e a7 $.vV6.....N..N.V..'.......G.....
0260 51 01 06 8d 10 b4 4b 9f 97 ab 3d 03 cd 76 ff 67 d0 df 8d d2 d6 e8 3f b9 73 5e 60 2b 99 f8 a2 da Q.....K...=..v.g......?.s^`+....
0280 54 bd 2c 7b bb 5b 84 7a 26 0f 02 69 5a d3 89 03 a0 ee b4 ea 84 f9 8e 70 ad 98 b5 1d 9b ab 87 a1 T.,{.[.z&..iZ..........p........
02a0 87 e4 ff 6b 9b e5 d9 d6 5a e7 3f 19 ed 93 51 58 5b d6 98 b5 46 7f 37 02 0c ea 25 64 f7 c6 49 cc ...k....Z.?...QX[...F.7...%d..I.
02c0 e3 53 67 d5 db 41 bb 57 42 e5 f4 d2 3d 1e b8 24 ec 76 27 ea 3d e7 2f dd d0 54 bd 9c 73 b8 5b f8 .Sg..A.WB...=..$.v'.=./..T..s.[.
02e0 22 8d 09 e3 fd 74 29 68 98 1a fa 1b dd 76 78 bd 37 c2 cc 7b 83 89 83 4b 76 ba df 8d cd f3 5c 83 "....t)h.....vx.7..{...Kv.....\.
0300 f6 4d 2f ac 29 6b 3b a5 31 69 e2 8d a3 72 7a 81 41 bd 04 ed 9e c7 a6 3a 36 89 cd 73 2f 2a a7 95 .M/.)k;.1i...rz.A......:6..s/*..
0320 e1 9b 22 b1 d8 0c ef 9f 95 75 2e d8 13 83 86 1a 61 e9 6b 71 e1 72 d0 e3 1f 5d 0a 78 e8 af ad a9 .."......u......a.kq.r...].x....
0340 12 7d 5b 03 d0 4c 23 f4 ac f7 bf af 05 11 8d b9 0f f7 5c e6 9f 81 f6 55 2b ac a9 b2 4e d6 1c 95 .}[..L#...........\....U+...N...
0360 d3 0b 0c ea 85 3a f4 ba b2 73 c4 51 b7 db fd 21 54 36 1b f3 b7 46 3e d7 7b 41 e8 69 7e 3e 57 d5 .....:...s.Q...!T6...F>.{A.i~>W.
0380 27 86 6e 8a 42 33 8d 32 f2 83 48 62 14 e0 b3 bf f5 22 17 34 d2 28 1d e7 79 d3 fa 1f aa f5 8a d8 '.n.B3.2..Hb.....".4.(..y.......
03a0 22 ef af 67 5d e7 d7 3d 7c b3 96 54 c7 51 55 9d af a3 b2 7a 81 41 bd d0 d1 78 50 d5 39 11 ac 72 "..g]..=|..T.QU....z.A...xP.9..r
03c0 57 a2 b2 99 e8 5c 18 e8 0b 87 a4 63 ea 7a 92 cc d9 d6 0a 8d 34 43 64 c8 29 5c 2d 74 dd 07 26 9a W....\.....c.z......4Cd.)\-t..&.
03e0 a1 eb 72 1f dc 87 04 92 fb 78 eb 98 77 08 69 90 09 d6 52 5d 0f 6b 8e ca ea 05 06 f5 42 1d da a6 ..r......x..w.i...R].k......B...
0400 ee 20 dd ac 0c a3 b2 88 ce 33 82 97 86 6a 53 b7 57 73 d6 4b 9d d0 44 33 2c a1 3a fb 6e f7 43 13 .........3...jS.Ws.K..D3,.:.n.C.
0420pre { line-height: 125%; } td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
// 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.Text;
using System.Windows.Threading;
using Tango.Scripting.Editors.Document;
using Tango.Scripting.Editors.Rendering;
using Tango.Scripting.Editors.Utils;

namespace Tango.Scripting.Editors.Folding
{
	/// <summary>
	/// A section that can be folded.
	/// </summary>
	public sealed class FoldingSection : TextSegment
	{
		readonly FoldingManager manager;
		bool isFolded;
		internal CollapsedLineSection[] collapsedSections;
		string title;
		
		/// <summary>
		/// Gets/sets if the section is folded.
		/// </summary>
		public bool IsFolded {
			get { return isFolded; }
			set {
				if (isFolded != value) {
					isFolded = value;
					ValidateCollapsedLineSections(); // create/destroy CollapsedLineSection
						manager.Redraw(this);
				}
			}
		}
		
		internal void ValidateCollapsedLineSections()
		{
			if (!isFolded) {
				RemoveCollapsedLineSection();
				return;
			}
			// It is possible that StartOffset/EndOffset get set to invalid values via the property setters in TextSegment,
			// so we coerce those values into the valid range.
			DocumentLine startLine = manager.document.GetLineByOffset(StartOffset.CoerceValue(0, manager.document.TextLength));
			DocumentLine endLine = manager.document.GetLineByOffset(EndOffset.CoerceValue(0, manager.document.TextLength));
			if (startLine == endLine) {
				RemoveCollapsedLineSection();
			} else {
				if (collapsedSections == null)
					collapsedSections = new CollapsedLineSection[manager.textViews.Count];
				// Validate collapsed line sections
				DocumentLine startLinePlusOne = startLine.NextLine;
				for (int i = 0; i < collapsedSections.Length; i++) {
					var collapsedSection = collapsedSections[i];
					if (collapsedSection == null || collapsedSection.Start != startLinePlusOne || collapsedSection.End != endLine) {
						// recreate this collapsed section
						if (collapsedSection != null) {
							Debug.WriteLine("CollapsedLineSection validation - recreate collapsed section from " + startLinePlusOne + " to " + endLine);
							collapsedSection.Uncollapse();
						}
						collapsedSections[i] = manager.textViews[i].CollapseLines(startLinePlusOne, endLine);
					}
				}
			}
		}
		
		/// <inheritdoc/>
		protected override void OnSegmentChanged()
		{
			ValidateCollapsedLineSections();
			base.OnSegmentChanged();
			// don't redraw if the FoldingSection wasn't added to the FoldingManager's collection yet
			if (IsConnectedToCollection)
				manager.Redraw(this);
		}
		
		/// <summary>
		/// Gets/Sets the text used to display the collapsed version of the folding section.
		/// </summary>
		public string Title {
			get {
				return title;
			}
			set {
				if (title != value) {
					title = value;
					if (this.IsFolded)
						manager.Redraw(this);
				}
			}
		}
		
		/// <summary>
		/// Gets the content of the collapsed lines as text.
		/// </summary>
		public string TextContent {
			get {
				return manager.document.GetText(StartOffset, EndOffset - StartOffset);
			}
		}
		
		/// <summary>
		/// Gets the content of the collapsed lines as tooltip text.
		/// </summary>
		[Obsolete]
		public string TooltipText {
			get {
				// This fixes SD-1394:
				// Each line is checked for leading indentation whitespaces. If
				// a line has the same or more indentation than the first line,
				// it is reduced. If a line is less indented than the first line
				// the indentation is removed completely.
				//
				// See the following example:
				// 	line 1
				// 		line 2
				// 			line 3
				//  line 4
				//
				// is reduced to:
				// line 1
				// 	line 2
				// 		line 3
				// line 4
				
				var startLine = manager.document.GetLineByOffset(StartOffset);
				var endLine = manager.document.GetLineByOffset(EndOffset);
				var builder = new StringBuilder();
				
				var current = startLine;
				ISegment startIndent = TextUtilities.GetLeadingWhitespace(manager.document, startLine);
				
				while (current != endLine.NextLine) {
					ISegment currentIndent = TextUtilities.GetLeadingWhitespace(manager.document, current);
					
					if (current == startLine && current == endLine)
						builder.Append(manager.document.GetText(StartOffset, EndOffset - StartOffset));
					else if (current == startLine) {
						if (current.EndOffset - StartOffset > 0)
							builder.AppendLine(manager.document.GetText(StartOffset, current.EndOffset - StartOffset).TrimStart());
					} else if (current == endLine) {
						if (startIndent.Length <= currentIndent.Length)
							builder.Append(manager.document.GetText(current.Offset + startIndent.Length, EndOffset - current.Offset - startIndent.Length));
						else
							builder.Append(manager.document.GetText(current.Offset + currentIndent.Length, EndOffset - current.Offset - currentIndent.Length));
					} else {
						if (startIndent.Length <= currentIndent.Length)
							builder.AppendLine(manager.document.GetText(current.Offset + startIndent.Length, current.Length - startIndent.Length));
						else
							builder.AppendLine(manager.document.GetText(current.Offset + currentIndent.Length, current.Length - currentIndent.Length));
					}
					
					current = current.NextLine;
				}
				
				return builder.ToString();
			}
		}
		
		/// <summary>
		/// Gets/Sets an additional object associated with this folding section.
		/// </summary>
		public object Tag { get; set; }
		
		internal FoldingSection(FoldingManager manager, int startOffset, int endOffset)
		{
			Debug.Assert(manager != null);
			this.manager = manager;
			this.StartOffset = startOffset;
			this.Length = endOffset - startOffset;
		}
		
		void RemoveCollapsedLineSection()
		{
			if (collapsedSections != null) {
				foreach (var collapsedSection in collapsedSections) {
					if (collapsedSection != null && collapsedSection.Start != null)
						collapsedSection.Uncollapse();
				}
				collapsedSections = null;
			}
		}
	}
}