Пример #1
0
        //CSI J
        protected void ProcessEraseInDisplay(string param)
        {
            int d = ParseInt(param, 0);

            TerminalDocument doc = GetDocument();
            int col = _manipulator.CaretColumn;

            switch (d)
            {
            case 0:                     //erase below
                _manipulator.RemoveAfterCaret();
                doc.ReplaceCurrentLine(_manipulator.Export());
                doc.RemoveAfter(doc.TopLineNumber + GetConnection().TerminalHeight);
                if (_currentdecoration.IsDefault)
                {
                    doc.ClearAfter(doc.CurrentLineNumber + 1);
                }
                else
                {
                    doc.ClearAfter(doc.CurrentLineNumber + 1, _currentdecoration);
                }
                _manipulator.Load(doc.CurrentLine, col);
                break;

            case 1:                     //erase above
                _manipulator.FillSpace(0, _manipulator.CaretColumn);
                doc.ReplaceCurrentLine(_manipulator.Export());
                if (_currentdecoration.IsDefault)
                {
                    doc.ClearRange(doc.TopLineNumber, doc.CurrentLineNumber);
                }
                else
                {
                    doc.ClearRange(doc.TopLineNumber, doc.CurrentLineNumber, _currentdecoration);
                }
                _manipulator.Load(doc.CurrentLine, col);
                break;

            case 2:                       //erase all
                doc.ReplaceCurrentLine(_manipulator.Export());
                if (_homePositionOnCSIJ2) //SFUではこうなる
                {
                    ProcessCursorPosition(1, 1);
                    col = 0;
                }
                if (_currentdecoration.IsDefault)
                {
                    doc.ClearAfter(doc.TopLineNumber);
                }
                else
                {
                    doc.ClearAfter(doc.TopLineNumber, _currentdecoration);
                }
                _manipulator.Load(doc.CurrentLine, col);
                break;

            default:
                throw new UnknownEscapeSequenceException(String.Format("unknown ED option {0}", param));
            }
        }
Пример #2
0
        //CSI J
        protected void ProcessEraseInDisplay(string param)
        {
            int d = ParseInt(param, 0);

            TerminalDocument doc = GetDocument();
            int col = _manipulator.CaretColumn;

            switch (d)
            {
            case 0:                     //erase below
            {
                EraseRight();
                doc.ReplaceCurrentLine(_manipulator.Export());
                int bottom = doc.TopLineNumber + doc.TerminalHeight;
                doc.EnsureLine(bottom - 1);
                doc.RemoveAfter(bottom);
                doc.ClearRange(doc.CurrentLineNumber + 1, bottom, _currentdecoration);
                _manipulator.Load(doc.CurrentLine, col);
            }
            break;

            case 1:                     //erase above
            {
                EraseLeft();
                doc.ReplaceCurrentLine(_manipulator.Export());
                doc.ClearRange(doc.TopLineNumber, doc.CurrentLineNumber, _currentdecoration);
                _manipulator.Load(doc.CurrentLine, col);
            }
            break;

            case 2:                     //erase all
            {
                doc.ReplaceCurrentLine(_manipulator.Export());
                //if(_homePositionOnCSIJ2) { //SFUではこうなる
                //	ProcessCursorPosition(1,1);
                //	col = 0;
                //}
                int top    = doc.TopLineNumber;
                int bottom = top + doc.TerminalHeight;
                doc.EnsureLine(bottom - 1);
                doc.RemoveAfter(bottom);
                doc.ClearRange(top, bottom, _currentdecoration);
                _manipulator.Load(doc.CurrentLine, col);
            }
            break;

            default:
                throw new UnknownEscapeSequenceException(String.Format("unknown ED option {0}", param));
            }
        }
