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//! - [`desktop`] — which program opens a file: the desktop's shared MIME database, the
67//!   installed programs' `.desktop` files and the person's defaults, read without drawing.
68//! - [`date`] — calendar dates, times of day and the local time zone offset.
69//! - [`uptime`] — the monotonic clocks that tell time awake from time the machine slept.
70//! - [`motion`] — easing, moving values and cell-stepped progress.
71//! - [`router`] — page navigation.
72//! - [`storage`] — settings saved as TOML in the platform config directory, checked against a
73//!   schema and optionally repaired; the config and data folders, atomic writes and the
74//!   one-instance lock every application needs around its own files.
75//! - [`document`] — an application's own data file: a schema'd TOML document that holds arrays
76//!   of tables and is never repaired behind the application's back.
77//!
78//! Every loader reports problems as [`diagnostics::Diagnostic`]s with file, line and column
79//! instead of failing, and built-in defaults are always available.
80
81pub mod animation;
82pub mod color;
83pub mod date;
84pub mod desktop;
85pub mod diagnostics;
86pub mod document;
87pub mod env;
88pub mod event;
89pub mod geometry;
90pub mod graphics;
91pub mod i18n;
92pub mod icons;
93pub mod keymap;
94pub mod motion;
95pub mod prelude;
96pub mod router;
97pub mod runtime;
98pub mod storage;
99pub mod style;
100pub mod text;
101pub mod theme;
102pub mod uptime;
103pub mod widget;
104pub mod widgets;
105
106mod assets;
107mod doc;
108
109/// Compiles and runs the example in the repository's README, so it cannot go stale.
110#[cfg(doctest)]
111#[doc = include_str!("../../../README.md")]
112struct ReadmeExample;