beamterm_core/lib.rs
1//! # Stability Policy
2//!
3//! beamterm-core's public API includes types from the following third-party crates:
4//!
5//! | Crate | Types exposed | Re-exported as |
6//! |-----------------|---------------------------------------------------------------------------------|---------------------------------------------|
7//! | [`glow`] | [`glow::Context`] in method parameters and [`RenderContext::gl`] | [`beamterm_core::glow`](glow) |
8//! | [`compact_str`] | [`CompactString`](compact_str::CompactString) in return types and struct fields | [`beamterm_core::compact_str`](compact_str) |
9//!
10//! These crates are re-exported so that downstream users can depend on
11//! `beamterm_core::glow` and `beamterm_core::compact_str` without adding
12//! separate dependencies or worrying about version mismatches.
13//!
14//! **Semver policy**: A dependency version bump (e.g. glow 0.17 to 0.18) is
15//! only considered a beamterm breaking change if the type signatures used in
16//! beamterm's public API actually change. A version bump that preserves the
17//! same type signatures is a compatible update.
18
19pub(crate) mod error;
20/// OpenGL rendering engine, atlas management, and terminal grid.
21pub mod gl;
22mod mat4;
23mod position;
24mod url;
25
26// Re-export third-party crates that appear in beamterm-core's public API.
27// This allows downstream users to use `beamterm_core::glow` and
28// `beamterm_core::compact_str` without adding separate dependencies
29// or worrying about version mismatches.
30pub use ::beamterm_data::{
31 CellSize, DebugSpacePattern, FontAtlasData, GlyphEffect, SerializationError, TerminalSize,
32};
33pub use beamterm_data::FontStyle;
34pub use beamterm_unicode::{is_double_width, is_emoji};
35pub use compact_str;
36pub use error::Error;
37pub use gl::{
38 Atlas, CellData, CellDynamic, CellIterator, CellQuery, Drawable, FontAtlas, GlState, GlyphSlot,
39 GlyphTracker, RenderContext, SelectionMode, SelectionTracker, StaticFontAtlas, TerminalGrid,
40 select,
41};
42#[cfg(feature = "native-dynamic-atlas")]
43pub use gl::{NativeDynamicAtlas, NativeGlyphRasterizer};
44pub use glow;
45pub use position::CursorPosition;
46pub use url::{UrlMatch, find_url_at_cursor};
47
48/// GL shader language target for version injection.
49#[derive(Debug, Clone, Copy, PartialEq, Eq)]
50#[non_exhaustive]
51pub enum GlslVersion {
52 /// WebGL2 / OpenGL ES 3.0: `#version 300 es`
53 Es300,
54 /// OpenGL 3.3 Core: `#version 330 core`
55 Gl330,
56}
57
58impl GlslVersion {
59 /// Returns the GLSL preamble for vertex shaders.
60 #[must_use]
61 pub fn vertex_preamble(&self) -> &'static str {
62 match self {
63 Self::Es300 => "#version 300 es\nprecision highp float;\n",
64 Self::Gl330 => "#version 330 core\n",
65 }
66 }
67
68 /// Returns the GLSL preamble for fragment shaders.
69 #[must_use]
70 pub fn fragment_preamble(&self) -> &'static str {
71 match self {
72 Self::Es300 => "#version 300 es\nprecision mediump float;\nprecision highp int;\n",
73 Self::Gl330 => "#version 330 core\n",
74 }
75 }
76}
77
78#[cfg(test)]
79mod tests {
80 use super::*;
81
82 #[test]
83 fn test_font_atlas_config_deserialization() {
84 let _ = FontAtlasData::default();
85 }
86}