Пример #3
0
        //これを送ってくるアプリケーションは viで下方スクロール
        protected void ProcessDeleteLines(string param)
        {
            int d = ParseInt(param, 1);

            /*
             * TerminalDocument doc = GetDocument();
             * _manipulator.Clear(GetConnection().TerminalWidth);
             * GLine target = doc.CurrentLine;
             * for(int i=0; i<d; i++) {
             *  target.Clear();
             *  target = target.NextLine;
             * }
             */

            TerminalDocument doc = GetDocument();
            int   caret_col      = _manipulator.CaretColumn;
            int   offset         = doc.CurrentLineNumber - doc.TopLineNumber;
            GLine nl             = _manipulator.Export();

            doc.ReplaceCurrentLine(nl);
            if (doc.ScrollingBottom == -1)
            {
                doc.SetScrollingRegion(0, doc.TerminalHeight - 1);
            }

            for (int i = 0; i < d; i++)
            {
                doc.ScrollDown(doc.CurrentLineNumber, doc.ScrollingBottom);
                doc.CurrentLineNumber = doc.TopLineNumber + offset;
            }
            _manipulator.Load(doc.CurrentLine, caret_col);
        }
Пример #4
0
        //これを送ってくるアプリケーションは viで上方スクロール
        protected void ProcessInsertLines(string param)
        {
            int d = ParseInt(param, 1);

            /*
             * TerminalDocument doc = GetDocument();
             * for(int i=0; i<d; i++)
             *      doc.InsertAfter(doc.CurrentLine, new GLine(GetConnection().TerminalWidth));
             */
            TerminalDocument doc = GetDocument();
            int   caret_pos      = _manipulator.CaretColumn;
            int   offset         = doc.CurrentLineNumber - doc.TopLineNumber;
            GLine nl             = _manipulator.Export();

            doc.ReplaceCurrentLine(nl);
            if (doc.ScrollingBottom == -1)
            {
                doc.SetScrollingRegion(0, GetConnection().TerminalHeight - 1);
            }

            for (int i = 0; i < d; i++)
            {
                doc.ScrollUp(doc.CurrentLineNumber, doc.ScrollingBottom);
                doc.CurrentLineNumber = doc.TopLineNumber + offset;
            }
            _manipulator.Load(doc.CurrentLine, caret_pos);
        }
Пример #5
0
        private void ProcessScrollUp(string param)
        {
            int d = ParseInt(param, 1);

            TerminalDocument doc = GetDocument();
            int   caret_col      = _manipulator.CaretColumn;
            int   offset         = doc.CurrentLineNumber - doc.TopLineNumber;
            GLine nl             = _manipulator.Export();

            doc.ReplaceCurrentLine(nl);
            if (doc.ScrollingBottom == -1)
            {
                doc.SetScrollingRegion(0, GetDocument().TerminalHeight - 1);
            }
            for (int i = 0; i < d; i++)
            {
                doc.ScrollDown(doc.ScrollingTop, doc.ScrollingBottom); // TerminalDocument's "Scroll-Down" means XTerm's "Scroll-Up"
                doc.CurrentLineNumber = doc.TopLineNumber + offset;    // find correct GLine
            }
            _manipulator.Load(doc.CurrentLine, caret_col);
        }
