Skip to main content

qframe/
lib.rs

1//! Quvyta framework: build beautiful terminal applications.
2//!
3//! quvyta-framework is a framework for building terminal applications in Rust. It was started to
4//! design Quvyta's own applications and has grown into an open-source framework anyone can use.
5//!
6//! An application gives the framework three things: language files, theme files (with icon
7//! files), and components built in code. A default theme, icon set and English and Turkish
8//! strings are embedded, so an application runs without any files.
9//!
10//! An application is data, a `view` that draws it and an `update` that changes it:
11//!
12//! ```
13//! use qframe::prelude::*;
14//!
15//! #[derive(Default)]
16//! struct Counter {
17//!     count: i32,
18//! }
19//!
20//! #[derive(Clone)]
21//! enum Msg {
22//!     Increment,
23//! }
24//!
25//! impl App for Counter {
26//!     type Msg = Msg;
27//!
28//!     fn update(&mut self, msg: Msg) -> Command<Msg> {
29//!         match msg {
30//!             Msg::Increment => self.count += 1,
31//!         }
32//!         Command::none()
33//!     }
34//!
35//!     fn view(&self, ui: &mut View<'_, Msg>) {
36//!         ui.column(|ui| {
37//!             ui.add(Text::new(format!("Count: {}", self.count)));
38//!             ui.add(Button::new("Add one").variant("primary").on_press(Msg::Increment));
39//!         })
40//!         .gap(1);
41//!     }
42//! }
43//!
44//! // Tests drive the application without a terminal; a program calls
45//! // `Runtime::new(Counter::default()).run()` in `main` instead.
46//! let mut app = Harness::new(Counter::default(), 30, 4);
47//! app.press("tab").press("enter");
48//! assert!(app.screen().contains("Count: 1"));
49//! ```
50//!
51//! Modules:
52//!
53//! - [`prelude`] — the names nearly every application uses.
54//! - [`runtime`] — the [`App`](runtime::App) trait, commands, the terminal runtime, background
55//!   tasks and the test harness.
56//! - [`widget`] — the widget model, the view builder and layout.
57//! - [`widgets`] — ready-made widgets.
58//! - [`theme`] — colour tokens, motion values and CSS-like style rules; [`style`] and [`color`]
59//!   hold the resolved styles and colours widgets paint with.
60//! - [`icons`] — icon sets with Nerd Font, Unicode and ASCII glyphs; [`animation`] — one-cell
61//!   animations defined in icon sets and themes.
62//! - [`i18n`] — locales, plural forms and the [`t!`](crate::t!) macro.
63//! - [`keymap`] — named actions bound to key chords; [`event`] — key, mouse and paste events.
64//! - [`env`](mod@env) — the loaded theme, icons, language and keymap an application runs with.
65//! - [`geometry`] and [`text`] — rectangles and padding in cells, and text measured in cells.
66//! - [`date`] — calendar dates, times of day and the local time zone offset.
67//! - [`uptime`] — the monotonic clocks that tell time awake from time the machine slept.
68//! - [`motion`] — easing, moving values and cell-stepped progress.
69//! - [`router`] — page navigation.
70//! - [`storage`] — settings saved as TOML in the platform config directory, checked against a
71//!   schema and optionally repaired; the config and data folders, atomic writes and the
72//!   one-instance lock every application needs around its own files.
73//! - [`document`] — an application's own data file: a schema'd TOML document that holds arrays
74//!   of tables and is never repaired behind the application's back.
75//!
76//! Every loader reports problems as [`diagnostics::Diagnostic`]s with file, line and column
77//! instead of failing, and built-in defaults are always available.
78
79pub mod animation;
80pub mod color;
81pub mod date;
82pub mod diagnostics;
83pub mod document;
84pub mod env;
85pub mod event;
86pub mod geometry;
87pub mod i18n;
88pub mod icons;
89pub mod keymap;
90pub mod motion;
91pub mod prelude;
92pub mod router;
93pub mod runtime;
94pub mod storage;
95pub mod style;
96pub mod text;
97pub mod theme;
98pub mod uptime;
99pub mod widget;
100pub mod widgets;
101
102mod assets;
103mod doc;
104
105/// Compiles and runs the example in the repository's README, so it cannot go stale.
106#[cfg(doctest)]
107#[doc = include_str!("../../../README.md")]
108struct ReadmeExample;