Beispiel #1
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);
        }
Beispiel #2
0
        public void DeleteCharactersTest()
        {
            TerminalLine line = new TerminalLine();

            line.SetCharacters(0, new string('0', 4), new TerminalFont()
            {
                Foreground = Color.FromRgb(0, 0, 0)
            });
            line.SetCharacters(4, new string('1', 4), new TerminalFont()
            {
                Foreground = Color.FromRgb(1, 1, 1)
            });
            line.SetCharacters(8, new string('2', 4), new TerminalFont()
            {
                Foreground = Color.FromRgb(2, 2, 2)
            });
            line.SetCharacters(12, new string('3', 4), new TerminalFont()
            {
                Foreground = Color.FromRgb(3, 3, 3)
            });
            line.DeleteCharacters(7, 6);

            TerminalRun[] expectedRuns = new[]
            {
                new TerminalRun(new string('0', 4), new TerminalFont()
                {
                    Foreground = Color.FromRgb(0, 0, 0)
                }),
                new TerminalRun(new string('1', 3), new TerminalFont()
                {
                    Foreground = Color.FromRgb(1, 1, 1)
                }),
                new TerminalRun(new string('3', 3), new TerminalFont()
                {
                    Foreground = Color.FromRgb(3, 3, 3)
                }),
            };

            AssertAreEqual(line.Runs[0], expectedRuns[0]);
            AssertAreEqual(line.Runs[1], expectedRuns[1]);
            AssertAreEqual(line.Runs[2], expectedRuns[2]);
        }
Beispiel #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);
        }