@@ -34,6 +34,8 @@ type Terminal = tui::Terminal<CrosstermBackend<std::io::Stdout>>;
35static EX: smol::Executor = smol::Executor::new();
35static EX: smol::Executor = smol::Executor::new();
37+const BASE_WIDTH: u16 = 30;
37pub struct Application {
39pub struct Application {
38 editor: Editor,
40 editor: Editor,
39 prompt: Option<Prompt>,
41 prompt: Option<Prompt>,
@@ -235,7 +237,52 @@ impl Renderer {
235 .set_string(1, self.size.1 - 2, mode, self.text_color);
237 .set_string(1, self.size.1 - 2, mode, self.text_color);
238− pub fn render_prompt(&mut self, prompt: &Prompt) {
240+ pub fn render_prompt(&mut self, view: &View, prompt: &Prompt) {
242+ if !prompt.completion.is_empty() {
243+ // TODO: find out better way of clearing individual lines of the screen
246+ let max_col = self.size.0 / BASE_WIDTH;
247+ let col_height = ((prompt.completion.len() as u16 + max_col - 1) / max_col);
249+ for i in (3..col_height + 3) {
250+ self.surface.set_string(
252+ self.size.1 - i as u16,
253+ " ".repeat(self.size.0 as usize),
257+ self.surface.set_style(
258+ Rect::new(0, self.size.1 - col_height - 2, self.size.0, col_height),
259+ view.theme.get("ui.statusline"),
261+ for (i, command) in prompt.completion.iter().enumerate() {
262+ let color = if prompt.completion_selection_index.is_some()
263+ && i == prompt.completion_selection_index.unwrap()
265+ Style::default().bg(Color::Rgb(104, 060, 232))
269+ self.surface.set_stringn(
270+ 1 + col * BASE_WIDTH,
271+ self.size.1 - col_height - 2 + row,
273+ BASE_WIDTH as usize - 1,
277+ if row > col_height - 1 {
239 // render buffer text
286 // render buffer text
240 self.surface
287 self.surface
241 .set_string(1, self.size.1 - 1, &prompt.prompt, self.text_color);
288 .set_string(1, self.size.1 - 1, &prompt.prompt, self.text_color);
@@ -309,10 +356,13 @@ impl Application {
310 if let Some(view) = &mut self.editor.view {
357 if let Some(view) = &mut self.editor.view {
311 self.terminal.render_view(view, viewport);
358 self.terminal.render_view(view, viewport);
314− if let Some(prompt) = &self.prompt {
359+ if let Some(prompt) = &self.prompt {
360+ if prompt.should_close {
315− self.terminal.render_prompt(prompt);
363+ self.terminal.render_prompt(view, prompt);
318 self.terminal.draw();
368 self.terminal.draw();
@@ -383,7 +433,46 @@ impl Application {
384 let prompt = Prompt::new(
434 let prompt = Prompt::new(
385 ":".to_owned(),
435 ":".to_owned(),
437+ // TODO: i need this duplicate list right now to avoid borrow checker issues
438+ let command_list = vec![
440+ String::from("aaa"),
441+ String::from("bbb"),
442+ String::from("ccc"),
443+ String::from("ddd"),
444+ String::from("eee"),
445+ String::from("averylongcommandaverylongcommandaverylongcommandaverylongcommandaverylongcommand"),
447+ String::from("aaa"),
448+ String::from("bbb"),
449+ String::from("ccc"),
450+ String::from("ddd"),
451+ String::from("eee"),
453+ String::from("aaa"),
454+ String::from("bbb"),
455+ String::from("ccc"),
456+ String::from("ddd"),
457+ String::from("eee"),
459+ String::from("aaa"),
460+ String::from("bbb"),
461+ String::from("ccc"),
462+ String::from("ddd"),
463+ String::from("eee"),
465+ String::from("aaa"),
466+ String::from("bbb"),
467+ String::from("ccc"),
468+ String::from("ddd"),
469+ String::from("eee"),
473+ .filter(|command| command.contains(_input))
386− |_input: &str| None, // completion
475+ }, // completion
387 |editor: &mut Editor, input: &str| match input {
476 |editor: &mut Editor, input: &str| match input {
388 "q" => editor.should_close = true,
477 "q" => editor.should_close = true,