use crate::{ColIndex, GraphemeString, Length, RowIndex, SegIndex};
use std::borrow::Cow;
pub trait GraphemeDoc {
type Line<'a>: GraphemeString
where
Self: 'a;
type LineIterator<'a>: Iterator<Item = Self::Line<'a>> + 'a
where
Self: 'a;
fn line_count(&self) -> Length;
fn get_line(&self, row: RowIndex) -> Option<Self::Line<'_>>;
fn is_empty(&self) -> bool { self.line_count() == Length::from(0) }
fn total_bytes(&self) -> usize;
fn iter_lines(&self) -> Self::LineIterator<'_>;
fn as_str(&self) -> Cow<'_, str>;
fn as_bytes(&self) -> Cow<'_, [u8]>;
}
pub trait GraphemeDocMut: GraphemeDoc {
type DocMutResult;
fn add_line(&mut self) -> usize;
fn remove_line(&mut self, row: RowIndex) -> bool;
fn insert_line_with_buffer_shift(&mut self, line_idx: usize);
fn clear(&mut self);
fn insert_text_at_grapheme(
&mut self,
row: RowIndex,
seg_index: SegIndex,
text: &str,
) -> miette::Result<Self::DocMutResult>;
fn delete_range_at_grapheme(
&mut self,
row: RowIndex,
start_seg: SegIndex,
end_seg: SegIndex,
) -> miette::Result<Self::DocMutResult>;
fn insert_empty_line(&mut self, row: RowIndex) -> miette::Result<Self::DocMutResult>;
fn merge_lines(&mut self, row: RowIndex) -> miette::Result<Self::DocMutResult>;
fn split_line(
&mut self,
row: RowIndex,
col: ColIndex,
) -> miette::Result<Self::DocMutResult>;
}