mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-27 19:26:09 +00:00
Update doc for theme module
This commit is contained in:
parent
0097789d46
commit
c84bbbdf45
118
src/theme/mod.rs
118
src/theme/mod.rs
@ -1,79 +1,117 @@
|
|||||||
//! Handle colors and themes in the UI.
|
//! Handle colors and themes in the UI.
|
||||||
//!
|
//!
|
||||||
//! # Color palette
|
//! # Colors
|
||||||
|
//!
|
||||||
|
//! Characters can be printed in the terminal with a specific color.
|
||||||
|
//! The [`Color`] enum represents the ways this can be set.
|
||||||
|
//!
|
||||||
|
//! [`Color`]: enum.Color.html
|
||||||
|
//!
|
||||||
|
//! # Palette
|
||||||
//!
|
//!
|
||||||
//! To achieve a customizable, yet unified look, Cursive uses a configurable
|
//! To achieve a customizable, yet unified look, Cursive uses a configurable
|
||||||
//! palette of colors to be used through the entire application.
|
//! palette of colors to be used through the entire application.
|
||||||
//!
|
//!
|
||||||
//! These colors are:
|
//! The [`PaletteColor`] enum defines possible entries in this palette.
|
||||||
//!
|
//!
|
||||||
//! * **`background`**: used to color the application background
|
//! [`PaletteColor`]: enum.PaletteColor.html
|
||||||
|
//!
|
||||||
|
//! These entries are:
|
||||||
|
//!
|
||||||
|
//! * **`Background`**: used to color the application background
|
||||||
//! (around views).
|
//! (around views).
|
||||||
//! Defaults to **blue**.
|
//! Defaults to **blue**.
|
||||||
//! * **`shadow`**: used to color shadow around views.
|
//! * **`Shadow`**: used to color shadow around views.
|
||||||
//! Defaults to **black**.
|
//! Defaults to **black**.
|
||||||
//! * **`view`**: used to color the background for views.
|
//! * **`View`**: used to color the background for views.
|
||||||
//! Defaults to **white**.
|
//! Defaults to **white**.
|
||||||
//! * **`primary`**: used to print primary text.
|
//! * **`Primary`**: used to print primary text.
|
||||||
//! Defaults to **black**.
|
//! Defaults to **black**.
|
||||||
//! * **`secondary`**: used to print secondary text.
|
//! * **`Secondary`**: used to print secondary text.
|
||||||
//! Defaults to **blue**.
|
//! Defaults to **blue**.
|
||||||
//! * **`tertiary`**: used to print tertiary text.
|
//! * **`Tertiary`**: used to print tertiary text.
|
||||||
//! Defaults to **white**.
|
//! Defaults to **white**.
|
||||||
//! * **`title_primary`**: used to print primary titles.
|
//! * **`TitlePrimary`**: used to print primary titles.
|
||||||
//! Defaults to **red**.
|
//! Defaults to **red**.
|
||||||
//! * **`title_secondary`**: used to print secondary titles.
|
//! * **`TitleSecondary`**: used to print secondary titles.
|
||||||
//! Defaults to **yellow**.
|
//! Defaults to **yellow**.
|
||||||
//! * **`highlight`**: used to highlight selected items.
|
//! * **`Highlight`**: used to highlight selected items.
|
||||||
//! Defaults to **red**.
|
//! Defaults to **red**.
|
||||||
//! * **`highlight_inactive`**: used to highlight selected but inactive items.
|
//! * **`HighlightInactive`**: used to highlight selected but inactive items.
|
||||||
//! Defaults to **blue**.
|
//! Defaults to **blue**.
|
||||||
//!
|
//!
|
||||||
|
//! A [`Palette`] then maps each of these to an actual [`Color`].
|
||||||
|
//!
|
||||||
|
//! [`Palette`]: struct.Palette.html
|
||||||
|
//! [`Color`]: enum.Color.html
|
||||||
|
//!
|
||||||
|
//! # Color Types
|
||||||
|
//!
|
||||||
|
//! When drawing views, color can be picked in two way:
|
||||||
|
//!
|
||||||
|
//! * An exact [`Color`] can be given directly
|
||||||
|
//! * A [`PaletteColor`] entry can be given, which will fetch whatever color
|
||||||
|
//! is currently defined for this.
|
||||||
|
//!
|
||||||
|
//! The [`ColorType`] enum abstract over these two choices.
|
||||||
|
//!
|
||||||
|
//! [`ColorType`]: enum.ColorType.html
|
||||||
|
//!
|
||||||
//! # Color Styles
|
//! # Color Styles
|
||||||
//!
|
//!
|
||||||
//! Each cell of the terminal uses two colors: *foreground* and *background*.
|
//! To actually print anything, two colors must be picked: one for the
|
||||||
|
//! foreground, and one for the background.
|
||||||
//!
|
//!
|
||||||
//! Color styles are defined to easily refer to a pair of colors from the
|
//! As such, a [`ColorStyle`] is made of a pair of `ColorType`.
|
||||||
//! palette.
|
|
||||||
//!
|
//!
|
||||||
//! * **`Background`**: style used to print the application background.
|
//! Since some pairs are frequently used, `ColorStyle` defines some methods to
|
||||||
//! * Its *background* color is `background`.
|
//! create these usual values:
|
||||||
|
//!
|
||||||
|
//! * **`ColorStyle::background()`**: style used to print the application background.
|
||||||
|
//! * Its *background* color is `Background`.
|
||||||
//! * Its *foreground* color is unimportant as no characters are ever
|
//! * Its *foreground* color is unimportant as no characters are ever
|
||||||
//! printed in the background.
|
//! printed in the background.
|
||||||
//! * **`Shadow`**: style used to print shadows behind views.
|
//! * **`ColorStyle::shadow()`**: style used to print shadows behind views.
|
||||||
//! * Its *background* color is `shadow`.
|
//! * Its *background* color is `Shadow`.
|
||||||
//! * Here again, the *foreground* color is unimportant.
|
//! * Here again, the *foreground* color is unimportant.
|
||||||
//! * **`Primary`**: style used to print primary text.
|
//! * **`ColorStyle::primary()`**: style used to print primary text.
|
||||||
//! * Its *background* color is `view`.
|
//! * Its *background* color is `View`.
|
||||||
//! * Its *foreground* color is `primary`.
|
//! * Its *foreground* color is `Primary`.
|
||||||
//! * **`Secondary`**: style used to print secondary text.
|
//! * **`ColorStyle::secondary()`**: style used to print secondary text.
|
||||||
//! * Its *background* color is `view`.
|
//! * Its *background* color is `View`.
|
||||||
//! * Its *foreground* color is `secondary`.
|
//! * Its *foreground* color is `Secondary`.
|
||||||
//! * **`Tertiary`**: style used to print tertiary text.
|
//! * **`ColorStyle::tertiary()`**: style used to print tertiary text.
|
||||||
//! * Its *background* color is `view`.
|
//! * Its *background* color is `View`.
|
||||||
//! * Its *foreground* color is `tertiary`.
|
//! * Its *foreground* color is `Tertiary`.
|
||||||
//! * **`TitlePrimary`**: style used to print titles.
|
//! * **`ColorStyle::title_primary()`**: style used to print titles.
|
||||||
//! * Its *background* color is `view`.
|
//! * Its *background* color is `View`.
|
||||||
//! * Its *foreground* color is `title_primary`.
|
//! * Its *foreground* color is `TitlePrimary`.
|
||||||
//! * **`TitleSecondary`**: style used to print secondary titles.
|
//! * **`ColorStyle::title_secondary()`**: style used to print secondary titles.
|
||||||
//! * Its *background* color is `view`.
|
//! * Its *background* color is `View`.
|
||||||
//! * Its *foreground* color is `title_secondary`.
|
//! * Its *foreground* color is `TitleSecondary`.
|
||||||
//! * **`Highlight`**: style used to print selected items.
|
//! * **`ColorStyle::highlight()`**: style used to print selected items.
|
||||||
//! * Its *background* color is `highlight`.
|
//! * Its *background* color is `Highlight`.
|
||||||
//! * Its *foreground* color is `view`.
|
//! * Its *foreground* color is `View`.
|
||||||
//! * **`HighlightInactive`**: style used to print selected,
|
//! * **`ColorStyle::highlight_inactive()`**: style used to print selected,
|
||||||
//! but inactive items.
|
//! but inactive items.
|
||||||
//! * Its *background* color is `highlight_inactive`.
|
//! * Its *background* color is `HighlightInactive`.
|
||||||
//! * Its *foreground* color is `view`.
|
//! * Its *foreground* color is `View`.
|
||||||
//!
|
//!
|
||||||
//! Using one of these pairs when styling your application helps give it a
|
//! Using one of these pairs when styling your application helps give it a
|
||||||
//! coherent look.
|
//! coherent look.
|
||||||
//!
|
//!
|
||||||
|
//! [`ColorStyle`]: struct.ColorStyle.html
|
||||||
|
//!
|
||||||
//! # Effects
|
//! # Effects
|
||||||
//!
|
//!
|
||||||
//! On top of a color style, some effects can be applied on cells: `Reverse`,
|
//! On top of a color style, some effects can be applied on cells: `Reverse`,
|
||||||
//! for instance, swaps the foreground and background colors of a cell.
|
//! for instance, swaps the foreground and background colors of a cell.
|
||||||
//!
|
//!
|
||||||
|
//! # Style
|
||||||
|
//!
|
||||||
|
//! Finally, a style combine a [`ColorType`] and a set of [`Effect`]s, to
|
||||||
|
//! represent any way text should be printed on screen.
|
||||||
|
//!
|
||||||
//! # Themes
|
//! # Themes
|
||||||
//!
|
//!
|
||||||
//! A theme defines the color palette an application will use, as well as
|
//! A theme defines the color palette an application will use, as well as
|
||||||
|
Loading…
Reference in New Issue
Block a user