aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/prompt.rs
diff options
context:
space:
mode:
authorJan Hrastnik2020-10-12 22:23:48 +0000
committerBlaž Hrastnik2020-10-16 03:00:28 +0000
commited03ec92a825b8e42005f2f8506b0f3db4923fa5 (patch)
treec7e3da955be3e296c4f2f549fc91c1d4d47a1f3b /helix-view/src/prompt.rs
parent7208c86f23ac6d75aff62268cff73089c068cf74 (diff)
moved prompt command matching to prompt.rs
Diffstat (limited to 'helix-view/src/prompt.rs')
-rw-r--r--helix-view/src/prompt.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/helix-view/src/prompt.rs b/helix-view/src/prompt.rs
index 4aaf770b..f1920daa 100644
--- a/helix-view/src/prompt.rs
+++ b/helix-view/src/prompt.rs
@@ -1,13 +1,18 @@
+use crate::commands;
+use crate::View;
+use crossterm::event::{KeyCode, KeyEvent};
use std::string::String;
pub struct Prompt {
pub buffer: String,
+ pub cursor_loc: usize,
}
impl Prompt {
pub fn new() -> Prompt {
let prompt = Prompt {
- buffer: String::from(""),
+ buffer: String::from(":"), // starting prompt symbol
+ cursor_loc: 0,
};
prompt
}
@@ -15,4 +20,17 @@ impl Prompt {
pub fn insert_char(&mut self, c: char) {
self.buffer.push(c);
}
+
+ pub fn handle_keyevent(&mut self, key_event: KeyEvent, view: &mut View) {
+ match key_event {
+ KeyEvent {
+ code: KeyCode::Char(c),
+ ..
+ } => self.insert_char(c),
+ KeyEvent {
+ code: KeyCode::Esc, ..
+ } => commands::normal_mode(view, 1),
+ _ => (),
+ }
+ }
}