static EditingCommandHandler()
        {
            AddBinding(EditingCommands.Delete, InputModifiers.None, Key.Delete, OnDelete(CaretMovementType.CharRight));
            AddBinding(EditingCommands.DeleteNextWord, InputModifiers.Control, Key.Delete,
                       OnDelete(CaretMovementType.WordRight));
            AddBinding(EditingCommands.Backspace, InputModifiers.None, Key.Back, OnDelete(CaretMovementType.Backspace));
            KeyBindings.Add(
                TextAreaDefaultInputHandler.CreateKeyBinding(EditingCommands.Backspace, InputModifiers.Shift,
                                                             Key.Back)); // make Shift-Backspace do the same as plain backspace
            AddBinding(EditingCommands.DeletePreviousWord, InputModifiers.Control, Key.Back,
                       OnDelete(CaretMovementType.WordLeft));
            AddBinding(EditingCommands.EnterParagraphBreak, InputModifiers.None, Key.Enter, OnEnter);
            AddBinding(EditingCommands.EnterLineBreak, InputModifiers.Shift, Key.Enter, OnEnter);
            AddBinding(EditingCommands.TabForward, InputModifiers.None, Key.Tab, OnTab);
            AddBinding(EditingCommands.TabBackward, InputModifiers.Shift, Key.Tab, OnShiftTab);

            AddBinding(ApplicationCommands.Copy, OnCopy, CanCutOrCopy);
            AddBinding(ApplicationCommands.Cut, OnCut, CanCutOrCopy);
            AddBinding(ApplicationCommands.Paste, OnPaste, CanPaste);

            AddBinding(AvaloniaEditCommands.ToggleOverstrike, OnToggleOverstrike);
            AddBinding(AvaloniaEditCommands.DeleteLine, OnDeleteLine);

            AddBinding(AvaloniaEditCommands.RemoveLeadingWhitespace, OnRemoveLeadingWhitespace);
            AddBinding(AvaloniaEditCommands.RemoveTrailingWhitespace, OnRemoveTrailingWhitespace);
            AddBinding(AvaloniaEditCommands.ConvertToUppercase, OnConvertToUpperCase);
            AddBinding(AvaloniaEditCommands.ConvertToLowercase, OnConvertToLowerCase);
            AddBinding(AvaloniaEditCommands.ConvertToTitleCase, OnConvertToTitleCase);
            AddBinding(AvaloniaEditCommands.InvertCase, OnInvertCase);
            AddBinding(AvaloniaEditCommands.ConvertTabsToSpaces, OnConvertTabsToSpaces);
            AddBinding(AvaloniaEditCommands.ConvertSpacesToTabs, OnConvertSpacesToTabs);
            AddBinding(AvaloniaEditCommands.ConvertLeadingTabsToSpaces, OnConvertLeadingTabsToSpaces);
            AddBinding(AvaloniaEditCommands.ConvertLeadingSpacesToTabs, OnConvertLeadingSpacesToTabs);
            AddBinding(AvaloniaEditCommands.IndentSelection, OnIndentSelection);
        }
Exemple #2
0
 private static void AddBinding(RoutedCommand command, KeyModifiers modifiers, Key key,
                                EventHandler <ExecutedRoutedEventArgs> handler)
 {
     CommandBindings.Add(new RoutedCommandBinding(command, handler));
     KeyBindings.Add(TextAreaDefaultInputHandler.CreateKeyBinding(command, modifiers, key));
 }
 private static void AddBinding(RoutedCommand command, KeyGesture gesture, EventHandler <ExecutedRoutedEventArgs> handler)
 {
     AddBinding(command, handler);
     KeyBindings.Add(TextAreaDefaultInputHandler.CreateKeyBinding(command, gesture));
 }