blob: 7b941818c83f22abd1f72cf12900a450bccfbf71 (
plain)
| ofs | hex dump | ascii |
|---|
| 0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 80 00 00 00 80 08 06 00 00 00 c3 3e 61 | .PNG........IHDR..............>a |
| 0020 | cb 00 00 00 04 73 42 49 54 08 08 08 08 7c 08 64 88 00 00 00 09 70 48 59 73 00 00 03 76 00 00 03 | .....sBIT....|.d.....pHYs...v... |
| 0040 | 76 01 7d d5 82 cc 00 00 00 19 74 45 58 74 53 6f 66 74 77 61 72 65 00 77 77 77 2e 69 6e 6b 73 63 | v.}.......tEXtSoftware.www.inksc |
| 0060 | 61 70 65 2e 6f 72 67 9b ee 3c 1a 00 00 19 94 49 44 41 54 78 9c ed 9d 79 7c 1b d5 b5 c7 bf 33 23 | ape.org..<.....IDATx...y|.....3# |
| 0080 | d9 96 f7 3d 51 9c 45 4e 82 b3 93 cd 31 21 04 08 09 21 40 53 12 20 b4 2c 09 7d d0 f7 a0 1b 65 2b | ...=Q.EN....1!...!@S...,.}....e+ |
| 00a0 | 14 02 64 81 02 2d ed 2b f0 da 3e de eb a7 ef f5 43 03 84 96 f5 b1 07 08 29 21 85 b0 26 6d 81 90 | ..d..-.+..>.....C.......)!..&m.. |
| 00c0 | 80 41 89 93 c8 d9 e3 55 b2 a4 d1 bc 3f 66 64 39 f6 95 ad 65 24 8d 83 7f 9f 8f 3e 96 34 33 f7 5e | .A.....U....?fd9...e$.....>.43.^ |
| 00e0 | eb fc ee b9 e7 9e 7b ee b9 92 a6 69 1c 6f f0 28 ae 42 a0 06 18 63 bc 46 01 c5 40 21 50 d0 ed 2f | ......{....i.o.(.B...c.F..@!P../ |
| 0100 | 40 33 d0 d2 ed ef 51 a0 1e d8 6e bc 76 38 55 77 73 fa fe 8b f4 40 ea ef 04 f0 28 ae 3c 60 36 30 | @3...// 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.Runtime.Serialization;
using System.Windows.Input;
using Tango.Scripting.Editors.Document;
namespace Tango.Scripting.Editors.Snippets
{
/// <summary>
/// Sets the caret position after interactive mode has finished.
/// </summary>
[Serializable]
public class SnippetCaretElement : SnippetElement
{
[OptionalField]
bool setCaretOnlyIfTextIsSelected;
/// <summary>
/// Creates a new SnippetCaretElement.
/// </summary>
public SnippetCaretElement()
{
}
/// <summary>
/// Creates a new SnippetCaretElement.
/// </summary>
/// <param name="setCaretOnlyIfTextIsSelected">
/// If set to true, the caret is set only when some text was selected.
/// This is useful when both SnippetCaretElement and SnippetSelectionElement are used in the same snippet.
/// </param>
public SnippetCaretElement(bool setCaretOnlyIfTextIsSelected)
{
this.setCaretOnlyIfTextIsSelected = setCaretOnlyIfTextIsSelected;
}
/// <inheritdoc/>
public override void Insert(InsertionContext context)
{
if (!setCaretOnlyIfTextIsSelected || !string.IsNullOrEmpty(context.SelectedText))
SetCaret(context);
}
internal static void SetCaret(InsertionContext context)
{
TextAnchor pos = context.Document.CreateAnchor(context.InsertionPosition);
pos.MovementType = AnchorMovementType.BeforeInsertion;
pos.SurviveDeletion = true;
context.Deactivated += (sender, e) => {
if (e.Reason == DeactivateReason.ReturnPressed || e.Reason == DeactivateReason.NoActiveElements) {
context.TextArea.Caret.Offset = pos.Offset;
}
};
}
}
}
|