Fix scrolling in Terminal

This commit is contained in:
James Babcock committed 2026-07-24 01:52:12 -07:00
1 parent 8ffccad7f0
commit d42e11e2a5
7 files changed
+90 -63

No files matched your search

+2 -7
View File
@@ -3,7 +3,7 @@ import { GrayImage } from "../../graphics/image";
import { clamp } from "../../util/numeric-util";
import { Layer, type DashboardInputEvent, type LayerActions, type LayerContext } from "../layers";
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL } from "../gestures";
import { drawSelectionHighlight } from "../menu";
import { drawSelectionHighlight, scrollToKeepSelectionVisible } from "../menu";
import {
buildSoundSequencePayload,
CFW_SEQ_MAX,
@@ -43,12 +43,7 @@ export class BuzzerDemoLayer implements Layer {
const listHeight = height - HEADER_HEIGHT - FOOTER_HEIGHT;
const visibleRows = Math.max(1, (listHeight / ROW_HEIGHT) | 0);
if (this.selectedIndex < this.scrollRow) {
this.scrollRow = this.selectedIndex;
} else if (this.selectedIndex >= this.scrollRow + visibleRows) {
this.scrollRow = this.selectedIndex - visibleRows + 1;
}
this.scrollRow = clamp(this.scrollRow, 0, Math.max(0, SOUND_EFFECTS.length - visibleRows));
this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, this.selectedIndex, visibleRows, SOUND_EFFECTS.length);
const lastVisible = Math.min(SOUND_EFFECTS.length, this.scrollRow + visibleRows);
for (let index = this.scrollRow; index < lastVisible; index++) {