pub struct TextBuffer {
pub rope: Rope,
pub version: u64,
pub kind: TextBufferKind,
}Expand description
Rope-backed authoritative text buffer for editable entities (W3.1).
- Attached alongside (and mirrored to)
crate::components::TextContenton<input>/<textarea>spawn (see the bootstrap system inlumen-text-edit). versionbumps on every successful edit so derived caches (shape, validation, syntax) can be invalidated withoutChanged<T>overuse.kindselects single-line vs multi-line semantics - single-line buffers reject\nat insert time (matches Qt’sQLineEdit::setText).
Fields§
§rope: RopeThe rope. Use [Self::as_str] / Self::slice for read access;
mutate only through lumen-text-edit::text_apply_edits.
version: u64Monotonic edit counter. Bump on every mutation.
kind: TextBufferKindSingle-line vs multiline policy.
Implementations§
Source§impl TextBuffer
impl TextBuffer
Sourcepub fn single_line(s: &str) -> Self
pub fn single_line(s: &str) -> Self
Build a single-line buffer from an initial string.
Sourcepub fn multi_line(s: &str) -> Self
pub fn multi_line(s: &str) -> Self
Build a multi-line buffer from an initial string.
Sourcepub fn slice(&self, range: Range<usize>) -> String
pub fn slice(&self, range: Range<usize>) -> String
Slice as a string. range is in bytes; out-of-range / non-boundary
inputs are clamped to the nearest valid char boundary.
Sourcepub fn is_single_line(&self) -> bool
pub fn is_single_line(&self) -> bool
true when the buffer is single-line (rejects \n at insert time).
Trait Implementations§
Source§impl Clone for TextBuffer
impl Clone for TextBuffer
Source§fn clone(&self) -> TextBuffer
fn clone(&self) -> TextBuffer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Component for TextBuffer
impl Component for TextBuffer
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
A constant indicating the storage type used for this component.
Source§type Mutability = Mutable
type Mutability = Mutable
A marker type to assist Bevy with determining if this component is
mutable, or immutable. Mutable components will have
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Registers required components. Read more
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Called when registering this component, allowing to override clone function (or disable cloning altogether) for this component. Read more
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
Returns [
ComponentRelationshipAccessor] required for working with relationships in dynamic contexts. Read more§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
Maps the entities on this component using the given
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSource§impl Debug for TextBuffer
impl Debug for TextBuffer
Source§impl Default for TextBuffer
impl Default for TextBuffer
Source§impl Display for TextBuffer
impl Display for TextBuffer
Source§impl From<&TextBuffer> for Arc<str>
Arc<str> snapshot of the buffer for binding-push (buffer -> signal).
impl From<&TextBuffer> for Arc<str>
Arc<str> snapshot of the buffer for binding-push (buffer -> signal).
Source§fn from(buf: &TextBuffer) -> Self
fn from(buf: &TextBuffer) -> Self
Converts to this type from the input type.
Source§impl From<&TextBuffer> for String
String snapshot.
impl From<&TextBuffer> for String
String snapshot.
Source§fn from(buf: &TextBuffer) -> Self
fn from(buf: &TextBuffer) -> Self
Converts to this type from the input type.
Source§impl From<&TextBuffer> for TextPos
impl From<&TextBuffer> for TextPos
Source§fn from(buf: &TextBuffer) -> Self
fn from(buf: &TextBuffer) -> Self
End-of-buffer.
Source§impl From<&str> for TextBuffer
Build a multi-line buffer from a string.
impl From<&str> for TextBuffer
Build a multi-line buffer from a string.
Auto Trait Implementations§
impl Freeze for TextBuffer
impl RefUnwindSafe for TextBuffer
impl Send for TextBuffer
impl Sync for TextBuffer
impl Unpin for TextBuffer
impl UnsafeUnpin for TextBuffer
impl UnwindSafe for TextBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Moves the components out of the bundle. Read more
§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
Applies the after-effects of spawning this bundle. Read more
§impl<T> FromTemplate for T
impl<T> FromTemplate for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
§impl<T> Template for T
impl<T> Template for T
§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
Uses this template and the given
entity context to produce a Template::Output.§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clones this template. See
Clone.