Example #1
0
        private void Terminal_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            int rowDiff = terminal.Size.Row - visuals.Count;

            for (int i = 0; i < rowDiff; ++i)
            {
                history.PushBack(terminal.CurrentScreen[terminal.Size.Row - rowDiff + i]);
                var newVisual = new TerminalLineVisual(this, history[history.Count - 1]);
                visuals.PushBack(newVisual);
                AddVisualChild(newVisual);

                newVisual = new TerminalLineVisual(this, null);
                extraVisuals.PushBack(newVisual);
            }

            for (int i = 0; i > rowDiff; --i)
            {
                TerminalLineVisual oldVisual;
                if (visuals.Count - 1 > e.OldCursorPos.Row)
                {
                    oldVisual = visuals.PopBack();
                }
                else
                {
                    verticalOffset++;
                    oldVisual = visuals.PopFront();
                }

                RemoveVisualChild(oldVisual);
                oldVisual.Line = null;

                extraVisuals.PopFront();
            }

            if (rowDiff < 0)
            {
                if (terminal.CurrentScreen == terminal.Screen)
                {
                    while (history[history.Count - 1].IsEmpty() && history.Count > terminal.Size.Row)
                    {
                        history.PopBack();
                    }
                }
                else
                {
                    for (int i = 0; i > rowDiff; --i)
                    {
                        history.PopBack();
                    }
                }
            }

            verifyVisuals();

            InvalidateMeasure();
            SetVerticalOffset(verticalOffset);
            updateVisuals();
        }
Example #2
0
        private TerminalLineVisual recycleVisual(TerminalLineVisual visual)
        {
            RemoveVisualChild(visual);
            visual.Line = null;
            visual.Select(0, 0);
            visual.Offset = new Vector(-1000, -1000);

            var newVisual = extraVisuals.PopFront();

            extraVisuals.PushBack(visual);
            AddVisualChild(newVisual);
            return(newVisual);
        }
Example #3
0
        public void AddMessage(string text, TerminalFont font)
        {
            prepareHistory(1);

            var line         = new TerminalLine();
            int leftPadding  = (Terminal.Size.Col - text.Length) / 2;
            int rightPadding = (Terminal.Size.Col - text.Length + 1) / 2;

            line.SetCharacters(0, new string(' ', leftPadding), font);
            line.SetCharacters(leftPadding, text, font);
            line.SetCharacters(leftPadding + text.Length, new string(' ', rightPadding), font);

            var visual = new TerminalLineVisual(this, line);

            visual.Offset = new Vector(0.0, history.Count * CharHeight);
            AddVisualChild(visual);
            history.PushBack(line);
        }
Example #4
0
        private void Terminal_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            int rowDiff = terminal.Size.Row - visuals.Count;
            for (int i = 0; i < rowDiff; ++i)
            {
                history.PushBack(terminal.CurrentScreen[terminal.Size.Row - rowDiff + i]);
                var newVisual = new TerminalLineVisual(this, history[history.Count - 1]);
                visuals.PushBack(newVisual);
                AddVisualChild(newVisual);

                newVisual = new TerminalLineVisual(this, null);
                extraVisuals.PushBack(newVisual);
            }

            for (int i = 0; i > rowDiff; --i)
            {
                TerminalLineVisual oldVisual;
                if (visuals.Count - 1 > e.OldCursorPos.Row)
                    oldVisual = visuals.PopBack();
                else
                {
                    verticalOffset++;
                    oldVisual = visuals.PopFront();
                }

                RemoveVisualChild(oldVisual);
                oldVisual.Line = null;

                extraVisuals.PopFront();
            }

            if (rowDiff < 0)
            {
                if (terminal.CurrentScreen == terminal.Screen)
                {
                    while (history[history.Count - 1].IsEmpty() && history.Count > terminal.Size.Row)
                        history.PopBack();
                }
                else
                {
                    for (int i = 0; i > rowDiff; --i)
                    {
                        history.PopBack();
                    }
                }
            }

            verifyVisuals();

            InvalidateMeasure();
            SetVerticalOffset(verticalOffset);
            updateVisuals();
        }
Example #5
0
        private TerminalLineVisual recycleVisual(TerminalLineVisual visual)
        {
            RemoveVisualChild(visual);
            visual.Line = null;
            visual.Select(0, 0);
            visual.Offset = new Vector(-1000, -1000);

            var newVisual = extraVisuals.PopFront();
            extraVisuals.PushBack(visual);
            AddVisualChild(newVisual);
            return newVisual;
        }
Example #6
0
        public void AddMessage(string text, TerminalFont font)
        {
            prepareHistory(1);

            var line = new TerminalLine();
            int leftPadding = (Terminal.Size.Col - text.Length) / 2;
            int rightPadding = (Terminal.Size.Col - text.Length + 1) / 2;
            line.SetCharacters(0, new string(' ', leftPadding), font);
            line.SetCharacters(leftPadding, text, font);
            line.SetCharacters(leftPadding + text.Length, new string(' ', rightPadding), font);

            var visual = new TerminalLineVisual(this, line);
            visual.Offset = new Vector(0.0, history.Count * CharHeight);
            AddVisualChild(visual);
            history.PushBack(line);
        }