浏览代码

Fixed charmap

Tig Kindel 2 年之前
父节点
当前提交
2e69bd1687

+ 1 - 0
Terminal.Gui/Core/Frame.cs

@@ -97,6 +97,7 @@ namespace Terminal.Gui {
 		/// <param name="clipRect"></param>
 		public override void Redraw (Rect clipRect)
 		{
+			if (Thickness == Thickness.Empty) return;
 
 			//OnDrawContent (bounds);
 			//OnDrawSubViews (bounds);

+ 5 - 0
Terminal.Gui/Core/Thickness.cs

@@ -70,6 +70,11 @@ namespace Terminal.Gui {
 			Right = right;
 			Bottom = bottom;
 		}
+		
+		///// <summary>
+		///// <see langword="true"/> if all dimensions are 0.
+		///// </summary>
+		//public bool Empty => Left == 0 && Top == 0 && Right == 0 && Bottom == 0;
 
 		/// <summary>
 		/// Returns a rectangle describing the location and size of the inner area of <paramref name="rect"/>

+ 1 - 0
Terminal.Gui/Views/ScrollBarView.cs

@@ -225,6 +225,7 @@ namespace Terminal.Gui {
 			}
 		}
 
+		// BUGBUG: v2 - for consistency this should be named "Parent" not "Host"
 		/// <summary>
 		/// Get or sets the view that host this <see cref="View"/>
 		/// </summary>

+ 1 - 1
Terminal.Gui/Views/ScrollView.cs

@@ -329,10 +329,10 @@ namespace Terminal.Gui {
 			//Clear ();
 
 			var savedClip = ClipToBounds ();
+			contentView.Redraw (contentView.Frame);
 			OnDrawContent (new Rect (ContentOffset,
 				new Size (Math.Max (Bounds.Width - (ShowVerticalScrollIndicator ? 1 : 0), 0),
 					Math.Max (Bounds.Height - (ShowHorizontalScrollIndicator ? 1 : 0), 0))));
-			contentView.Redraw (contentView.Frame);
 			Driver.Clip = savedClip;
 
 			if (autoHideScrollBars) {

+ 10 - 10
UICatalog/Scenarios/CharacterMap.cs

@@ -30,35 +30,36 @@ namespace UICatalog.Scenarios {
 			_charMap = new CharMap () {
 				X = 0,
 				Y = 0,
-				Height = Dim.Fill (),
+				Height = Dim.Fill ()
 			};
+			Win.Add (_charMap);
 
 			var jumpLabel = new Label ("Jump To Glyph:") { X = Pos.Right (_charMap) + 1, Y = Pos.Y (_charMap) };
 			Win.Add (jumpLabel);
 			var jumpEdit = new TextField () { X = Pos.Right (jumpLabel) + 1, Y = Pos.Y (_charMap), Width = 10, };
 			Win.Add (jumpEdit);
-			var unicodeLabel = new Label ("") { X = Pos.Right (jumpEdit) + 1, Y = Pos.Y (_charMap) };
-			Win.Add (unicodeLabel);
+			var errorLabel = new Label ("") { X = Pos.Right (jumpEdit) + 1, Y = Pos.Y (_charMap), ColorScheme = Colors.ColorSchemes ["error"] };
+			Win.Add (errorLabel);
 			jumpEdit.TextChanged += (s) => {
 				uint result = 0;
 				if (jumpEdit.Text.Length == 0) return;
 				try {
 					result = Convert.ToUInt32 (jumpEdit.Text.ToString (), 10);
 				} catch (OverflowException) {
-					unicodeLabel.Text = $"Invalid (overflow)";
+					errorLabel.Text = $"Invalid (overflow)";
 					return;
 				} catch (FormatException) {
 					try {
 						result = Convert.ToUInt32 (jumpEdit.Text.ToString (), 16);
 					} catch (OverflowException) {
-						unicodeLabel.Text = $"Invalid (overflow)";
+						errorLabel.Text = $"Invalid (overflow)";
 						return;
 					} catch (FormatException) {
-						unicodeLabel.Text = $"Invalid (can't parse)";
+						errorLabel.Text = $"Invalid (can't parse)";
 						return;
 					}
 				}
-				unicodeLabel.Text = $"U+{result:x4}";
+				errorLabel.Text = $"U+{result:x4}";
 				_charMap.SelectedGlyph = result;
 			};
 
@@ -73,7 +74,6 @@ namespace UICatalog.Scenarios {
 				return ($"{title} (U+{start:x5}-{end:x5})", start, end);
 			}
 
-			Win.Add (_charMap);
 			var label = new Label ("Jump To Unicode Block:") { X = Pos.Right (_charMap) + 1, Y = Pos.Bottom (jumpLabel) + 1 };
 			Win.Add (label);
 
@@ -229,10 +229,10 @@ namespace UICatalog.Scenarios {
 		private void CharMap_DrawContent (Rect viewport)
 		{
 			var oldClip = Driver.Clip;
-			Driver.Clip = Frame;
+			Driver.Clip = Bounds;
 			// Redraw doesn't know about the scroll indicators, so if off, add one to height
 			if (!ShowHorizontalScrollIndicator) {
-				Driver.Clip = new Rect (Frame.X, Frame.Y, Frame.Width, Frame.Height + 1);
+				Driver.Clip = new Rect (Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height + 1);
 			}
 			Driver.SetAttribute (HasFocus ? ColorScheme.HotFocus : ColorScheme.Focus);
 			Move (0, 0);