@@ -1,6 +1,6 @@
1use crate::commands;
1use crate::commands;
2use crate::View;
2use crate::View;
3−use crossterm::event::{KeyCode, KeyEvent};
3+use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
4use std::string::String;
4use std::string::String;
6pub struct Prompt {
6pub struct Prompt {
@@ -22,18 +22,26 @@ impl Prompt {
22 self.cursor_loc += 1;
22 self.cursor_loc += 1;
25− pub fn move_char_left_prompt(&mut self) {
25+ pub fn move_char_left(&mut self) {
26 if self.cursor_loc > 1 {
26 if self.cursor_loc > 1 {
27 self.cursor_loc -= 1;
27 self.cursor_loc -= 1;
31− pub fn move_char_right_prompt(&mut self) {
31+ pub fn move_char_right(&mut self) {
32 if self.cursor_loc < self.buffer.len() {
32 if self.cursor_loc < self.buffer.len() {
33 self.cursor_loc += 1;
33 self.cursor_loc += 1;
37+ pub fn move_start(&mut self) {
41+ pub fn move_end(&mut self) {
42+ self.cursor_loc = self.buffer.len();
37 pub fn delete_char_backwards(&mut self) {
45 pub fn delete_char_backwards(&mut self) {
38 if self.cursor_loc > 0 {
46 if self.cursor_loc > 0 {
39 self.buffer.remove(self.cursor_loc - 1);
47 self.buffer.remove(self.cursor_loc - 1);
@@ -41,11 +49,15 @@ impl Prompt {
52+ pub fn success_fn() {
44 pub fn handle_input(&mut self, key_event: KeyEvent, view: &mut View) {
56 pub fn handle_input(&mut self, key_event: KeyEvent, view: &mut View) {
45 match key_event {
57 match key_event {
46 KeyEvent {
58 KeyEvent {
47 code: KeyCode::Char(c),
59 code: KeyCode::Char(c),
48− ..
60+ modifiers: KeyModifiers::NONE,
49 } => self.insert_char(c),
61 } => self.insert_char(c),
50 KeyEvent {
62 KeyEvent {
51 code: KeyCode::Esc, ..
63 code: KeyCode::Esc, ..
@@ -53,11 +65,19 @@ impl Prompt {
53 KeyEvent {
65 KeyEvent {
54 code: KeyCode::Right,
66 code: KeyCode::Right,
56− } => self.move_char_right_prompt(),
68+ } => self.move_char_right(),
57 KeyEvent {
69 KeyEvent {
58 code: KeyCode::Left,
70 code: KeyCode::Left,
60− } => self.move_char_left_prompt(),
72+ } => self.move_char_left(),
74+ code: KeyCode::Char('e'),
75+ modifiers: KeyModifiers::CONTROL,
76+ } => self.move_end(),
78+ code: KeyCode::Char('a'),
79+ modifiers: KeyModifiers::CONTROL,
80+ } => self.move_start(),
61 KeyEvent {
81 KeyEvent {
62 code: KeyCode::Backspace,
82 code: KeyCode::Backspace,