[][src]Struct rslint_lexer::Highlighter

pub struct Highlighter<'s> {
    pub source: &'s str,
    // some fields omitted
}

A structure for syntax highlighting pieces of JavaScript source code using ANSI.

The highlighter will auto detect if stderr or stdout are terminals, if they are not then it will return the original uncolored source code. All errors encountered while lexing are ignored.

The highlighter is iterator based, which allows for coloring a part of code at a time. The highlighter's position can be controlled through various methods which allows for reuse of the highlighter without the need to rescan the source code

Fields

source: &'s str

Implementations

impl<'s> Highlighter<'s>[src]

pub fn new(source: &'s str) -> Highlighter<'s>

Notable traits for Highlighter<'s>

impl<'s> Iterator for Highlighter<'s> type Item = ANSIGenericString<'s, str>;
[src]

Make a new highlighter, this will invoke the lexer to get tokens.

pub fn reset(&mut self)[src]

Reset the highlighter to the start of the source code

pub fn color(&mut self) -> String[src]

Consume the rest of the highlighter's tokens and turn them into an ANSI colored string. This returns an unaltered string if stdout and stderr are not terminals.

Trait Implementations

impl<'s> Clone for Highlighter<'s>[src]

impl<'s> Debug for Highlighter<'s>[src]

impl<'s> Eq for Highlighter<'s>[src]

impl<'s> Hash for Highlighter<'s>[src]

impl<'s> Iterator for Highlighter<'s>[src]

type Item = ANSIGenericString<'s, str>

An individual colored token, you can see the color used by checking the string's style foreground

impl<'s> PartialEq<Highlighter<'s>> for Highlighter<'s>[src]

impl<'s> StructuralEq for Highlighter<'s>[src]

impl<'s> StructuralPartialEq for Highlighter<'s>[src]

Auto Trait Implementations

impl<'s> RefUnwindSafe for Highlighter<'s>

impl<'s> Send for Highlighter<'s>

impl<'s> Sync for Highlighter<'s>

impl<'s> Unpin for Highlighter<'s>

impl<'s> UnwindSafe for Highlighter<'s>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erasable for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.