sense specific buttons
This commit is contained in:
@@ -123,7 +123,20 @@ impl<'a> TextEditCtx<'a> {
|
||||
self.text.cursor = Some(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, text: &str) {
|
||||
let mut lines = text.split('\n');
|
||||
let Some(first) = lines.next() else {
|
||||
return;
|
||||
};
|
||||
self.insert_inner(first);
|
||||
for line in lines {
|
||||
self.newline();
|
||||
self.insert_inner(line);
|
||||
}
|
||||
}
|
||||
|
||||
fn insert_inner(&mut self, text: &str) {
|
||||
if let Some(cursor) = &mut self.text.cursor {
|
||||
let line = &mut self.text.buf.lines[cursor.line];
|
||||
let mut line_text = line.text().to_string();
|
||||
@@ -189,7 +202,7 @@ impl<'a> TextEditCtx<'a> {
|
||||
NamedKey::Backspace => self.backspace(),
|
||||
NamedKey::Delete => self.delete(),
|
||||
NamedKey::Space => self.insert(" "),
|
||||
NamedKey::Enter => self.newline(),
|
||||
NamedKey::Enter => self.insert("\n"),
|
||||
NamedKey::ArrowRight => self.motion(Motion::Right),
|
||||
NamedKey::ArrowLeft => self.motion(Motion::Left),
|
||||
NamedKey::ArrowUp => self.motion(Motion::Up),
|
||||
|
||||
Reference in New Issue
Block a user