private void CheckDiscardDocument()
        {
            if (_tag == null || _tag.Terminal.TerminalMode == TerminalMode.Application)
            {
                return;
            }

            TerminalDocument document = _tag.Document;
            int del = document.DiscardOldLines(GEnv.Options.TerminalBufferSize + _tag.Connection.TerminalHeight);

            if (del > 0)
            {
                _tag.NotifyUpdate();
                TextSelection sel = GEnv.TextSelection;
                if (sel.Owner == _tag.Pane)
                {
                    sel.ClearIfOverlapped(document.FirstLineNumber);
                }
                int newvalue = _transientScrollBarValue - del;
                if (newvalue < 0)
                {
                    newvalue = 0;
                }
                _transientScrollBarValue = newvalue;
                document.InvalidateAll();                 //本当はここまでしなくても良さそうだが念のため
            }
        }