use crate::{cursor::{MutCursor, Cursor}, flext::Flext};
pub struct Lext {
pub cursor: MutCursor,
pub current: Option<char>,
}
impl Lext {
#[inline]
pub fn new(file_name: String, contents: &str) -> Self {
let cursor = MutCursor::new(Cursor::new(file_name, contents));
let current = cursor.pos_end.get_char();
Self {
cursor,
current,
}
}
#[inline]
pub fn rposition(&self) -> crate::cursor::Position {
let mut clone = self.cursor.clone();
clone.revance();
clone.position()
}
}
impl Flext for Lext {
#[inline]
fn advance(&mut self) {
self.cursor.advance();
self.current = self.cursor.current_char;
}
#[inline]
fn revance(&mut self) {
self.cursor.revance();
self.current = self.cursor.current_char;
}
#[inline]
fn spawn(&self) -> Self {
Self {
cursor: self.cursor.spawn(),
current: self.current,
}
}
#[inline]
fn position(&self) -> crate::cursor::Position {
self.cursor.position()
}
}