A simple CPU rendered GUI IDE experience.
Diffstat (limited to 'src/text.rs')
-rw-r--r--src/text.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/text.rs b/src/text.rs
index cb6518a..1f92481 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -7,6 +7,7 @@ use ropey::Rope;
use tree_sitter_highlight::{
HighlightConfiguration, HighlightEvent, Highlighter,
};
+use winit::keyboard::SmolStr;
#[rustfmt::skip]
const NAMES: [&str; 13] = ["attribute", "comment", "constant", "function", "keyword", "number", "operator", "punctuation",
"string", "tag", "type", "variable", "variable.parameter"];
@@ -34,7 +35,7 @@ const fn color(x: &[u8; 6]) -> [u8; 3] {
#[derive(Default)]
pub struct TextArea {
- rope: Rope,
+ pub rope: Rope,
pub cursor: usize,
highlighter: Highlighter,
column: usize,
@@ -46,8 +47,13 @@ impl TextArea {
self.rope.len_lines()
}
+ pub fn insert_(&mut self, c: SmolStr) {
+ self.rope.insert(self.cursor, &c);
+ self.cursor += c.chars().count();
+ self.setc();
+ }
pub fn insert(&mut self, c: &str) {
- self.rope.insert(self.cursor, c);
+ self.rope.insert(self.cursor, &c);
self.cursor += c.chars().count();
self.setc();
}