JFLib

plat crate root#

Re-exports: rt::os::exit

Re-exports: rt::os::{write_stderr, write_stdout}

Re-exports: rt::{VERSION, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH}

Re-exports: rt::crash::{CK_ACCESS, CK_BUS, CK_DIVIDE, CK_ILLEGAL, CK_OTHER, CK_PANIC, CK_STACK, CrashHook, CrashInfo}

  • fn back_trap(on: bool) Android: while on, the back key reaches the app as Esc (a page of the app goes back, a popup closes; UIC_ESCAPE when nothing took it) instead of ending the activity. Elsewhere nothing: there Esc is a key of its own

  • fn app_finish() Android: the runtime ended (ui.quit): the activity goes and its process with it, a new start needs a new runtime; iOS: the process ends (UIKit's loop never returns). Elsewhere nothing: there the main loop ends the program

  • fn touch_primary() -> bool (ui touch.rs) the host's main pointer is a finger at the start (Android, iOS; a phone's browser: pointer: coarse; a Windows tablet in slate posture): no scroll bars from the first frame on; the next pointer event decides again

  • fn touch_keyboard(w: i32, show: bool) (ui touch.rs) a text field got the focus through a finger (show) or lost it: the on-screen keyboard of window w. Windows: InputPane; Wayland: text-input follows the focus by itself (the compositor's keyboard); elsewhere the host's job (Android, the browser) or nothing there is to ask (X11)

  • fn touch_reached(reached: bool) (ui touch.rs) a finger's gesture reached a widget (a tap, a drag), or it did not (a scroll): Android and iOS ask after the finger lifted whether the keyboard has to follow

  • fn touch_long_press() (ui touch.rs) a finger rested long enough: the host's feedback (Android: performLongClick)

  • fn reach_clamp(p: [i32; 2], w: i32, screen: [i32; 2], dpi: i32) -> [i32; 2] where a window the user moves may be (x, y; w its width; screen the area's size; dpi for the margin): the title bar stays on the screen, at least 48 DIP of the window at each side

  • struct Event one platform event (the EV_* record): type, button, modifiers, window index (0 = the main window), position (px; E_RESIZE: size), data

    • typ: u8
    • btn: u8
    • mods: u8
    • win: u8
    • x: i32
    • y: i32
    • data: u32
  • struct Frame<'a> the pixels to present: rows of 32-bit B, G, R, x

    • px: &'a [u8]
    • w: i32
    • h: i32
    • stride: i32

files

FO_READ: u32 = 0  // existing file, read only
FO_WRITE: u32 = 1  // create or truncate, read + write
FO_RW: u32 = 2  // open or create (contents kept), read + write
  • struct Date a date and time (date(): Windows local time, Linux, Apple and Android UTC, the browser the page's)

    • year: u16
    • month: u16
    • day: u16
    • hour: u16
    • min: u16
    • sec: u16
    • ms: u16
    • wday: u16 -- 0 = Sunday
  • fn persistent_name(name: &str) -> String The name under which a file the user chose stays reachable after a restart, for a list of recent files or a session (ui.recent_add keeps this one). A document of Flatpak's documents portal ($XDG_RUNTIME_DIR/doc/ID/NAME) is asked for its lasting form (Documents.Add, persistent; linux_docs.rs): <mount>/<ID>/<NAME> of the portal's answer. Where the portal reaches the real file that is a lasting document of it; for a document of its own mount the portal answers that document's own ID, so inside the sandbox the name stays as the dialog gave it (the portal's file dialog makes lasting documents, "Open with" session ones). Every other name comes back unchanged: Android keeps the grant of a content:// document and the browser the handle of a /handles/ file when the user chooses it, and OS paths need nothing. The name must be readable under the app's permissions.

  • fn file_dialog_paths() -> alloc::vec::Vec<String> (E8) the files the last system file dialog with FD_MULTI chose (its first is also in file_dialog's path; Ctrl / Shift in the dialog choose more); one entry after a dialog that chose one file, empty after a cancelled one. Windows and Linux's portal choose several, the other systems' dialogs one (docs/GUIDE.md section 7)

  • fn file_dialog_poll() -> Option<(i32, u32, String)> The answer of a system file dialog that answers later (file_dialog -> FD_PENDING: only Android's picker and the browser's, web.rs, and iOS's, apple_ios_services.rs): None while it is open, then once (1 chosen / 0 not, index, path).

  • fn arg_value(name: &str) -> Option<String> the argument after name on the command line (argument 0, the program, is skipped) [arg_value]

/// the library's options that take a value (`--size 800x600`): a program whose plain
/// arguments are files skips the value after these
VALUE_OPTS: &[&str] = &[ "--size", "--scale", "--auto-close", "--anim", "--them ...
  • fn crash_hook(f: Option<CrashHook>) f(&CrashInfo) runs in the crash handler, after the stderr line, before exit code 3; also for panics (CK_PANIC) [plat_crash_hook]

  • extern "C" fn crash_test() -> ! a deliberate crash for tests: mov eax, 16 (5 bytes), then a 4-byte write to address 0x10 -- the faulting instruction is at crash_test + 5

  • extern "C" fn crash_test_caller() -> ! (plat-win) crash_test called from a known place (call rel32): the return address crash_test_caller + 5 must be among CrashInfo::frames (plattest's call chain check)

  • extern "C" fn crash_test() -> ! Deliberate trap for browser runtime diagnostics.

  • extern "C" fn crash_test_caller() -> ! Deliberate trap through the compatibility caller API.

  • extern "C" fn crash_test() -> ! a deliberate crash for tests on ARM64 (Apple, Linux, Windows): x0 = 16, then a 4-byte write to address 0x10 -- the faulting instruction is at crash_test + 4

  • extern "C" fn crash_test_caller() -> ! crash_test called from a known place (bl): the return address crash_test_caller + 4 must be among CrashInfo::frames

  • extern "C" fn crash_test() -> ! Deliberate termination on Android, where no hardware exception translator is installed.

  • extern "C" fn crash_test_caller() -> ! Compatibility caller for the Android diagnostic termination.

Source: docs/API.md in the JFLib repository.