Browse Source

Update AvalonEdit and SharpTreeView to 4.2.0.8752.

pull/348/head
Daniel Grunwald 13 years ago
parent
commit
51a5475150
  1. 3
      AvalonEdit/ICSharpCode.AvalonEdit.Tests/Document/CollapsingTests.cs
  2. 4
      AvalonEdit/ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj
  3. 114
      AvalonEdit/ICSharpCode.AvalonEdit.Tests/Search/FindTests.cs
  4. 12
      AvalonEdit/ICSharpCode.AvalonEdit.Tests/WeakReferenceTests.cs
  5. 2
      AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs
  6. 2
      AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs
  7. 6
      AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs
  8. 12
      AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextAreaDefaultInputHandlers.cs
  9. 31
      AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs
  10. 39
      AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs
  11. 2
      AvalonEdit/ICSharpCode.AvalonEdit/Folding/XmlFoldingStrategy.cs
  12. 3
      AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  13. 8
      AvalonEdit/ICSharpCode.AvalonEdit/Properties/GlobalAssemblyInfo.cs
  14. 42
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/CollapsedLineSection.cs
  15. 16
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  16. 8
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
  17. 18
      AvalonEdit/ICSharpCode.AvalonEdit/Search/RegexSearchStrategy.cs
  18. 5
      AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchStrategyFactory.cs
  19. 4
      ILSpy/Properties/app.config.template
  20. 6
      SharpTreeView/EditTextBox.cs
  21. 2
      SharpTreeView/FlatListTreeNode.cs
  22. 12
      SharpTreeView/Properties/GlobalAssemblyInfo.cs
  23. 14
      SharpTreeView/SharpTreeNodeView.cs
  24. 4
      SharpTreeView/SharpTreeView.cs

3
AvalonEdit/ICSharpCode.AvalonEdit.Tests/Document/CollapsingTests.cs

@ -143,7 +143,8 @@ namespace ICSharpCode.AvalonEdit.Document @@ -143,7 +143,8 @@ namespace ICSharpCode.AvalonEdit.Document
CheckHeights();
Assert.AreSame(null, sec1.Start);
Assert.AreSame(null, sec1.End);
Assert.IsTrue(sec1.IsCollapsed);
// section gets uncollapsed when it is removed
Assert.IsFalse(sec1.IsCollapsed);
}
void CheckHeights()

4
AvalonEdit/ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj

@ -85,6 +85,7 @@ @@ -85,6 +85,7 @@
<Compile Include="Document\HeightTests.cs" />
<Compile Include="Document\RandomizedLineManagerTest.cs" />
<Compile Include="Document\LineManagerTests.cs" />
<Compile Include="Search\FindTests.cs" />
<Compile Include="Utils\CaretNavigationTests.cs" />
<Compile Include="Utils\CompressingTreeListTests.cs" />
<Compile Include="Utils\ExtensionMethodsTests.cs" />
@ -104,4 +105,7 @@ @@ -104,4 +105,7 @@
<Name>ICSharpCode.AvalonEdit</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Search" />
</ItemGroup>
</Project>

114
AvalonEdit/ICSharpCode.AvalonEdit.Tests/Search/FindTests.cs

