| ofs | hex dump | ascii |
|---|
| 0000 | 21 3c 61 72 63 68 3e 0a 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 31 34 38 35 31 31 39 34 | !<arch>./...............14851194 |
| 0020 | 37 30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 20 20 20 20 20 20 20 31 31 39 32 30 20 20 20 | 70..............0.......11920... |
| 0040 | 20 20 60 0a 00 00 01 03 00 00 65 3a 00 00 65 3a 00 00 65 3a 00 00 65 3a 00 00 65 3a 00 00 65 3a | ..`.......e:..e:..e:..e:..e:..e: |
| 0060 | 00 00 6c 58 00 00 90 ea 00 00 aa 32 00 00 aa 32 00 00 aa 32 00 00 aa 32 00 00 aa 32 00 00 aa 32 | ..lX.......2...2...2...2...2...2 |
| 0080 | 00 00 aa 32 00 00 aa 32 00 00 b1 e0 00 00 ca 66 00 00 ca 66 00 00 ca 66 00 00 d4 0a 00 00 d4 0a | ...2...2.......f...f...f........ |
| 00a0 | 00 00 d4 0a 00 00 d4 0a 00 00 d4 0a 00 00 d4 0a 00 00 d4 0a 00 00 d4 0a 00 00 d4 0a 00 00 d4 0a | ................................ |
| 00c0 | 00 00 d4 0a 00 00 d4 0a 00 00 d4 0a 00 01 20 4a 00 01 28 bc 00 01 28 bc 00 01 28 bc 00 01 28 bc | ...............J..(...(...(...(. |
| 00e0 | 00 01 28 bc 00 01 28 bc 00 01 28 bc 00 01 33 dc 00 01 39 24 00 01 3e 52 00 01 3e 52 00 01 3e 52 | ..(...(...(...3...9$..>R..>R..>R |
| 0100 | 00 01 3e 52 00 01 3e 52 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..>R..>R..E...E...E...E...E...E. |
| 0120 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 0140 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 0160 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 0180 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 01a0 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 01c0 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 01e0 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 0200 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 0220 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 0240 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 0260 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 0280 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 02a0 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 02c0 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 02e0 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 0300 | 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 00 01 45 c0 | ..E...E...E...E...E...E...E...E. |
| 0320 | 00 01 b8 9e 00 01 c9 14 00 01 d0 aa 00 01 e5 d6 00 02 15 04 00 02 15 04 00 02 15 04 00 02 2a ba | ..............................*. |
| 0340 | 00 02 2a ba 00 02 2a ba 00 02 2a ba 00 02 52 a0 00 02 5f 98 00 02 6b d4 00 02 6b d4 00 02 6b d4 | ..*...*...*...R..._...k...k...k. |
| 0360 | 00 02 6b d4 00 02 8f 78 00 02 a0 3e 00 02 d5 e2 00 02 ec 6e 00 02 f2 e4 00 02 f8 a2 00 02 f8 a2 | ..k....x...>.......n............ |
| 0380 | 00 02 f8 a2 00 02 f8 a2 00 02 f8 a2 00 02 f8 a2 00 02 f8 a2 00 03 0c 20 00 03 0c 20 00 03 0c 20 | ................................ |
| 03a0 | 00 03 0c 20 00 03 0c 20 00 03 0c 20 00 03 0c 20 00 03 0c 20 00 03 0c 20 00 03 19 a0 00 03 2b 84 | ..............................+. |
| 03c0 | 00 03 36 32 00 03 4d 94 00 03 4d 94 00 03 4d 94 00 03 4d 94 00 03 4d 94 00 03 4d 94 00 03 4d 94 | ..62..M...M...M...M...M...M...M. |
| 03e0 | 00 03 4d 94 00 03 69 14 00 03 69 14 00 03 69 14 00 03 69 14 00 03 6d ba 00 03 80 16 00 03 95 0c | ..M...i...i...i...i...m......... |
| 0400 | 00 03 9a 14 00 03 9f b6 00 03 9f b6 00 03 9f b6 00 05 0c a4 00 05 0c a4 00 05 0c a4 00 05 22 b4 | ..............................". |
| 0420 | 00 05 47 ea 00 05 55 26 00 05 55 26 00 05 55 26 00 05 5b 08 00 05 5b 08 00 05 5b 08 00 05 5b 08 | ..G...U&..U&..U&..[...[...[...[. |
| 0440 | 00 05 5b 08 00 05 5b 08 00 05 5b 08 00 05 5b 08 00 05 5b 08 5f 63 68 72 6f 6d 69 75 6d 5f 6a 63 | ..[...[...[...[...[._chromium_jc |
| 0460 | 6f 70 79 5f 62 6c 6f 63 6b 5f 72 6f 77 00 5f 63 68 72 6f 6d 69 75 6d 5f 6a 63 6f 70 79 5f 73 61 | opy_block_row._chromium_jcopy_sa |
| 0480 | 6d 70 6c 65 5f 72 6f 77 73 00 5f 63 68 72 6f 6d 69 75 6d 5f 6a 64 69 76 5f 72 6f 75 6e 64 5f 75 | mple_rows._chromium_jdiv_round_u |
| 04a0 | 70 00 5f 63 68 72 6f 6d 69 75 6d 5f 6a 70 65 67 5f 6e 61 74 75 72 61 6c 5f 6f 72 64 65 72 00 5f | p._chromium_jpeg_natural_order._ |
| 04c0 | 63 68 72 6f 6d 69 75 6d 5f 6a 72 6f 75 6e 64 5f 75 70 00 5f 63 68 72 6f 6d 69 75 6d 5f 6a 7a 65 | chromium_jround_up._chromium_jze |
| 04e0 | 72 6f 5f 66 61 72 00 5f 63 68 72 6f 6d 69 75 6d 5f 6a 69 6e 69 74 5f 32 70 61 73 73 5f 71 75 61 | ro_far._chromium_jinit_2pass_qua |
| 0500 | 6e 74 69 7a 65 72 00 5f 63 68 72 6f 6d 69 75 6d 5f 6a 69 6e 69 74 5f 31 70 61 73 73 5f 71 75 61 | ntizer._chromium_jinit_1pass_qua |
| 0520 | 6e 74 69 7a 65 72 00 5f 63 68 72 6f 6d 69 75 6d 5f 6a 70 65 67 5f 66 72 65 65 5f 6c 61 72 67 65 | ntizer._chromium_jpeg_free_large |
| 0540 | 00 5f 63 68 72 6f 6d 69 75 6d 5f 6a 70 65 67 5f 66 72 65 65 5f 73 6d 61 6c 6c 00 5f 63 68// 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.Collections.Generic;
using System.Text;
using System.Windows;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Editing
{
/// <summary>
/// Base class for selections.
/// </summary>
public abstract class Selection
{
/// <summary>
/// Creates a new simple selection that selects the text from startOffset to endOffset.
/// </summary>
public static Selection Create(TextArea textArea, int startOffset, int endOffset)
{
if (textArea == null)
throw new ArgumentNullException("textArea");
if (startOffset == endOffset)
return textArea.emptySelection;
else
return new SimpleSelection(textArea,
new TextViewPosition(textArea.Document.GetLocation(startOffset)),
new TextViewPosition(textArea.Document.GetLocation(endOffset)));
}
internal static Selection Create(TextArea textArea, TextViewPosition start, TextViewPosition end)
{
if (textArea == null)
throw new ArgumentNullException("textArea");
if (textArea.Document.GetOffset(start.Location) == textArea.Document.GetOffset(end.Location) && start.VisualColumn == end.VisualColumn)
return textArea.emptySelection;
else
return new SimpleSelection(textArea, start, end);
}
/// <summary>
/// Creates a new simple selection that selects the text in the specified segment.
/// </summary>
public static Selection Create(TextArea textArea, ISegment segment)
{
if (segment == null)
throw new ArgumentNullException("segment");
return Create(textArea, segment.Offset, segment.EndOffset);
}
internal readonly TextArea textArea;
/// <summary>
/// Constructor for Selection.
/// </summary>
protected Selection(TextArea textArea)
{
if (textArea == null)
throw new ArgumentNullException("textArea");
this.textArea = textArea;
}
/// <summary>
/// Gets the start position of the selection.
/// </summary>
public abstract TextViewPosition StartPosition { get; }
/// <summary>
/// Gets the end position of the selection.
/// </summary>
public abstract TextViewPosition EndPosition { get; }
/// <summary>
/// Gets the selected text segments.
/// </summary>
public abstract IEnumerable<SelectionSegment> Segments { get; }
/// <summary>
/// Gets the smallest segment that contains all segments in this selection.
/// May return null if the selection is empty.
/// </summary>
public abstract ISegment SurroundingSegment { get; }
/// <summary>
/// Replaces the selection with the specified text.
/// </summary>
public abstract void ReplaceSelectionWithText(string newText);
internal string AddSpacesIfRequired(string newText, TextViewPosition start, TextViewPosition end)
{
if (EnableVirtualSpace && InsertVirtualSpaces(newText, start, end)) {
var line = textArea.Document.GetLineByNumber(start.Line);
string lineText = textArea.Document.GetText(line);
var vLine = textArea.TextView.GetOrConstructVisualLine(line);
int colDiff = start.VisualColumn - vLine.VisualLengthWithEndOfLineMarker;
if (colDiff > 0) {
string additionalSpaces = "";
if (!textArea.Options.ConvertTabsToSpaces && lineText.Trim('\t').Length == 0) {
int tabCount = (int)(colDiff / textArea.Options.IndentationSize);
additionalSpaces = new string('\t', tabCount);
colDiff -= tabCount * textArea.Options.IndentationSize;
}
additionalSpaces += new string(' ', colDiff);
return additionalSpaces + newText;
}
}
return newText;
}
bool InsertVirtualSpaces(string newText, TextViewPosition start, TextViewPosition end)
{
return (!string.IsNullOrEmpty(newText) || !(IsInVirtualSpace(start) && IsInVirtualSpace(end)))
&& newText != "\r\n"
&& newText != "\n"
&& newText != "\r";
}
bool IsInVirtualSpace(TextViewPosition pos)
{
return pos.VisualColumn > textArea.TextView.GetOrConstructVisualLine(textArea.Document.GetLineByNumber(pos.Line)).VisualLength;
}
/// <summary>
/// Updates the selection when the document changes.
/// </summary>
public abstract Selection UpdateOnDocumentChange(DocumentChangeEventArgs e);
/// <summary>
/// Gets whether the selection is empty.
/// </summary>
public virtual bool IsEmpty {
get { return Length == 0; }
}
/// <summary>
/// Gets whether virtual space is enabled for this selection.
/// </summary>
public virtual bool EnableVirtualSpace {
get { return textArea.Options.EnableVirtualSpace; }
}
/// <summary>
/// Gets the selection length.
/// </summary>
public abstract int Length { get; }
/// <summary>
/// Returns a new selection with the changed end point.
/// </summary>
/// <exception cref="NotSupportedException">Cannot set endpoint for empty selection</exception>
public abstract Selection SetEndpoint(TextViewPosition endPosition);
/// <summary>
/// If this selection is empty, starts a new selection from <paramref name="startPosition"/> to
/// <paramref name="endPosition"/>, otherwise, changes the endpoint of this selection.
/// </summary>
public abstract Selection StartSelectionOrSetEndpoint(TextViewPosition startPosition, TextViewPosition endPosition);
/// <summary>
/// Gets whether the selection is multi-line.
/// </summary>
public virtual bool IsMultiline {
get {
ISegment surroundingSegment = this.SurroundingSegment;
if (surroundingSegment == null)
return false;
int start = surroundingSegment.Offset;
int end = start + surroundingSegment.Length;
var document = textArea.Document;
if (document == null)
throw ThrowUtil.NoDocumentAssigned();
return document.GetLineByOffset(start) != document.GetLineByOffset(end);
}
}
/// <summary>
/// Gets the selected text.
/// </summary>
public virtual string GetText()
{
var document = textArea.Document;
if (document == null)
throw ThrowUtil.NoDocumentAssigned();
StringBuilder b = null;
string text = null;
foreach (ISegment s in Segments) {
if (text != null) {
if (b == null)
b = new StringBuilder(text);
else
b.Append(text);
}
text = document.GetText(s);
}
if (b != null) {
if (text != null) b.Append(text);
return b.ToString();
} else {
return text ?? string.Empty;
}
}
/// <summary>
/// Creates a HTML fragment for the selected text.
/// </summary>
public string CreateHtmlFragment(HtmlOptions options)
{
if (options == null)
throw new ArgumentNullException("options");
IHighlighter highlighter = textArea.GetService(typeof(IHighlighter)) as IHighlighter;
StringBuilder html = new StringBuilder();
bool first = true;
foreach (ISegment selectedSegment in this.Segments) {
if (first)
first = false;
else
html.AppendLine("<br>");
html.Append(HtmlClipboard.CreateHtmlFragment(textArea.Document, highlighter, selectedSegment, options));
}
return html.ToString();
}
/// <inheritdoc/>
public abstract override bool Equals(object obj);
/// <inheritdoc/>
public abstract override int GetHashCode();
/// <summary>
/// Gets whether the specified offset is included in the selection.
/// </summary>
/// <returns>True, if the selection contains the offset (selection borders inclusive);
/// otherwise, false.</returns>
public virtual bool Contains(int offset)
{
if (this.IsEmpty)
return false;
if (this.SurroundingSegment.Contains(offset)) {
foreach (ISegment s in this.Segments) {
if (s.Contains(offset)) {
return true;
}
}
}
return false;
}
/// <summary>
/// Creates a data object containing the selection's text.
/// </summary>
public virtual DataObject CreateDataObject(TextArea textArea)
{
string text = GetText();
// Ensure we use the appropriate newline sequence for the OS
DataObject data = new DataObject(TextUtilities.NormalizeNewLines(text, Environment.NewLine));
// we cannot use DataObject.SetText - then we cannot drag to SciTe
// (but dragging to Word works in both cases)
// Also copy text in HTML format to clipboard - good for pasting text into Word
// or to the SharpDevelop forums.
HtmlClipboard.SetHtml(data, CreateHtmlFragment(new HtmlOptions(textArea.Options)));
return data;
}
}
}
|