Esempio n. 1
0
        void InsertLine(int line)
        {
            lock (tree) {
                var newLine = new HeightNode()
                {
                    count  = 1,
                    height = editor.LineHeight
                };

                try {
                    if (line == tree.Root.totalCount + 1)
                    {
                        tree.InsertAfter(tree.Root.GetOuterRight(), newLine);
                        return;
                    }
                    var node = GetNodeByLine(line);
                    if (node == null)
                    {
                        return;
                    }
                    if (node.count == 1)
                    {
                        tree.InsertBefore(node, newLine);
                        return;
                    }
                    node.count++;
                } finally {
                    newLine.UpdateAugmentedData();
                    OnLineUpdateFrom(new HeightChangedEventArgs(line));
                }
            }
        }
Esempio n. 2
0
 void ChangeHeight(HeightNode node, int newCount, double newHeight)
 {
     lock (tree) {
         node.count  = newCount;
         node.height = newHeight;
         node.UpdateAugmentedData();
     }
 }
Esempio n. 3
0
        public void SetLineHeight(int lineNumber, double height)
        {
            lock (tree)
            {
                var node = GetNodeByLine(lineNumber);
                if (node == null)
                {
                    throw new Exception("No node for line number " + lineNumber + " found. (maxLine=" + tree.Root.totalCount + ")");
                }
                int nodeStartLine = node.GetLineNumber();
                int remainingLineCount;
                if (nodeStartLine == lineNumber)
                {
                    remainingLineCount = node.count - 1;
                    ChangeHeight(node, 1, height);
                    if (remainingLineCount > 0)
                    {
                        InsertAfter(node, new HeightNode()
                        {
                            count     = remainingLineCount,
                            height    = editor.LineHeight * remainingLineCount,
                            foldLevel = node.foldLevel
                        }
                                    );
                    }
                }
                else
                {
                    int newLineCount = lineNumber - nodeStartLine;
                    remainingLineCount = node.count - newLineCount - 1;
                    if (newLineCount != node.count)
                    {
                        double newHeight = editor.LineHeight * newLineCount;
                        ChangeHeight(node, newLineCount, newHeight);
                    }

                    var newNode = new HeightNode()
                    {
                        count     = 1,
                        height    = height,
                        foldLevel = node.foldLevel
                    };
                    InsertAfter(node, newNode);

                    if (remainingLineCount > 0)
                    {
                        InsertAfter(newNode, new HeightNode()
                        {
                            count     = remainingLineCount,
                            height    = editor.LineHeight * remainingLineCount,
                            foldLevel = node.foldLevel
                        }
                                    );
                    }
                }
            }
            OnLineUpdateFrom(new HeightChangedEventArgs(lineNumber));
        }
Esempio n. 4
0
 void InsertBefore(HeightNode node, HeightNode newNode)
 {
     if (newNode.count <= 0)
     {
         throw new ArgumentOutOfRangeException("new node count <= 0.");
     }
     tree.InsertBefore(node, newNode);
     newNode.UpdateAugmentedData();
 }
Esempio n. 5
0
		public void InsertLine (int line)
		{
			var node = GetNodeByLine (line);
			if (node == null)
				return;
			if (node.count == 1) {
				var newLine = new HeightNode () {
					count = 1,
					height = editor.LineHeight
				};
				tree.InsertBefore (node, newLine);
				return;
			}
			node.count++;
		}
Esempio n. 6
0
        HeightNode GetSingleLineNode(int lineNumber)
        {
            var node = GetNodeByLine(lineNumber);

            if (node == null || node.count == 1)
            {
                return(node);
            }

            int nodeStartLine = node.GetLineNumber();
            int linesBefore   = lineNumber - nodeStartLine;

            if (linesBefore > 0)
            {
                var splittedNode = new HeightNode();
                splittedNode.count     = linesBefore;
                splittedNode.height    = linesBefore * editor.LineHeight;
                splittedNode.foldLevel = node.foldLevel;
                if (splittedNode.count > 0)
                {
                    InsertBefore(node, splittedNode);
                }

                node.count  -= linesBefore;
                node.height -= splittedNode.height;
                node.UpdateAugmentedData();

                if (node.count == 1)
                {
                    return(node);
                }
            }
            Debug.Assert(lineNumber == node.GetLineNumber(), lineNumber + " should match node line number " + node.GetLineNumber() + " (max: " + tree.Root.totalCount + ")");

            InsertAfter(node, new HeightNode()
            {
                count     = node.count - 1,
                height    = (node.count - 1) * editor.LineHeight,
                foldLevel = node.foldLevel
            });

            node.count  = 1;
            node.height = editor.LineHeight;
            node.UpdateAugmentedData();
            return(node);
        }
