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)); } } }
void ChangeHeight(HeightNode node, int newCount, double newHeight) { lock (tree) { node.count = newCount; node.height = newHeight; node.UpdateAugmentedData(); } }
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)); }
void InsertBefore(HeightNode node, HeightNode newNode) { if (newNode.count <= 0) { throw new ArgumentOutOfRangeException("new node count <= 0."); } tree.InsertBefore(node, newNode); newNode.UpdateAugmentedData(); }
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); } } 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); }
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); }
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; }
void ChangeHeight (HeightNode node, int newCount, double newHeight) { lock (tree) { node.count = newCount; node.height = newHeight; node.UpdateAugmentedData (); } }
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 (); } }
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)); }
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)); } } }
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)); } }
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; }
void InsertAfter (HeightNode node, HeightNode newNode) { if (node.right == null) { tree.InsertRight (node, newNode); } else { tree.InsertLeft (node.GetOuterLeft (), newNode); } newNode.UpdateAugmentedData (); }