alma 0.1.0

A Bevy-native modal text editor with Vim-style navigation.
Documentation
//! Buffer ECS components.

use crate::text_stream::TextByteStream;
use bevy::prelude::{Component, Entity};

/// Typed ECS identity for an authoritative editor buffer entity.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct BufferEntity(pub Entity);

impl BufferEntity {
    /// Returns the raw Bevy entity.
    pub const fn get(self) -> Entity {
        self.0
    }
}

/// Typed ECS identity for an editor view entity.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct ViewEntity(pub Entity);

impl ViewEntity {
    /// Returns the raw Bevy entity.
    pub const fn get(self) -> Entity {
        self.0
    }
}

/// Marker for the current editor buffer entity.
#[derive(Clone, Copy, Component, Debug, Default, Eq, PartialEq)]
pub struct EditorBuffer;

/// Interactive editor view over an authoritative buffer.
#[derive(Clone, Copy, Component, Debug, Eq, PartialEq)]
pub struct EditorView {
    /// Buffer whose text and persistence state this view observes.
    pub buffer: BufferEntity,
}

/// Marker for the editor view currently receiving input and chrome sync.
#[derive(Clone, Copy, Component, Debug, Default, Eq, PartialEq)]
pub struct FocusedEditorView;

/// Authoritative text attached to an editor buffer entity.
#[derive(Clone, Component, Debug, Default, Eq, PartialEq)]
pub struct BufferText {
    /// Validated UTF-8 text stream.
    pub stream: TextByteStream,
}

/// Cached stream revision for systems that need cheap revision checks.
#[derive(Clone, Copy, Component, Debug, Default, Eq, PartialEq)]
pub struct BufferRevision {
    /// Monotonic buffer revision.
    pub revision: u64,
}