Example #1
0
        //--------------------------------------------------------------------------
        private bool mwgSendKey(Keys key)
        {
            if (key == Keys.Enter || key == Keys.LineFeed)
            {
                SendCharArray(TerminalUtil.NewLineChars(GetTerminalSettings().TransmitNL));
                return(true);
            }

            if ((key & Keys.Alt) != 0 && GEnv.Options.LeftAltKey == AltKeyAction.Meta)
            {
                key = key & ~Keys.Alt | Mods.MetaE;
            }

            byte[] data;
            int    len = GetTerminal().EncodeInputKey2(key, out data);

            if (len > 0)
            {
                mwgSendBytes(data, len);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        private void SendLine(string line, bool appendnl)
        {
            if (_tag.Connection.IsClosed || GEnv.Frame.MacroIsRunning)
            {
                return;
            }

            //GEnv.Frame.StatusBar.IndicateSendData();
            if (appendnl)
            {
                line += new string(TerminalUtil.NewLineChars(_tag.Connection.Param.TransmitNL));
            }
            char[] chars = line.ToCharArray();
            if (_tag.Connection.Param.LocalEcho)
            {
                lock (_tag.Document) {
                    _tag.Terminal.Input(chars, 0, chars.Length);
                }
            }

            if (_tag.Connection.Param is SFUTerminalParam)              //SFUはまとめて送信すると取りこぼしがでてしまう。糞め。
            {
                int x = 0;
                while (x < chars.Length)
                {
                    _tag.Connection.WriteChar(chars[x++]);
                    if ((x % 100) == 0)
                    {
                        Thread.Sleep(100);
                    }
                }
                Thread.Sleep(100);
            }
            else
            {
                _tag.Connection.WriteChars(chars);
            }
        }
Example #3
0
        /// <summary>
        /// <ja>特別なキーの入力を受け付けます。
        /// Enter Up Dn Right Left Del Ins Home End PgUp PgDn, C-記号, etc.</ja>
        /// <en>Processes special key inputs such as
        /// Enter, Up, Dn, Right, Left, Del, Ins, Home, End, PgUp, PgDn, C-symbols, etc.</en>
        /// </summary>
        /// <param name="key">押されたキーに関する情報を指定します。</param>
        /// <returns>キー入力が処理された場合に true を返します。</returns>
        protected override bool ProcessDialogKey(Keys key)
        {
            Keys modifiers = key & Keys.Modifiers;
            Keys keybody   = key & Keys.KeyCode;

            //接続中でないとだめなキー
            if (IsAcceptableUserInput())
            {
                //TODO Enter,Space,SequenceKey系もカスタムキーに入れてしまいたい
                char[] custom = TerminalEmulatorPlugin.Instance.CustomKeySettings.Scan(key);                 //カスタムキー
                if (custom != null)
                {
                    SendCharArray(custom);
                    return(true);
                }
                else if (ProcessAdvancedFeatureKey(modifiers, keybody))
                {
                    return(true);
                }

                switch (key)
                {
                case Keys.Enter:                         // Keys.Return
                case Keys.LineFeed:
                    _escForVI = false;
                    SendCharArray(TerminalUtil.NewLineChars(GetTerminalSettings().TransmitNL));
                    return(true);

                case Keys.Control | Keys.Space:
                    SendChar('\0');
                    return(true);

                case Keys.Tab:
                case Keys.Tab | Keys.Shift:
                    SendChar('\t');
                    return(true);
                }

                if ((key & Keys.Alt) == 0 && mwgSendKey(key))
                {
                    return(true);
                }

#if DEBUG_UNRECOGNIZED_INPUT
                System.Console.WriteLine("ProcessDialogKey: unknown key = " + key);
#endif
            }

            //常に送れるキー
            if (keybody == Keys.Apps)            //コンテキストメニュー
            {
                TerminalDocument document = GetDocument();
                int   x = document.CaretColumn;
                int   y = document.CurrentLineNumber - document.TopLineNumber;
                SizeF p = GetRenderProfile().Pitch;
                _terminalEmulatorMouseHandler.ShowContextMenu(new Point((int)(p.Width * x), (int)(p.Height * y)));
                return(true);
            }

            return(base.ProcessDialogKey(key));
        }
 /// <summary>
 /// <ja>
 /// 改行を送信します。
 /// </ja>
 /// <en>
 /// Transmit line feed.
 /// </en>
 /// </summary>
 /// <remarks>
 /// <ja>
 /// 実際に送るデータは改行設定により、「CR」「LF」「CR+LF」のいずれかになります。
 /// </ja>
 /// <en>
 /// The data actually sent becomes either of "CR" "LF" "CR+LF" by the changing line setting.
 /// </en>
 /// </remarks>
 public void SendLineBreak()
 {
     byte[] t = TerminalUtil.NewLineBytes(_settings.TransmitNL);
     Transmit(t);
 }