Exemple #1
0
 internal override byte[] SequenceKeyData(Keys modifier, Keys key)
 {
     if ((int)Keys.F1 <= (int)key && (int)key <= (int)Keys.F12)
     {
         return(base.SequenceKeyData(modifier, key));
     }
     else if (RuntimeUtil.IsCursorKey(key))
     {
         return(base.SequenceKeyData(modifier, key));
     }
     else
     {
         byte[] r = new byte[4];
         r[0] = 0x1B;
         r[1] = (byte)'[';
         r[3] = (byte)'~';
         //‚±‚Ì‚ ‚½‚è‚Íxterm‚Å‚ÍŠ„‚ƈႤ‚悤‚¾
         if (key == Keys.Insert)
         {
             r[2] = (byte)'2';
         }
         else if (key == Keys.Home)
         {
             r[2] = (byte)'7';
         }
         else if (key == Keys.PageUp)
         {
             r[2] = (byte)'5';
         }
         else if (key == Keys.Delete)
         {
             r[2] = (byte)'3';
         }
         else if (key == Keys.End)
         {
             r[2] = (byte)'8';
         }
         else if (key == Keys.PageDown)
         {
             r[2] = (byte)'6';
         }
         else
         {
             throw new ArgumentException("unknown key " + key.ToString());
         }
         return(r);
     }
 }
Exemple #2
0
        //“Á’è‚̃f[ƒ^‚𗬂·ƒ^ƒCƒvBŒ»ÝAƒJ[ƒ\ƒ‹ƒL[‚ƃtƒ@ƒ“ƒNƒVƒ‡ƒ“ƒL[‚ªŠY“–‚·‚é
        internal override byte[] SequenceKeyData(Keys modifier, Keys body)
        {
            if ((int)Keys.F1 <= (int)body && (int)body <= (int)Keys.F12)
            {
                byte[] r = new byte[5];
                r[0] = 0x1B;
                r[1] = (byte)'[';
                int n = (int)body - (int)Keys.F1;
                if ((modifier & Keys.Shift) != Keys.None)
                {
                    n += 10;                                                      //shift‚Í’l‚ð10‚¸‚ç‚·
                }
                char tail;
                if (n >= 20)
                {
                    tail = (modifier & Keys.Control) != Keys.None? '@' : '$';
                }
                else
                {
                    tail = (modifier & Keys.Control) != Keys.None? '^' : '~';
                }
                string f = FUNCTIONKEY_MAP[n];
                r[2] = (byte)f[0];
                r[3] = (byte)f[1];
                r[4] = (byte)tail;
                return(r);
            }
            else if (RuntimeUtil.IsCursorKey(body))
            {
                byte[] r = new byte[3];
                r[0] = 0x1B;
                if (_cursorKeyMode == TerminalMode.Normal)
                {
                    r[1] = (byte)'[';
                }
                else
                {
                    r[1] = (byte)'O';
                }

                switch (body)
                {
                case Keys.Up:
                    r[2] = (byte)'A';
                    break;

                case Keys.Down:
                    r[2] = (byte)'B';
                    break;

                case Keys.Right:
                    r[2] = (byte)'C';
                    break;

                case Keys.Left:
                    r[2] = (byte)'D';
                    break;

                default:
                    throw new ArgumentException("unknown cursor key code", "key");
                }
                return(r);
            }
            else
            {
                byte[] r = new byte[4];
                r[0] = 0x1B;
                r[1] = (byte)'[';
                r[3] = (byte)'~';
                if (body == Keys.Insert)
                {
                    r[2] = (byte)'1';
                }
                else if (body == Keys.Home)
                {
                    r[2] = (byte)'2';
                }
                else if (body == Keys.PageUp)
                {
                    r[2] = (byte)'3';
                }
                else if (body == Keys.Delete)
                {
                    r[2] = (byte)'4';
                }
                else if (body == Keys.End)
                {
                    r[2] = (byte)'5';
                }
                else if (body == Keys.PageDown)
                {
                    r[2] = (byte)'6';
                }
                else
                {
                    throw new ArgumentException("unknown key " + body.ToString());
                }
                return(r);
            }
        }