scoop:scoop.window:0.1.0
src/accessibility/text_scroll.scoop
Selected production source · src/accessibility/text_scroll.scoop
1
package scoop.window.accessibility3
public enum SemanticScrollAlignment {4
Start, Center, End, Nearest5
}7
public struct SemanticTextScroll(8
val horizontal: SemanticScrollAlignment = SemanticScrollAlignment.Nearest,9
val vertical: SemanticScrollAlignment = SemanticScrollAlignment.Nearest10
)12
internal fun semanticTextScroll(value: Double): SemanticTextScroll? {13
if (!value.isFinite() || value < 0.0 || value > 15.0 || value != value.toInt().toDouble())14
return None15
val code = value.toInt()16
return Some(SemanticTextScroll(semanticAlignment(code % 4), semanticAlignment(code / 4)))17
}19
private fun semanticAlignment(value: Int): SemanticScrollAlignment =20
when (value) {21
case 0 -> SemanticScrollAlignment.Start22
case 1 -> SemanticScrollAlignment.Center23
case 2 -> SemanticScrollAlignment.End24
else -> SemanticScrollAlignment.Nearest25
}