From c60f1a655333f41460e21a2e193734864f43211c Mon Sep 17 00:00:00 2001 From: Jan Hrastnik Date: Fri, 9 Oct 2020 22:55:45 +0200 Subject: created prompt.rs --- helix-view/src/commands.rs | 9 ++++++++- helix-view/src/lib.rs | 1 + helix-view/src/prompt.rs | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 helix-view/src/prompt.rs (limited to 'helix-view/src') 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); + } +} -- cgit v1.2.3-70-g09d2