Pārlūkot izejas kodu

Merge pull request #3398 from BDisp/v1_listview-scrolling-fix_3396

V1 Fixes #3396. ListViewWIthSelection scenario does not show all rows and other issues
Tig 1 gadu atpakaļ
vecāks
revīzija
8ef6c531e7

+ 4 - 4
Terminal.Gui/Core/Event.cs

@@ -753,13 +753,13 @@ namespace Terminal.Gui {
 		/// </summary>
 		/// </summary>
 		WheeledDown = unchecked((int)0x20000000),
 		WheeledDown = unchecked((int)0x20000000),
 		/// <summary>
 		/// <summary>
-		/// Vertical button wheeled up while pressing ButtonShift.
+		/// Vertical button wheeled up while pressing ButtonCtrl.
 		/// </summary>
 		/// </summary>
-		WheeledLeft = ButtonShift | WheeledUp,
+		WheeledLeft = ButtonCtrl | WheeledUp,
 		/// <summary>
 		/// <summary>
-		/// Vertical button wheeled down while pressing ButtonShift.
+		/// Vertical button wheeled down while pressing ButtonCtrl.
 		/// </summary>
 		/// </summary>
-		WheeledRight = ButtonShift | WheeledDown,
+		WheeledRight = ButtonCtrl | WheeledDown,
 		/// <summary>
 		/// <summary>
 		/// Mask that captures all the events.
 		/// Mask that captures all the events.
 		/// </summary>
 		/// </summary>

+ 3 - 2
Terminal.Gui/Views/ListView.cs

@@ -864,7 +864,8 @@ namespace Terminal.Gui {
 
 
 		void RenderUstr (ConsoleDriver driver, ustring ustr, int col, int line, int width, int start = 0)
 		void RenderUstr (ConsoleDriver driver, ustring ustr, int col, int line, int width, int start = 0)
 		{
 		{
-			var u = TextFormatter.ClipAndJustify (ustr, width + start, TextAlignment.Left);
+			ustring str = start > ustr.ConsoleWidth ? string.Empty : ustr.Substring (Math.Min (start, ustr.ToRunes ().Length - 1));
+			ustring u = TextFormatter.ClipAndJustify (str, width, TextAlignment.Left);
 			driver.AddStr (u);
 			driver.AddStr (u);
 			width -= TextFormatter.GetTextWidth (u);
 			width -= TextFormatter.GetTextWidth (u);
 			while (width-- + start > 0) {
 			while (width-- + start > 0) {
@@ -876,7 +877,7 @@ namespace Terminal.Gui {
 		public void Render (ListView container, ConsoleDriver driver, bool marked, int item, int col, int line, int width, int start = 0)
 		public void Render (ListView container, ConsoleDriver driver, bool marked, int item, int col, int line, int width, int start = 0)
 		{
 		{
 			var savedClip = container.ClipToBounds ();
 			var savedClip = container.ClipToBounds ();
-			container.Move (col - start, line);
+			container.Move (Math.Max (col - start, 0), line);
 			var t = src? [item];
 			var t = src? [item];
 			if (t == null) {
 			if (t == null) {
 				RenderUstr (driver, ustring.Make (""), col, line, width);
 				RenderUstr (driver, ustring.Make (""), col, line, width);

+ 2 - 2
UICatalog/Scenarios/ListViewWithSelection.cs

@@ -79,9 +79,9 @@ namespace UICatalog.Scenarios {
 			};
 			};
 
 
 			_listView.DrawContent += (e) => {
 			_listView.DrawContent += (e) => {
-				_scrollBar.Size = _listView.Source.Count - 1;
+				_scrollBar.Size = _listView.Source.Count;
 				_scrollBar.Position = _listView.TopItem;
 				_scrollBar.Position = _listView.TopItem;
-				_scrollBar.OtherScrollBarView.Size = _listView.Maxlength - 1;
+				_scrollBar.OtherScrollBarView.Size = _listView.Maxlength;
 				_scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
 				_scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
 				_scrollBar.Refresh ();
 				_scrollBar.Refresh ();
 			};
 			};