Scoop API

scoop:scoop.window:0.1.0

src/accessibility/text_scroll.scoop

Selected production source · src/accessibility/text_scroll.scoop

1package scoop.window.accessibility
3public enum SemanticScrollAlignment {
4 Start, Center, End, Nearest
5}
7public struct SemanticTextScroll(
8 val horizontal: SemanticScrollAlignment = SemanticScrollAlignment.Nearest,
9 val vertical: SemanticScrollAlignment = SemanticScrollAlignment.Nearest
12internal fun semanticTextScroll(value: Double): SemanticTextScroll? {
13 if (!value.isFinite() || value < 0.0 || value > 15.0 || value != value.toInt().toDouble())
14 return None
15 val code = value.toInt()
16 return Some(SemanticTextScroll(semanticAlignment(code % 4), semanticAlignment(code / 4)))
19private fun semanticAlignment(value: Int): SemanticScrollAlignment =
20 when (value) {
21 case 0 -> SemanticScrollAlignment.Start
22 case 1 -> SemanticScrollAlignment.Center
23 case 2 -> SemanticScrollAlignment.End
24 else -> SemanticScrollAlignment.Nearest
25 }