Standard library
The standard library is written in Cuarzo, in std/, and the
compiler carries it, so any program can import it from anywhere:
import "std/term"
import "std/args"| Module | For |
|---|---|
std/term |
colors and styles, the cursor and the screen, measuring and laying out text |
std/args |
command-line options, flags, subcommands, and generated help |
std/prompt |
questions, menus, passwords, a line editor, spinners, and progress bars |
std/fs |
paths, lines of files, and listing directories |
std/time |
durations, dates, and "3 minutes ago" |
std/random |
random ranges, choices, and shuffling |
std/math |
constants, clamping, statistics, and divisors |
std/json |
reading and writing JSON |
std/toml |
reading and writing TOML 1.0, with the line of each key |
std/process |
running commands and collecting what they write, processes on the event loop, and pseudo-terminals |
std/http |
HTTP and HTTPS requests |
std/buffer |
building and reading binary data |
std/loop |
the event loop, its timers, and signals |
std/watch |
watching files and directories for changes |
std/async |
settling, waiting for, and combining tasks, timeouts, cancellation, queues, semaphores, rate limits, and retries |
std/com |
COM on Windows: objects, interfaces, HRESULTs, BSTRs, VARIANTs, and objects written in Cuarzo |
std/objc |
Objective-C on macOS: messages, Foundation's values, classes and blocks written in Cuarzo |
std/encoding |
hexadecimal, base32, base64, percent-encoding, forms and query strings, and text in UTF-16, UTF-32, Latin-1, and Windows-1252 |
std/url |
reading, writing, resolving, and normalizing URLs, international domain names, and file:// URLs |
std/unicode |
grapheme clusters, character properties, case, normalization, word and line boundaries, display width, and UTF-16 offsets |
std/regex |
regular expressions in linear time: matching, finding, groups, replacing, and splitting |
std/env |
.env files and variables read as settings, with every problem reported at once |
std/config |
settings in layers from defaults, files, and the environment, checked and watched |
std/log |
logging with levels and fields, as text or JSON Lines, to files that rotate |
std/text |
a text builder, terminal widths, padding, wrapping, and fuzzy matching |
std/json_schema |
checking JSON values against JSON Schema, draft 2020-12 |
std/desktop |
desktop applications: windows, menus and shortcuts, dialogs, the clipboard, dragging and dropping, notifications, tray icons, single instances, file and URL associations, the screens, and the system's settings |
std/webview |
an interface in HTML, CSS, and JavaScript in the system's web view, with a bridge of commands, events, channels, and shared state |
std/compiler |
the compiler as a library: checking a program and asking about its code, as an editor does |
std/test |
tests for cuarzo test: assertions, async tests, benchmarks, properties, snapshots, and interactive programs on a terminal |
std/diff |
line, word, and character differences, unified diffs, patches, three-way merges, and changes within a line |
std/textbuffer |
text being edited: edits, lines and columns, undo and redo, and snapshots in logarithmic time |
std/search |
searching a project's files, as .gitignore leaves them, replacing across them, and quick open |
std/terminal_emulator |
a terminal's screen, as a program that draws terminals keeps it: VT and xterm sequences, scrollback, modes, and what keys, pastes, and the mouse send |
std/settings |
an application's settings: a schema's defaults, the user's and the workspace's files over them, changes told, and a settings page's model |
std/keybindings |
key bindings with chords, conditions, platform defaults, and the user's over them |
std/extensions |
extensions of an application, each a program in a process of its own: manifests, what they add, activation, and isolation; std/extension is an extension's side |
std/hash |
SHA-1, SHA-2, SHA-3, BLAKE2, BLAKE3, MD5, CRC-32, CRC-32C, Adler-32, and xxHash64, at once or a part at a time |
std/crypto |
HMAC, HKDF, PBKDF2, scrypt, Argon2id, random values from the system, and authenticated encryption |
std/uuid |
UUIDs of versions 4 and 7, and reading them |
std/git |
Git repositories: status, staging files and hunks, commits, the log and its graph, branches, remotes, blame, stashes, merges, and rebases |
The modules build on the built-ins for
terminals, input, and time.
A plain import "std/term" makes the module's names part of the program's,
so the program cannot declare a function with the same name as one of its
functions. import "std/term" as term keeps them apart: the module's names
are then written term.paint, term.table, and so on. Internal helpers start
with the module's name, as in term_decode, and are private: only the
functions and types described here are public.
Five complete programs show the library at work:
cuarzo examples/cli/tasks.cz --help # a task manager with an interactive shell
cuarzo examples/games/snake.cz # the snake game
cuarzo examples/games/shardstorm.cz # a fixed shooter with diving formations
cuarzo examples/games/rally.cz # the classic paddle game
cuarzo examples/desktop/notes.cz # notes in a window, with a web view for its interfaceContents
- std/term
- std/args
- std/prompt
- std/fs
- std/time
- std/random
- std/math
- std/json
- std/process
- std/http
- std/buffer
- std/loop
- std/watch
- std/async
- std/com
- std/objc
- std/encoding
- std/url
- std/unicode
- std/regex
- std/toml
- std/json_schema
- std/text
- std/env
- std/config
- std/log
- std/desktop
- std/webview
- std/compiler
- std/test
- std/diff
- std/textbuffer
- std/search
- std/git
- std/terminal_emulator
- std/settings
- std/keybindings
- std/extensions
- std/hash
- std/crypto
- std/asn1
- std/publickey
- std/jwt
- std/compress
- std/brotli
- std/zstd
- std/archive
- std/image
- std/bundle
- std/crash
- std/update
- std/uuid