goblinfactory / konsole

Home of the simple console library consisting of ProgressBar, Window, Form, Draw & MockConsole (C# console progress bar with support for single or multithreaded progress updates) Window is a 100%-ish console compatible window, supporting all normal console writing to a windowed section of the screen, supporting scrolling and clipping of console output.
718 stars 62 forks source link

Embedded CrLf cause window isolation to break. #72

Closed goblinfactory closed 3 years ago

goblinfactory commented 3 years ago

embedded CrLf or Cr or Lf breaks the window isolation causing printing to print outside the border of it's window.

        [Test]
        public void replace_crlf_cr_lf_lfcr_with_individual_writeLines()
        {
            var w = new MockConsole(20, 5);
            (var left, var right) = w.SplitLeftRight("left", "right");

            left.Write("one\r\ntwo\rthree\nfour");
            right.Write("one\r\ntwo\rthree\nfour");
            var expected = new[]
            {
                "┌─ left ─┬─ right ─┐",
                "│two     │two      │",
                "│three   │three    │",
                "│four    │four     │",
                "└────────┴─────────┘"
            };
            w.Buffer.Should().BeEquivalentTo(expected);
        }

Currently this breaks with the window layout totally broken as each CrLf starts printing on the full left of the console, breaking the printed border.