pub struct Cursor<'a> {
pub err: &'a Option<ExprValidationError>,
pub txt: &'a str,
pub noderef: NodeRef,
pub auto: Option<String>,
/* private fields */
}
Expand description
A tokenizer cursor for ExprTK parsing.
Because ExprTK reports errors in column/row coordinates and visually needs
to be applied to an entire token rather than a single character, we need
fairly obnoxious counter logic to figure out how to generate the resulting
syntax-highlighted HTML. The Counter<'a>
struct encpsulates this logic,
generating a NodeRef
to any autocomplete-able <span>
tokens, as well
as other convenient data for HTML rendering, and can be called incrementally
while iterating tokens after parsing.
Fields§
§err: &'a Option<ExprValidationError>
§txt: &'a str
§noderef: NodeRef
§auto: Option<String>
Implementations§
Source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
pub fn new(err: &'a Option<ExprValidationError>) -> Self
Sourcepub const fn is_error(&self) -> bool
pub const fn is_error(&self) -> bool
Is the cursor currently overlapping a token with an error?
Sourcepub const fn is_autocomplete(&self, position: u32) -> bool
pub const fn is_autocomplete(&self, position: u32) -> bool
Is the cursor currently overlapping an autocomplete-able token?
Sourcepub fn map_rows<T, F: Fn(u32) -> T>(self, f: F) -> impl Iterator<Item = T>
pub fn map_rows<T, F: Fn(u32) -> T>(self, f: F) -> impl Iterator<Item = T>
TODO this is alot of type backage for what could just be num_rows()
.
Sourcepub fn increment_column(&mut self, size: u32)
pub fn increment_column(&mut self, size: u32)
Increment the counter column by size
characters.
Sourcepub fn increment_line(&mut self)
pub fn increment_line(&mut self)
Increment to the next line, typewriter-style.
Auto Trait Implementations§
impl<'a> Freeze for Cursor<'a>
impl<'a> !RefUnwindSafe for Cursor<'a>
impl<'a> !Send for Cursor<'a>
impl<'a> !Sync for Cursor<'a>
impl<'a> Unpin for Cursor<'a>
impl<'a> !UnwindSafe for Cursor<'a>
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<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> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self
to a value of a Properties
struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self
to a value of a Properties
struct.