File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,16 @@ namespace ICSharpCode.AvalonEdit
2626 /// </summary>
2727 public static class AvalonEditCommands
2828 {
29+ /// <summary>
30+ /// Toggles Overstrike mode
31+ /// The default shortcut is Ins.
32+ /// </summary>
33+ public static readonly RoutedCommand ToggleOverstrike = new RoutedCommand (
34+ "ToggleOverstrike" , typeof ( TextEditor ) ,
35+ new InputGestureCollection {
36+ new KeyGesture ( Key . Insert )
37+ } ) ;
38+
2939 /// <summary>
3040 /// Deletes the current line.
3141 /// The default shortcut is Ctrl+D.
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ static EditingCommandHandler()
7878 CommandBindings . Add ( new CommandBinding ( ApplicationCommands . Cut , OnCut , CanCutOrCopy ) ) ;
7979 CommandBindings . Add ( new CommandBinding ( ApplicationCommands . Paste , OnPaste , CanPaste ) ) ;
8080
81+ CommandBindings . Add ( new CommandBinding ( AvalonEditCommands . ToggleOverstrike , OnToggleOverstrike ) ) ;
8182 CommandBindings . Add ( new CommandBinding ( AvalonEditCommands . DeleteLine , OnDeleteLine ) ) ;
8283
8384 CommandBindings . Add ( new CommandBinding ( AvalonEditCommands . RemoveLeadingWhitespace , OnRemoveLeadingWhitespace ) ) ;
@@ -484,6 +485,15 @@ internal static string GetTextToPaste(DataObjectPastingEventArgs pastingEventArg
484485 }
485486 #endregion
486487
488+ #region Toggle Overstrike
489+ static void OnToggleOverstrike ( object target , ExecutedRoutedEventArgs args )
490+ {
491+ TextArea textArea = GetTextArea ( target ) ;
492+ if ( textArea != null && textArea . Options . AllowToggleOverstrikeMode )
493+ textArea . OverstrikeMode = ! textArea . OverstrikeMode ;
494+ }
495+ #endregion
496+
487497 #region DeleteLine
488498 static void OnDeleteLine ( object target , ExecutedRoutedEventArgs args )
489499 {
Original file line number Diff line number Diff line change @@ -971,13 +971,6 @@ public IIndentationStrategy IndentationStrategy {
971971 protected override void OnPreviewKeyDown ( KeyEventArgs e )
972972 {
973973 base . OnPreviewKeyDown ( e ) ;
974-
975- if ( ! e . Handled && e . Key == Key . Insert && this . Options . AllowToggleOverstrikeMode ) {
976- this . OverstrikeMode = ! this . OverstrikeMode ;
977- e . Handled = true ;
978- return ;
979- }
980-
981974 foreach ( TextAreaStackedInputHandler h in stackedInputHandlers ) {
982975 if ( e . Handled )
983976 break ;
You can’t perform that action at this time.
0 commit comments