Constants & Enums
Kraken TUI exports several constant objects and enums for use in event handling, animation, theming, and accessibility.Animation Constants
AnimProp
Animation property identifiers forWidget.animate().
| Constant | Value | Description |
|---|---|---|
AnimProp.Opacity | 0 | Widget opacity (0.0 to 1.0) |
AnimProp.FgColor | 1 | Foreground color (RGB) |
AnimProp.BgColor | 2 | Background color (RGB) |
AnimProp.BorderColor | 3 | Border color (RGB) |
AnimProp.PositionX | 4 | X offset for position animation |
AnimProp.PositionY | 5 | Y offset for position animation |
Example
Easing
Easing function identifiers for animations.| Constant | Value | Description |
|---|---|---|
Easing.Linear | 0 | Constant speed throughout |
Easing.EaseIn | 1 | Slow start, accelerates |
Easing.EaseOut | 2 | Fast start, decelerates |
Easing.EaseInOut | 3 | Slow start and end, fast middle |
Easing.CubicIn | 4 | Cubic acceleration |
Easing.CubicOut | 5 | Cubic deceleration |
Easing.Elastic | 6 | Elastic bounce effect |
Easing.Bounce | 7 | Bouncing effect |
Example
Easing functions are implemented in the Rust core. See Animation Concepts for visual curves.
Event Constants
EventType
Event type identifiers.| Constant | Value | Description |
|---|---|---|
EventType.None | 0 | No event (sentinel) |
EventType.Key | 1 | Keyboard event |
EventType.Mouse | 2 | Mouse event (click, scroll) |
EventType.Resize | 3 | Terminal resize |
EventType.FocusChange | 4 | Focus gained/lost |
EventType.Change | 5 | Widget value changed |
EventType.Submit | 6 | Form submitted |
EventType.Accessibility | 7 | Accessibility event |
Example
The
KrakenEvent object has both a string type field and a numeric eventType field. Use whichever is more convenient.KeyCode
Special key code constants (non-printable keys).| Constant | Value | Key |
|---|---|---|
KeyCode.Backspace | 0x0100 | Backspace |
KeyCode.Enter | 0x0101 | Enter/Return |
KeyCode.Left | 0x0102 | Left arrow |
KeyCode.Right | 0x0103 | Right arrow |
KeyCode.Up | 0x0104 | Up arrow |
KeyCode.Down | 0x0105 | Down arrow |
KeyCode.Home | 0x0106 | Home |
KeyCode.End | 0x0107 | End |
KeyCode.PageUp | 0x0108 | Page Up |
KeyCode.PageDown | 0x0109 | Page Down |
KeyCode.Tab | 0x010a | Tab |
KeyCode.BackTab | 0x010b | Shift+Tab |
KeyCode.Delete | 0x010c | Delete |
KeyCode.Insert | 0x010d | Insert |
KeyCode.Escape | 0x010e | Escape |
KeyCode.F1 | 0x0110 | F1 function key |
Printable character keys (letters, numbers, symbols) use their Unicode codepoints directly. Only special keys use these
0x0100+ constants.Example
Modifier
Keyboard modifier flags (bitfield).| Constant | Value | Description |
|---|---|---|
Modifier.Shift | 0x01 | Shift key held |
Modifier.Ctrl | 0x02 | Control key held |
Modifier.Alt | 0x04 | Alt/Option key held |
Modifier.Super | 0x08 | Super/Windows/Command key held |
Example
Widget Constants
NodeType
Widget type identifiers (used internally by the FFI).| Constant | Value | Widget Class |
|---|---|---|
NodeType.Box | 0 | Box |
NodeType.Text | 1 | Text |
NodeType.Input | 2 | Input |
NodeType.Select | 3 | Select |
NodeType.ScrollBox | 4 | ScrollBox |
NodeType.TextArea | 5 | TextArea |
You generally don’t need to use
NodeType directly in application code. It’s primarily used internally by the FFI layer.Accessibility Constants
AccessibilityRole
Accessibility role identifiers for assistive technologies.| Constant | Value | Description |
|---|---|---|
AccessibilityRole.Button | 0 | Button or clickable element |
AccessibilityRole.Checkbox | 1 | Checkbox or toggle |
AccessibilityRole.Input | 2 | Text input field |
AccessibilityRole.TextArea | 3 | Multi-line text input |
AccessibilityRole.List | 4 | List container |
AccessibilityRole.ListItem | 5 | Item within a list |
AccessibilityRole.Heading | 6 | Section heading |
AccessibilityRole.Region | 7 | Landmark region |
AccessibilityRole.Status | 8 | Status or live region |
Example
Theme Constants
DARK_THEME
Handle for the built-in dark theme.1
LIGHT_THEME
Handle for the built-in light theme.2
These constants represent theme handles. The actual theme definitions are built into the Rust core.
Performance Counter IDs
PERF_ACTIVE_ANIMATIONS
Performance counter ID for the number of active animations.6
See Kraken.getPerfCounter() for usage.
Usage Patterns
Import Only What You Need
Type-Safe Constant Objects
All constant objects are defined withas const to ensure type safety:
Bitfield Operations
For modifier flags:Source References
- Animation constants:
ts/src/animation-constants.ts - Event/Widget constants:
ts/src/ffi/structs.ts - Loop constants:
ts/src/loop.ts - Theme constants:
ts/src/theme.ts
Related APIs
Animation
Widget animation methods
Event Handling
Working with events
Themes
Theme customization
Accessibility
Accessibility methods