Skip to main content

Module system

Module system 

Source
Expand description

System preferences the UI follows (light / dark, accent colour, reduced motion, more contrast) and hand-offs to the OS (open a URL in the browser, open a file in its default app, reveal a file in the file manager).

Preferences are read on demand and cheap enough for a settings change or window focus, not for every frame: cache them and re-read when the window gains focus.

Structs§

Preferences
What the user chose in the OS. None = unknown here.

Enums§

Appearance

Constants§

MAX_LANGUAGES
The most languages preferred_languages returns.
OPEN_URL_SCHEMES
URL schemes open_url hands to the OS. Anything else (file:, javascript:, custom app schemes) could start arbitrary programs, so it is refused.

Functions§

bring_to_front
Bring the app and window to the front and give it the keyboard focus, restoring it if it is minimized. For “the second launch hands over to the first” and tray / global-shortcut activations, where the windowing library’s focus request alone may be refused.
check_url
Check a URL for open_url: an allowed scheme, one line, bounded.
open_path
Open a file or folder in its default app.
open_url
Open a web or mail link in the user’s default app.
preferences
The OS preferences now.
preferred_languages
The user’s preferred UI languages, most preferred first, as BCP 47 tags (en-GB, de, zh-Hans-CN): macOS NSLocale.preferredLanguages, Windows GetUserPreferredUILanguages; empty elsewhere (Linux has LANG/LANGUAGE) and when unknown. Desktop launches often have no LANG, so apps read this as well. At most MAX_LANGUAGES tags of at most 64 bytes.
reveal
Show a file selected in Finder / Explorer / the file manager.