Browse Source

Merge branch '4.0'

pull/21/head
Daniel Grunwald 15 years ago
parent
commit
c7ab696cf9
  1. 16
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LinkElementGenerator.cs
  2. 5
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs
  3. 10
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
  4. 26
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
  5. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/StringSegment.cs
  6. 10
      src/Main/Base/Project/Src/Gui/Pads/AbstractConsolePad.cs

16
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LinkElementGenerator.cs

@ -57,25 +57,29 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -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;
}
/// <inheritdoc/>
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;
}
/// <inheritdoc/>
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;

5
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs

@ -62,9 +62,8 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -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)

10
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs

@ -137,8 +137,14 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -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;
}

26
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

@ -3,6 +3,7 @@ @@ -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 @@ -13,6 +14,31 @@ namespace ICSharpCode.AvalonEdit
[Serializable]
public class TextEditorOptions : INotifyPropertyChanged
{
#region ctor
/// <summary>
/// Initializes an empty instance of TextEditorOptions.
/// </summary>
public TextEditorOptions()
{
}
/// <summary>
/// Initializes a new instance of TextEditorOptions by copying all values
/// from <paramref name="options"/> to the new instance.
/// </summary>
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
/// <inheritdoc/>
[field: NonSerialized]

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/StringSegment.cs

@ -1,5 +1,5 @@ @@ -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;

10
src/Main/Base/Project/Src/Gui/Pads/AbstractConsolePad.cs

@ -1,6 +1,7 @@ @@ -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 @@ -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 @@ -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();

Loading…
Cancel
Save