Esempio n. 7
0
        HeightNode GetSingleLineNode(int lineNumber)
        {
            var node = GetNodeByLine(lineNumber);

            if (node == null || node.count == 1)
            {
                return(node);
            }

            int nodeStartLine = node.GetLineNumber();
            int linesBefore   = lineNumber - nodeStartLine;

            if (linesBefore > 0)
            {
                var splittedNode = new HeightNode();
                splittedNode.count     = linesBefore;
                splittedNode.height    = linesBefore * editor.LineHeight;
                splittedNode.foldLevel = node.foldLevel;
                if (splittedNode.count > 0)
                {
                    InsertBefore(node, splittedNode);
                }

                node.count  -= linesBefore;
                node.height -= splittedNode.height;
                node.UpdateAugmentedData();

                if (node.count == 1)
                {
                    return(node);
                }
            }

            InsertAfter(node, new HeightNode()
            {
                count     = node.count - 1,
                height    = (node.count - 1) * editor.LineHeight,
                foldLevel = node.foldLevel
            });

            node.count  = 1;
            node.height = editor.LineHeight;
            node.UpdateAugmentedData();
            return(node);
        }
Esempio n. 8
0
        public void InsertLine(int line)
        {
            var node = GetNodeByLine(line);

            if (node == null)
            {
                return;
            }
            if (node.count == 1)
            {
                var newLine = new HeightNode()
                {
                    count  = 1,
                    height = editor.LineHeight
                };
                tree.InsertBefore(node, newLine);
                return;
            }
            node.count++;
        }
		HeightNode GetSingleLineNode (int lineNumber)
		{
			var node = GetNodeByLine (lineNumber);
			if (node == null || node.count == 1)
				return node;
			
			int nodeStartLine = node.GetLineNumber ();
			int linesBefore = lineNumber - nodeStartLine;
			if (linesBefore > 0) {
				var splittedNode = new HeightNode ();
				splittedNode.count = linesBefore ;
				splittedNode.height = linesBefore * editor.LineHeight;
				splittedNode.foldLevel = node.foldLevel;
				if (splittedNode.count > 0)
					InsertBefore (node, splittedNode);
					
				node.count -= linesBefore;
				node.height -= splittedNode.height;
				node.UpdateAugmentedData ();
				
				if (node.count == 1)
					return node;
			}

			InsertAfter (node, new HeightNode () {
				count = node.count - 1,
				height = (node.count - 1) * editor.LineHeight,
				foldLevel = node.foldLevel
			});
			
			node.count = 1;
			node.height = editor.LineHeight;
			node.UpdateAugmentedData ();
			return node;
		}
Esempio n. 10
0
		void ChangeHeight (HeightNode node, int newCount, double newHeight)
		{
			lock (tree) {
				node.count = newCount;
				node.height = newHeight;
				node.UpdateAugmentedData ();
			}
		}
Esempio n. 11
0
		void InsertBefore (HeightNode node, HeightNode newNode)
		{
			lock (tree) {
				if (newNode.count <= 0)
					throw new ArgumentOutOfRangeException ("new node count <= 0.");
				tree.InsertBefore (node, newNode);
				newNode.UpdateAugmentedData ();
			}
		}
