Esempio n. 1
0
        //‚±‚ê‚ð‘—‚Á‚Ä‚­‚éƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚Í vi‚ʼnº•ûƒXƒNƒ[ƒ‹
        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        = doc.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);
        }
Esempio n. 2
0
        public AbstractTerminal(TerminalInitializeInfo info)
        {
            //TerminalEmulatorPlugin.Instance.LaterInitialize();
            _session = info.Session;

            // //_invalidateParam = new InvalidateParam();
            _document = new TerminalDocument(info.InitialWidth, info.InitialHeight);
            //_document.SetOwner(_session.ISession);
            _afterExitLockActions = new List <AfterExitLockDelegate>();

            _decoder      = new ISO2022CharDecoder(this, EncodingProfile.Get(info.Session.TerminalSettings.Encoding));
            _terminalMode = TerminalMode.Normal;
            _logService   = new LogService(info.TerminalParameter, _session.TerminalSettings, _session.TerminalOptions);
            //_promptRecognizer = new PromptRecognizer(this);

            //if (info.Session.TerminalSettings.LogSettings != null)
            //{
            //    _logService.ApplyLogSettings(_session.TerminalSettings.LogSettings, false);
            //}

            //event handlers
            ITerminalSettings ts = info.Session.TerminalSettings;

            ts.ChangeEncoding  += delegate(EncodingType t) { this.Reset(); };
            _document.DebugFlag = ts.DebugFlag;

            _document.LineFeedRule = GetTerminalSettings().LineFeedRule; //(Telnet.LineFeedRule)
            //ToDo: Set Encoding
            //_document.Encoding = Encoding.GetEncoding("iso-2022-jp")
        }
Esempio n. 3
0
        //CSI K
        private void ProcessEraseInLine(string param)
        {
            int d = ParseInt(param, 0);

            TerminalDocument doc = GetDocument();

            switch (d)
            {
            case 0:                     //erase right
                doc.RemoveAfterCaret();
                break;

            case 1:                     //erase left
                doc.CleanLineRange(0, doc.CaretColumn);
                break;

            case 2:                     //erase all
                                        //doc.Clear(GetDocument().TerminalWidth);
                doc.CleanLineRange(0, doc.TerminalWidth);
                break;

            default:
                throw new UnknownEscapeSequenceException(String.Format("unknown EL option {0}", param));
            }
        }
Esempio n. 4
0
        //CSI J
        protected void ProcessEraseInDisplay(string param)
        {
            int d = ParseInt(param, 0);

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

            switch (d)
            {
            case 0:                     //erase below
                doc.RemoveAfterCaret();
                //doc.RemoveAfter(doc.TopLineNumber+doc.TerminalHeight);
                doc.ClearAfter(doc.CurrentLineNumber + 1);
                //_manipulator.Load(doc.CurrentLine, col);
                break;

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

            case 2:                     //erase all
                doc.ClearAfter(doc.TopLineNumber);
                break;

            default:
                throw new UnknownEscapeSequenceException(String.Format("unknown ED option {0}", param));
            }
        }
Esempio n. 5
0
 private void CleanupCommon()
 {
     if (!_cleanup)
     {
         _cleanup = true;
         _logService.Close(_document.CurrentLine);
         _document = null;
         _decoder  = null;
     }
 }
Esempio n. 6
0
        private void RestoreScreen(int sw)
        {
            if (_savedScreen[sw] == null)
            {
                ClearScreen();                  // emulate new buffer
                return;
            }
            TerminalDocument doc = GetDocument();
            int w = doc.TerminalWidth;
            int m = doc.TerminalHeight;
            int t = doc.TopLineNumber;

            throw new InvalidOperationException("XTerm: RestoreScreen is not implemented!");

            /* foreach(string l in _savedScreen[sw]) {
             *      //l.ExpandBuffer(w);
             * doc.Replace(t, l);  // doc.AddLine(l);
             * t++;
             *      if(--m == 0) break;
             * } */
        }
