| ofs | hex dump | ascii |
|---|
| 0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 40 00 00 00 40 08 03 00 00 00 9d b7 81 | .PNG........IHDR...@...@........ |
| 0020 | ec 00 00 00 03 73 42 49 54 08 08 08 db e1 4f e0 00 00 00 09 70 48 59 73 00 00 01 bb 00 00 01 bb | .....sBIT.....O.....pHYs........ |
| 0040 | 01 3a ec e3 e2 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 61 | .:.......tEXtSoftware.www.inksca |
| 0060 | 70 65 2e 6f 72 67 9b ee 3c 1a 00 00 02 d0 50 4c 54 45 ff ff ff cc cc 66 bf df 60 ee ee ee ee ee | pe.org..<.....PLTE.....f..`..... |
| 0080 | ee eb eb f0 c6 e0 65 eb eb ef c2 e1 63 c5 de 64 c3 de 63 c4 df 65 ec ec ee c4 df 65 c4 df 65 ec | ......e.....c..d..c..e.....e..e. |
| 00a0 | ee ef ec ed ef e4 e7 e9 ec ed ef eb ed f0 ec ed ee db de e0 ec ec ef c3 df 64 df e2 e4 ec ed ef | .........................d...... |
| 00c0 | df e1 e4 c4 df 64 c4 df 64 cf d3 d8 cb d9 a5 c9 e1 75 ec ed ef ec ed ef ec ed ef c4 e0 64 c5 dd | .....d..d........u...........d.. |
| 00e0 | 70 c5 df 65 52 9e 44 52 9e 45 53 9e 45 54 9f 46 56 9f 48 57 a0 4a 57 a0 4b 5c a2 51 64 a5 59 6b | p..eR.DR.ES.ET.FV.HW.JW.K\.Qd.Yk |
| 0100 | a7 62 6c a8 63 71 aa 6a 75 ab 6d 7a ad 73 7a ad 75 7d ae 78 7f af 7b 84 b1 81 85 b1 82 88 b3 85 | .bl.cq.ju.mz.sz.u}.x..{......... |
| 0120 | 8a b3 88 8c b4 89 8e 95 9f 8f 96 a0 90 96 a0 91 98 a1 91 98 a2 91 b6 90 92 99 a2 93 9a a3 93 9a | ................................ |
| 0140 | a4 93 b7 92 96 b8 95 97 b8 96 97 b8 97 98 9f a8 99 9f a8 9a a0 a9 9b a1 aa 9c a3 ab 9d ba 9e a0 | ................................ |
| 0160 | a6 ae a1 bc a2 a2 a8 b0 a3 bd a4 a3 bd a6 a4 a9 b1 a5 aa b2 a5 ab b3 a6 ab b3 a6 ac b4 a7 ac b4 | ................................ |
| 0180 | a8 ad b5 a8 ae b5 a9 af b6 a9 af b7 aa af b7 ac b1 b8 ac b1 b9 ad c1 b1 af b4 bb b0 b5 bc b0 b6 | ................................ |
| 01a0 | bd b0 c2 b4 b1 b6 bd b1 c2 b6 b3 b8 be b3 b8 bf b3 b9 bf b4 b9 c0 b5 ba c0 b6 bb c1 b6 bc c1 b7 | ................................ |
| 01c0 | bc c2 b7 bd c3 ba bf c5 bb c0 c5 bb c0 c6 bc c0 c6 bc c1 c6 bc c1 c7 bc c6 c3 bd c1 c7 bd c2 c7 | ................................ |
| 01e0 | bd c7 c4 be c2 c8 bf c3 c9 bf c4 c9 bf c7 c6 c0 c4 ca c1 c5 ca c1 c6 cb c1 c8 c9 c2 c6 cb c2 c7 | ................................ |
| 0200 | cc c2 c9 cb c3 c7 cc c3 c8 cd c3 c9 cb c4 c8 cd c4 c9 cd c4 c9 ce c4 da 7e c4 dc 74 c4 df 64 c4 | ........................~..t..d. |
| 0220 | df 65 c5 c9 ce c5 ca ce c5 d2 a5 c5 d3 a3 c5 df 66 c5 e0 68 c6 ca ce c6 ca cf c6 cc c3 c6 de 76 | .e..............f..h...........v |
| 0240 | c6 e0 68 c6 e0 69 c6 e0 6a c7 cb d0 c7 e1 6b c7 e1 6c c8 cc d1 c8 e1 70 c9 cd d2 c9 e2 71 ca e2 | ..h..i..j.....k..l.....p.....q.. |
| 0260 | 73 ca e2 74 cb e1 7c cb e3 77 cc d0 d4 cc e2 7e cc e2 7f cc e3 79 cc e4 7a cd e4 7d ce e5 7f cf | s..t..|..w.....~.....y..z..}.... |
| 0280 | e5 81 d0 e5 82 d0 e6 85 d1 e6 87 d2 e6 88 d3 d6 da d4 d7 db d5 d7 db d5 e8 91 d5 e8 92 d6 e9 92 | ................................ |
| 02a0 | d7 e9 96 d7 ea 97 d8 da dd d8 da de d8 ea 98 d9 dc df da dd e0 da eb 9d da eb 9f db de e0 dc ec | ................................ |
| 02c0 | a3 dd e8 bb de e0 e3 de e1 e4 df e1 e4 df e2 e4 e0 e2 e5 e1 e3 e6 e2 e4 e7 e2 ef b2 e3 e4 e7 e4 | ................................ |
| 02e0 | f0 b7 e4 f0 b8 e6 f1 bc e7 e9 eb e7 f2 c0 e8 ea ec e8 f2 c2 e9 eb ed e9 f3 c5 e9 f3 c6 ea eb ed | ..........................// 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.Windows;
using System.Windows.Input;
using Tango.Scripting.Editors.Document;
namespace Tango.Scripting.Editors.Editing
{
/// <summary>
/// Contains the predefined input handlers.
/// </summary>
public class TextAreaDefaultInputHandler : TextAreaInputHandler
{
/// <summary>
/// Gets the caret navigation input handler.
/// </summary>
public TextAreaInputHandler CaretNavigation { get; private set; }
/// <summary>
/// Gets the editing input handler.
/// </summary>
public TextAreaInputHandler Editing { get; private set; }
/// <summary>
/// Gets the mouse selection input handler.
/// </summary>
public ITextAreaInputHandler MouseSelection { get; private set; }
/// <summary>
/// Creates a new TextAreaDefaultInputHandler instance.
/// </summary>
public TextAreaDefaultInputHandler(TextArea textArea) : base(textArea)
{
this.NestedInputHandlers.Add(CaretNavigation = CaretNavigationCommandHandler.Create(textArea));
this.NestedInputHandlers.Add(Editing = EditingCommandHandler.Create(textArea));
this.NestedInputHandlers.Add(MouseSelection = new SelectionMouseHandler(textArea));
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo, ExecuteUndo, CanExecuteUndo));
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Redo, ExecuteRedo, CanExecuteRedo));
}
internal static KeyBinding CreateFrozenKeyBinding(ICommand command, ModifierKeys modifiers, Key key)
{
KeyBinding kb = new KeyBinding(command, key, modifiers);
// Mark KeyBindings as frozen because they're shared between multiple editor instances.
// KeyBinding derives from Freezable only in .NET 4, so we have to use this little trick:
Freezable f = ((object)kb) as Freezable;
if (f != null)
f.Freeze();
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 (with a potentially large document).
UIElement dummyElement = new UIElement();
dummyElement.InputBindings.AddRange(inputBindings);
}
#region Undo / Redo
UndoStack GetUndoStack()
{
TextDocument document = this.TextArea.Document;
if (document != null)
return document.UndoStack;
else
return null;
}
void ExecuteUndo(object sender, ExecutedRoutedEventArgs e)
{
var undoStack = GetUndoStack();
if (undoStack != null) {
if (undoStack.CanUndo) {
undoStack.Undo();
this.TextArea.Caret.BringCaretToView();
}
e.Handled = true;
}
}
void CanExecuteUndo(object sender, CanExecuteRoutedEventArgs e)
{
var undoStack = GetUndoStack();
if (undoStack != null) {
e.Handled = true;
e.CanExecute = undoStack.CanUndo;
}
}
void ExecuteRedo(object sender, ExecutedRoutedEventArgs e)
{
var undoStack = GetUndoStack();
if (undoStack != null) {
if (undoStack.CanRedo) {
undoStack.Redo();
this.TextArea.Caret.BringCaretToView();
}
e.Handled = true;
}
}
void CanExecuteRedo(object sender, CanExecuteRoutedEventArgs e)
{
var undoStack = GetUndoStack();
if (undoStack != null) {
e.Handled = true;
e.CanExecute = undoStack.CanRedo;
}
}
#endregion
}
}
|