parse-tree
Jordan Orelli 2 years ago
parent d1c379c755
commit f8f59c2de5

@ -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(),

@ -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(())
}
}
Loading…
Cancel
Save