diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LinkElementGenerator.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LinkElementGenerator.cs
index 70d59358ae..354281fce8 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LinkElementGenerator.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LinkElementGenerator.cs
@@ -57,25 +57,29 @@ namespace ICSharpCode.AvalonEdit.Rendering
this.RequireControlModifierForClick = options.RequireControlModifierForHyperlinkClick;
}
- Match GetMatch(int startOffset)
+ Match GetMatch(int startOffset, out int matchOffset)
{
int endOffset = CurrentContext.VisualLine.LastDocumentLine.EndOffset;
StringSegment relevantText = CurrentContext.GetText(startOffset, endOffset - startOffset);
- return linkRegex.Match(relevantText.Text, relevantText.Offset, relevantText.Count);
+ Match m = linkRegex.Match(relevantText.Text, relevantText.Offset, relevantText.Count);
+ matchOffset = m.Success ? m.Index - relevantText.Offset + startOffset : -1;
+ return m;
}
///
public override int GetFirstInterestedOffset(int startOffset)
{
- Match m = GetMatch(startOffset);
- return m.Success ? startOffset + m.Index : -1;
+ int matchOffset;
+ GetMatch(startOffset, out matchOffset);
+ return matchOffset;
}
///
public override VisualLineElement ConstructElement(int offset)
{
- Match m = GetMatch(offset);
- if (m.Success && m.Index == 0) {
+ int matchOffset;
+ Match m = GetMatch(offset, out matchOffset);
+ if (m.Success && matchOffset == offset) {
Uri uri = GetUriFromMatch(m);
if (uri == null)
return null;
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs
index 4ff5def317..1ad5dcb207 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs
@@ -62,9 +62,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
DocumentLine endLine = CurrentContext.VisualLine.LastDocumentLine;
StringSegment relevantText = CurrentContext.GetText(startOffset, endLine.EndOffset - startOffset);
- int endPos = relevantText.Offset + relevantText.Count;
- for (int i = relevantText.Offset; i < endPos; i++) {
- char c = relevantText.Text[i];
+ for (int i = 0; i < relevantText.Count; i++) {
+ char c = relevantText.Text[relevantText.Offset + i];
switch (c) {
case ' ':
if (ShowSpaces)
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
index 2e4136b41a..53b606521f 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
@@ -137,8 +137,14 @@ namespace ICSharpCode.AvalonEdit.Rendering
askInterestOffset = 0;
offset += element.DocumentLength;
if (offset > currentLineEnd) {
- LastDocumentLine = document.GetLineByOffset(offset);
- currentLineEnd = LastDocumentLine.Offset + LastDocumentLine.Length;
+ DocumentLine newEndLine = document.GetLineByOffset(offset);
+ if (newEndLine == this.LastDocumentLine) {
+ 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;
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
index bf8c0dfaec..a2b708a1f6 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
@@ -3,6 +3,7 @@
using System;
using System.ComponentModel;
+using System.Reflection;
using System.Text;
namespace ICSharpCode.AvalonEdit
@@ -13,6 +14,31 @@ namespace ICSharpCode.AvalonEdit
[Serializable]
public class TextEditorOptions : INotifyPropertyChanged
{
+ #region ctor
+ ///
+ /// Initializes an empty instance of TextEditorOptions.
+ ///
+ public TextEditorOptions()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of TextEditorOptions by copying all values
+ /// from to the new instance.
+ ///
+ public TextEditorOptions(TextEditorOptions options)
+ {
+ // get all the fields in the class
+ FieldInfo[] fields = typeof(TextEditorOptions).GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
+
+ // copy each value over to 'this'
+ foreach(FieldInfo fi in fields) {
+ if (!fi.IsNotSerialized)
+ fi.SetValue(this, fi.GetValue(options));
+ }
+ }
+ #endregion
+
#region PropertyChanged handling
///
[field: NonSerialized]
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/StringSegment.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/StringSegment.cs
index 8a39ea874f..cb5467f128 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/StringSegment.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/StringSegment.cs
@@ -1,5 +1,5 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
diff --git a/src/Main/Base/Project/Src/Gui/Pads/AbstractConsolePad.cs b/src/Main/Base/Project/Src/Gui/Pads/AbstractConsolePad.cs
index 26d42ff11d..762743bf1a 100755
--- a/src/Main/Base/Project/Src/Gui/Pads/AbstractConsolePad.cs
+++ b/src/Main/Base/Project/Src/Gui/Pads/AbstractConsolePad.cs
@@ -1,6 +1,7 @@
// 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 ICSharpCode.AvalonEdit;
using ICSharpCode.Core.Presentation;
using System;
using System.Collections.Generic;
@@ -265,6 +266,8 @@ namespace ICSharpCode.SharpDevelop.Gui
public event TextCompositionEventHandler TextAreaTextEntered;
public event KeyEventHandler TextAreaPreviewKeyDown;
+ static TextEditorOptions consoleOptions;
+
public ConsoleControl()
{
this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
@@ -279,6 +282,13 @@ namespace ICSharpCode.SharpDevelop.Gui
this.editor.SetValue(Grid.RowProperty, 0);
this.editor.ShowLineNumbers = false;
+ if (consoleOptions == null) {
+ consoleOptions = new TextEditorOptions(editor.Options);
+ consoleOptions.AllowScrollBelowDocument = false;
+ }
+
+ this.editor.Options = consoleOptions;
+
this.Children.Add(editor);
editor.TextArea.ReadOnlySectionProvider = readOnlyRegion = new BeginReadOnlySectionProvider();