Esempio n. 7
0
        private void ProcessScrollDown(string param)
        {
            int d = ParseInt(param, 1);

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

            //GLine nl = _manipulator.Export();
            doc.CleanLineRange(0, doc.TerminalWidth);             // .ReplaceCurrentLine(nl);
            if (doc.ScrollingBottom == -1)
            {
                doc.SetScrollingRegion(0, GetDocument().TerminalHeight - 1);
            }
            for (int i = 0; i < d; i++)
            {
                doc.ScrollUp(doc.ScrollingTop, doc.ScrollingBottom);                // TerminalDocument's "Scroll-Up" means XTerm's "Scroll-Down"
                doc.CurrentLineNumber = doc.TopLineNumber + offset;                 // find correct GLine
            }
            //_manipulator.Load(doc.CurrentLine, caret_col);
        }
Esempio n. 8
0
        //‚±‚ê‚ð‘—‚Á‚Ä‚­‚éƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚Í vi‚ŏã•ûƒXƒNƒ[ƒ‹
        protected void ProcessInsertLines(string param)
        {
            int d = ParseInt(param, 1);

            TerminalDocument doc = GetDocument();
            int caret_pos        = doc.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.ScrollUp(/* doc.CurrentLineNumber, doc.ScrollingBottom */);
                doc.CurrentLineNumber = doc.TopLineNumber + offset;
            }
            //_manipulator.Load(doc.CurrentLine, caret_pos);
        }
Esempio n. 9
0
/*
 *      //ModalTerminalTaskŽü•Ó
 *      public virtual void StartModalTerminalTask(IModalTerminalTask task) {
 *          _modalTerminalTask = task;
 *          new ModalTerminalTaskSite(this).Start(task);
 *      }
 *      public virtual void EndModalTerminalTask() {
 *          _modalTerminalTask = null;
 *      }
 *      public IModalTerminalTask CurrentModalTerminalTask {
 *          get {
 *              return _modalTerminalTask;
 *          }
 *      }
 */
        #region IByteAsyncInputStream
        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‚Æ‚©)‚Ì‚Æ‚«‚̓^[ƒ~ƒiƒ‹‚É—^‚¦‚È‚¢
                //}

                //ƒoƒCƒiƒŠƒƒO‚̏o—Í
                _logService.BinaryLogger.Write(data);

                if (pass_to_terminal)
                {
                    TerminalDocument document = _document;
                    if (document != null)
                    {
                        lock (document)
                        {
                            //_invalidateParam.Reset();
                            //‚±‚±‚©‚ç‹ŒInput()
                            //_manipulator.Load(GetDocument().CurrentLine, 0);
                            //_manipulator.CaretColumn = GetDocument().CaretColumn;

                            //ˆ—–{‘Ì
                            _decoder.OnReception(data);

                            //GetDocument().ReplaceCurrentLine(_manipulator.Export());
                            //GetDocument().CaretColumn = _manipulator.CaretColumn;
                            //‚±‚±‚Ü‚Å

                            //‰E’[‚ɃLƒƒƒŒƒbƒg‚ª—ˆ‚½‚Æ‚«‚Í•Ö‹X“I‚ÉŽŸs‚Ì“ª‚É‚à‚Á‚Ä‚¢‚­
                            //if(document.CaretColumn==document.TerminalWidth) {
                            //    document.CurrentLineNumber++; //‚±‚ê‚É‚æ‚Á‚ÄŽŸs‚Ì‘¶Ý‚ð•ÛØ
                            //    document.CaretColumn = 0;
                            //}

                            CheckDiscardDocument();
                            //AdjustTransientScrollBar();

                            //Œ»Ýs‚ª‰º’[‚ÉŒ©‚¦‚é‚悤‚ÈScrollBarValue‚ðŒvŽZ
                            //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‚ÌŠO‚ɏo‚·B‚±‚Ì‚Ù‚¤‚ªˆÀ‘S‚ÆŽv‚í‚ꂽ

                            //ŽóMƒXƒŒƒbƒh“à‚ł̓}[ƒN‚ð‚‚¯‚é‚̂݁Bƒ^ƒCƒ}[‚ōs‚¤‚Ì‚ÍIntelliSense‚É•›ì—p‚ ‚é‚̂ňꎞ’âŽ~
                            //_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);
            }
        }