alma 0.1.0

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

use bevy::prelude::Component;

/// UTF-8 byte offset.
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd)]
pub struct ByteIndex(pub usize);

impl ByteIndex {
    /// Returns the raw byte index.
    pub const fn get(self) -> usize {
        self.0
    }
}

/// Cursor byte position in a view over an authoritative UTF-8 buffer.
#[derive(Clone, Copy, Component, Debug, Default, Eq, PartialEq)]
pub struct CursorPosition {
    /// UTF-8 boundary byte index.
    pub byte_index: ByteIndex,
    /// Preferred character column for repeated vertical movement.
    pub desired_column: Option<usize>,
}