Пример #1
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;

            doc.UpdateCurrentLine(_manipulator);
            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);
        }
Пример #2
0
        //これを送ってくるアプリケーションは viで上方スクロール
        protected void ProcessInsertLines(string param)
        {
            int d = ParseInt(param, 1);

            TerminalDocument doc = GetDocument();
            int caret_pos        = _manipulator.CaretColumn;
            int offset           = doc.CurrentLineNumber - doc.TopLineNumber;

            doc.UpdateCurrentLine(_manipulator);
            if (doc.ScrollingBottom == -1)
            {
                doc.SetScrollingRegion(0, GetDocument().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);
        }
Пример #3
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;

                        _decoder.OnReception(data);

                        document.UpdateCurrentLine(_manipulator);
                        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);
            }
        }
Пример #4
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.UpdateCurrentLine(_manipulator);
                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.UpdateCurrentLine(_manipulator);
                doc.ClearRange(top, cur, _currentdecoration);
                _manipulator.Load(doc.CurrentLine, col);
            }
            break;

            case 2:     //erase all
                ERASE_ALL : {
                    GetDocument().ApplicationModeBackColor =
                        (_currentdecoration != null) ? _currentdecoration.GetBackColorSpec() : ColorSpec.Default;

                    doc.UpdateCurrentLine(_manipulator);
                    //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));
            }
        }