Skip to content

Commit

Permalink
Add ANSI parser, and cursor support.
Browse files Browse the repository at this point in the history
  • Loading branch information
thejpster committed Jul 15, 2023
1 parent 9d450df commit 4f95add
Show file tree
Hide file tree
Showing 4 changed files with 487 additions and 78 deletions.
35 changes: 33 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ panic = "abort"
panic = "abort"

[dependencies]
neotron-common-bios = "0.9"
neotron-common-bios = "0.10"
pc-keyboard = "0.7"
r0 = "1.0"
postcard = "1.0"
Expand All @@ -51,6 +51,7 @@ chrono = { version = "0.4", default-features = false }
embedded-sdmmc = { version = "0.5", default-features = false }
neotron-api = "0.1"
neotron-loader = "0.1"
vte = { git = "https://github.com/neotron-compute/vte", branch="limit-osc-raw-size" }

[features]
lib-mode = []
20 changes: 12 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use config::Config as OsConfig;
// ===========================================================================

/// The OS version string
const OS_VERSION: &str = concat!("Neotron OS, version ", env!("OS_VERSION"));
const OS_VERSION: &str = concat!("Neotron OS, v", env!("OS_VERSION"));

/// Used to convert between POSIX epoch (for `chrono`) and Neotron epoch (for BIOS APIs).
const SECONDS_BETWEEN_UNIX_AND_NEOTRON_EPOCH: i64 = 946684800;
Expand Down Expand Up @@ -136,7 +136,7 @@ struct SerialConsole(u8);
impl SerialConsole {
fn write_bstr(&mut self, data: &[u8]) -> core::fmt::Result {
let api = API.get();
let is_panic = IS_PANIC.load(Ordering::SeqCst);
let is_panic = IS_PANIC.load(Ordering::Relaxed);
let res = (api.serial_write)(
// Which port
self.0,
Expand All @@ -155,7 +155,7 @@ impl SerialConsole {
impl core::fmt::Write for SerialConsole {
fn write_str(&mut self, data: &str) -> core::fmt::Result {
let api = API.get();
let is_panic = IS_PANIC.load(Ordering::SeqCst);
let is_panic = IS_PANIC.load(Ordering::Relaxed);
let res = (api.serial_write)(
// Which port
self.0,
Expand Down Expand Up @@ -252,7 +252,7 @@ pub extern "C" fn os_main(api: &bios::Api) -> ! {
unsafe {
VGA_CONSOLE = Some(vga);
}
println!("Configured VGA console {}x{}", width, height);
println!("\u{001b}[0mConfigured VGA console {}x{}", width, height);
}
}

Expand All @@ -263,8 +263,8 @@ pub extern "C" fn os_main(api: &bios::Api) -> ! {
}

// Now we can call println!
println!("Welcome to {}!", OS_VERSION);
println!("Copyright © Jonathan 'theJPster' Pallant and the Neotron Developers, 2022");
println!("\u{001b}[44;33;1m{}\u{001b}[0m", OS_VERSION);
println!("\u{001b}[41;37;1mCopyright © Jonathan 'theJPster' Pallant and the Neotron Developers, 2022\u{001b}[0m");

let (tpa_start, tpa_size) = match (api.memory_get_region)(0) {
bios::FfiOption::None => {
Expand Down Expand Up @@ -295,11 +295,14 @@ pub extern "C" fn os_main(api: &bios::Api) -> ! {
};

println!(
"TPA: {} bytes @ {:p}",
"\u{001b}[7mTPA: {} bytes @ {:p}\u{001b}[0m",
ctx.tpa.as_slice_u8().len(),
ctx.tpa.as_slice_u8().as_ptr()
);

// Show the cursor
print!("\u{001b}[?25h");

let mut buffer = [0u8; 256];
let mut menu = menu::Runner::new(&commands::OS_MENU, &mut buffer, ctx);

Expand Down Expand Up @@ -376,7 +379,8 @@ pub extern "C" fn os_main(api: &bios::Api) -> ! {
#[panic_handler]
#[cfg(not(feature = "lib-mode"))]
fn panic(info: &core::panic::PanicInfo) -> ! {
IS_PANIC.store(true, Ordering::SeqCst);
unsafe { core::arch::asm!("int3") };
IS_PANIC.store(true, Ordering::Relaxed);
println!("PANIC!\n{:#?}", info);
let api = API.get();
loop {
Expand Down
Loading

0 comments on commit 4f95add

Please sign in to comment.