Esempio n. 12
0
		public void SetLineHeight (int lineNumber, double height)
		{
			lock (tree) {
				var node = GetNodeByLine (lineNumber);
				if (node == null)
					throw new Exception ("No node for line number " + lineNumber + " found. (maxLine=" + tree.Root.totalCount + ")");
				int nodeStartLine = node.GetLineNumber ();
				int remainingLineCount;
				if (nodeStartLine == lineNumber) {
					remainingLineCount = node.count - 1;
					ChangeHeight (node, 1, height);
					if (remainingLineCount > 0) {
						InsertAfter (node, new HeightNode () {
							count = remainingLineCount,
							height = editor.LineHeight * remainingLineCount,
							foldLevel = node.foldLevel
						}
						);
					}
				} else {
					int newLineCount = lineNumber - nodeStartLine;
					remainingLineCount = node.count - newLineCount - 1;
					if (newLineCount != node.count) {
						double newHeight = editor.LineHeight * newLineCount;
						ChangeHeight (node, newLineCount, newHeight);
					}
					
					var newNode = new HeightNode () {
						count = 1,
						height = height,
						foldLevel = node.foldLevel
					};
					InsertAfter (node, newNode);
					
					if (remainingLineCount > 0) {
						InsertAfter (newNode, new HeightNode () {
							count = remainingLineCount,
							height = editor.LineHeight * remainingLineCount,
							foldLevel = node.foldLevel
						}
						);
					}
				}
			}
			OnLineUpdateFrom (new HeightChangedEventArgs (lineNumber));
		}
Esempio n. 13
0
		void InsertLine (int line)
		{
			lock (tree) {
				var newLine = new HeightNode () {
					count = 1,
					height = editor.LineHeight
				};

				try {
					if (line == tree.Root.totalCount + 1) {
						tree.InsertAfter (tree.Root.GetOuterRight (), newLine);
						return;
					}
					var node = GetNodeByLine (line);
					if (node == null)
						return;
					if (node.count == 1) {
						tree.InsertBefore (node, newLine);
						return;
					}
					node.count++;
				} finally {
					newLine.UpdateAugmentedData ();
					OnLineUpdateFrom (new HeightChangedEventArgs (line));
				}
			}
		}
Esempio n. 14
0
		void InsertLine (int line)
		{
			try {
				var node = GetNodeByLine (line);
				if (node == null)
					return;
				if (node.count == 1) {
					var newLine = new HeightNode () {
						count = 1,
						height = editor.LineHeight
					};
					tree.InsertBefore (node, newLine);
					return;
				}
				node.count++;
			} finally {
				OnLineUpdateFrom (new HeightChangedEventArgs (line));
			}
		}
Esempio n. 15
0
		HeightNode GetSingleLineNode (int lineNumber)
		{
			var node = GetNodeByLine (lineNumber);
			if (node == null || node.count == 1)
				return node;
			
			int nodeStartLine = node.GetLineNumber ();
			int linesBefore = lineNumber - nodeStartLine;
			if (linesBefore > 0) {
				var splittedNode = new HeightNode ();
				splittedNode.count = linesBefore ;
				splittedNode.height = linesBefore * editor.LineHeight;
				splittedNode.foldLevel = node.foldLevel;
				if (splittedNode.count > 0)
					InsertBefore (node, splittedNode);
					
				node.count -= linesBefore;
				node.height -= splittedNode.height;
				node.UpdateAugmentedData ();
				
				if (node.count == 1)
					return node;
			}
			Debug.Assert (lineNumber == node.GetLineNumber (), lineNumber + " should match node line number " + node.GetLineNumber () + " (max: " + tree.Root.totalCount + ")");
			
			InsertAfter (node, new HeightNode () {
				count = node.count - 1,
				height = (node.count - 1) * editor.LineHeight,
				foldLevel = node.foldLevel
			});
			
			node.count = 1;
			node.height = editor.LineHeight;
			node.UpdateAugmentedData ();
			return node;
		}
Esempio n. 16
0
		void InsertAfter (HeightNode node, HeightNode newNode)
		{
			if (node.right == null) {
				tree.InsertRight (node, newNode);
			} else {
				tree.InsertLeft (node.GetOuterLeft (), newNode);
			}
			newNode.UpdateAugmentedData ();
		}