scoop:scoop.ui:0.1.0
src/text/editor/options.scoop
Selected production source · src/text/editor/options.scoop
1
package scoop.ui.text3
import scoop.graphics.*4
import scoop.graphics.text.*5
import scoop.time.Duration6
import scoop.ui.*7
import scoop.window.TextInputPurpose9
public enum TextTabBehavior {10
Navigate, Insert11
}13
public enum TextSubmitKeys {14
None, Enter, PrimaryEnter15
}17
/** Editing policy is independent of the control's theme and border. */18
public class TextEditOptions public constructor(19
public val multiline: Boolean = false,20
public val wrap: Boolean = true,21
public val readOnly: Boolean = false,22
public val enabled: Boolean = true,23
public val tab: TextTabBehavior = TextTabBehavior.Navigate,24
public val submit: TextSubmitKeys = TextSubmitKeys.Enter,25
public val direction: TextDirection? = None,26
public val alignment: TextAlignment = TextAlignment.Start,27
public val paintCache: PaintCachePolicy = PaintCachePolicy.None,28
public val caretBlink: Duration? = None,29
public val policy: TextEditPolicy = textEditPolicy(),30
public val projection: TextProjection = textProjection(),31
public val copy: TextCopyPolicy = TextCopyPolicy.Default,32
public val contextMenu: TextContextMenuOptions = TextContextMenuOptions(),33
/** A protected purpose remains set when its display projection becomes plain text. */34
public val protectedText: Boolean = false,35
public val acceptDrops: Boolean = true,36
public val drag: TextDragOptions = TextDragOptions(),37
public val touch: TextTouchOptions = TextTouchOptions(),38
public val touchScroll: TouchScrollOptions = TouchScrollOptions(),39
public val scrollPhysics: ScrollPhysicsOptions = ScrollPhysicsOptions(),40
public val inputPurpose: TextInputPurpose = TextInputPurpose.Normal,41
public val softwareKeyboard: Boolean = true,42
public val primarySelection: TextPrimarySelectionOptions = TextPrimarySelectionOptions(),43
public val automaticTextReplacement: Boolean = false44
) {45
internal fun check() {46
drag.check()47
when (caretBlink) {48
case Some(val value) -> requireUi(49
value.floorSeconds >= 0L,50
"negative caret blink interval"51
)52
case None -> {}53
}54
checkPaintCachePolicy(paintCache)55
}56
}58
/** Borrows fonts and immutable styles; the host owns only the resulting layouts. */59
public class TextEditAppearance public constructor(60
public val fonts: FontCollection,61
public val textStyle: TextStyle = textStyle(),62
public val placeholderStyle: TextStyle = textStyle { this.color = Color(0.5, 0.5, 0.5) },63
public val selectionColor: Color = Color(0.2, 0.45, 0.9, 0.3),64
public val inactiveSelectionColor: Color = Color(0.5, 0.5, 0.5, 0.25),65
public val caretColor: Color = Color.Black,66
public val markedColor: Color = Color.Black,67
public val caretWidth: Double? = None,68
public val reduceMotion: Boolean = false,69
/** None preserves the original selected glyph colors in the active window. */70
public val selectionTextColor: Color? = None,71
/** None preserves the original selected glyph colors in an inactive window. */72
public val inactiveSelectionTextColor: Color? = None73
) {74
internal fun check() {75
when (caretWidth) {76
case Some(val value) -> requireUi(77
value.isFinite() && value > 0.0,78
"invalid caret width"79
)80
case None -> {}81
}82
for (color in [selectionColor, inactiveSelectionColor, caretColor, markedColor])83
requireUi(84
color.red.isFinite() &&85
color.green.isFinite() &&86
color.blue.isFinite() &&87
color.alpha.isFinite(),88
"non-finite editor color"89
)90
for (color in [selectionTextColor, inactiveSelectionTextColor])91
when (color) {92
case Some(val value) -> checkSelectableColor(value)93
case None -> {}94
}95
requireUi(!fonts.isClosed, "editor fonts are closed")96
}97
}99
public struct TextEditInteraction(100
val focused: Boolean = false,101
val hovered: Boolean = false,102
val focusVisible: Boolean = false103
)