pub struct DrawnTranscript { /* private fields */ }Expand description
The transcript as the view drew it at its last frame: every row laid
out, on screen or not, as drawn (wrapped, as its renderer drew it),
with the items they belong to and the matches the view lit in each. A
plugin counts and scrolls over this, not over the source text.
TranscriptLayout lays one out without
drawing it, for any agent; a plugin’s test, with no terminal to draw,
inserts such a one as this resource.
It costs nothing until a plugin adds it to a pane. From then on, each
frame that lays out the pane, in
TuiSystems::Layout, copies the text of
every row of it, and with TranscriptView::highlights set counts
their matches in each, so its work and memory grow with the
transcript; a streaming reply draws at most about 30 frames a second.
Frames that draw the same rows leave it unchanged, so
Ref::is_changed says what is drawn changed.
use rig_harness::prelude::*;
use rig_tui::{DrawnTranscript, ItemRow, ScrollTo, TranscriptItem};
/// Shows the first item with a lit match, by its first one.
fn first_match(panes: Query<(Entity, Ref<DrawnTranscript>)>, mut commands: Commands) {
for (pane, drawn) in panes.iter().filter(|(_, drawn)| drawn.is_changed()) {
let mut lit = drawn.items().iter().filter(|(item, _)| drawn.lit_in(item) > 0);
if let Some((item, _)) = lit.next() {
commands.trigger(ScrollTo { pane, item: Some(item.clone()), row: ItemRow::Lit(0) });
}
}
}Implementations§
Source§impl DrawnTranscript
impl DrawnTranscript
Sourcepub fn agent(&self) -> Option<Entity>
pub fn agent(&self) -> Option<Entity>
The agent whose transcript it is; None for a conversation no
agent holds, or with no agent shown, when the pane draws the
notices about every agent.
Sourcepub fn area(&self) -> Rect
pub fn area(&self) -> Rect
Where its rows on screen are drawn: the first at the top; empty in one laid out without drawing it.
Sourcepub fn lines(&self) -> impl Iterator<Item = DrawnLine> + '_
pub fn lines(&self) -> impl Iterator<Item = DrawnLine> + '_
Its lines as they were before the view wrapped them, top to bottom, each with its rows. Text a wrap split across two rows is whole here, for a search or a copy.
Sourcepub fn items(&self) -> &[(TranscriptItem, Range<usize>)]
pub fn items(&self) -> &[(TranscriptItem, Range<usize>)]
Each item’s rows, top to bottom by first row. An item’s rows hold those of the items drawn inside it: a message’s, its calls and the notices and notes written inside it. Rows of no item, such as the reply streaming in, are in none.
Sourcepub fn rows_of(&self, item: &TranscriptItem) -> Option<Range<usize>>
pub fn rows_of(&self, item: &TranscriptItem) -> Option<Range<usize>>
The rows of item, or None when it is not drawn.
Sourcepub fn item_at(&self, row: usize) -> Option<&TranscriptItem>
pub fn item_at(&self, row: usize) -> Option<&TranscriptItem>
The innermost item row belongs to, such as a call rather than
its message, or a decorator’s rows rather than their call.
Sourcepub fn lit_in(&self, item: &TranscriptItem) -> usize
pub fn lit_in(&self, item: &TranscriptItem) -> usize
How many matches of every highlight the view lit in item’s rows:
n in ItemRow::Lit counts these, so it finds a row for each n
below this.
Sourcepub fn on_screen(&self) -> Range<usize> ⓘ
pub fn on_screen(&self) -> Range<usize> ⓘ
The rows on screen; none in one laid out without drawing it.
Sourcepub fn item(&self, item: &TranscriptItem) -> Option<Self>
pub fn item(&self, item: &TranscriptItem) -> Option<Self>
Only item’s rows, as a transcript of their own: its rows from 0,
the items drawn in it, and its rows on screen.
None when it is not drawn.
Trait Implementations§
Source§impl Clone for DrawnTranscript
impl Clone for DrawnTranscript
Source§impl Component for DrawnTranscript
impl Component for DrawnTranscript
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
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<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§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,
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§const HAS_SUMMARY_TICK: bool = false
const HAS_SUMMARY_TICK: bool = false
Source§impl Debug for DrawnTranscript
impl Debug for DrawnTranscript
Source§impl Default for DrawnTranscript
impl Default for DrawnTranscript
impl Eq for DrawnTranscript
Source§impl PartialEq for DrawnTranscript
impl PartialEq for DrawnTranscript
impl StructuralPartialEq for DrawnTranscript
Auto Trait Implementations§
impl Freeze for DrawnTranscript
impl RefUnwindSafe for DrawnTranscript
impl Send for DrawnTranscript
impl Sync for DrawnTranscript
impl Unpin for DrawnTranscript
impl UnsafeUnpin for DrawnTranscript
impl UnwindSafe for DrawnTranscript
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
Source§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§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
Source§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
Source§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FromTemplate for T
impl<T> FromTemplate for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Template for T
impl<T> Template for T
Source§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>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
self.