Пример #6
0
        //CSI J
        protected void ProcessEraseInDisplay(string param)
        {
            int d = ParseInt(param, 0);

            TerminalDocument doc = GetDocument();
            int cur    = doc.CurrentLineNumber;
            int top    = doc.TopLineNumber;
            int bottom = top + doc.TerminalHeight;
            int col    = _manipulator.CaretColumn;

            switch (d)
            {
            case 0:     //erase below
            {
                if (col == 0 && cur == top)
                {
                    goto ERASE_ALL;
                }

                EraseRight();
                doc.ReplaceCurrentLine(_manipulator.Export());
                doc.EnsureLine(bottom - 1);
                doc.RemoveAfter(bottom);
                doc.ClearRange(cur + 1, bottom, _currentdecoration);
                _manipulator.Load(doc.CurrentLine, col);
            }
            break;

            case 1:     //erase above
            {
                if (col == doc.TerminalWidth - 1 && cur == bottom - 1)
                {
                    goto ERASE_ALL;
                }

                EraseLeft();
                doc.ReplaceCurrentLine(_manipulator.Export());
                doc.ClearRange(top, cur, _currentdecoration);
                _manipulator.Load(doc.CurrentLine, col);
            }
            break;

            case 2:     //erase all
ERASE_ALL:
                {
                    GetDocument().ApplicationModeBackColor = (_currentdecoration != null) ? _currentdecoration.BackColor : Color.Empty;

                    doc.ReplaceCurrentLine(_manipulator.Export());
                    //if(_homePositionOnCSIJ2) { //SFUではこうなる
                    //	ProcessCursorPosition(1,1);
                    //	col = 0;
                    //}
                    doc.EnsureLine(bottom - 1);
                    doc.RemoveAfter(bottom);
                    doc.ClearRange(top, bottom, _currentdecoration);
                    _manipulator.Load(doc.CurrentLine, col);
                }
                break;

            default:
                throw new UnknownEscapeSequenceException(String.Format("unknown ED option {0}", param));
            }
        }
Пример #7
0
        public void OnReception(ByteDataFragment data)
        {
            try {
                bool pass_to_terminal = true;
                if (_modalTerminalTask != null)
                {
                    bool show_input = _modalTerminalTask.ShowInputInTerminal;
                    _modalTerminalTask.OnReception(data);
                    if (!show_input)
                    {
                        pass_to_terminal = false; //入力を見せない(XMODEMとか)のときはターミナルに与えない
                    }
                }

                //バイナリログの出力
                _logService.BinaryLogger.Write(data);

                if (pass_to_terminal)
                {
                    TerminalDocument document = _document;
                    lock (document) {
                        _manipulator.Load(document.CurrentLine, 0);
                        _manipulator.CaretColumn       = document.CaretColumn;
                        _manipulator.DefaultDecoration = _currentdecoration;

                        _decoder.OnReception(data);

                        document.ReplaceCurrentLine(_manipulator.Export());
                        document.CaretColumn = _manipulator.CaretColumn;

                        CheckDiscardDocument();
                        AdjustTransientScrollBar();

                        //現在行が下端に見えるようなScrollBarValueを計算
                        int n = document.CurrentLineNumber - document.TerminalHeight + 1 - document.FirstLineNumber;
                        if (n < 0)
                        {
                            n = 0;
                        }

                        //Debug.WriteLine(String.Format("E={0} C={1} T={2} H={3} LC={4} MAX={5} n={6}", _transientScrollBarEnabled, _tag.Document.CurrentLineNumber, _tag.Document.TopLineNumber, _tag.Connection.TerminalHeight, _transientScrollBarLargeChange, _transientScrollBarMaximum, n));
                        if (IsAutoScrollMode(n))
                        {
                            _scrollBarValues.Value = n;
                            document.TopLineNumber = n + document.FirstLineNumber;
                        }
                        else
                        {
                            _scrollBarValues.Value = document.TopLineNumber - document.FirstLineNumber;
                        }

                        //Invalidateをlockの外に出す。このほうが安全と思われた

                        //受信スレッド内ではマークをつけるのみ。タイマーで行うのはIntelliSenseに副作用あるので一時停止
                        //_promptRecognizer.SetContentUpdateMark();
                        _promptRecognizer.Recognize();
                    }

                    if (_afterExitLockActions.Count > 0)
                    {
                        Control main = _session.OwnerWindow.AsControl();
                        foreach (AfterExitLockDelegate action in _afterExitLockActions)
                        {
                            main.Invoke(action);
                        }
                        _afterExitLockActions.Clear();
                    }
                }

                if (_modalTerminalTask != null)
                {
                    _modalTerminalTask.NotifyEndOfPacket();
                }
                _session.NotifyViewsDataArrived();
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
            }
        }