@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
// 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.Linq;
using ICSharpCode.AvalonEdit.Document;
using NUnit.Framework;
namespace ICSharpCode.AvalonEdit.Search
{
[TestFixture]
public class FindTests
{
[Test]
public void SkipWordBorderSimple()
{
var strategy = SearchStrategyFactory.Create("All", false, true, SearchMode.Normal);
var text = new StringTextSource(" FindAllTests ");
var results = strategy.FindAll(text, 0, text.TextLength).ToArray();
Assert.IsEmpty(results, "No results should be found!");
}
[Test]
public void SkipWordBorder()
{
var strategy = SearchStrategyFactory.Create("AllTests", false, true, SearchMode.Normal);
var text = new StringTextSource("name=\"{FindAllTests}\"");
var results = strategy.FindAll(text, 0, text.TextLength).ToArray();
Assert.IsEmpty(results, "No results should be found!");
}
[Test]
public void SkipWordBorder2()
{
var strategy = SearchStrategyFactory.Create("AllTests", false, true, SearchMode.Normal);
var text = new StringTextSource("name=\"FindAllTests ");
var results = strategy.FindAll(text, 0, text.TextLength).ToArray();
Assert.IsEmpty(results, "No results should be found!");
}
[Test]
public void SkipWordBorder3()
{
var strategy = SearchStrategyFactory.Create("// find", false, true, SearchMode.Normal);
var text = new StringTextSource(" // findtest");
var results = strategy.FindAll(text, 0, text.TextLength).ToArray();
Assert.IsEmpty(results, "No results should be found!");
}
[Test]
public void WordBorderTest()
{
var strategy = SearchStrategyFactory.Create("// find", false, true, SearchMode.Normal);
var text = new StringTextSource(" // find me");
var results = strategy.FindAll(text, 0, text.TextLength).ToArray();
Assert.AreEqual(1, results.Length, "One result should be found!");
Assert.AreEqual(" ".Length, results[0].Offset);
Assert.AreEqual("// find".Length, results[0].Length);
}
[Test]
public void ResultAtStart()
{
var strategy = SearchStrategyFactory.Create("result", false, true, SearchMode.Normal);
var text = new StringTextSource("result // find me");
var results = strategy.FindAll(text, 0, text.TextLength).ToArray();
Assert.AreEqual(1, results.Length, "One result should be found!");
Assert.AreEqual(0, results[0].Offset);
Assert.AreEqual("result".Length, results[0].Length);
}
[Test]
public void ResultAtEnd()
{
var strategy = SearchStrategyFactory.Create("me", false, true, SearchMode.Normal);
var text = new StringTextSource("result // find me");
var results = strategy.FindAll(text, 0, text.TextLength).ToArray();
Assert.AreEqual(1, results.Length, "One result should be found!");
Assert.AreEqual("result // find ".Length, results[0].Offset);
Assert.AreEqual("me".Length, results[0].Length);
}
[Test]
public void TextWithDots()
{
var strategy = SearchStrategyFactory.Create("Text", false, true, SearchMode.Normal);
var text = new StringTextSource(".Text.");
var results = strategy.FindAll(text, 0, text.TextLength).ToArray();
Assert.AreEqual(1, results.Length, "One result should be found!");
Assert.AreEqual(".".Length, results[0].Offset);
Assert.AreEqual("Text".Length, results[0].Length);
}
[Test]
public void SimpleTest()
{
var strategy = SearchStrategyFactory.Create("AllTests", false, false, SearchMode.Normal);
var text = new StringTextSource("name=\"FindAllTests ");
var results = strategy.FindAll(text, 0, text.TextLength).ToArray();
Assert.AreEqual(1, results.Length, "One result should be found!");
Assert.AreEqual("name=\"Find".Length, results[0].Offset);
Assert.AreEqual("AllTests".Length, results[0].Length);
}
}
}

12
AvalonEdit/ICSharpCode.AvalonEdit.Tests/WeakReferenceTests.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Rendering;
@ -45,7 +46,6 @@ namespace ICSharpCode.AvalonEdit @@ -45,7 +46,6 @@ namespace ICSharpCode.AvalonEdit
}
[Test]
[Ignore]
public void DocumentDoesNotHoldReferenceToTextArea()
{
TextDocument textDocument = new TextDocument();
@ -61,7 +61,6 @@ namespace ICSharpCode.AvalonEdit @@ -61,7 +61,6 @@ namespace ICSharpCode.AvalonEdit
}
[Test]
[Ignore]
public void DocumentDoesNotHoldReferenceToTextEditor()
{
TextDocument textDocument = new TextDocument();
@ -102,9 +101,12 @@ namespace ICSharpCode.AvalonEdit @@ -102,9 +101,12 @@ namespace ICSharpCode.AvalonEdit
static void GarbageCollect()
{
GC.WaitForPendingFinalizers();
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
GC.WaitForPendingFinalizers();
for (int i = 0; i < 3; i++) {
GC.WaitForPendingFinalizers();
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
// pump WPF messages so that WeakEventManager can unregister
Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background, new Action(delegate {}));
}
}
}
}

