diff options
Diffstat (limited to 'src/commands/command_line.rs')
-rw-r--r-- | src/commands/command_line.rs | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/commands/command_line.rs b/src/commands/command_line.rs index 4f67ee8..3376f83 100644 --- a/src/commands/command_line.rs +++ b/src/commands/command_line.rs @@ -1,9 +1,9 @@ use crate::commands::{self, JoshutoCommand, JoshutoRunnable}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; -use crate::textfield::JoshutoTextField; +use crate::textfield::TextField; use crate::ui; -use crate::window::JoshutoView; +use crate::ui::TuiBackend; #[derive(Clone, Debug)] pub struct CommandLine { @@ -19,20 +19,13 @@ impl CommandLine { "console" } - pub fn readline(&self, context: &mut JoshutoContext, view: &JoshutoView) -> JoshutoResult<()> { - const PROMPT: &str = ":"; - let (term_rows, term_cols) = ui::getmaxyx(); - let user_input: Option<String> = { - let textfield = JoshutoTextField::new( - 1, - term_cols, - (term_rows as usize - 1, 0), - PROMPT, - &self.prefix, - &self.suffix, - ); - textfield.readline() - }; + pub fn readline( + &self, + context: &mut JoshutoContext, + backend: &mut TuiBackend, + ) -> JoshutoResult<()> { + // let mut textfield = TextField::new(&mut terminal, &context.events); + let user_input: Option<String> = None; //textfield.readline(); if let Some(s) = user_input { let trimmed = s.trim_start(); @@ -41,11 +34,10 @@ impl CommandLine { let (command, xs) = trimmed.split_at(ind); let xs = xs.trim_start(); let args: Vec<String> = vec![String::from(xs)]; - commands::from_args(String::from(command), args)?.execute(context, view) - } - None => { - commands::from_args(String::from(trimmed), Vec::new())?.execute(context, view) + commands::from_args(String::from(command), args)?.execute(context, backend) } + None => commands::from_args(String::from(trimmed), Vec::new())? + .execute(context, backend), } } else { Ok(()) @@ -62,8 +54,8 @@ impl std::fmt::Display for CommandLine { } impl JoshutoRunnable for CommandLine { - fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) -> JoshutoResult<()> { - let res = self.readline(context, view); + fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { + let res = self.readline(context, backend); ncurses::doupdate(); res } |