setXOffset method
Sets the X offset (clamped to valid range).
Implementation
ViewportModel setXOffset(int n) {
if (softWrap) {
// In soft-wrap mode horizontal scrolling doesn't apply.
return xOffset == 0 ? this : copyWith(xOffset: 0);
}
final maxXOffset = _longestLineWidth - _contentWidth;
return copyWith(xOffset: n.clamp(0, maxXOffset > 0 ? maxXOffset : 0));
}