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 and their arithmetic.
67//! - [`motion`] — easing, moving values and cell-stepped progress.
68//! - [`router`] — page navigation.
69//! - [`storage`] — settings saved as TOML in the platform config directory, checked against a
70//!   schema and optionally repaired.
71//!
72//! Every loader reports problems as [`diagnostics::Diagnostic`]s with file, line and column
73//! instead of failing, and built-in defaults are always available.
74
75pub mod animation;
76pub mod color;
77pub mod date;
78pub mod diagnostics;
79pub mod env;
80pub mod event;
81pub mod geometry;
82pub mod i18n;
83pub mod icons;
84pub mod keymap;
85pub mod motion;
86pub mod prelude;
87pub mod router;
88pub mod runtime;
89pub mod storage;
90pub mod style;
91pub mod text;
92pub mod theme;
93pub mod widget;
94pub mod widgets;
95
96mod assets;
97mod doc;
98
99/// Compiles and runs the example in the repository's README, so it cannot go stale.
100#[cfg(doctest)]
101#[doc = include_str!("../../../README.md")]
102struct ReadmeExample;