WWindowSpan
AI coding workspace

Fixed-row viewport bounds

A scrolling list needs a precise answer about which rows belong in view. WindowSpan gives that index calculation a Windows coding workspace, with a compatible model connection and proposed changes you can review against boundary examples.

● ● ●WindowSpan●
A concrete starting point · Fixed-row viewport bounds ×
from math import isfinite, ceil

def row_window(count, row_height, offset, viewport, overscan=1):
    if type(count) is not int or count < 0 or type(overscan) is not int or overscan < 0:
        raise ValueError("rows.count")
    if not all(type(x) in (int, float) and isfinite(x) for x in (row_height, offset, viewport)) or row_height <= 0 or viewport < 0:
        raise ValueError("rows.geometry")
    start_units = max(0, offset) / row_height
    first = count if start_units >= count else int(start_units)
    if first == count or viewport == 0:
        return first, first
    span = viewport / row_height
    end = count if span >= count - start_units else min(count, ceil(start_units + span) + overscan)
    return max(0, first - overscan), end
✳Fixed-row viewport bounds
✓ ChangesReview before applying ↗
Illustrative workspace
Connection
Base URL, credentials and a reachable server.
Project
Test negative scroll, overscroll and a zero-height viewport, clipping indices to the item count and rejecting an invalid row height.
Review before applying
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
Workflows

Fixed-row viewport bounds

Workflows ↗
A concrete starting point
from math import isfinite, ceil

def row_window(count, row_height, offset, viewport, overscan=1):
    if type(count) is not int or count < 0 or type(overscan) is not int or overscan < 0:
        raise ValueError("rows.count")
    if not all(type(x) in (int, float) and isfinite(x) for x in (row_height, offset, viewport)) or row_height <= 0 or viewport < 0:
        raise ValueError("rows.geometry")
    start_units = max(0, offset) / row_height
    first = count if start_units >= count else int(start_units)
    if first == count or viewport == 0:
        return first, first
    span = viewport / row_height
    end = count if span >= count - start_units else min(count, ceil(start_units + span) + overscan)
    return max(0, first - overscan), end
AI coding workspace

Your next change starts here.

Get the Windows app ↗