diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs
index 27eba5b2a..3284843f4 100644
--- a/Terminal.Gui/Views/TextView.cs
+++ b/Terminal.Gui/Views/TextView.cs
@@ -863,29 +863,23 @@ namespace Terminal.Gui {
}
///
- /// Will scroll the to display the specified row at the top
+ /// Will scroll the to display the specified row at the top if is true or
+ /// will scroll the to display the specified column at the left if is false.
///
- /// Row that should be displayed at the top, if the value is negative it will be reset to zero
- public void ScrollToRow (int row)
+ /// Row that should be displayed at the top or Column that should be displayed at the left,
+ /// if the value is negative it will be reset to zero
+ /// If true (default) the is a row, column otherwise.
+ public void ScrollTo (int idx, bool isRow = true)
{
- if (row < 0) {
- row = 0;
+ if (idx < 0) {
+ idx = 0;
}
- topRow = row > model.Count - 1 ? model.Count - 1 : row;
- SetNeedsDisplay ();
- }
-
- ///
- /// Will scroll the to display the specified column at the left
- ///
- /// Column that should be displayed at the left, if the value is negative it will be reset to zero
- public void ScrollToCol (int col)
- {
- if (col < 0) {
- col = 0;
+ if (isRow) {
+ topRow = idx > model.Count - 1 ? model.Count - 1 : idx;
+ } else {
+ var maxlength = model.GetMaxVisibleLine (topRow, topRow + Frame.Height);
+ leftColumn = idx > maxlength - 1 ? maxlength - 1 : idx;
}
- var maxlength = model.GetMaxVisibleLine (topRow, topRow + Frame.Height);
- leftColumn = col > maxlength - 1 ? maxlength - 1 : col;
SetNeedsDisplay ();
}
@@ -1398,19 +1392,19 @@ namespace Terminal.Gui {
} else if (ev.Flags == MouseFlags.WheeledDown) {
lastWasKill = false;
columnTrack = currentColumn;
- ScrollToRow (topRow + 1);
+ ScrollTo (topRow + 1);
} else if (ev.Flags == MouseFlags.WheeledUp) {
lastWasKill = false;
columnTrack = currentColumn;
- ScrollToRow (topRow - 1);
+ ScrollTo (topRow - 1);
} else if (ev.Flags == MouseFlags.WheeledRight) {
lastWasKill = false;
columnTrack = currentColumn;
- ScrollToCol (leftColumn + 1);
+ ScrollTo (leftColumn + 1, false);
} else if (ev.Flags == MouseFlags.WheeledLeft) {
lastWasKill = false;
columnTrack = currentColumn;
- ScrollToCol (leftColumn - 1);
+ ScrollTo (leftColumn - 1, false);
}
return true;