1#[macro_use]
2extern crate lazy_static;
3mod bterm;
4mod consoles;
5mod gamestate;
6mod hal;
7mod initializer;
8mod input;
9pub mod rex;
10pub use bracket_embedding::prelude::{embedded_resource, link_resource, EMBED};
11
12pub type BResult<T> = anyhow::Result<T, Box<dyn std::error::Error + Send + Sync>>;
13pub(crate) use input::clear_input_state;
14pub type FontCharType = u16;
15pub use consoles::console;
16
17#[cfg(all(
18 any(feature = "opengl", feature = "webgpu"),
19 any(feature = "crossterm", feature = "curses")
20))]
21compile_error!("Default features (opengl) must be disabled for other back-ends");
22
23pub mod prelude {
24
25 pub use crate::bterm::*;
26 pub use crate::consoles::*;
27 pub use crate::gamestate::GameState;
28 pub use crate::hal::{init_raw, BTermPlatform, Font, InitHints, Shader, BACKEND};
29 pub use crate::initializer::*;
30 pub use crate::input::{BEvent, Input, INPUT};
31 pub use crate::rex;
32 pub use crate::rex::*;
33 pub use crate::BResult;
34 pub use crate::FontCharType;
35 pub use bracket_color::prelude::*;
36 pub use bracket_embedding::prelude::{embedded_resource, link_resource, EMBED};
37 pub use bracket_geometry::prelude::*;
38 pub type BError = std::result::Result<(), Box<dyn std::error::Error + Send + Sync>>;
39
40 #[cfg(all(feature = "opengl", not(target_arch = "wasm32")))]
41 pub use glutin::event::VirtualKeyCode;
42
43 #[cfg(all(feature = "webgpu", not(feature = "opengl")))]
44 pub use crate::hal::VirtualKeyCode;
45
46 #[cfg(all(feature = "opengl", not(target_arch = "wasm32")))]
47 pub use crate::hal::GlCallback;
48
49 #[cfg(target_arch = "wasm32")]
50 pub use crate::hal::VirtualKeyCode;
51
52 #[cfg(feature = "curses")]
53 pub use crate::hal::VirtualKeyCode;
54
55 #[cfg(feature = "crossterm")]
56 pub use crate::hal::VirtualKeyCode;
57}
58
59#[macro_export]
60macro_rules! add_wasm_support {
61 () => {
62 #[cfg(target_arch = "wasm32")]
63 use wasm_bindgen::prelude::*;
64
65 #[cfg(target_arch = "wasm32")]
66 #[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
67 pub fn wasm_main() {
68 main().expect("Error in main");
69 }
70 };
71}