Inital Commit
This commit is contained in:
33
src/ropeintegration.rs
Normal file
33
src/ropeintegration.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use eframe::egui::{self, scroll_area::State};
|
||||
use ropey;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ERopey {
|
||||
pub rope: ropey::Rope,
|
||||
viewbuffer: String,
|
||||
}
|
||||
|
||||
impl egui::widgets::TextBuffer for ERopey {
|
||||
fn is_mutable(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn as_str(&self) -> &str {
|
||||
self.rope.slice(..).as_str().unwrap()
|
||||
}
|
||||
|
||||
fn insert_text(&mut self, text: &str, char_index: usize) -> usize {
|
||||
let first = self.rope.len_chars();
|
||||
self.rope.insert(char_index, text);
|
||||
let second = self.rope.len_chars();
|
||||
second-first
|
||||
}
|
||||
|
||||
fn delete_char_range(&mut self, char_range: std::ops::Range<usize>) {
|
||||
self.rope.remove(char_range);
|
||||
}
|
||||
|
||||
fn type_id(&self) -> std::any::TypeId {
|
||||
std::any::TypeId::of::<Self>()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user