Skip to main content

pixel8_console/
lib.rs

1//! The Pixel8 console as a library: the shell (boot prompt, mode machine,
2//! run loop), the five editors, build orchestration and web export —
3//! everything except presentation and input, which each frontend supplies.
4//!
5//! Two frontends drive it: the `pixel8` binary in this crate — whose
6//! windowed frontend (winit + wgpu) sits behind the default-on `window`
7//! feature, while its headless subcommands always build — and the
8//! `pixel8-tui` crate (sixel/half-block terminal rendering). Frontends
9//! that don't want the GPU stack depend on this crate with
10//! `default-features = false`; everything a frontend needs — ticking the
11//! [`shell::Shell`], feeding it keys and mouse state, presenting the
12//! framebuffer it draws — is exported here.
13
14pub mod builder;
15mod clipboard;
16mod editor;
17#[cfg(feature = "window")]
18pub mod gpu;
19pub mod shell;
20pub mod ui;
21mod watch;
22pub mod webexport;
23
24use std::{
25    path::{Path, PathBuf},
26    time::Duration,
27};
28
29/// One tick's wall-clock budget at a given rate (30 normally, 60 while a
30/// 60 fps cart runs).
31pub fn frame_duration(fps: u32) -> Duration {
32    Duration::from_nanos(1_000_000_000 / fps.max(1) as u64)
33}
34
35/// Where the `pixel8` SDK crate lives, for generated project manifests.
36/// Defaults to this source tree; override with PIXEL8_SDK for installs.
37pub fn sdk_path() -> PathBuf {
38    if let Ok(p) = std::env::var("PIXEL8_SDK") {
39        return PathBuf::from(p);
40    }
41    Path::new(env!("CARGO_MANIFEST_DIR")).join("../pixel8")
42}