From d2cc31ee49d673f343ce5089071ef3628c3cdc97 Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 17 May 2021 16:55:09 +0530 Subject: add tab to complete env variables --- src/app.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/app.rs') diff --git a/src/app.rs b/src/app.rs index 04468a6..aba71f8 100644 --- a/src/app.rs +++ b/src/app.rs @@ -27,7 +27,6 @@ use std::{ path::{Path, PathBuf}, }; -use log::info; use obi::{CompressionType, Image}; use sdl2::{ event::Event, @@ -319,10 +318,7 @@ impl<'ctx> AppState<'ctx> { } pub fn eval_expr(&mut self, expr: &LispExpr) { - let mut evaluator = eval::Evaluator { - app: self, - context: Vec::new(), - }; + let mut evaluator = eval::Evaluator::new(self); match evaluator.eval(expr) { Ok(val) => self.message.set_info(format!("{}", val)), Err(eval_err) => self.message.set_error(format!("{}", eval_err)), @@ -745,7 +741,6 @@ impl<'ctx> AppState<'ctx> { self.mode = Mode::Command; } } - info!("key press: {:?}", &event); match self.mode { Mode::Draw => { match event { @@ -1047,6 +1042,7 @@ impl<'ctx> AppState<'ctx> { Keycode::Up => self.command_box.hist_prev(), Keycode::Down => self.command_box.hist_next(), Keycode::Return => self.eval_command(), + Keycode::Tab => self.command_box.complete_next(&self.lisp_env), Keycode::Escape => { self.command_box.clear(); self.message.text.clear(); @@ -1062,11 +1058,11 @@ impl<'ctx> AppState<'ctx> { _ => (), }, // how does one handle alt keys - // _ if keymod == Mod::LALTMOD => match k { - // Keycode::B => self.command_box.cursor_back_word(), - // Keycode::F => self.command_box.cursor_forward_word(), - // _ => (), - // }, + _ if keymod == Mod::LALTMOD => match k { + Keycode::B => self.command_box.cursor_back_word(), + Keycode::F => self.command_box.cursor_forward_word(), + _ => (), + }, _ => (), }, Event::TextInput { text, .. } => { -- cgit v1.2.3