Skip to main content

API Functions

Ziva provides a rich set of global functions for configuring library behavior, optimizing performance, and advanced usage.
These functions complement the core library components and allow fine-tuning Ziva behavior for your specific application requirements.

Auto-configuration

AutoConfigure()

Automatically configures Ziva for optimal performance on the current system.
This function:
  • Analyzes available system memory
  • Detects processor architecture
  • Optimizes settings for embedded systems
  • Configures caching and buffering

DisableCompletionDelay()

Turns off the default completion delay that keeps the last task on screen for a short moment.
Use it when you prefer immediate transitions between tasks or when running automated tests where every extra millisecond matters.

Is64Bit()

Determines system architecture for optimal algorithm selection.

Performance Utilities

RepeatEfficient(s string, count int) string

Creates a string by efficiently repeating the base string.

JoinEfficient(parts []string, separator string) string

Joins strings with minimal memory allocations.

FastConcat(parts …string) string

Fast concatenation of arbitrary number of strings.

CleanWhitespaceEfficient(s string) string

Cleans string from excessive whitespace characters.

Color Management

SetErrorColor(errorsColor, statusColor lipgloss.TerminalColor)

Configures color scheme for error display.

ResetErrorColors()

Resets error colors to default values.

SetExitMenuItemStyle(style lipgloss.Style)

Changes the style used to render localized “Exit” menu items in list tasks. By default Ziva highlights the action with a cyan bold style (ziva.MenuActionDefaultStyle()).

SetBackMenuItemStyle(style lipgloss.Style)

Changes the style used to render localized “Back” menu items in list tasks. Uses the same highlighted style as the exit action by default.

ResetExitMenuItemStyle()

Restores the default highlight for “Exit” items.

ResetBackMenuItemStyle()

Restores the default highlight for “Back” items.
Returns the cyan bold style used for special menu actions.
Returns the neutral style that matches regular menu items.

EnableEmbeddedMode()

Enables embedded system mode with simplified color palette.

EnableASCIIMode()

Switches to ASCII mode for legacy terminals.

IsEmbeddedColorMode() bool

Checks if embedded system mode is enabled.

Advanced Validators

NewPasswordValidator(minLength int) Validator

Creates validator for password complexity checking.

NewEmailValidator() Validator

Email address validator according to RFC standards.

NewIPValidator(allowIPv4, allowIPv6 bool) Validator

Configurable IP address validator.

NewIPv4Validator() / NewIPv6Validator() Validator

Specialized validators for specific IP versions.

NewDomainValidator() Validator

Domain name validator.

NewTextValidator(minLen, maxLen int) Validator

Text validator with length constraints.

Memory Optimization

InternString(s string) string

String interning for memory efficiency.

GetCacheStats() (size, capacity int)

Get statistics of interned string cache.

ClearInternCache()

Clear interned string cache.

Layout Utilities

CalculateLayoutWidth(screenWidth int) int

Calculates optimal layout width.

Combined Examples

Embedded System Setup

Form Validation Setup

Performance Data Processing

All these functions are designed for maximum performance and can be used in high-load applications without performance degradation.
Functions EnableEmbeddedMode() and EnableASCIIMode() change global library state. It’s recommended to call them only once at the beginning of the program.