diff --git a/src/main.rs b/src/main.rs index 9210c98..aac5323 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,10 @@ mod error; mod line; mod log; +mod prompt; use line::Line; +use prompt::Prompt; use windows::Win32::{Foundation::HANDLE, System::Console}; use anyhow::{Context, Result}; @@ -250,7 +252,9 @@ fn main() -> Result<()> { let stdout = stdout_handle()?; let mut buf = [Console::INPUT_RECORD::default(); 100]; let mut line = Line::new(); + let prompt = Prompt::new(); + prompt.print()?; loop { let mut n: u32 = 0; unsafe { @@ -313,13 +317,15 @@ fn main() -> Result<()> { None, None, ))?; + prompt.print()?; line.clear(); } } else if key_code == 74 && (modifiers & Console::LEFT_CTRL_PRESSED == Console::LEFT_CTRL_PRESSED) { - let text = "•"; + // red bullet + let text = "\x1b[31m\u{2022}\x1b[0m"; Error::check(Console::WriteConsoleA( stdout, text.as_bytes(), diff --git a/src/prompt.rs b/src/prompt.rs new file mode 100644 index 0000000..4f6a159 --- /dev/null +++ b/src/prompt.rs @@ -0,0 +1,27 @@ +use crate::{error::Error, stdout_handle}; +use anyhow::Result; +use windows::Win32::System::Console; + +pub struct Prompt { + s: String, +} + +impl Prompt { + pub fn new() -> Self { + Self { + s: String::from("\x1b[32m>\x1b[0m "), + } + } + + pub fn print(&self) -> Result<()> { + unsafe { + Error::check(Console::WriteConsoleA( + stdout_handle()?, + self.s.as_bytes(), + None, + None, + ))?; + } + Ok(()) + } +}