裕依 hace 1 mes
padre
commit
cf3f377b82
Se han modificado 3 ficheros con 8 adiciones y 21 borrados
  1. 0 1
      Cargo.toml
  2. 4 8
      src/shell/command/mod.rs
  3. 4 12
      src/shell/mod.rs

+ 0 - 1
Cargo.toml

@@ -8,7 +8,6 @@ authors = [ "MemoryShore <1353318529@qq.com>" ]
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-dragonos-dsc = { git = "https://git.mirrors.dragonos.org/DragonOS-Community/dragonos-dsc.git", rev = "7c654bcccc" }
 lazy_static = "1.4.0"
 regex = "1.10.2"
 libc = "0.2"

+ 4 - 8
src/shell/command/mod.rs

@@ -1,9 +1,9 @@
+use colored::Colorize;
 use help::Help;
 use path_clean::PathClean;
 use regex::{Captures, Regex};
 use std::intrinsics::unlikely;
 use std::io::Read;
-use std::os::unix::ffi::OsStrExt;
 use std::{
     format,
     fs::{self, File, OpenOptions},
@@ -311,15 +311,11 @@ impl Shell {
 
         for entry in dir {
             let entry = entry.unwrap();
+            let name = entry.file_name().into_string().unwrap();
             if entry.file_type().unwrap().is_dir() {
-                crate::shell::Printer::print_color(
-                    entry.file_name().as_bytes(),
-                    0x000088ff,
-                    0x00000000,
-                );
-                print!("    ");
+                print!("{}\t", name.truecolor(0x00, 0x88, 0xff));
             } else {
-                print!("{}    ", entry.file_name().into_string().unwrap());
+                print!("{}\t", name);
             }
         }
         println!();

+ 4 - 12
src/shell/mod.rs

@@ -85,7 +85,7 @@ impl Shell {
         crossterm::terminal::enable_raw_mode().expect("failed to enable raw mode");
         loop {
             self.printer.init_before_readline();
-            if self.readline(0) == 0 {
+            if self.readline() == 0 {
                 println!();
                 break;
             }
@@ -151,7 +151,7 @@ impl Shell {
         buf[0]
     }
 
-    fn readline(&mut self, _fd: usize) -> usize {
+    fn readline(&mut self) -> usize {
         let mut stdout = std::io::stdout();
         self.history_commands.push(Rc::clone(&self.printer.buf));
         let mut command_index = self.history_commands.len() - 1;
@@ -285,9 +285,9 @@ impl Shell {
                                 println!();
                                 for candidate in candidates {
                                     print!(
-                                        "{}    ",
+                                        "{}\t",
                                         if candidate.ends_with('/') {
-                                            candidate.cyan()
+                                            candidate.truecolor(0x00, 0x88, 0xff)
                                         } else {
                                             candidate.white()
                                         }
@@ -446,14 +446,6 @@ impl Printer {
     fn print(bytes: &[u8]) {
         print!("{}", String::from_utf8(bytes.to_vec()).unwrap());
     }
-
-    fn print_color(bytes: &[u8], front_color: usize, background_color: usize) {
-        std::io::stdout().flush().unwrap();
-        let cstr = std::ffi::CString::new(bytes).unwrap();
-        unsafe {
-            dsc::syscall!(SYS_PUT_STRING, cstr.as_ptr(), front_color, background_color);
-        }
-    }
 }
 
 pub fn _print_color_example() {