From 40c99b47b5fcbb42ccda8ad59c3f8c356c9eb355 Mon Sep 17 00:00:00 2001 From: Able Date: Wed, 23 Nov 2022 02:32:12 -0600 Subject: [PATCH] changing color parsing from \0 to \1a --- ableos/assets/kernel.toml | 6 +++--- ableos/src/scratchpad.rs | 30 +++++++++++++++++++++------- ableos/src/vterm.rs | 42 +++++++++++++++++++-------------------- 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/ableos/assets/kernel.toml b/ableos/assets/kernel.toml index e06d334..1f0ad21 100644 --- a/ableos/assets/kernel.toml +++ b/ableos/assets/kernel.toml @@ -7,10 +7,10 @@ enabled = true level = "Trace" log_to_serial = true log_to_vterm = false +filter = ["ableos::ps2_mouse", "ableos::vterm", "ableos::filesystem::vfs"] + + # Exact paths required -filter = ["ableos::ps2_mouse", "ableos::vterm"] - - [tests] run_tests = false run_demos = false diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index cf6177c..3a4d935 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -87,10 +87,10 @@ pub fn scratchpad() { println!( "{} - ,-------. OS: \0BLUE\0AbleOS\0RESET\0 - ,'\\ _ _`. Host: \0PINK\0{}\0RESET\0 - / \\)_)-)_)-\\ Kernel: \0RED\0AKern-{}-v{}\0RESET\0 -: : Uptime: \0GREEN\0{}\0RESET\0 + ,-------. OS: \u{001A}BLUE\u{001A}AbleOS\u{001A}RESET\u{001A} + ,'\\ _ _`. Host: \u{001A}PINK\u{001A}{}\u{001A}RESET\u{001A} + / \\)_)-)_)-\\ Kernel: \u{001A}RED\u{001A}AKern-{}-v{}\u{001A}RESET\u{001A} +: : Uptime: \u{001A}GREEN\u{001A}{}\u{001A}RESET\u{001A} \\ / Packages: None \\ / Shell: BuiltinShell `. ,' Resolution: 640x480 @@ -341,7 +341,11 @@ pub fn echo_file(path: String) { Some(file) => { trace!("checking is directory"); if file.is_dir() { - println!("{} is a directory", path); + println!( + "\u{001A}RED\u{001A}ERROR\u{001A}RESET\u{001A} {} is a directory", + path + ); + error!("{} is a directory", path); } else { trace!("allocating buffer for file contents"); let mut file_contents = Vec::new(); @@ -353,9 +357,21 @@ pub fn echo_file(path: String) { } } - None => todo!(), + None => { + error!("File {} doesn't exist", path); + println!( + "\u{001A}RED\u{001A}ERROR\u{001A}RESET\u{001A}: File {} doesn't exist", + path + ); + } } } - Err(err) => error!("path {} Error {}", path, err), + Err(err) => { + println!( + "\u{001A}RED\u{001A}ERROR\u{001A}RESET\u{001A}: path {} Error {}", + path, err + ); + error!("path {} Error {}", path, err); + } } } diff --git a/ableos/src/vterm.rs b/ableos/src/vterm.rs index 2ebc75b..a904551 100644 --- a/ableos/src/vterm.rs +++ b/ableos/src/vterm.rs @@ -36,7 +36,7 @@ impl VTerm { dirty: false, x: 0, back_buffer: [0; 640 * 480], - term: [('\0', Color16::DarkGrey); 80 * 60], + term: [('\u{001A}', Color16::DarkGrey); 80 * 60], color: Color16::White, } } @@ -88,7 +88,7 @@ impl VTerm { } // trace!("C"); match c { - '\0' => { + '\u{001A}' => { self.term[TERM_MINUS_ONE_LINE + (self.x as usize)] = (c, self.color); self.x += 1; @@ -101,7 +101,7 @@ impl VTerm { } self.x -= 1; self.term[TERM_MINUS_ONE_LINE + (self.x as usize)] = - ('\0', Color16::LightGrey); + ('\u{001A}', Color16::LightGrey); } '\n' => { self.move_up(); @@ -124,7 +124,7 @@ impl VTerm { pub fn move_up(&mut self) { self.term.rotate_left(80); for x in 0..80 { - self.term[TERM_MINUS_ONE_LINE + x] = ('\0', Color16::DarkGrey); + self.term[TERM_MINUS_ONE_LINE + x] = ('\u{001A}', Color16::DarkGrey); } self.x = 0; } @@ -211,40 +211,40 @@ enum Token { #[error] Error, - #[token("\0RESET\0", priority = 10)] + #[token("\u{001A}RESET\u{001A}", priority = 10)] Reset, - #[token("\0BLACK\0", priority = 10)] + #[token("\u{001A}BLACK\u{001A}", priority = 10)] TBlack, - #[regex("\0BLUE\0", priority = 10)] + #[regex("\u{001A}BLUE\u{001A}", priority = 10)] TBlue, - #[token("\0GREEN\0", priority = 10)] + #[token("\u{001A}GREEN\u{001A}", priority = 10)] TGreen, - #[token("\0CYAN\0", priority = 10)] + #[token("\u{001A}CYAN\u{001A}", priority = 10)] TCyan, - #[token("\0RED\0", priority = 10)] + #[token("\u{001A}RED\u{001A}", priority = 10)] TRed, - #[token("\0MAGENTA\0", priority = 10)] + #[token("\u{001A}MAGENTA\u{001A}", priority = 10)] TMagenta, - #[token("\0BROWN\0", priority = 10)] + #[token("\u{001A}BROWN\u{001A}", priority = 10)] TBrown, - #[token("\0LIGHTGREY\0", priority = 10)] + #[token("\u{001A}LIGHTGREY\u{001A}", priority = 10)] TLightGrey, - #[token("\0DARKGREY\0", priority = 10)] + #[token("\u{001A}DARKGREY\u{001A}", priority = 10)] TDarkGrey, - #[token("\0LIGHTBLUE\0", priority = 10)] + #[token("\u{001A}LIGHTBLUE\u{001A}", priority = 10)] TLightBlue, - #[token("\0LIGHTGREEN\0", priority = 10)] + #[token("\u{001A}LIGHTGREEN\u{001A}", priority = 10)] TLightGreen, - #[token("\0LIGHTCYAN\0", priority = 10)] + #[token("\u{001A}LIGHTCYAN\u{001A}", priority = 10)] TLightCyan, - #[token("\0LIGHTRED\0", priority = 10)] + #[token("\u{001A}LIGHTRED\u{001A}", priority = 10)] TLightRed, - #[token("\0PINK\0", priority = 10)] + #[token("\u{001A}PINK\u{001A}", priority = 10)] TPink, - #[token("\0YELLOW\0", priority = 10)] + #[token("\u{001A}YELLOW\u{001A}", priority = 10)] TYellow, - #[token("\0WHITE\0", priority = 10)] + #[token("\u{001A}WHITE\u{001A}", priority = 10)] TWhite, // #[token(" ")]