2
AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs

@ -73,6 +73,8 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -73,6 +73,8 @@ namespace ICSharpCode.AvalonEdit.Editing
AddBinding(EditingCommands.SelectToDocumentEnd, Ctrl | Shift, Key.End, OnMoveCaretExtendSelection(CaretMovementType.DocumentEnd));
CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, OnSelectAll));
TextAreaDefaultInputHandler.WorkaroundWPFMemoryLeak(InputBindings);
}
static void OnSelectAll(object target, ExecutedRoutedEventArgs args)

2
AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs

@ -75,6 +75,8 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -75,6 +75,8 @@ namespace ICSharpCode.AvalonEdit.Editing
CommandBindings.Add(new CommandBinding(AvalonEditCommands.ConvertLeadingTabsToSpaces, OnConvertLeadingTabsToSpaces));
CommandBindings.Add(new CommandBinding(AvalonEditCommands.ConvertLeadingSpacesToTabs, OnConvertLeadingSpacesToTabs));
CommandBindings.Add(new CommandBinding(AvalonEditCommands.IndentSelection, OnIndentSelection));
TextAreaDefaultInputHandler.WorkaroundWPFMemoryLeak(InputBindings);
}
static TextArea GetTextArea(object target)

6
AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs

@ -806,11 +806,13 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -806,11 +806,13 @@ namespace ICSharpCode.AvalonEdit.Editing
//Debug.WriteLine("TextInput: Text='" + e.Text + "' SystemText='" + e.SystemText + "' ControlText='" + e.ControlText + "'");
base.OnTextInput(e);
if (!e.Handled && this.Document != null) {
if (string.IsNullOrEmpty(e.Text) || e.Text == "\x1b") {
if (string.IsNullOrEmpty(e.Text) || e.Text == "\x1b" || e.Text == "\b") {
// ASCII 0x1b = ESC.
// WPF produces a TextInput event with that old ASCII control char
// when Escape is pressed. We'll just ignore it.
// A deadkey followed by backspace causes a textinput event for the BS character.
// Similarly, some shortcuts like Alt+Space produce an empty TextInput event.
// We have to ignore those (not handle them) to keep the shortcut working.
return;
@ -846,7 +848,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -846,7 +848,7 @@ namespace ICSharpCode.AvalonEdit.Editing
throw ThrowUtil.NoDocumentAssigned();
OnTextEntering(e);
if (!e.Handled) {
if (e.Text == "\n" || e.Text == "\r\n")
if (e.Text == "\n" || e.Text == "\r" || e.Text == "\r\n")
ReplaceSelectionWithNewLine();
else
ReplaceSelectionWithText(e.Text);

12
AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextAreaDefaultInputHandlers.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;
@ -54,6 +54,16 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -54,6 +54,16 @@ namespace ICSharpCode.AvalonEdit.Editing
return kb;
}
internal static void WorkaroundWPFMemoryLeak(List<InputBinding> inputBindings)
{
// Work around WPF memory leak:
// KeyBinding retains a reference to whichever UIElement it is used in first.
// Using a dummy element for this purpose ensures that we don't leak
// a real text editor (which a potentially large document).
UIElement dummyElement = new UIElement();
dummyElement.InputBindings.AddRange(inputBindings);
}
#region Undo / Redo
UndoStack GetUndoStack()
{

31
AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs

@ -68,13 +68,16 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -68,13 +68,16 @@ namespace ICSharpCode.AvalonEdit.Folding
void OnDocumentChanged(DocumentChangeEventArgs e)
{
foldings.UpdateOffsets(e);
FoldingSection s = foldings.FindFirstSegmentWithStartAfter(e.Offset);
while (s != null && s.StartOffset == e.Offset) {
FoldingSection next = foldings.GetNextSegment(s);
if (s.Length == 0) {
RemoveFolding(s);
int newEndOffset = e.Offset + e.InsertionLength;
// extend end offset to the end of the line (including delimiter)
var endLine = document.GetLineByOffset(newEndOffset);
newEndOffset = endLine.Offset + endLine.TotalLength;
foreach (var affectedFolding in foldings.FindOverlappingSegments(e.Offset, newEndOffset - e.Offset)) {
if (affectedFolding.Length == 0) {
RemoveFolding(affectedFolding);
} else {
affectedFolding.ValidateCollapsedLineSections();
}
s = next;
}
}
#endregion
@ -100,7 +103,7 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -100,7 +103,7 @@ namespace ICSharpCode.AvalonEdit.Folding
throw new ArgumentException();
foreach (FoldingSection fs in foldings) {
if (fs.collapsedSections != null) {
CollapsedLineSection[] c = new CollapsedLineSection[textViews.Count];
var c = new CollapsedLineSection[textViews.Count];
Array.Copy(fs.collapsedSections, 0, c, 0, pos);
Array.Copy(fs.collapsedSections, pos + 1, c, pos, c.Length - pos);
fs.collapsedSections = c;
@ -108,15 +111,6 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -108,15 +111,6 @@ namespace ICSharpCode.AvalonEdit.Folding
}
}
internal CollapsedLineSection[] CollapseLines(DocumentLine start, DocumentLine end)
{
CollapsedLineSection[] c = new CollapsedLineSection[textViews.Count];
for (int i = 0; i < c.Length; i++) {
c[i] = textViews[i].CollapseLines(start, end);
}
return c;
}
internal void Redraw()
{
foreach (TextView textView in textViews)
@ -138,6 +132,8 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -138,6 +132,8 @@ namespace ICSharpCode.AvalonEdit.Folding
{
if (startOffset >= endOffset)
throw new ArgumentException("startOffset must be less than endOffset");
if (startOffset < 0 || endOffset > document.TextLength)
throw new ArgumentException("Folding must be within document boundary");
FoldingSection fs = new FoldingSection(this, startOffset, endOffset);
foldings.Add(fs);
Redraw(fs);
@ -254,6 +250,9 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -254,6 +250,9 @@ namespace ICSharpCode.AvalonEdit.Folding
throw new ArgumentException("newFoldings must be sorted by start offset");
previousStartOffset = newFolding.StartOffset;
int startOffset = newFolding.StartOffset.CoerceValue(0, document.TextLength);
int endOffset = newFolding.EndOffset.CoerceValue(0, document.TextLength);
if (newFolding.StartOffset == newFolding.EndOffset)
continue; // ignore zero-length foldings

39
AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// 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 ICSharpCode.AvalonEdit.Document;
@ -28,15 +29,20 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -28,15 +29,20 @@ namespace ICSharpCode.AvalonEdit.Folding
if (isFolded != value) {
isFolded = value;
if (value) {
// Create collapsed sections
if (manager != null) {
DocumentLine startLine = manager.document.GetLineByOffset(StartOffset);
DocumentLine endLine = manager.document.GetLineByOffset(EndOffset);
if (startLine != endLine) {
DocumentLine startLinePlusOne = startLine.NextLine;
collapsedSections = manager.CollapseLines(startLinePlusOne, endLine);
collapsedSections = new CollapsedLineSection[manager.textViews.Count];
for (int i = 0; i < collapsedSections.Length; i++) {
collapsedSections[i] = manager.textViews[i].CollapseLines(startLinePlusOne, endLine);
}
}
}
} else {
// Destroy collapsed sections
RemoveCollapsedLineSection();
}
if (manager != null)
@ -45,6 +51,9 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -45,6 +51,9 @@ namespace ICSharpCode.AvalonEdit.Folding
}
}
/// <summary>
/// Creates new collapsed section when a text view is added to the folding manager.
/// </summary>
internal CollapsedLineSection CollapseSection(TextView textView)
{
DocumentLine startLine = manager.document.GetLineByOffset(StartOffset);
@ -56,6 +65,34 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -56,6 +65,34 @@ namespace ICSharpCode.AvalonEdit.Folding
return null;
}
internal void ValidateCollapsedLineSections()
{
if (!isFolded) {
RemoveCollapsedLineSection();
return;
}
DocumentLine startLine = manager.document.GetLineByOffset(StartOffset);
DocumentLine endLine = manager.document.GetLineByOffset(EndOffset);
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
Debug.WriteLine("CollapsedLineSection validation - recreate collapsed section from " + startLinePlusOne + " to " + endLine);
if (collapsedSection != null)
collapsedSection.Uncollapse();
collapsedSections[i] = manager.textViews[i].CollapseLines(startLinePlusOne, endLine);
}
}
}
}
/// <summary>
/// Gets/Sets the text used to display the collapsed version of the folding section.
/// </summary>

2
AvalonEdit/ICSharpCode.AvalonEdit/Folding/XmlFoldingStrategy.cs

@ -110,7 +110,7 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -110,7 +110,7 @@ namespace ICSharpCode.AvalonEdit.Folding
// into account the <!-- chars.
int startOffset = GetOffset(document, reader) - 4;
int endOffset = startOffset + comment.Length + 3;
int endOffset = startOffset + comment.Length + 7;
string foldText = String.Concat("<!--", comment.Substring(0, firstNewLine).TrimEnd('\r') , "-->");
foldMarkers.Add(new NewFolding(startOffset, endOffset) { Name = foldText } );

3
AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -42,8 +42,9 @@ @@ -42,8 +42,9 @@
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>452984832</BaseAddress>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

8
AvalonEdit/ICSharpCode.AvalonEdit/Properties/GlobalAssemblyInfo.cs

@ -18,7 +18,7 @@ using System.Reflection; @@ -18,7 +18,7 @@ using System.Reflection;
[assembly: AssemblyProduct("SharpDevelop")]
[assembly: AssemblyCopyright("2000-2012 AlphaSierraPapa for the SharpDevelop Team")]
[assembly: AssemblyVersion(RevisionClass.Major + "." + RevisionClass.Minor + "." + RevisionClass.Build + "." + RevisionClass.Revision)]
[assembly: AssemblyInformationalVersion(RevisionClass.FullVersion + "-49ea0a14")]
[assembly: AssemblyInformationalVersion(RevisionClass.FullVersion + "-ca8a8e28")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly",
@ -29,8 +29,8 @@ internal static class RevisionClass @@ -29,8 +29,8 @@ internal static class RevisionClass
public const string Major = "4";
public const string Minor = "2";
public const string Build = "0";
public const string Revision = "8549";
public const string VersionName = "beta";
public const string Revision = "8752";
public const string VersionName = "Beta 2";
public const string FullVersion = Major + "." + Minor + "." + Build + ".8549-beta";
public const string FullVersion = Major + "." + Minor + "." + Build + ".8752-Beta 2";
}

42
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/CollapsedLineSection.cs

@ -11,9 +11,8 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -11,9 +11,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
/// Represents a collapsed line section.
/// Use the Uncollapse() method to uncollapse the section.
/// </summary>
public sealed class CollapsedLineSection : INotifyPropertyChanged
public sealed class CollapsedLineSection
{
bool isCollapsed = true;
DocumentLine start, end;
HeightTree heightTree;
@ -41,7 +40,7 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -41,7 +40,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
/// This property initially is true and turns to false when uncollapsing the section.
/// </summary>
public bool IsCollapsed {
get { return isCollapsed; }
get { return start != null; }
}
/// <summary>
@ -51,10 +50,7 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -51,10 +50,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
/// </summary>
public DocumentLine Start {
get { return start; }
internal set {
start = value;
// TODO: raised property changed event (but only after the operation is complete)
}
internal set { start = value; }
}
/// <summary>
@ -64,46 +60,26 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -64,46 +60,26 @@ namespace ICSharpCode.AvalonEdit.Rendering
/// </summary>
public DocumentLine End {
get { return end; }
internal set {
end = value;
// TODO: raised property changed event (but only after the operation is complete)
}
internal set { end = value; }
}
/// <summary>
/// Uncollapses the section.
/// This causes the Start and End properties to be set to null!
/// Runtime: O(log(n))
/// Does nothing if the section is already uncollapsed.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The section is already uncollapsed, or the text containing the section was deleted.
/// </exception>
public void Uncollapse()
{
if (start == null)
throw new InvalidOperationException();
return;
heightTree.Uncollapse(this);
#if DEBUG
heightTree.CheckProperties();
#endif
start = end = null;
isCollapsed = false;
NotifyPropertyChanged("Start");
NotifyPropertyChanged("End");
NotifyPropertyChanged("IsCollapsed");
}
/// <summary>
/// Is raised when of the properties Start,End,IsCollapsed changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
start = null;
end = null;
}
/// <summary>
@ -113,7 +89,7 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -113,7 +89,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
public override string ToString()
{
return "[CollapsedSection" + ID + " Start=" + (start != null ? start.LineNumber.ToString() : "null")
+ " End=" + (end != null ? end.LineNumber.ToString() : "null") + " IsCollapsed=" + isCollapsed + "]";
+ " End=" + (end != null ? end.LineNumber.ToString() : "null") + "]";
}
}
}

16
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -999,12 +999,18 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -999,12 +999,18 @@ namespace ICSharpCode.AvalonEdit.Rendering
visualLine.ConstructVisualElements(textSource, elementGeneratorsArray);
#if DEBUG
for (int i = visualLine.FirstDocumentLine.LineNumber + 1; i <= visualLine.LastDocumentLine.LineNumber; i++) {
if (!heightTree.GetIsCollapsed(i))
throw new InvalidOperationException("Line " + i + " was skipped by a VisualLineElementGenerator, but it is not collapsed.");
if (visualLine.FirstDocumentLine != visualLine.LastDocumentLine) {
// Check whether the lines are collapsed correctly:
double firstLinePos = heightTree.GetVisualPosition(visualLine.FirstDocumentLine.NextLine);
double lastLinePos = heightTree.GetVisualPosition(visualLine.LastDocumentLine);
if (!firstLinePos.IsClose(lastLinePos)) {
for (int i = visualLine.FirstDocumentLine.LineNumber + 1; i <= visualLine.LastDocumentLine.LineNumber; i++) {
if (!heightTree.GetIsCollapsed(i))
throw new InvalidOperationException("Line " + i + " was skipped by a VisualLineElementGenerator, but it is not collapsed.");
}
throw new InvalidOperationException("All lines collapsed but visual pos different - height tree inconsistency?");
}
}
#endif
visualLine.RunTransformers(textSource, lineTransformersArray);

8
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs

@ -151,13 +151,13 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -151,13 +151,13 @@ namespace ICSharpCode.AvalonEdit.Rendering
offset += element.DocumentLength;
if (offset > currentLineEnd) {
DocumentLine newEndLine = document.GetLineByOffset(offset);
if (newEndLine == this.LastDocumentLine) {
currentLineEnd = newEndLine.Offset + newEndLine.Length;
this.LastDocumentLine = newEndLine;
if (currentLineEnd < offset) {
throw new InvalidOperationException(
"The VisualLineElementGenerator " + g.GetType().Name +
" produced an element which ends within the line delimiter");
}
currentLineEnd = newEndLine.Offset + newEndLine.Length;
this.LastDocumentLine = newEndLine;
}
break;
}
@ -179,7 +179,7 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -179,7 +179,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
textOffset += element.DocumentLength;
}
VisualLength = visualOffset;
Debug.Assert(textOffset == LastDocumentLine.Offset + LastDocumentLine.Length - FirstDocumentLine.Offset);
Debug.Assert(textOffset == LastDocumentLine.EndOffset - FirstDocumentLine.Offset);
}
internal void RunTransformers(ITextRunConstructionContext context, IVisualLineTransformer[] transformers)

18
AvalonEdit/ICSharpCode.AvalonEdit/Search/RegexSearchStrategy.cs

@ -6,6 +6,7 @@ using System.Collections.Generic; @@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Documents;
using ICSharpCode.AvalonEdit.Document;
@ -14,23 +15,34 @@ namespace ICSharpCode.AvalonEdit.Search @@ -14,23 +15,34 @@ namespace ICSharpCode.AvalonEdit.Search
class RegexSearchStrategy : ISearchStrategy
{
readonly Regex searchPattern;
readonly bool matchWholeWords;
public RegexSearchStrategy(Regex searchPattern)
public RegexSearchStrategy(Regex searchPattern, bool matchWholeWords)
{
if (searchPattern == null)
throw new ArgumentNullException("searchPattern");
this.searchPattern = searchPattern;
this.matchWholeWords = matchWholeWords;
}
public IEnumerable<ISearchResult> FindAll(ITextSource document, int offset, int length)
{
int endOffset = offset + length;
foreach (Match result in searchPattern.Matches(document.Text)) {
if (offset <= result.Index && endOffset >= (result.Length + result.Index))
yield return new SearchResult { StartOffset = result.Index, Length = result.Length, Data = result };
int resultEndOffset = result.Length + result.Index;
if (offset > result.Index || endOffset < resultEndOffset)
continue;
if (matchWholeWords && (!IsWordBorder(document, result.Index) || !IsWordBorder(document, resultEndOffset)))
continue;
yield return new SearchResult { StartOffset = result.Index, Length = result.Length, Data = result };
}
}
static bool IsWordBorder(ITextSource document, int offset)
{
return TextUtilities.GetNextCaretPosition(document, offset - 1, LogicalDirection.Forward, CaretPositioningMode.WordBorder) == offset;
}
public ISearchResult FindNext(ITextSource document, int offset, int length)
{
return FindAll(document, offset, length).FirstOrDefault();

5
AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchStrategyFactory.cs

@ -33,12 +33,9 @@ namespace ICSharpCode.AvalonEdit.Search @@ -33,12 +33,9 @@ namespace ICSharpCode.AvalonEdit.Search
searchPattern = ConvertWildcardsToRegex(searchPattern);
break;
}
if (matchWholeWords)
searchPattern = "\\b" + searchPattern + "\\b";
try {
Regex pattern = new Regex(searchPattern, options);
return new RegexSearchStrategy(pattern);
return new RegexSearchStrategy(pattern, matchWholeWords);
} catch (ArgumentException ex) {
throw new SearchPatternException(ex.Message, ex);
}

4
ILSpy/Properties/app.config.template

@ -9,11 +9,11 @@ @@ -9,11 +9,11 @@
<!-- No guarantee they'll work correctly, though (there might be breaking API changes in ILSpy). -->
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.TreeView" publicKeyToken="d4bfe873e7598c49" culture="neutral"/>
<bindingRedirect oldVersion="4.1.0.0-99.9.9.9" newVersion="4.1.0.7275"/>
<bindingRedirect oldVersion="4.1.0.0-99.9.9.9" newVersion="4.2.0.8752"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.AvalonEdit" publicKeyToken="9cc39be672370310" culture="neutral"/>
<bindingRedirect oldVersion="4.1.0.0-99.9.9.9" newVersion="4.2.0.8549"/>
<bindingRedirect oldVersion="4.1.0.0-99.9.9.9" newVersion="4.2.0.8752"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.NRefactory" publicKeyToken="d4bfe873e7598c49" culture="neutral"/>

6
SharpTreeView/EditTextBox.cs

@ -27,8 +27,7 @@ namespace ICSharpCode.TreeView @@ -27,8 +27,7 @@ namespace ICSharpCode.TreeView
public SharpTreeViewItem Item { get; set; }
public SharpTreeNode Node
{
public SharpTreeNode Node {
get { return Item.Node; }
}
@ -43,8 +42,7 @@ namespace ICSharpCode.TreeView @@ -43,8 +42,7 @@ namespace ICSharpCode.TreeView
{
if (e.Key == Key.Enter) {
Commit();
}
else if (e.Key == Key.Escape) {
} else if (e.Key == Key.Escape) {
Node.IsEditing = false;
}
}

2
SharpTreeView/FlatListTreeNode.cs

@ -364,6 +364,8 @@ namespace ICSharpCode.TreeView @@ -364,6 +364,8 @@ namespace ICSharpCode.TreeView
Debug.Assert(node.listParent == null);
Debug.Assert(node.left == null);
Debug.Assert(node.right == null);
node.height = 1;
node.totalListLength = -1;
if (balancingNode != null)
RebalanceUntilRoot(balancingNode);
}

12
SharpTreeView/Properties/GlobalAssemblyInfo.cs

@ -16,9 +16,9 @@ using System.Reflection; @@ -16,9 +16,9 @@ using System.Reflection;
[assembly: System.Runtime.InteropServices.ComVisible(false)]
[assembly: AssemblyCompany("ic#code")]
[assembly: AssemblyProduct("SharpDevelop")]
[assembly: AssemblyCopyright("2000-2011 AlphaSierraPapa for the SharpDevelop Team")]
[assembly: AssemblyCopyright("2000-2012 AlphaSierraPapa for the SharpDevelop Team")]
[assembly: AssemblyVersion(RevisionClass.Major + "." + RevisionClass.Minor + "." + RevisionClass.Build + "." + RevisionClass.Revision)]
[assembly: AssemblyInformationalVersion(RevisionClass.FullVersion + "-d9a90d79")]
[assembly: AssemblyInformationalVersion(RevisionClass.FullVersion + "-ca8a8e28")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly",
@ -27,10 +27,10 @@ using System.Reflection; @@ -27,10 +27,10 @@ using System.Reflection;
internal static class RevisionClass
{
public const string Major = "4";
public const string Minor = "1";
public const string Minor = "2";
public const string Build = "0";
public const string Revision = "7275";
public const string VersionName = "alpha";
public const string Revision = "8752";
public const string VersionName = "Beta 2";
public const string FullVersion = Major + "." + Minor + "." + Build + ".7275-alpha";
public const string FullVersion = Major + "." + Minor + "." + Build + ".8752-Beta 2";
}

14
SharpTreeView/SharpTreeNodeView.cs

@ -38,6 +38,15 @@ namespace ICSharpCode.TreeView @@ -38,6 +38,15 @@ namespace ICSharpCode.TreeView
}
public SharpTreeViewItem ParentItem { get; private set; }
public static readonly DependencyProperty CellEditorProperty =
DependencyProperty.Register("CellEditor", typeof(Control), typeof(SharpTreeNodeView),
new FrameworkPropertyMetadata());
public Control CellEditor {
get { return (Control)GetValue(CellEditorProperty); }
set { SetValue(CellEditorProperty, value); }
}
public SharpTreeView ParentTreeView
{
@ -104,7 +113,10 @@ namespace ICSharpCode.TreeView @@ -104,7 +113,10 @@ namespace ICSharpCode.TreeView
{
var textEditorContainer = Template.FindName("textEditorContainer", this) as Border;
if (Node.IsEditing) {
textEditorContainer.Child = new EditTextBox() { Item = ParentItem };
if (CellEditor == null)
textEditorContainer.Child = new EditTextBox() { Item = ParentItem };
else
textEditorContainer.Child = CellEditor;
}
else {
textEditorContainer.Child = null;

4
SharpTreeView/SharpTreeView.cs

@ -176,6 +176,10 @@ namespace ICSharpCode.TreeView @@ -176,6 +176,10 @@ namespace ICSharpCode.TreeView
base.PrepareContainerForItemOverride(element, item);
SharpTreeViewItem container = element as SharpTreeViewItem;
container.ParentTreeView = this;
// Make sure that the line renderer takes into account the new bound data
if (container.NodeView != null) {
container.NodeView.LinesRenderer.InvalidateVisual();
}
}
bool doNotScrollOnExpanding;

Loading…
Cancel
Save