Ambiente de programação com IA
Limites de janela com linhas fixas
Calcule um intervalo visível semiaberto usando altura fixa das linhas, deslocamento e altura da janela.
● ● ●WindowSpan●
Fluxos de trabalho · Limites de janela com linhas fixas ×
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✳Limites de janela com linhas fixas
✓ AlteraçõesRevise antes de aplicar ↗
Ilustração do ambiente
- Modelos
- Configure um endpoint compatível com OpenAI ou Anthropic com a URL base e uma chave API, quando necessária. Teste a conexão. O servidor local precisa estar em execução; ferramentas remotas podem transmitir dados separadamente.
- Projeto
- Teste rolagem negativa, excesso de rolagem e janela com altura zero, limitando os índices e rejeitando altura de linha inválida.
- Revise antes de aplicar
- Compare o comportamento real com o resultado esperado. Se uma verificação falhar, investigue a causa antes de fazer outras alterações.
Fluxos de trabalho
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