Пример #1
0
 void OnKey(object sender, KeyPressedEventArgs e)
 {
     switch (e.Key.VirtualKeyCode)
     {
         case KeyCode.Escape:
             if (_Edit.Line.Length > 0)
             {
                 e.Ignore = true;
                 _Edit.Text = "";
             }
             break;
         case KeyCode.Tab:
             if (e.Key.Is())
             {
                 e.Ignore = true;
                 EditorKit.ExpandCode(_Edit.Line, null);
             }
             break;
         case KeyCode.UpArrow:
             goto case KeyCode.DownArrow;
         case KeyCode.DownArrow:
             if (e.Key.Is())
             {
                 e.Ignore = true;
                 _Edit.Text = History.GetNextCommand(e.Key.VirtualKeyCode == KeyCode.UpArrow, _Edit.Text);
                 _Edit.Line.Caret = -1;
             }
             break;
         case KeyCode.F1:
             e.Ignore = true;
             Help.ShowHelpForContext("CommandConsoleDialog");
             break;
         case KeyCode.F4:
             e.Ignore = true;
             var args = new EditTextArgs() { Text = _Edit.Text, Title = "Input code", Extension = "psm1" };
             var text = Far.Api.AnyEditor.EditText(args);
             if (text != args.Text)
             {
                 _TextFromEditor = text;
                 _Dialog.Close();
             }
             break;
         case KeyCode.F7:
             e.Ignore = true;
             A.Psf.ShowHistory();
             break;
     }
 }
Пример #2
0
 //! Do not add Close() on Enter, Enter is called on ButtonClick (why?)
 void OnKeyPressed(object sender, KeyPressedEventArgs e)
 {
     switch (e.Key.VirtualKeyCode)
     {
         case KeyCode.UpArrow:
             if (e.Key.IsCtrl())
             {
                 e.Ignore = true;
                 Dialog.SetFocus(_ListBox2.Id);
                 DoUp();
                 return;
             }
             break;
         case KeyCode.DownArrow:
             if (e.Key.IsCtrl())
             {
                 e.Ignore = true;
                 Dialog.SetFocus(_ListBox2.Id);
                 DoDown();
                 return;
             }
             break;
         case KeyCode.Tab:
             if (Dialog.Focused == _ListBox2)
             {
                 e.Ignore = true;
                 Dialog.SetFocus(_ListBox1.Id);
                 return;
             }
             break;
         case KeyCode.Enter:
         case KeyCode.Spacebar:
             if (Dialog.Focused == _ListBox1)
             {
                 e.Ignore = true;
                 DoAdd();
                 return;
             }
             else if (Dialog.Focused == _ListBox2)
             {
                 e.Ignore = true;
                 DoRemove();
                 return;
             }
             break;
     }
 }
Пример #3
0
 void OnKey(object sender, KeyPressedEventArgs e)
 {
     switch (e.Key.VirtualKeyCode)
     {
         case KeyCode.Escape:
             if (_Edit.Line.Length > 0)
             {
                 e.Ignore = true;
                 _Edit.Text = "";
             }
             break;
         case KeyCode.F4:
             e.Ignore = true;
             var args = new EditTextArgs() { Text = _Edit.Text, Title = "Input text" };
             var text = Far.Api.AnyEditor.EditText(args);
             if (text != args.Text)
             {
                 _Text2 = text;
                 _Dialog.Close();
             }
             break;
         case KeyCode.F1:
             e.Ignore = true;
             if (!string.IsNullOrEmpty(HelpMessage))
                 Far.Api.Message(HelpMessage);
             break;
     }
 }