From f43bcc07e5626850ea3b64a0ef23c9d038d0e7c6 Mon Sep 17 00:00:00 2001 From: BDisp Date: Wed, 25 Nov 2020 20:01:35 +0000 Subject: [PATCH] Fixes #1024. TextView is printing the new line character "\n" with a symbol. --- Terminal.Gui/Views/TextView.cs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index a37619c96..76429274c 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -419,7 +419,13 @@ namespace Terminal.Gui { SetNeedsDisplay (new Rect (0, minRow, Frame.Width, maxRow)); } - Move (CurrentColumn - leftColumn, CurrentRow - topRow); + var line = model.GetLine (currentRow); + var retreat = 0; + if (line.Count > 0) { + retreat = Math.Max ((SpecialRune (line [Math.Max (CurrentColumn - leftColumn - 1, 0)]) + ? 1 : 0), 0); + } + Move (CurrentColumn - leftColumn - retreat, CurrentRow - topRow); } void ClearRegion (int left, int top, int right, int bottom) @@ -566,17 +572,30 @@ namespace Terminal.Gui { for (int col = bounds.Left; col < right; col++) { var lineCol = leftColumn + col; var rune = lineCol >= lineRuneCount ? ' ' : line [lineCol]; - if (selecting && PointInSelection (col, row)) + if (selecting && PointInSelection (col, row)) { ColorSelection (); - else + } else { ColorNormal (); + } - AddRune (col, row, rune); + if (!SpecialRune (rune)) { + AddRune (col, row, rune); + } } } PositionCursor (); } + bool SpecialRune (Rune rune) + { + switch (rune) { + case (uint)Key.Enter: + case 0xd: + return true; + default: + return false; } + } + /// public override bool CanFocus { get => base.CanFocus;