Fix #43 alternate shortcut for copy (Ctrl+Ins) not working if Options.AllowToggleOverstrikeMode is enabled.

Based on @nippur72's fix in #44.
This commit is contained in:
Daniel Grunwald 2015-12-13 12:48:19 +01:00
Родитель 0e8be49c76
Коммит 379439bac1
3 изменённых файлов: 20 добавлений и 7 удалений

Просмотреть файл

@ -26,6 +26,16 @@ namespace ICSharpCode.AvalonEdit
/// </summary>
public static class AvalonEditCommands
{
/// <summary>
/// Toggles Overstrike mode
/// The default shortcut is Ins.
/// </summary>
public static readonly RoutedCommand ToggleOverstrike = new RoutedCommand(
"ToggleOverstrike", typeof(TextEditor),
new InputGestureCollection {
new KeyGesture(Key.Insert)
});
/// <summary>
/// Deletes the current line.
/// The default shortcut is Ctrl+D.

Просмотреть файл

@ -78,6 +78,7 @@ namespace ICSharpCode.AvalonEdit.Editing
CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, OnCut, CanCutOrCopy));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, OnPaste, CanPaste));
CommandBindings.Add(new CommandBinding(AvalonEditCommands.ToggleOverstrike, OnToggleOverstrike));
CommandBindings.Add(new CommandBinding(AvalonEditCommands.DeleteLine, OnDeleteLine));
CommandBindings.Add(new CommandBinding(AvalonEditCommands.RemoveLeadingWhitespace, OnRemoveLeadingWhitespace));
@ -484,6 +485,15 @@ namespace ICSharpCode.AvalonEdit.Editing
}
#endregion
#region Toggle Overstrike
static void OnToggleOverstrike(object target, ExecutedRoutedEventArgs args)
{
TextArea textArea = GetTextArea(target);
if (textArea != null && textArea.Options.AllowToggleOverstrikeMode)
textArea.OverstrikeMode = !textArea.OverstrikeMode;
}
#endregion
#region DeleteLine
static void OnDeleteLine(object target, ExecutedRoutedEventArgs args)
{

Просмотреть файл

@ -971,13 +971,6 @@ namespace ICSharpCode.AvalonEdit.Editing
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
base.OnPreviewKeyDown(e);
if (!e.Handled && e.Key == Key.Insert && this.Options.AllowToggleOverstrikeMode) {
this.OverstrikeMode = !this.OverstrikeMode;
e.Handled = true;
return;
}
foreach (TextAreaStackedInputHandler h in stackedInputHandlers) {
if (e.Handled)
break;