pub mod animation;
pub mod app;
pub mod buffer;
pub mod components;
pub mod element;
pub mod focus;
pub mod input;
pub mod layout;
pub mod log_update;
pub mod output;
pub mod reactive;
pub mod renderer;
pub mod style;
pub mod timeline;
#[cfg(feature = "async")]
pub mod async_runtime;
pub use animation::{lerp_rgb, lerp_u8, AnimationTimer, BlinkPattern, Easing, IndicatorStyle};
pub use app::{App, AppConfig, AppResult, ExitReason};
pub use buffer::{Buffer, Cell};
pub use components::{
alert, animated_indicator, animated_indicator_colored, badge, badge_bracket, bar_chart,
bar_chart_with_values, blink, blink_or, blink_pattern, blinking_dot, breadcrumbs,
breadcrumbs_path, checkbox, confirm_modal, confirm_prompt, countdown,
countdown_with_thresholds, diff_lines, divider, divider_with_label, error_modal, flex_spacer,
git_branch, gradient, gradient_preset, icons, key_hints, link, link_url, log_box,
markdown_block, progress_bar, progress_bar_bracketed, pulsing_dot, spacer, sparkline,
sparkline_labeled, spinner_frame, spinner_frame_interval, status_error, status_ok,
status_warning, stopwatch, success_modal, syntax_highlight, syntax_highlight_with_lines,
timer_display, transforms, tree_view, Autocomplete, AutocompleteItem, AutocompleteProps,
AutocompleteState, Badge, BadgeProps, BadgeStyle, BarChart, BarChartProps, BarData, BarStyle,
BorderChars, BorderColors, BorderSides, BorderStyle, Box, BoxProps, BreadcrumbSeparator,
Breadcrumbs, BreadcrumbsProps, CellAlign, Checkbox, CheckboxProps, CheckboxStyle, ColorStop,
ColumnWidth, Confirm, ConfirmProps, ConfirmStyle, Crumb, Diff, DiffLine, DiffLineType,
DiffProps, DiffStyle, Divider, DividerProps, DividerStyle, FilterMode, Gradient,
GradientPreset, GradientProps, Indent, IndentProps, KeyHint, KeyHintSeparator, KeyHintStyle,
KeyHints, KeyHintsProps, LineNumberStyle, Link, LinkProps, LogBox, LogBoxProps, LogLine,
Markdown, MarkdownProps, Modal, ModalButton, ModalProps, ModalStyle, MultiSelect,
MultiSelectItem, MultiSelectProps, MultiSelectState, MultiSelectStyle, Newline, NewlineProps,
Progress, ProgressChars, ProgressProps, ProgressStyle, Row, RowStyle, Select, SelectIndicator,
SelectItem, SelectProps, SelectState, Spacer, SpacerProps, Sparkline, SparklineProps,
SparklineStyle, Spinner, SpinnerProps, SpinnerStyle, Static, StaticItem, StaticProps,
StatusBar, StatusBarProps, StatusSegment, StatusSeparator, SyntaxHighlight,
SyntaxHighlightProps, SyntaxTheme, Tab, TabDivider, TabStyle, Table, TableCell, TableProps,
TableState, Tabs, TabsProps, TabsState, Text, TextInput, TextInputProps, TextInputState,
TextProps, TextWrap, TimeFormat, Timer, TimerMode, TimerProps, Transform, TransformFn,
TransformProps, TreeConnectors, TreeNode, TreeState, TreeStyle, TreeView, TreeViewProps,
ValueFormat,
};
pub use element::{Component, Element};
pub use focus::{FocusCallback, FocusEvent, FocusId, FocusManager, FocusState};
pub use input::{match_key, poll_key, read_key, Arrow, InputHandler, Key, KeyMatcher};
pub use layout::{
AlignContent, AlignItems, AlignSelf, Display, FlexDirection, FlexWrap, GridAutoFlow,
GridPlacement, JustifyContent, LayoutResult, LayoutStyle, LayoutTree, Overflow, Position,
TrackSize,
};
pub use log_update::LogUpdate;
pub use output::{Output, OutputResult};
pub use renderer::Blaeck;
pub use style::{rgb_to_256, supports_truecolor, Color, Modifier, Style};
pub use timeline::{
Act, Animatable, LoopBehavior, PlayingTimeline, Spring, SpringTrack, StaggerConfig,
StaggerOrder, StaggerTrack, Timeline, TimelineDebugInfo, TimelineState, Track,
};
#[cfg(feature = "async")]
pub use async_runtime::{
channel, poll_key_async, read_key_async, AppEvent, AsyncApp, AsyncAppConfig, Receiver, Sender,
};
pub use blaeck_macros::element;
pub fn print(element: Element) -> std::io::Result<()> {
let mut blaeck = Blaeck::new(std::io::stdout())?;
blaeck.render(element)?;
blaeck.unmount()
}
pub mod prelude {
pub use crate::animation::{AnimationTimer, BlinkPattern, Easing, IndicatorStyle};
pub use crate::components::{
alert, animated_indicator, animated_indicator_colored, badge, badge_bracket, bar_chart,
bar_chart_with_values, blink, blink_or, blink_pattern, blinking_dot, breadcrumbs,
breadcrumbs_path, checkbox, confirm_modal, confirm_prompt, countdown,
countdown_with_thresholds, diff_lines, divider, divider_with_label, error_modal,
flex_spacer, git_branch, gradient, gradient_preset, icons, key_hints, link, link_url,
log_box, markdown_block, progress_bar, progress_bar_bracketed, pulsing_dot, spacer,
sparkline, sparkline_labeled, spinner_frame, spinner_frame_interval, status_error,
status_ok, status_warning, stopwatch, success_modal, syntax_highlight,
syntax_highlight_with_lines, timer_display, transforms, tree_view, Autocomplete,
AutocompleteItem, AutocompleteProps, AutocompleteState, Badge, BadgeProps, BadgeStyle,
BarChart, BarChartProps, BarData, BarStyle, BorderChars, BorderColors, BorderSides,
BorderStyle, Box, BoxProps, BreadcrumbSeparator, Breadcrumbs, BreadcrumbsProps, CellAlign,
Checkbox, CheckboxProps, CheckboxStyle, ColorStop, ColumnWidth, Confirm, ConfirmProps,
ConfirmStyle, Crumb, Diff, DiffLine, DiffLineType, DiffProps, DiffStyle, Divider,
DividerProps, DividerStyle, FilterMode, Gradient, GradientPreset, GradientProps, Indent,
IndentProps, KeyHint, KeyHintSeparator, KeyHintStyle, KeyHints, KeyHintsProps,
LineNumberStyle, Link, LinkProps, LogBox, LogBoxProps, LogLine, Markdown, MarkdownProps,
Modal, ModalButton, ModalProps, ModalStyle, MultiSelect, MultiSelectItem, MultiSelectProps,
MultiSelectState, MultiSelectStyle, Newline, NewlineProps, Progress, ProgressChars,
ProgressProps, ProgressStyle, Row, RowStyle, Select, SelectIndicator, SelectItem,
SelectProps, SelectState, Spacer, SpacerProps, Sparkline, SparklineProps, SparklineStyle,
Spinner, SpinnerProps, SpinnerStyle, Static, StaticItem, StaticProps, StatusBar,
StatusBarProps, StatusSegment, StatusSeparator, SyntaxHighlight, SyntaxHighlightProps,
SyntaxTheme, Tab, TabDivider, TabStyle, Table, TableCell, TableProps, TableState, Tabs,
TabsProps, TabsState, Text, TextInput, TextInputProps, TextInputState, TextProps, TextWrap,
TimeFormat, Timer, TimerMode, TimerProps, Transform, TransformFn, TransformProps,
TreeConnectors, TreeNode, TreeState, TreeStyle, TreeView, TreeViewProps, ValueFormat,
};
pub use crate::element::{Component, Element};
pub use crate::layout::{
AlignContent, AlignItems, AlignSelf, Display, FlexDirection, FlexWrap, GridAutoFlow,
GridPlacement, JustifyContent, LayoutResult, LayoutStyle, Overflow, Position, TrackSize,
};
pub use crate::renderer::Blaeck;
pub use crate::style::{rgb_to_256, supports_truecolor, Color, Modifier, Style};
pub use crate::timeline::{
Act, Animatable, LoopBehavior, PlayingTimeline, Spring, SpringTrack, StaggerConfig,
StaggerOrder, StaggerTrack, Timeline, TimelineDebugInfo, Track,
};
pub use blaeck_macros::element;
#[cfg(feature = "async")]
pub use crate::async_runtime::{channel, AppEvent, AsyncApp, AsyncAppConfig, Receiver, Sender};
}
#[cfg(test)]
mod macro_tests {
use crate::prelude::*;
#[test]
fn test_macro_simple_text() {
let elem = element! {
Text(content: "Hello")
};
assert!(elem.is_node());
}
#[test]
fn test_macro_text_with_props() {
let elem = element! {
Text(content: "Styled", color: Color::Red, bold: true)
};
assert!(elem.is_node());
}
#[test]
fn test_macro_box_empty() {
let elem = element! {
Box
};
assert!(elem.is_node());
}
#[test]
fn test_macro_box_with_props() {
let elem = element! {
Box(flex_direction: FlexDirection::Row, padding: 2.0)
};
assert!(elem.is_node());
}
#[test]
fn test_macro_nested() {
let elem = element! {
Box {
Text(content: "A")
Text(content: "B")
}
};
assert!(elem.is_node());
assert_eq!(elem.children().len(), 2);
}
#[test]
fn test_macro_deeply_nested() {
let elem = element! {
Box(flex_direction: FlexDirection::Column) {
Box(flex_direction: FlexDirection::Row) {
Text(content: "Left")
Spacer
Text(content: "Right")
}
Text(content: "Bottom")
}
};
assert!(elem.is_node());
assert_eq!(elem.children().len(), 2);
}
#[test]
fn test_macro_spacer() {
let elem = element! {
Spacer
};
assert!(elem.is_node());
}
#[test]
fn test_macro_box_with_border() {
let elem = element! {
Box(border_style: BorderStyle::Single, padding: 1.0) {
Text(content: "Bordered")
}
};
assert!(elem.is_node());
assert_eq!(elem.children().len(), 1);
}
#[test]
fn test_macro_with_string_expression() {
let message = "Dynamic".to_string();
let elem = element! {
Text(content: message)
};
assert!(elem.is_node());
}
#[test]
fn test_macro_with_format() {
let count = 42;
let elem = element! {
Text(content: format!("Count: {}", count))
};
assert!(elem.is_node());
}
}