Skip to main content

theframework/
lib.rs

1pub mod theapp;
2pub mod thecolor;
3pub mod thecontext;
4pub mod thedim;
5pub mod thedraw2d;
6pub mod thenodecanvas;
7pub mod thepalette;
8pub mod thergbabuffer;
9pub mod thetime;
10pub mod thetrait;
11#[cfg(any(feature = "winit_app", feature = "winit_app_softbuffer"))]
12pub mod thewinitapp;
13#[cfg(any(feature = "winit_app", feature = "winit_app_softbuffer"))]
14mod thewinitbackend;
15
16#[cfg(feature = "ui")]
17pub mod theui;
18
19#[cfg(feature = "log")]
20pub mod thelogger;
21
22#[cfg(feature = "i18n")]
23pub mod thei18n;
24
25pub use crate::theapp::TheApp;
26pub use crate::thecontext::TheContext;
27pub use crate::thetrait::TheTrait;
28
29#[cfg(feature = "ui")]
30pub use crate::theui::TheUI;
31
32use rust_embed::RustEmbed;
33#[derive(RustEmbed)]
34#[folder = "embedded/"]
35#[exclude = "*.txt"]
36#[exclude = "*.DS_Store"]
37pub struct Embedded;
38pub use serde::{Deserialize, Serialize};
39
40#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
41pub enum TheKeyCode {
42    Escape,
43    Return,
44    Delete,
45    Home,
46    End,
47    Up,
48    Right,
49    Down,
50    Left,
51    Space,
52    Tab,
53}
54
55use ::serde::de::{self, Deserializer};
56use ::serde::ser::{self, Serializer};
57use flate2::{Compression, read::ZlibDecoder, write::ZlibEncoder};
58use std::io::{Read, Write};
59
60fn compress<S>(data: &[u8], serializer: S) -> Result<S::Ok, S::Error>
61where
62    S: Serializer,
63{
64    let mut encoder = ZlibEncoder::new(Vec::new(), Compression::default());
65    encoder.write_all(data).map_err(ser::Error::custom)?;
66    let compressed_data = encoder.finish().map_err(ser::Error::custom)?;
67
68    serializer.serialize_bytes(&compressed_data)
69}
70
71fn decompress<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
72where
73    D: Deserializer<'de>,
74{
75    let data = Vec::<u8>::deserialize(deserializer)?;
76    let mut decoder = ZlibDecoder::new(&data[..]);
77    let mut decompressed_data = Vec::new();
78    decoder
79        .read_to_end(&mut decompressed_data)
80        .map_err(de::Error::custom)?;
81
82    Ok(decompressed_data)
83}
84
85pub mod prelude {
86    pub use serde::{Deserialize, Serialize};
87
88    pub use crate::thedim::*;
89    pub use crate::thergbabuffer::{
90        TheRGBABuffer, TheRGBARegion, TheRGBARegionSequence, TheRGBATile,
91    };
92
93    pub use rustc_hash::*;
94    pub use uuid::Uuid;
95    pub use vek::*;
96
97    pub use crate::theapp::TheApp;
98    pub use crate::thecolor::TheColor;
99    pub use crate::thecontext::TheContext;
100    pub use crate::thecontext::TheCursorIcon;
101    pub use crate::thedraw2d::{
102        TheDraw2D, TheFontPreference, TheFontSettings, TheHorizontalAlign, TheVerticalAlign,
103    };
104    pub use crate::thenodecanvas::{TheNode, TheNodeCanvas, TheNodeTerminal};
105    pub use crate::thepalette::ThePalette;
106    pub use crate::thetime::TheTime;
107
108    pub use crate::TheKeyCode;
109    pub use crate::thetrait::TheTrait;
110
111    //#[cfg(feature = "renderer")]
112    //pub use therenderer::prelude::*;
113
114    #[cfg(feature = "ui")]
115    pub use crate::theui::prelude::*;
116
117    //#[cfg(feature = "code")]
118    //pub use crate::thecode::prelude::*;
119
120    #[cfg(feature = "log")]
121    pub use crate::thelogger::setup_logger;
122
123    #[cfg(any(feature = "winit_app", feature = "winit_app_softbuffer"))]
124    pub use crate::thewinitapp::run_winit_app;
125
126    #[cfg(feature = "i18n")]
127    pub use crate::thei18n::TheFontScript;
128}