@@ -1,6 +1,6 @@
1use clap::ArgMatches as Args;
1use clap::ArgMatches as Args;
2use helix_core::{indent::TAB_WIDTH, state::Mode, syntax::HighlightEvent, Position, Range, State};
2use helix_core::{indent::TAB_WIDTH, state::Mode, syntax::HighlightEvent, Position, Range, State};
3−use helix_view::{commands, keymap, View};
3+use helix_view::{commands, keymap, prompt::Prompt, View};
6 borrow::Cow,
6 borrow::Cow,
@@ -36,6 +36,7 @@ pub struct Editor {
36 size: (u16, u16),
36 size: (u16, u16),
37 surface: Surface,
37 surface: Surface,
38 cache: Surface,
38 cache: Surface,
41impl Editor {
42impl Editor {
@@ -45,6 +46,7 @@ impl Editor {
45 let mut terminal = Terminal::new(backend)?;
46 let mut terminal = Terminal::new(backend)?;
46 let size = terminal::size().unwrap();
47 let size = terminal::size().unwrap();
47 let area = Rect::new(0, 0, size.0, size.1);
48 let area = Rect::new(0, 0, size.0, size.1);
49+ let prompt = Prompt::new();
49 let mut editor = Editor {
51 let mut editor = Editor {
@@ -52,6 +54,8 @@ impl Editor {
53 surface: Surface::empty(area),
55 surface: Surface::empty(area),
54 cache: Surface::empty(area),
56 cache: Surface::empty(area),
57+ // TODO; move to state
57 if let Some(file) = args.values_of_t::<PathBuf>("files").unwrap().pop() {
61 if let Some(file) = args.values_of_t::<PathBuf>("files").unwrap().pop() {
@@ -264,8 +268,14 @@ impl Editor {
264 Rect::new(0, self.size.1 - 1, self.size.0, 1),
268 Rect::new(0, self.size.1 - 1, self.size.0, 1),
265 view.theme.get("ui.statusline"),
269 view.theme.get("ui.statusline"),
271+ // render buffer text
272+ let buffer_string = &self.prompt.buffer;
274+ .set_string(2, self.size.1 - 1, buffer_string, text_color);
267 self.surface
276 self.surface
268 .set_string(1, self.size.1 - 1, mode, text_color);
277 .set_string(1, self.size.1 - 1, mode, text_color);
269 self.terminal
279 self.terminal
270 .backend_mut()
280 .backend_mut()
271 .draw(self.cache.diff(&self.surface).into_iter());
281 .draw(self.cache.diff(&self.surface).into_iter());
@@ -282,7 +292,7 @@ impl Editor {
282 mode => write!(stdout, "\x1B[2 q"),
292 mode => write!(stdout, "\x1B[2 q"),
284 if view.state.mode() == Mode::Command {
294 if view.state.mode() == Mode::Command {
285− pos = Position::new(self.size.0 as usize, 2);
295+ pos = Position::new(self.size.0 as usize, 2 + self.prompt.buffer.len());
287 if let Some(path) = view.state.path() {
297 if let Some(path) = view.state.path() {
288 self.surface
298 self.surface
@@ -349,12 +359,16 @@ impl Editor {
349 commands::insert::insert_char(view, c);
359 commands::insert::insert_char(view, c);
351 view.ensure_cursor_in_view();
361 view.ensure_cursor_in_view();
354 Mode::Command => {
363 Mode::Command => {
355 if let Some(command) = keymap[&Mode::Command].get(&keys) {
364 if let Some(command) = keymap[&Mode::Command].get(&keys) {
356 command(view, 1);
365 command(view, 1);
357− self.render();
366+ } else if let KeyEvent {
367+ code: KeyCode::Char(c),
371+ commands::insert_char_prompt(&mut self.prompt, c)
360 mode => {
374 mode => {
@@ -363,7 +377,6 @@ impl Editor {
364 // TODO: simplistic ensure cursor in view for now
378 // TODO: simplistic ensure cursor in view for now
365 view.ensure_cursor_in_view();
379 view.ensure_cursor_in_view();