resolveTuiWheelReportCount function
int
resolveTuiWheelReportCount(
- TuiWheelEvent event, {
- required num multiplier,
- required TuiWheelDistanceState state,
- double? cellHeight,
- int? rows,
- bool forceTrackpad = false,
Resolve how many TUI mouse-wheel reports to emit for event.
Port of Orca resolveTerminalTuiMouseWheelReportCount.
forceTrackpad: treat event as a pixel trackpad stream even when
|deltaY| exceeds the discrete notch threshold (used when coalescing many
small trackpad ticks into one ingest).
Implementation
int resolveTuiWheelReportCount(
TuiWheelEvent event, {
required num multiplier,
required TuiWheelDistanceState state,
double? cellHeight,
int? rows,
bool forceTrackpad = false,
}) {
final direction = _resolveWheelDirection(event);
if (state.pendingDirection != 0 && state.pendingDirection != direction) {
state.fastStreak = 0;
state.lastDistanceRows = null;
state.lastInputAt = null;
state.pendingRows = 0;
}
state.pendingDirection = direction;
final distanceRows = forceTrackpad
? event.deltaY.abs() / _normalizeCellHeight(cellHeight)
: _resolveWheelDistanceRows(
event,
cellHeight: cellHeight,
rows: rows,
);
if (forceTrackpad || _isTrackpadLikePixelWheelEvent(event)) {
final totalRows = state.pendingRows + distanceRows;
final reports = totalRows.truncate();
state.pendingRows = totalRows - reports;
return reports;
}
final scaledRows = math.min(
_tuiWheelBurstMaxDistanceRowsPerEvent,
_compressWheelDistanceRows(distanceRows) +
_resolveBurstWheelDistanceRows(event, state, distanceRows),
) *
normalizeTuiScrollSensitivity(multiplier);
final totalRows = state.pendingRows + scaledRows;
final reports = totalRows.truncate();
state.pendingRows = totalRows - reports;
return reports;
}