private void BuildCompletionProviders() { this.completionProviders = new Dictionary <Predicate <KeyEventArgs>, RegexCompletionProvider>(); this.completionProviders.Add(e => keyTypeConverter.ConvertToChar(e.Key) == '{', new BracketCompletions()); this.completionProviders.Add(e => keyTypeConverter.ConvertToChar(e.Key) == '[', new SquareBracketCompletions()); this.completionProviders.Add(e => keyTypeConverter.ConvertToChar(e.Key) == '(', new ParenthesisCompletions()); this.completionProviders.Add(e => keyTypeConverter.ConvertToChar(e.Key) == '\\', new SlashCompletions()); }
public override void KeyDown(KeyEventArgs args) { // Convert the Key into a char char?key = keyTypeConverter.ConvertToChar(args.Key); if (key.HasValue) { if (IsCtrlKeyDown()) { switch (key) { // Paste command case 'v': case 'V': if (editorOperations.CanPaste) { this.editorOperations.Paste(); } return; // Copy command case 'c': case 'C': this.editorOperations.CopySelection(); return; // Cut command case 'x': case 'X': if (editorOperations.CanCut) { this.editorOperations.CutSelection(); } return; // Select All command case 'a': case 'A': editorOperations.SelectAll(); return; } } else { this.editorOperations.InsertText(key.Value.ToString()); } args.Handled = true; } else { args.Handled = true; switch (args.Key) { case Key.Left: this.editorOperations.MoveToPreviousCharacter(IsShiftKeyDown()); return; case Key.Right: this.editorOperations.MoveToNextCharacter(IsShiftKeyDown()); return; case Key.Home: this.editorOperations.MoveToStartOfLine(IsShiftKeyDown()); return; case Key.End: this.editorOperations.MoveToEndOfLine(IsShiftKeyDown()); return; case Key.Delete: this.editorOperations.Delete(); return; } args.Handled = false; } }