diff --git a/src/user/bin/grapher.rs b/src/user/bin/grapher.rs index 4638dae..63ce656 100644 --- a/src/user/bin/grapher.rs +++ b/src/user/bin/grapher.rs @@ -43,7 +43,7 @@ impl Application for Grapher { async fn run(&mut self, args: Vec) -> Result<(), Error> { Screen::Application.set_mode().map_err(|_| Error::ApplicationError(String::from("failed to set application mode")))?; - self.frame.frame = vec![vec![ColouredChar::coloured(' ', ColorCode::new(Color::White, Color::DarkGray)); self.frame.dimensions.x]; self.frame.dimensions.y]; + self.frame.frame = vec![vec![ColouredChar::new(' '); self.frame.dimensions.x]; self.frame.dimensions.y]; if args.len() > 0 { let equation: String = args.into_iter().collect(); @@ -85,9 +85,11 @@ impl Application for Grapher { entry_box.clear(); }, KeyStroke::Char(Stdin::BACKSPACE) => { - serial_println!("backspace"); entry_box.backspace() }, + KeyStroke::Char('`') => { + break; + } KeyStroke::Char(c) => entry_box.write_char(c), KeyStroke::Left => entry_box.move_cursor(false), KeyStroke::Right => entry_box.move_cursor(true), @@ -96,8 +98,8 @@ impl Application for Grapher { } if commandresult.len() > 0 { - let equation = commandresult.chars().take(40).collect(); - self.graph_equation(equation); + self.reset_frame(); + self.graph_equation(commandresult.clone()); commandresult.clear(); } @@ -108,8 +110,9 @@ impl Application for Grapher { frame.write_to_screen().map_err(|_| Error::ApplicationError(String::from("failed to write to screen")))?; } } - } + } + Screen::Terminal.set_mode().map_err(|_| Error::ApplicationError(String::from("failed to set application mode")))?; Ok(()) } } @@ -149,13 +152,11 @@ impl Grapher { let offset_x = point.x + OFFSET_X; let offset_y = point.y + OFFSET_Y; - - self.frame.write(Position::new(offset_x as usize, 22-offset_y as usize), ColouredChar::coloured('*', ColorCode::new(Color::White, Color::DarkGray))); + self.frame.write(Position::new(offset_x as usize, 21-offset_y as usize), ColouredChar::new('*')); } - - fn display(&mut self) { - self.frame.write_to_screen().unwrap(); + fn reset_frame(&mut self) { + self.frame.frame = vec![vec![ColouredChar::new(' '); self.frame.dimensions.x]; self.frame.dimensions.y]; } } diff --git a/src/user/bin/shell.rs b/src/user/bin/shell.rs index 2b97b50..5fe4a1f 100644 --- a/src/user/bin/shell.rs +++ b/src/user/bin/shell.rs @@ -192,7 +192,7 @@ async fn exec() -> Result<(), Error> { Screen::Application.set_mode().unwrap(); setup_ui(|c| match c { - KeyStroke::Char('x') => (c, true), + KeyStroke::Char('`') => (c, true), _ => (c, false), }).await; @@ -262,7 +262,7 @@ struct CmdHistory { async fn setup_ui(input: impl Fn(KeyStroke) -> (KeyStroke, bool)) { - let textbox = CgTextBox::new( + let mut textbox = CgTextBox::new( String::from("i'd just like to interject for a moment"), String::from("I'd just like to interject for a moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!"), Position::new(2, 5), @@ -279,8 +279,8 @@ async fn setup_ui(input: impl Fn(KeyStroke) -> (KeyStroke, bool)) { let mut statusbar = CgStatusBar::new(Position::new(0, 0), Dimensions::new(80, 1)); let mut textedit = CgLineEdit::new( - Position::new(0, 20), - 80, + Position::new(10, 20), + 60, String::from("enter text here >"), ); @@ -309,14 +309,13 @@ async fn setup_ui(input: impl Fn(KeyStroke) -> (KeyStroke, bool)) { } if commandresult.len() > 0 { - let string = commandresult.chars().take(40).collect(); - label.set_text(string); + let string = commandresult.clone(); + textbox.content = string; } container.insert(Box::new(&textbox)); container.insert(Box::new(&statusbar)); container.insert(Box::new(&textedit)); - container.insert(Box::new(&label)); if let Ok(frame) = container.render() { frame.write_to_screen().unwrap(); diff --git a/src/user/lib/libgui/cg_inputs.rs b/src/user/lib/libgui/cg_inputs.rs index 157a8a7..d3b20cd 100644 --- a/src/user/lib/libgui/cg_inputs.rs +++ b/src/user/lib/libgui/cg_inputs.rs @@ -64,7 +64,7 @@ impl CgTextEdit for CgLineEdit { self.ptr += 1; } fn backspace(&mut self) { - if self.ptr >= 0 { + if self.ptr > 0 { self.ptr -= 1; self.text.remove(self.ptr); } diff --git a/src/user/lib/libgui/cg_widgets.rs b/src/user/lib/libgui/cg_widgets.rs index acb4057..32eb4d4 100644 --- a/src/user/lib/libgui/cg_widgets.rs +++ b/src/user/lib/libgui/cg_widgets.rs @@ -76,7 +76,7 @@ impl CgComponent for CgContainer<'_> { #[derive(Debug, Clone)] pub struct CgTextBox { title: String, - content: String, + pub content: String, pub position: Position, pub dimensions: Dimensions, outlined: bool, @@ -85,7 +85,7 @@ pub struct CgTextBox { impl CgTextBox { pub fn new(title: String, content: String, position: Position, dimensions: Dimensions, outlined: bool) -> CgTextBox { - CgTextBox { title, content, position, dimensions, outlined, wrap_words: false } + CgTextBox { title, content, position, dimensions, outlined, wrap_words: true } } fn render_title(&self, frame: &mut Frame) {