diff options
author | Jan Hrastnik | 2020-10-09 20:55:45 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-10-16 02:59:09 +0000 |
commit | c60f1a655333f41460e21a2e193734864f43211c (patch) | |
tree | 581322c499546f03abb77e19455adaa73d3c4669 /helix-view/src | |
parent | 9e7b6465c6d4ce087af82ec07e41e19dbf4abdfb (diff) |
created prompt.rs
Diffstat (limited to 'helix-view/src')
-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); + } +} |