diff options
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/commands.rs | 9 | ||||
-rw-r--r-- | helix-view/src/lib.rs | 1 | ||||
-rw-r--r-- | helix-view/src/prompt.rs | 18 |
3 files changed, 27 insertions, 1 deletions
diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs index 0e3f7ce8..6efbf98d 100644 --- a/helix-view/src/commands.rs +++ b/helix-view/src/commands.rs @@ -8,7 +8,10 @@ use helix_core::{ }; use once_cell::sync::Lazy; -use crate::view::{View, PADDING}; +use crate::{ + prompt::Prompt, + view::{View, PADDING}, +}; /// A command is a function that takes the current state and a count, and does a side-effect on the /// state (usually by creating and applying a transaction). @@ -478,6 +481,10 @@ pub mod insert { } } +pub fn insert_char_prompt(prompt: &mut Prompt, c: char) { + prompt.insert_char(c); +} + // Undo / Redo pub fn undo(view: &mut View, _count: usize) { diff --git a/helix-view/src/lib.rs b/helix-view/src/lib.rs index 2a000f32..e0a230ca 100644 --- a/helix-view/src/lib.rs +++ b/helix-view/src/lib.rs @@ -1,5 +1,6 @@ pub mod commands; pub mod keymap; +pub mod prompt; pub mod theme; pub mod view; diff --git a/helix-view/src/prompt.rs b/helix-view/src/prompt.rs new file mode 100644 index 00000000..4aaf770b --- /dev/null +++ b/helix-view/src/prompt.rs @@ -0,0 +1,18 @@ +use std::string::String; + +pub struct Prompt { + pub buffer: String, +} + +impl Prompt { + pub fn new() -> Prompt { + let prompt = Prompt { + buffer: String::from(""), + }; + prompt + } + + pub fn insert_char(&mut self, c: char) { + self.buffer.push(c); + } +} |