示例#1
0
        internal Commands(Scintilla scintilla)
            : base(scintilla)
        {
            //	Ha Ha Ha Ha all your commands are belong to us!
            NativeScintilla.ClearAllCmdKeys();

            //	The reason we're doing this is because ScintillaNET is going to own
            //	all the command bindings. There are two reasons for this: #1 it makes
            //	it easier to handle ScintillaNET specific commands, we don't have to
            //	do special logic if its a native command vs. ScintillaNET extension.

            //	#2 Scintilla's built in support for commands binding only allows 1
            //	command per key combination. Our key handling allows for any number
            //	of commands to be bound to a keyboard combination.

            //	Other future enhancements that I want to do in the future are:
            //	Visual Studioesque Key/Chord commands like Ctrl+D, w

            //	Binding contexts. This is another CodeRush inspired idea where
            //	commands can only execute if a given context is satisfied (or not).
            //	Some examples are "At beginning of line", "In comment",
            //	"Autocomplete window active", "In Snippet Range".

            //	OK in order for these commands to play nice with each other some of them
            //	have to have knowledge of each other AND they have to execute in a certain
            //	order.

            //	Since all the native Scintilla Commands already know how to work together
            //	properly they all have the same order. But our commands have to execute first

            _commandComparer.CommandOrder.Add(BindableCommand.AutoCShow, 100);
            _commandComparer.CommandOrder.Add(BindableCommand.AutoCComplete, 100);
            _commandComparer.CommandOrder.Add(BindableCommand.AutoCCancel, 100);
            _commandComparer.CommandOrder.Add(BindableCommand.DoSnippetCheck, 200);
            _commandComparer.CommandOrder.Add(BindableCommand.AcceptActiveSnippets, 200);
            _commandComparer.CommandOrder.Add(BindableCommand.CancelActiveSnippets, 200);
            _commandComparer.CommandOrder.Add(BindableCommand.NextSnippetRange, 200);
            _commandComparer.CommandOrder.Add(BindableCommand.PreviousSnippetRange, 200);

            AddBinding(Keys.Down, Keys.None, BindableCommand.LineDown);
            AddBinding(Keys.Down, Keys.Shift, BindableCommand.LineDownExtend);
            AddBinding(Keys.Down, Keys.Control, BindableCommand.LineScrollDown);
            AddBinding(Keys.Down, Keys.Alt | Keys.Shift, BindableCommand.LineDownRectExtend);
            AddBinding(Keys.Up, Keys.None, BindableCommand.LineUp);
            AddBinding(Keys.Up, Keys.Shift, BindableCommand.LineUpExtend);
            AddBinding(Keys.Up, Keys.Control, BindableCommand.LineScrollUp);
            AddBinding(Keys.Up, Keys.Alt | Keys.Shift, BindableCommand.LineUpRectExtend);
            AddBinding('[', Keys.Control, BindableCommand.ParaUp);
            AddBinding('[', Keys.Control | Keys.Shift, BindableCommand.ParaUpExtend);
            AddBinding(']', Keys.Control, BindableCommand.ParaDown);
            AddBinding(']', Keys.Control | Keys.Shift, BindableCommand.ParaDownExtend);
            AddBinding(Keys.Left, Keys.None, BindableCommand.CharLeft);
            AddBinding(Keys.Left, Keys.Shift, BindableCommand.CharLeftExtend);
            AddBinding(Keys.Left, Keys.Control, BindableCommand.WordLeft);
            AddBinding(Keys.Left, Keys.Control | Keys.Shift, BindableCommand.WordLeftExtend);
            AddBinding(Keys.Left, Keys.Alt | Keys.Shift, BindableCommand.CharLeftRectExtend);
            AddBinding(Keys.Right, Keys.None, BindableCommand.CharRight);
            AddBinding(Keys.Right, Keys.Shift, BindableCommand.CharRightExtend);
            AddBinding(Keys.Right, Keys.Control, BindableCommand.WordRight);
            AddBinding(Keys.Right, Keys.Control | Keys.Shift, BindableCommand.WordRightExtend);
            AddBinding(Keys.Right, Keys.Alt | Keys.Shift, BindableCommand.CharRightRectExtend);
            AddBinding('/', Keys.Control, BindableCommand.WordPartLeftExtend);
            AddBinding('/', Keys.Control | Keys.Shift, BindableCommand.WordPartLeftExtend);
            AddBinding('\\', Keys.Control, BindableCommand.WordPartRight);
            AddBinding('\\', Keys.Control | Keys.Shift, BindableCommand.WordPartRightExtend);
            AddBinding(Keys.Home, Keys.None, BindableCommand.VCHome);
            AddBinding(Keys.Home, Keys.Shift, BindableCommand.VCHomeExtend);
            AddBinding(Keys.Home, Keys.Control, BindableCommand.DocumentStart);
            AddBinding(Keys.Home, Keys.Control | Keys.Shift, BindableCommand.DocumentStartExtend);
            AddBinding(Keys.Home, Keys.Alt, BindableCommand.HomeDisplay);
            AddBinding(Keys.Home, Keys.Alt | Keys.Shift, BindableCommand.VCHomeRectExtend);
            AddBinding(Keys.End, Keys.None, BindableCommand.LineEnd);
            AddBinding(Keys.End, Keys.Shift, BindableCommand.LineEndExtend);
            AddBinding(Keys.End, Keys.Control, BindableCommand.DocumentEnd);
            AddBinding(Keys.End, Keys.Control | Keys.Shift, BindableCommand.DocumentEndExtend);
            AddBinding(Keys.End, Keys.Alt, BindableCommand.LineEndDisplay);
            AddBinding(Keys.End, Keys.Alt | Keys.Shift, BindableCommand.LineEndRectExtend);
            AddBinding(Keys.PageUp, Keys.None, BindableCommand.PageUp);
            AddBinding(Keys.PageUp, Keys.Shift, BindableCommand.PageUpExtend);
            AddBinding(Keys.PageUp, Keys.Alt | Keys.Shift, BindableCommand.PageUpRectExtend);
            AddBinding(Keys.PageDown, Keys.None, BindableCommand.PageDown);
            AddBinding(Keys.PageDown, Keys.Shift, BindableCommand.PageDownExtend);
            AddBinding(Keys.PageDown, Keys.Alt | Keys.Shift, BindableCommand.PageDownRectExtend);
            AddBinding(Keys.Delete, Keys.None, BindableCommand.Clear);
            AddBinding(Keys.Delete, Keys.Shift, BindableCommand.Cut);
            AddBinding(Keys.Delete, Keys.Control, BindableCommand.DelWordRight);
            AddBinding(Keys.Delete, Keys.Control | Keys.Shift, BindableCommand.DelLineRight);
            AddBinding(Keys.Insert, Keys.None, BindableCommand.EditToggleOvertype);
            AddBinding(Keys.Insert, Keys.Shift, BindableCommand.Paste);
            AddBinding(Keys.Insert, Keys.Control, BindableCommand.Copy);
            AddBinding(Keys.Escape, Keys.None, BindableCommand.Cancel);
            AddBinding(Keys.Back, Keys.None, BindableCommand.DeleteBack);
            AddBinding(Keys.Back, Keys.Shift, BindableCommand.DeleteBack);
            AddBinding(Keys.Back, Keys.Control, BindableCommand.DelWordLeft);
            AddBinding(Keys.Back, Keys.Alt, BindableCommand.Undo);
            AddBinding(Keys.Back, Keys.Control | Keys.Shift, BindableCommand.DelLineLeft);
            AddBinding(Keys.Z, Keys.Control, BindableCommand.Undo);
            AddBinding(Keys.Y, Keys.Control, BindableCommand.Redo);
            AddBinding(Keys.X, Keys.Control, BindableCommand.Cut);
            AddBinding(Keys.C, Keys.Control, BindableCommand.Copy);
            AddBinding(Keys.V, Keys.Control, BindableCommand.Paste);
            AddBinding(Keys.A, Keys.Control, BindableCommand.SelectAll);
            AddBinding(Keys.Tab, Keys.None, BindableCommand.Tab);
            AddBinding(Keys.Tab, Keys.Shift, BindableCommand.BackTab);
            AddBinding(Keys.Enter, Keys.None, BindableCommand.NewLine);
            AddBinding(Keys.Enter, Keys.Shift, BindableCommand.NewLine);
            AddBinding(Keys.Add, Keys.Control, BindableCommand.ZoomIn);
            AddBinding(Keys.Subtract, Keys.Control, BindableCommand.ZoomOut);
            AddBinding(Keys.Divide, Keys.Control, BindableCommand.SetZoom);
            AddBinding(Keys.L, Keys.Control, BindableCommand.LineCut);
            AddBinding(Keys.L, Keys.Control | Keys.Shift, BindableCommand.LineDelete);
            AddBinding(Keys.T, Keys.Control | Keys.Shift, BindableCommand.LineCopy);
            AddBinding(Keys.T, Keys.Control, BindableCommand.LineTranspose);
            AddBinding(Keys.D, Keys.Control, BindableCommand.SelectionDuplicate);
            AddBinding(Keys.U, Keys.Control, BindableCommand.LowerCase);
            AddBinding(Keys.U, Keys.Control | Keys.Shift, BindableCommand.UpperCase);

            AddBinding(Keys.Space, Keys.Control, BindableCommand.AutoCShow);
            AddBinding(Keys.Tab, BindableCommand.DoSnippetCheck);
            AddBinding(Keys.Tab, BindableCommand.NextSnippetRange);
            AddBinding(Keys.Tab, Keys.Shift, BindableCommand.PreviousSnippetRange);
            AddBinding(Keys.Escape, BindableCommand.CancelActiveSnippets);
            AddBinding(Keys.Enter, BindableCommand.AcceptActiveSnippets);

            AddBinding(Keys.P, Keys.Control, BindableCommand.Print);
            AddBinding(Keys.P, Keys.Control | Keys.Shift, BindableCommand.PrintPreview);

            AddBinding(Keys.F, Keys.Control, BindableCommand.ShowFind);
            AddBinding(Keys.H, Keys.Control, BindableCommand.ShowReplace);
            AddBinding(Keys.F3, BindableCommand.FindNext);
            AddBinding(Keys.F3, Keys.Shift, BindableCommand.FindPrevious);
            AddBinding(Keys.I, Keys.Control, BindableCommand.IncrementalSearch);

            AddBinding(Keys.Q, Keys.Control, BindableCommand.LineComment);
            AddBinding(Keys.Q, Keys.Control | Keys.Shift, BindableCommand.LineUncomment);

            AddBinding('-', Keys.Control, BindableCommand.DocumentNavigateBackward);
            AddBinding('-', Keys.Control | Keys.Shift, BindableCommand.DocumentNavigateForward);

            AddBinding(Keys.J, Keys.Control, BindableCommand.ShowSnippetList);

            AddBinding(Keys.M, Keys.Control, BindableCommand.DropMarkerDrop);
            AddBinding(Keys.Escape, BindableCommand.DropMarkerCollect);

            AddBinding(Keys.G, Keys.Control, BindableCommand.ShowGoTo);
        }