2026-04-01 23:15:19 +00:00
|
|
|
import { MacOSScrollAccel, type ScrollAcceleration } from "@opentui/core"
|
2026-04-16 06:03:03 +00:00
|
|
|
import type { TuiConfig } from "@/cli/cmd/tui/config/tui"
|
2026-04-01 23:15:19 +00:00
|
|
|
|
|
|
|
|
export class CustomSpeedScroll implements ScrollAcceleration {
|
|
|
|
|
constructor(private speed: number) {}
|
|
|
|
|
|
|
|
|
|
tick(_now?: number): number {
|
|
|
|
|
return this.speed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reset(): void {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getScrollAcceleration(tuiConfig?: TuiConfig.Info): ScrollAcceleration {
|
|
|
|
|
if (tuiConfig?.scroll_acceleration?.enabled) {
|
|
|
|
|
return new MacOSScrollAccel()
|
|
|
|
|
}
|
2026-04-01 23:36:49 +00:00
|
|
|
if (tuiConfig?.scroll_speed !== undefined) {
|
2026-04-01 23:15:19 +00:00
|
|
|
return new CustomSpeedScroll(tuiConfig.scroll_speed)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new CustomSpeedScroll(3)
|
|
|
|
|
}
|