소스 검색

Fixes #1024. TextView is printing the new line character "\n" with a symbol.

BDisp 4 년 전
부모
커밋
f43bcc07e5
1개의 변경된 파일23개의 추가작업 그리고 4개의 파일을 삭제
  1. 23 4
      Terminal.Gui/Views/TextView.cs

+ 23 - 4
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;			}
+		}
+
 		///<inheritdoc/>
 		public override bool CanFocus {
 			get => base.CanFocus;