aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/prompt.rs
diff options
context:
space:
mode:
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),
+ _ => (),
+ }
+ }
}